xslt.patch
text/x-patch
Filename: xslt.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| contrib/xml2/xslt_proc.c | 32 | 18 |
*** ./contrib/xml2/xslt_proc.c.orig 2010-07-06 21:18:55.000000000 +0200
--- ./contrib/xml2/xslt_proc.c 2010-08-02 09:31:32.410911283 +0200
***************
*** 41,49 ****
extern void pgxml_parser_init(void);
/* local defs */
! static void parse_params(const char **params, text *paramstr);
! #define MAXPARAMS 20 /* must be even, see parse_params() */
#endif /* USE_LIBXSLT */
--- 41,50 ----
extern void pgxml_parser_init(void);
/* local defs */
! const char **parse_params(text *paramstr);
! #define INIT_PARAMS 20 /* must be even, see parse_params() */
! #define EXTEND_PARAMS 20 /* must be even, see parse_params() */
#endif /* USE_LIBXSLT */
***************
*** 57,63 ****
text *doct = PG_GETARG_TEXT_P(0);
text *ssheet = PG_GETARG_TEXT_P(1);
text *paramstr;
! const char *params[MAXPARAMS + 1]; /* +1 for the terminator */
xsltStylesheetPtr stylesheet = NULL;
xmlDocPtr doctree;
xmlDocPtr restree;
--- 58,64 ----
text *doct = PG_GETARG_TEXT_P(0);
text *ssheet = PG_GETARG_TEXT_P(1);
text *paramstr;
! const char **params;
xsltStylesheetPtr stylesheet = NULL;
xmlDocPtr doctree;
xmlDocPtr restree;
***************
*** 69,79 ****
if (fcinfo->nargs == 3)
{
paramstr = PG_GETARG_TEXT_P(2);
! parse_params(params, paramstr);
}
else
/* No parameters */
params[0] = NULL;
/* Setup parser */
pgxml_parser_init();
--- 70,83 ----
if (fcinfo->nargs == 3)
{
paramstr = PG_GETARG_TEXT_P(2);
! params = parse_params(paramstr);
}
else
+ {
/* No parameters */
+ params = palloc(sizeof(char *));
params[0] = NULL;
+ }
/* Setup parser */
pgxml_parser_init();
***************
*** 139,160 ****
#ifdef USE_LIBXSLT
! static void
! parse_params(const char **params, text *paramstr)
{
char *pos;
char *pstr;
- int i;
char *nvsep = "=";
char *itsep = ",";
!
pstr = text_to_cstring(paramstr);
pos = pstr;
!
! for (i = 0; i < MAXPARAMS; i++)
{
! params[i] = pos;
pos = strstr(pos, nvsep);
if (pos != NULL)
{
--- 143,175 ----
#ifdef USE_LIBXSLT
! 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)
{
***************
*** 165,176 ****
{
/* No equal sign, so ignore this "parameter" */
/* We'll reset params[i] to NULL below the loop */
break;
}
! /* Value */
! i++;
/* since MAXPARAMS is even, we still have i < MAXPARAMS */
! params[i] = pos;
pos = strstr(pos, itsep);
if (pos != NULL)
{
--- 180,191 ----
{
/* 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)
{
***************
*** 178,190 ****
pos++;
}
else
- {
- i++;
break;
- }
}
! params[i] = NULL;
}
#endif /* USE_LIBXSLT */
--- 193,204 ----
pos++;
}
else
break;
}
! params[nparams] = NULL;
!
! return params;
}
#endif /* USE_LIBXSLT */