Hello

One Czech pg user reported problems with function xslt_process. This
function is coded with ten parameters limit.

Attached patch add support to unlimited number of parameters.

const char **
parse_params(text *paramstr)
{
        char       *pos;
        char       *pstr;
        char       *nvsep = "=";
        char       *itsep = ",";
        const char **params;
        int     nparams;
        int     mparams;                /* max params */
        
        pstr = text_to_cstring(paramstr);
        
        mparams = INIT_PARAMS;
        params = (const char **) palloc(INIT_PARAMS * sizeof(char *) + 1);

        pos = pstr;
        nparams = 0;
        while (*pos != '\0')
        {
                if (nparams >= mparams)
                {
                        /* extend params params */
                        mparams += EXTEND_PARAMS;
                        params = (const char **) repalloc(params, mparams * 
sizeof(char *) + 1);
                }
                params[nparams++] = pos;
                pos = strstr(pos, nvsep);
                if (pos != NULL)
                {
                        *pos = '\0';
                        pos++;
                }
                else
                {
                        /* No equal sign, so ignore this "parameter" */
                        /* We'll reset params[i] to NULL below the loop */
                        nparams--;
                        break;
                }

                /* since MAXPARAMS is even, we still have i < MAXPARAMS */
                params[nparams++] = pos;
                pos = strstr(pos, itsep);
                if (pos != NULL)
                {
                        *pos = '\0';
                        pos++;
                }
                else
                        break;
        }

        params[nparams] = NULL;

        return params;
}

Regards
Pavel Stehule

Attachment: nolimit.diff
Description: Binary data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to