/src/libxslt/libexslt/strings.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | #define IN_LIBEXSLT  | 
2  |  | #include "libexslt/libexslt.h"  | 
3  |  |  | 
4  |  | #include <libxml/tree.h>  | 
5  |  | #include <libxml/xpath.h>  | 
6  |  | #include <libxml/xpathInternals.h>  | 
7  |  | #include <libxml/parser.h>  | 
8  |  | #include <libxml/encoding.h>  | 
9  |  | #include <libxml/uri.h>  | 
10  |  |  | 
11  |  | #include <libxslt/xsltutils.h>  | 
12  |  | #include <libxslt/xsltInternals.h>  | 
13  |  | #include <libxslt/extensions.h>  | 
14  |  |  | 
15  |  | #include "exslt.h"  | 
16  |  |  | 
17  |  | /**  | 
18  |  |  * exsltStrTokenizeFunction:  | 
19  |  |  * @ctxt: an XPath parser context  | 
20  |  |  * @nargs: the number of arguments  | 
21  |  |  *  | 
22  |  |  * Splits up a string on the characters of the delimiter string and returns a  | 
23  |  |  * node set of token elements, each containing one token from the string.  | 
24  |  |  */  | 
25  |  | static void  | 
26  |  | exsltStrTokenizeFunction(xmlXPathParserContextPtr ctxt, int nargs)  | 
27  | 13.3k  | { | 
28  | 13.3k  |     xsltTransformContextPtr tctxt;  | 
29  | 13.3k  |     xmlChar *str, *delimiters, *cur;  | 
30  | 13.3k  |     const xmlChar *token, *delimiter;  | 
31  | 13.3k  |     xmlNodePtr node;  | 
32  | 13.3k  |     xmlDocPtr container;  | 
33  | 13.3k  |     xmlXPathObjectPtr ret = NULL;  | 
34  | 13.3k  |     int clen;  | 
35  |  |  | 
36  | 13.3k  |     if ((nargs < 1) || (nargs > 2)) { | 
37  | 136  |         xmlXPathSetArityError(ctxt);  | 
38  | 136  |         return;  | 
39  | 136  |     }  | 
40  |  |  | 
41  | 13.2k  |     if (nargs == 2) { | 
42  | 7.02k  |         delimiters = xmlXPathPopString(ctxt);  | 
43  | 7.02k  |         if (xmlXPathCheckError(ctxt))  | 
44  | 0  |             return;  | 
45  | 7.02k  |     } else { | 
46  | 6.21k  |         delimiters = xmlStrdup((const xmlChar *) "\t\r\n ");  | 
47  | 6.21k  |     }  | 
48  | 13.2k  |     if (delimiters == NULL)  | 
49  | 0  |         return;  | 
50  |  |  | 
51  | 13.2k  |     str = xmlXPathPopString(ctxt);  | 
52  | 13.2k  |     if (xmlXPathCheckError(ctxt) || (str == NULL)) { | 
53  | 0  |         xmlFree(delimiters);  | 
54  | 0  |         return;  | 
55  | 0  |     }  | 
56  |  |  | 
57  |  |     /* Return a result tree fragment */  | 
58  | 13.2k  |     tctxt = xsltXPathGetTransformContext(ctxt);  | 
59  | 13.2k  |     if (tctxt == NULL) { | 
60  | 0  |         xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,  | 
61  | 0  |         "exslt:tokenize : internal error tctxt == NULL\n");  | 
62  | 0  |   goto fail;  | 
63  | 0  |     }  | 
64  |  |  | 
65  | 13.2k  |     container = xsltCreateRVT(tctxt);  | 
66  | 13.2k  |     if (container != NULL) { | 
67  | 13.2k  |         xsltRegisterLocalRVT(tctxt, container);  | 
68  | 13.2k  |         ret = xmlXPathNewNodeSet(NULL);  | 
69  | 13.2k  |         if (ret != NULL) { | 
70  | 7.23M  |             for (cur = str, token = str; *cur != 0; cur += clen) { | 
71  | 7.22M  |           clen = xmlUTF8Strsize(cur, 1);  | 
72  | 7.22M  |     if (*delimiters == 0) { /* empty string case */ | 
73  | 223k  |         xmlChar ctmp;  | 
74  | 223k  |         ctmp = *(cur+clen);  | 
75  | 223k  |         *(cur+clen) = 0;  | 
76  | 223k  |                     node = xmlNewDocRawNode(container, NULL,  | 
77  | 223k  |                                        (const xmlChar *) "token", cur);  | 
78  | 223k  |         xmlAddChild((xmlNodePtr) container, node);  | 
79  | 223k  |         xmlXPathNodeSetAddUnique(ret->nodesetval, node);  | 
80  | 223k  |                     *(cur+clen) = ctmp; /* restore the changed byte */  | 
81  | 223k  |                     token = cur + clen;  | 
82  | 95.9M  |                 } else for (delimiter = delimiters; *delimiter != 0;  | 
83  | 90.9M  |         delimiter += xmlUTF8Strsize(delimiter, 1)) { | 
84  | 90.9M  |                     if (!xmlUTF8Charcmp(cur, delimiter)) { | 
85  | 1.99M  |                         if (cur == token) { | 
86  |  |                             /* discard empty tokens */  | 
87  | 1.92M  |                             token = cur + clen;  | 
88  | 1.92M  |                             break;  | 
89  | 1.92M  |                         }  | 
90  | 68.2k  |                         *cur = 0; /* terminate the token */  | 
91  | 68.2k  |                         node = xmlNewDocRawNode(container, NULL,  | 
92  | 68.2k  |                                            (const xmlChar *) "token", token);  | 
93  | 68.2k  |       xmlAddChild((xmlNodePtr) container, node);  | 
94  | 68.2k  |       xmlXPathNodeSetAddUnique(ret->nodesetval, node);  | 
95  | 68.2k  |                         *cur = *delimiter; /* restore the changed byte */  | 
96  | 68.2k  |                         token = cur + clen;  | 
97  | 68.2k  |                         break;  | 
98  | 1.99M  |                     }  | 
99  | 90.9M  |                 }  | 
100  | 7.22M  |             }  | 
101  | 13.2k  |             if (token != cur) { | 
102  | 7.11k  |     node = xmlNewDocRawNode(container, NULL,  | 
103  | 7.11k  |             (const xmlChar *) "token", token);  | 
104  | 7.11k  |                 xmlAddChild((xmlNodePtr) container, node);  | 
105  | 7.11k  |           xmlXPathNodeSetAddUnique(ret->nodesetval, node);  | 
106  | 7.11k  |             }  | 
107  | 13.2k  |         }  | 
108  | 13.2k  |     }  | 
109  |  |  | 
110  | 13.2k  | fail:  | 
111  | 13.2k  |     if (str != NULL)  | 
112  | 13.2k  |         xmlFree(str);  | 
113  | 13.2k  |     if (delimiters != NULL)  | 
114  | 13.2k  |         xmlFree(delimiters);  | 
115  | 13.2k  |     if (ret != NULL)  | 
116  | 13.2k  |         valuePush(ctxt, ret);  | 
117  | 0  |     else  | 
118  | 0  |         valuePush(ctxt, xmlXPathNewNodeSet(NULL));  | 
119  | 13.2k  | }  | 
120  |  |  | 
121  |  | /**  | 
122  |  |  * exsltStrSplitFunction:  | 
123  |  |  * @ctxt: an XPath parser context  | 
124  |  |  * @nargs: the number of arguments  | 
125  |  |  *  | 
126  |  |  * Splits up a string on a delimiting string and returns a node set of token  | 
127  |  |  * elements, each containing one token from the string.  | 
128  |  |  */  | 
129  |  | static void  | 
130  | 166k  | exsltStrSplitFunction(xmlXPathParserContextPtr ctxt, int nargs) { | 
131  | 166k  |     xsltTransformContextPtr tctxt;  | 
132  | 166k  |     xmlChar *str, *delimiter, *cur;  | 
133  | 166k  |     const xmlChar *token;  | 
134  | 166k  |     xmlNodePtr node;  | 
135  | 166k  |     xmlDocPtr container;  | 
136  | 166k  |     xmlXPathObjectPtr ret = NULL;  | 
137  | 166k  |     int delimiterLength;  | 
138  |  |  | 
139  | 166k  |     if ((nargs < 1) || (nargs > 2)) { | 
140  | 588  |         xmlXPathSetArityError(ctxt);  | 
141  | 588  |         return;  | 
142  | 588  |     }  | 
143  |  |  | 
144  | 165k  |     if (nargs == 2) { | 
145  | 87.9k  |         delimiter = xmlXPathPopString(ctxt);  | 
146  | 87.9k  |         if (xmlXPathCheckError(ctxt))  | 
147  | 0  |             return;  | 
148  | 87.9k  |     } else { | 
149  | 77.8k  |         delimiter = xmlStrdup((const xmlChar *) " ");  | 
150  | 77.8k  |     }  | 
151  | 165k  |     if (delimiter == NULL)  | 
152  | 0  |         return;  | 
153  | 165k  |     delimiterLength = xmlStrlen (delimiter);  | 
154  |  |  | 
155  | 165k  |     str = xmlXPathPopString(ctxt);  | 
156  | 165k  |     if (xmlXPathCheckError(ctxt) || (str == NULL)) { | 
157  | 0  |         xmlFree(delimiter);  | 
158  | 0  |         return;  | 
159  | 0  |     }  | 
160  |  |  | 
161  |  |     /* Return a result tree fragment */  | 
162  | 165k  |     tctxt = xsltXPathGetTransformContext(ctxt);  | 
163  | 165k  |     if (tctxt == NULL) { | 
164  | 0  |         xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,  | 
165  | 0  |         "exslt:tokenize : internal error tctxt == NULL\n");  | 
166  | 0  |   goto fail;  | 
167  | 0  |     }  | 
168  |  |  | 
169  |  |     /*  | 
170  |  |     * OPTIMIZE TODO: We are creating an xmlDoc for every split!  | 
171  |  |     */  | 
172  | 165k  |     container = xsltCreateRVT(tctxt);  | 
173  | 165k  |     if (container != NULL) { | 
174  | 165k  |         xsltRegisterLocalRVT(tctxt, container);  | 
175  | 165k  |         ret = xmlXPathNewNodeSet(NULL);  | 
176  | 165k  |         if (ret != NULL) { | 
177  | 354M  |             for (cur = str, token = str; *cur != 0; cur++) { | 
178  | 354M  |     if (delimiterLength == 0) { | 
179  | 20.5M  |         if (cur != token) { | 
180  | 20.5M  |       xmlChar tmp = *cur;  | 
181  | 20.5M  |       *cur = 0;  | 
182  | 20.5M  |                         node = xmlNewDocRawNode(container, NULL,  | 
183  | 20.5M  |                                            (const xmlChar *) "token", token);  | 
184  | 20.5M  |       xmlAddChild((xmlNodePtr) container, node);  | 
185  | 20.5M  |       xmlXPathNodeSetAddUnique(ret->nodesetval, node);  | 
186  | 20.5M  |       *cur = tmp;  | 
187  | 20.5M  |       token++;  | 
188  | 20.5M  |         }  | 
189  | 20.5M  |     }  | 
190  | 333M  |     else if (!xmlStrncasecmp(cur, delimiter, delimiterLength)) { | 
191  | 56.9M  |         if (cur == token) { | 
192  |  |       /* discard empty tokens */  | 
193  | 51.4M  |       cur = cur + delimiterLength - 1;  | 
194  | 51.4M  |       token = cur + 1;  | 
195  | 51.4M  |       continue;  | 
196  | 51.4M  |         }  | 
197  | 5.50M  |         *cur = 0;  | 
198  | 5.50M  |         node = xmlNewDocRawNode(container, NULL,  | 
199  | 5.50M  |                (const xmlChar *) "token", token);  | 
200  | 5.50M  |         xmlAddChild((xmlNodePtr) container, node);  | 
201  | 5.50M  |         xmlXPathNodeSetAddUnique(ret->nodesetval, node);  | 
202  | 5.50M  |         *cur = *delimiter;  | 
203  | 5.50M  |         cur = cur + delimiterLength - 1;  | 
204  | 5.50M  |         token = cur + 1;  | 
205  | 5.50M  |                 }  | 
206  | 354M  |             }  | 
207  | 165k  |       if (token != cur) { | 
208  | 141k  |     node = xmlNewDocRawNode(container, NULL,  | 
209  | 141k  |            (const xmlChar *) "token", token);  | 
210  | 141k  |     xmlAddChild((xmlNodePtr) container, node);  | 
211  | 141k  |     xmlXPathNodeSetAddUnique(ret->nodesetval, node);  | 
212  | 141k  |       }  | 
213  | 165k  |         }  | 
214  | 165k  |     }  | 
215  |  |  | 
216  | 165k  | fail:  | 
217  | 165k  |     if (str != NULL)  | 
218  | 165k  |         xmlFree(str);  | 
219  | 165k  |     if (delimiter != NULL)  | 
220  | 165k  |         xmlFree(delimiter);  | 
221  | 165k  |     if (ret != NULL)  | 
222  | 165k  |         valuePush(ctxt, ret);  | 
223  | 0  |     else  | 
224  | 0  |         valuePush(ctxt, xmlXPathNewNodeSet(NULL));  | 
225  | 165k  | }  | 
226  |  |  | 
227  |  | /**  | 
228  |  |  * exsltStrEncodeUriFunction:  | 
229  |  |  * @ctxt: an XPath parser context  | 
230  |  |  * @nargs: the number of arguments  | 
231  |  |  *  | 
232  |  |  * URI-Escapes a string  | 
233  |  |  */  | 
234  |  | static void  | 
235  | 7.92k  | exsltStrEncodeUriFunction (xmlXPathParserContextPtr ctxt, int nargs) { | 
236  | 7.92k  |     int escape_all = 1, str_len = 0;  | 
237  | 7.92k  |     xmlChar *str = NULL, *ret = NULL, *tmp;  | 
238  |  |  | 
239  | 7.92k  |     if ((nargs < 2) || (nargs > 3)) { | 
240  | 197  |   xmlXPathSetArityError(ctxt);  | 
241  | 197  |   return;  | 
242  | 197  |     }  | 
243  |  |  | 
244  | 7.72k  |     if (nargs >= 3) { | 
245  |  |         /* check for UTF-8 if encoding was explicitly given;  | 
246  |  |            we don't support anything else yet */  | 
247  | 86  |         tmp = xmlXPathPopString(ctxt);  | 
248  | 86  |         if (xmlUTF8Strlen(tmp) != 5 || xmlStrcmp((const xmlChar *)"UTF-8",tmp)) { | 
249  | 84  |       xmlXPathReturnEmptyString(ctxt);  | 
250  | 84  |       xmlFree(tmp);  | 
251  | 84  |       return;  | 
252  | 84  |   }  | 
253  | 2  |   xmlFree(tmp);  | 
254  | 2  |     }  | 
255  |  |  | 
256  | 7.63k  |     escape_all = xmlXPathPopBoolean(ctxt);  | 
257  |  |  | 
258  | 7.63k  |     str = xmlXPathPopString(ctxt);  | 
259  | 7.63k  |     str_len = xmlUTF8Strlen(str);  | 
260  |  |  | 
261  | 7.63k  |     if (str_len <= 0) { | 
262  | 1.14k  |         if (str_len < 0)  | 
263  | 1.05k  |             xsltGenericError(xsltGenericErrorContext,  | 
264  | 1.05k  |                              "exsltStrEncodeUriFunction: invalid UTF-8\n");  | 
265  | 1.14k  |   xmlXPathReturnEmptyString(ctxt);  | 
266  | 1.14k  |   xmlFree(str);  | 
267  | 1.14k  |   return;  | 
268  | 1.14k  |     }  | 
269  |  |  | 
270  | 6.49k  |     ret = xmlURIEscapeStr(str,(const xmlChar *)(escape_all?"-_.!~*'()":"-_.!~*'();/?:@&=+$,[]"));  | 
271  | 6.49k  |     xmlXPathReturnString(ctxt, ret);  | 
272  |  |  | 
273  | 6.49k  |     if (str != NULL)  | 
274  | 6.49k  |   xmlFree(str);  | 
275  | 6.49k  | }  | 
276  |  |  | 
277  |  | /**  | 
278  |  |  * exsltStrDecodeUriFunction:  | 
279  |  |  * @ctxt: an XPath parser context  | 
280  |  |  * @nargs: the number of arguments  | 
281  |  |  *  | 
282  |  |  * reverses URI-Escaping of a string  | 
283  |  |  */  | 
284  |  | static void  | 
285  | 9.53k  | exsltStrDecodeUriFunction (xmlXPathParserContextPtr ctxt, int nargs) { | 
286  | 9.53k  |     int str_len = 0;  | 
287  | 9.53k  |     xmlChar *str = NULL, *ret = NULL, *tmp;  | 
288  |  |  | 
289  | 9.53k  |     if ((nargs < 1) || (nargs > 2)) { | 
290  | 103  |   xmlXPathSetArityError(ctxt);  | 
291  | 103  |   return;  | 
292  | 103  |     }  | 
293  |  |  | 
294  | 9.43k  |     if (nargs >= 2) { | 
295  |  |         /* check for UTF-8 if encoding was explicitly given;  | 
296  |  |            we don't support anything else yet */  | 
297  | 72  |         tmp = xmlXPathPopString(ctxt);  | 
298  | 72  |         if (xmlUTF8Strlen(tmp) != 5 || xmlStrcmp((const xmlChar *)"UTF-8",tmp)) { | 
299  | 58  |       xmlXPathReturnEmptyString(ctxt);  | 
300  | 58  |       xmlFree(tmp);  | 
301  | 58  |       return;  | 
302  | 58  |   }  | 
303  | 14  |   xmlFree(tmp);  | 
304  | 14  |     }  | 
305  |  |  | 
306  | 9.37k  |     str = xmlXPathPopString(ctxt);  | 
307  | 9.37k  |     str_len = xmlUTF8Strlen(str);  | 
308  |  |  | 
309  | 9.37k  |     if (str_len <= 0) { | 
310  | 3.52k  |         if (str_len < 0)  | 
311  | 3.28k  |             xsltGenericError(xsltGenericErrorContext,  | 
312  | 3.28k  |                              "exsltStrDecodeUriFunction: invalid UTF-8\n");  | 
313  | 3.52k  |   xmlXPathReturnEmptyString(ctxt);  | 
314  | 3.52k  |   xmlFree(str);  | 
315  | 3.52k  |   return;  | 
316  | 3.52k  |     }  | 
317  |  |  | 
318  | 5.84k  |     ret = (xmlChar *) xmlURIUnescapeString((const char *)str,0,NULL);  | 
319  | 5.84k  |     if (!xmlCheckUTF8(ret)) { | 
320  |  |   /* FIXME: instead of throwing away the whole URI, we should  | 
321  |  |         only discard the invalid sequence(s). How to do that? */  | 
322  | 1.83k  |   xmlXPathReturnEmptyString(ctxt);  | 
323  | 1.83k  |   xmlFree(str);  | 
324  | 1.83k  |   xmlFree(ret);  | 
325  | 1.83k  |   return;  | 
326  | 1.83k  |     }  | 
327  |  |  | 
328  | 4.01k  |     xmlXPathReturnString(ctxt, ret);  | 
329  |  |  | 
330  | 4.01k  |     if (str != NULL)  | 
331  | 4.01k  |   xmlFree(str);  | 
332  | 4.01k  | }  | 
333  |  |  | 
334  |  | /**  | 
335  |  |  * exsltStrPaddingFunction:  | 
336  |  |  * @ctxt: an XPath parser context  | 
337  |  |  * @nargs: the number of arguments  | 
338  |  |  *  | 
339  |  |  * Creates a padding string of a certain length.  | 
340  |  |  */  | 
341  |  | static void  | 
342  | 9.03k  | exsltStrPaddingFunction (xmlXPathParserContextPtr ctxt, int nargs) { | 
343  | 9.03k  |     int number, str_len = 0, str_size = 0;  | 
344  | 9.03k  |     double floatval;  | 
345  | 9.03k  |     xmlChar *str = NULL;  | 
346  | 9.03k  |     xmlBufferPtr buf;  | 
347  |  |  | 
348  | 9.03k  |     if ((nargs < 1) || (nargs > 2)) { | 
349  | 68  |   xmlXPathSetArityError(ctxt);  | 
350  | 68  |   return;  | 
351  | 68  |     }  | 
352  |  |  | 
353  | 8.96k  |     if (nargs == 2) { | 
354  | 8.17k  |   str = xmlXPathPopString(ctxt);  | 
355  | 8.17k  |   str_len = xmlUTF8Strlen(str);  | 
356  | 8.17k  |   str_size = xmlStrlen(str);  | 
357  | 8.17k  |     }  | 
358  |  |  | 
359  | 8.96k  |     floatval = xmlXPathPopNumber(ctxt);  | 
360  |  |  | 
361  | 8.96k  |     if (str_len <= 0) { | 
362  | 5.05k  |         if (str_len < 0) { | 
363  | 4.23k  |             xsltGenericError(xsltGenericErrorContext,  | 
364  | 4.23k  |                              "exsltStrPaddingFunction: invalid UTF-8\n");  | 
365  | 4.23k  |             xmlXPathReturnEmptyString(ctxt);  | 
366  | 4.23k  |             xmlFree(str);  | 
367  | 4.23k  |             return;  | 
368  | 4.23k  |         }  | 
369  | 821  |   if (str != NULL) xmlFree(str);  | 
370  | 821  |   str = xmlStrdup((const xmlChar *) " ");  | 
371  | 821  |   str_len = 1;  | 
372  | 821  |   str_size = 1;  | 
373  | 821  |     }  | 
374  |  |  | 
375  | 4.72k  |     if (xmlXPathIsNaN(floatval) || floatval < 0.0) { | 
376  | 584  |         number = 0;  | 
377  | 4.14k  |     } else if (floatval >= 100000.0) { | 
378  | 359  |         number = 100000;  | 
379  | 359  |     }  | 
380  | 3.78k  |     else { | 
381  | 3.78k  |         number = (int) floatval;  | 
382  | 3.78k  |     }  | 
383  |  |  | 
384  | 4.72k  |     if (number <= 0) { | 
385  | 1.01k  |   xmlXPathReturnEmptyString(ctxt);  | 
386  | 1.01k  |   xmlFree(str);  | 
387  | 1.01k  |   return;  | 
388  | 1.01k  |     }  | 
389  |  |  | 
390  | 3.71k  |     buf = xmlBufferCreateSize(number);  | 
391  | 3.71k  |     if (buf == NULL) { | 
392  | 0  |         xmlXPathSetError(ctxt, XPATH_MEMORY_ERROR);  | 
393  | 0  |   xmlFree(str);  | 
394  | 0  |   return;  | 
395  | 0  |     }  | 
396  | 3.71k  |     xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);  | 
397  |  |  | 
398  | 4.70M  |     while (number >= str_len) { | 
399  | 4.70M  |         xmlBufferAdd(buf, str, str_size);  | 
400  | 4.70M  |   number -= str_len;  | 
401  | 4.70M  |     }  | 
402  | 3.71k  |     if (number > 0) { | 
403  | 2.85k  |   str_size = xmlUTF8Strsize(str, number);  | 
404  | 2.85k  |         xmlBufferAdd(buf, str, str_size);  | 
405  | 2.85k  |     }  | 
406  |  |  | 
407  | 3.71k  |     xmlXPathReturnString(ctxt, xmlBufferDetach(buf));  | 
408  |  |  | 
409  | 3.71k  |     xmlBufferFree(buf);  | 
410  | 3.71k  |     if (str != NULL)  | 
411  | 3.71k  |   xmlFree(str);  | 
412  | 3.71k  | }  | 
413  |  |  | 
414  |  | /**  | 
415  |  |  * exsltStrAlignFunction:  | 
416  |  |  * @ctxt: an XPath parser context  | 
417  |  |  * @nargs: the number of arguments  | 
418  |  |  *  | 
419  |  |  * Aligns a string within another string.  | 
420  |  |  */  | 
421  |  | static void  | 
422  | 10.6k  | exsltStrAlignFunction (xmlXPathParserContextPtr ctxt, int nargs) { | 
423  | 10.6k  |     xmlChar *str, *padding, *alignment, *ret;  | 
424  | 10.6k  |     int str_l, padding_l;  | 
425  |  |  | 
426  | 10.6k  |     if ((nargs < 2) || (nargs > 3)) { | 
427  | 369  |   xmlXPathSetArityError(ctxt);  | 
428  | 369  |   return;  | 
429  | 369  |     }  | 
430  |  |  | 
431  | 10.2k  |     if (nargs == 3)  | 
432  | 5.48k  |   alignment = xmlXPathPopString(ctxt);  | 
433  | 4.80k  |     else  | 
434  | 4.80k  |   alignment = NULL;  | 
435  |  |  | 
436  | 10.2k  |     padding = xmlXPathPopString(ctxt);  | 
437  | 10.2k  |     str = xmlXPathPopString(ctxt);  | 
438  |  |  | 
439  | 10.2k  |     str_l = xmlUTF8Strlen (str);  | 
440  | 10.2k  |     padding_l = xmlUTF8Strlen (padding);  | 
441  |  |  | 
442  | 10.2k  |     if (str_l < 0 || padding_l < 0) { | 
443  | 4.16k  |         xsltGenericError(xsltGenericErrorContext,  | 
444  | 4.16k  |                          "exsltStrAlignFunction: invalid UTF-8\n");  | 
445  | 4.16k  |         xmlXPathReturnEmptyString(ctxt);  | 
446  | 4.16k  |         xmlFree(str);  | 
447  | 4.16k  |         xmlFree(padding);  | 
448  | 4.16k  |         xmlFree(alignment);  | 
449  | 4.16k  |         return;  | 
450  | 4.16k  |     }  | 
451  |  |  | 
452  | 6.12k  |     if (str_l == padding_l) { | 
453  | 627  |   xmlXPathReturnString (ctxt, str);  | 
454  | 627  |   xmlFree(padding);  | 
455  | 627  |   xmlFree(alignment);  | 
456  | 627  |   return;  | 
457  | 627  |     }  | 
458  |  |  | 
459  | 5.49k  |     if (str_l > padding_l) { | 
460  | 1.49k  |   ret = xmlUTF8Strndup (str, padding_l);  | 
461  | 3.99k  |     } else { | 
462  | 3.99k  |   if (xmlStrEqual(alignment, (const xmlChar *) "right")) { | 
463  | 311  |       ret = xmlUTF8Strndup (padding, padding_l - str_l);  | 
464  | 311  |       ret = xmlStrcat (ret, str);  | 
465  | 3.68k  |   } else if (xmlStrEqual(alignment, (const xmlChar *) "center")) { | 
466  | 970  |       int left = (padding_l - str_l) / 2;  | 
467  | 970  |       int right_start;  | 
468  |  |  | 
469  | 970  |       ret = xmlUTF8Strndup (padding, left);  | 
470  | 970  |       ret = xmlStrcat (ret, str);  | 
471  |  |  | 
472  | 970  |       right_start = xmlUTF8Strsize (padding, left + str_l);  | 
473  | 970  |       ret = xmlStrcat (ret, padding + right_start);  | 
474  | 2.71k  |   } else { | 
475  | 2.71k  |       int str_s;  | 
476  |  |  | 
477  | 2.71k  |       str_s = xmlUTF8Strsize(padding, str_l);  | 
478  | 2.71k  |       ret = xmlStrdup (str);  | 
479  | 2.71k  |       ret = xmlStrcat (ret, padding + str_s);  | 
480  | 2.71k  |   }  | 
481  | 3.99k  |     }  | 
482  |  |  | 
483  | 5.49k  |     xmlXPathReturnString (ctxt, ret);  | 
484  |  |  | 
485  | 5.49k  |     xmlFree(str);  | 
486  | 5.49k  |     xmlFree(padding);  | 
487  | 5.49k  |     xmlFree(alignment);  | 
488  | 5.49k  | }  | 
489  |  |  | 
490  |  | /**  | 
491  |  |  * exsltStrConcatFunction:  | 
492  |  |  * @ctxt: an XPath parser context  | 
493  |  |  * @nargs: the number of arguments  | 
494  |  |  *  | 
495  |  |  * Takes a node set and returns the concatenation of the string values  | 
496  |  |  * of the nodes in that node set.  If the node set is empty, it  | 
497  |  |  * returns an empty string.  | 
498  |  |  */  | 
499  |  | static void  | 
500  | 732  | exsltStrConcatFunction (xmlXPathParserContextPtr ctxt, int nargs) { | 
501  | 732  |     xmlXPathObjectPtr obj;  | 
502  | 732  |     xmlBufferPtr buf;  | 
503  | 732  |     int i;  | 
504  |  |  | 
505  | 732  |     if (nargs  != 1) { | 
506  | 91  |   xmlXPathSetArityError(ctxt);  | 
507  | 91  |   return;  | 
508  | 91  |     }  | 
509  |  |  | 
510  | 641  |     if (!xmlXPathStackIsNodeSet(ctxt)) { | 
511  | 36  |   xmlXPathSetTypeError(ctxt);  | 
512  | 36  |   return;  | 
513  | 36  |     }  | 
514  |  |  | 
515  | 605  |     obj = valuePop (ctxt);  | 
516  |  |  | 
517  | 605  |     if (xmlXPathNodeSetIsEmpty(obj->nodesetval)) { | 
518  | 109  |         xmlXPathFreeObject(obj);  | 
519  | 109  |   xmlXPathReturnEmptyString(ctxt);  | 
520  | 109  |   return;  | 
521  | 109  |     }  | 
522  |  |  | 
523  | 496  |     buf = xmlBufferCreate();  | 
524  | 496  |     if (buf == NULL) { | 
525  | 0  |         xmlXPathSetError(ctxt, XPATH_MEMORY_ERROR);  | 
526  | 0  |         xmlXPathFreeObject(obj);  | 
527  | 0  |   return;  | 
528  | 0  |     }  | 
529  | 496  |     xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);  | 
530  |  |  | 
531  | 163k  |     for (i = 0; i < obj->nodesetval->nodeNr; i++) { | 
532  | 163k  |   xmlChar *tmp;  | 
533  | 163k  |   tmp = xmlXPathCastNodeToString(obj->nodesetval->nodeTab[i]);  | 
534  |  |  | 
535  | 163k  |         xmlBufferCat(buf, tmp);  | 
536  |  |  | 
537  | 163k  |   xmlFree(tmp);  | 
538  | 163k  |     }  | 
539  |  |  | 
540  | 496  |     xmlXPathFreeObject (obj);  | 
541  |  |  | 
542  | 496  |     xmlXPathReturnString(ctxt, xmlBufferDetach(buf));  | 
543  | 496  |     xmlBufferFree(buf);  | 
544  | 496  | }  | 
545  |  |  | 
546  |  | /**  | 
547  |  |  * exsltStrReturnString:  | 
548  |  |  * @ctxt: an XPath parser context  | 
549  |  |  * @str: a string  | 
550  |  |  * @len: length of string  | 
551  |  |  *  | 
552  |  |  * Returns a string as a node set.  | 
553  |  |  */  | 
554  |  | static int  | 
555  |  | exsltStrReturnString(xmlXPathParserContextPtr ctxt, const xmlChar *str,  | 
556  |  |                      int len)  | 
557  | 10.5k  | { | 
558  | 10.5k  |     xsltTransformContextPtr tctxt = xsltXPathGetTransformContext(ctxt);  | 
559  | 10.5k  |     xmlDocPtr container;  | 
560  | 10.5k  |     xmlNodePtr text_node;  | 
561  | 10.5k  |     xmlXPathObjectPtr ret;  | 
562  |  |  | 
563  | 10.5k  |     container = xsltCreateRVT(tctxt);  | 
564  | 10.5k  |     if (container == NULL) { | 
565  | 0  |         xmlXPathSetError(ctxt, XPATH_MEMORY_ERROR);  | 
566  | 0  |         return(-1);  | 
567  | 0  |     }  | 
568  | 10.5k  |     xsltRegisterLocalRVT(tctxt, container);  | 
569  |  |  | 
570  | 10.5k  |     text_node = xmlNewTextLen(str, len);  | 
571  | 10.5k  |     if (text_node == NULL) { | 
572  | 0  |         xmlXPathSetError(ctxt, XPATH_MEMORY_ERROR);  | 
573  | 0  |         return(-1);  | 
574  | 0  |     }  | 
575  | 10.5k  |     xmlAddChild((xmlNodePtr) container, text_node);  | 
576  |  |  | 
577  | 10.5k  |     ret = xmlXPathNewNodeSet(text_node);  | 
578  | 10.5k  |     if (ret == NULL) { | 
579  | 0  |         xmlXPathSetError(ctxt, XPATH_MEMORY_ERROR);  | 
580  | 0  |         return(-1);  | 
581  | 0  |     }  | 
582  |  |  | 
583  | 10.5k  |     valuePush(ctxt, ret);  | 
584  |  |  | 
585  | 10.5k  |     return(0);  | 
586  | 10.5k  | }  | 
587  |  |  | 
588  |  | /**  | 
589  |  |  * exsltStrReplaceFunction:  | 
590  |  |  * @ctxt: an XPath parser context  | 
591  |  |  * @nargs: the number of arguments  | 
592  |  |  *  | 
593  |  |  * Takes a string, and two node sets and returns the string with all strings in  | 
594  |  |  * the first node set replaced by all strings in the second node set.  | 
595  |  |  */  | 
596  |  | static void  | 
597  | 11.0k  | exsltStrReplaceFunction (xmlXPathParserContextPtr ctxt, int nargs) { | 
598  | 11.0k  |     int i, i_empty, n, slen0, rlen0, *slen, *rlen;  | 
599  | 11.0k  |     void *mem = NULL;  | 
600  | 11.0k  |     const xmlChar *src, *start;  | 
601  | 11.0k  |     xmlChar *string, *search_str = NULL, *replace_str = NULL;  | 
602  | 11.0k  |     xmlChar **search, **replace;  | 
603  | 11.0k  |     xmlNodeSetPtr search_set = NULL, replace_set = NULL;  | 
604  | 11.0k  |     xmlBufferPtr buf;  | 
605  |  |  | 
606  | 11.0k  |     if (nargs  != 3) { | 
607  | 572  |         xmlXPathSetArityError(ctxt);  | 
608  | 572  |         return;  | 
609  | 572  |     }  | 
610  |  |  | 
611  |  |     /* get replace argument */  | 
612  |  |  | 
613  | 10.5k  |     if (!xmlXPathStackIsNodeSet(ctxt))  | 
614  | 1.87k  |         replace_str = xmlXPathPopString(ctxt);  | 
615  | 8.64k  |     else  | 
616  | 8.64k  |         replace_set = xmlXPathPopNodeSet(ctxt);  | 
617  |  |  | 
618  | 10.5k  |     if (xmlXPathCheckError(ctxt))  | 
619  | 0  |         goto fail_replace;  | 
620  |  |  | 
621  |  |     /* get search argument */  | 
622  |  |  | 
623  | 10.5k  |     if (!xmlXPathStackIsNodeSet(ctxt)) { | 
624  | 1.26k  |         search_str = xmlXPathPopString(ctxt);  | 
625  | 1.26k  |         n = 1;  | 
626  | 1.26k  |     }  | 
627  | 9.25k  |     else { | 
628  | 9.25k  |         search_set = xmlXPathPopNodeSet(ctxt);  | 
629  | 9.25k  |         n = search_set != NULL ? search_set->nodeNr : 0;  | 
630  | 9.25k  |     }  | 
631  |  |  | 
632  | 10.5k  |     if (xmlXPathCheckError(ctxt))  | 
633  | 0  |         goto fail_search;  | 
634  |  |  | 
635  |  |     /* get string argument */  | 
636  |  |  | 
637  | 10.5k  |     string = xmlXPathPopString(ctxt);  | 
638  | 10.5k  |     if (xmlXPathCheckError(ctxt))  | 
639  | 0  |         goto fail_string;  | 
640  |  |  | 
641  |  |     /* check for empty search node list */  | 
642  |  |  | 
643  | 10.5k  |     if (n <= 0) { | 
644  | 471  |         exsltStrReturnString(ctxt, string, xmlStrlen(string));  | 
645  | 471  |         goto done_empty_search;  | 
646  | 471  |     }  | 
647  |  |  | 
648  |  |     /* allocate memory for string pointer and length arrays */  | 
649  |  |  | 
650  | 10.0k  |     if (n == 1) { | 
651  | 2.25k  |         search = &search_str;  | 
652  | 2.25k  |         replace = &replace_str;  | 
653  | 2.25k  |         slen = &slen0;  | 
654  | 2.25k  |         rlen = &rlen0;  | 
655  | 2.25k  |     }  | 
656  | 7.79k  |     else { | 
657  | 7.79k  |         mem = xmlMalloc(2 * n * (sizeof(const xmlChar *) + sizeof(int)));  | 
658  | 7.79k  |         if (mem == NULL) { | 
659  | 0  |             xmlXPathSetError(ctxt, XPATH_MEMORY_ERROR);  | 
660  | 0  |             goto fail_malloc;  | 
661  | 0  |         }  | 
662  | 7.79k  |         search = (xmlChar **) mem;  | 
663  | 7.79k  |         replace = search + n;  | 
664  | 7.79k  |         slen = (int *) (replace + n);  | 
665  | 7.79k  |         rlen = slen + n;  | 
666  | 7.79k  |     }  | 
667  |  |  | 
668  |  |     /* process arguments */  | 
669  |  |  | 
670  | 10.0k  |     i_empty = -1;  | 
671  |  |  | 
672  | 364k  |     for (i=0; i<n; ++i) { | 
673  | 354k  |         if (search_set != NULL) { | 
674  | 352k  |             search[i] = xmlXPathCastNodeToString(search_set->nodeTab[i]);  | 
675  | 352k  |             if (search[i] == NULL) { | 
676  | 0  |                 n = i;  | 
677  | 0  |                 goto fail_process_args;  | 
678  | 0  |             }  | 
679  | 352k  |         }  | 
680  |  |  | 
681  | 354k  |         slen[i] = xmlStrlen(search[i]);  | 
682  | 354k  |         if (i_empty < 0 && slen[i] == 0)  | 
683  | 647  |             i_empty = i;  | 
684  |  |  | 
685  | 354k  |         if (replace_set != NULL) { | 
686  | 342k  |             if (i < replace_set->nodeNr) { | 
687  | 24.3k  |                 replace[i] = xmlXPathCastNodeToString(replace_set->nodeTab[i]);  | 
688  | 24.3k  |                 if (replace[i] == NULL) { | 
689  | 0  |                     n = i + 1;  | 
690  | 0  |                     goto fail_process_args;  | 
691  | 0  |                 }  | 
692  | 24.3k  |             }  | 
693  | 318k  |             else  | 
694  | 318k  |                 replace[i] = NULL;  | 
695  | 342k  |         }  | 
696  | 11.4k  |         else { | 
697  | 11.4k  |             if (i == 0)  | 
698  | 1.89k  |                 replace[i] = replace_str;  | 
699  | 9.55k  |             else  | 
700  | 9.55k  |                 replace[i] = NULL;  | 
701  | 11.4k  |         }  | 
702  |  |  | 
703  | 354k  |         if (replace[i] == NULL)  | 
704  | 328k  |             rlen[i] = 0;  | 
705  | 26.0k  |         else  | 
706  | 26.0k  |             rlen[i] = xmlStrlen(replace[i]);  | 
707  | 354k  |     }  | 
708  |  |  | 
709  | 10.0k  |     if (i_empty >= 0 && rlen[i_empty] == 0)  | 
710  | 130  |         i_empty = -1;  | 
711  |  |  | 
712  |  |     /* replace operation */  | 
713  |  |  | 
714  | 10.0k  |     buf = xmlBufferCreate();  | 
715  | 10.0k  |     if (buf == NULL) { | 
716  | 0  |         xmlXPathSetError(ctxt, XPATH_MEMORY_ERROR);  | 
717  | 0  |         goto fail_buffer;  | 
718  | 0  |     }  | 
719  | 10.0k  |     xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);  | 
720  | 10.0k  |     src = string;  | 
721  | 10.0k  |     start = string;  | 
722  |  |  | 
723  | 5.16M  |     while (*src != 0) { | 
724  | 5.15M  |         int max_len = 0, i_match = 0;  | 
725  |  |  | 
726  | 33.4M  |         for (i=0; i<n; ++i) { | 
727  | 28.2M  |             if (*src == search[i][0] &&  | 
728  | 28.2M  |                 slen[i] > max_len &&  | 
729  | 28.2M  |                 xmlStrncmp(src, search[i], slen[i]) == 0)  | 
730  | 874k  |             { | 
731  | 874k  |                 i_match = i;  | 
732  | 874k  |                 max_len = slen[i];  | 
733  | 874k  |             }  | 
734  | 28.2M  |         }  | 
735  |  |  | 
736  | 5.15M  |         if (max_len == 0) { | 
737  | 4.27M  |             if (i_empty >= 0 && start < src) { | 
738  | 577k  |                 if (xmlBufferAdd(buf, start, src - start) ||  | 
739  | 577k  |                     xmlBufferAdd(buf, replace[i_empty], rlen[i_empty]))  | 
740  | 0  |                 { | 
741  | 0  |                     xmlXPathSetError(ctxt, XPATH_MEMORY_ERROR);  | 
742  | 0  |                     goto fail_buffer_add;  | 
743  | 0  |                 }  | 
744  | 577k  |                 start = src;  | 
745  | 577k  |             }  | 
746  |  |  | 
747  | 4.27M  |             src += xmlUTF8Strsize(src, 1);  | 
748  | 4.27M  |         }  | 
749  | 874k  |         else { | 
750  | 874k  |             if ((start < src &&  | 
751  | 874k  |                  xmlBufferAdd(buf, start, src - start)) ||  | 
752  | 874k  |                 (rlen[i_match] &&  | 
753  | 874k  |                  xmlBufferAdd(buf, replace[i_match], rlen[i_match])))  | 
754  | 0  |             { | 
755  | 0  |                 xmlXPathSetError(ctxt, XPATH_MEMORY_ERROR);  | 
756  | 0  |                 goto fail_buffer_add;  | 
757  | 0  |             }  | 
758  |  |  | 
759  | 874k  |             src += slen[i_match];  | 
760  | 874k  |             start = src;  | 
761  | 874k  |         }  | 
762  | 5.15M  |     }  | 
763  |  |  | 
764  | 10.0k  |     if (start < src && xmlBufferAdd(buf, start, src - start)) { | 
765  | 0  |         xmlXPathSetError(ctxt, XPATH_MEMORY_ERROR);  | 
766  | 0  |         goto fail_buffer_add;  | 
767  | 0  |     }  | 
768  |  |  | 
769  |  |     /* create result node set */  | 
770  |  |  | 
771  | 10.0k  |     exsltStrReturnString(ctxt, xmlBufferContent(buf), xmlBufferLength(buf));  | 
772  |  |  | 
773  |  |     /* clean up */  | 
774  |  |  | 
775  | 10.0k  | fail_buffer_add:  | 
776  | 10.0k  |     xmlBufferFree(buf);  | 
777  |  |  | 
778  | 10.0k  | fail_buffer:  | 
779  | 10.0k  | fail_process_args:  | 
780  | 10.0k  |     if (search_set != NULL) { | 
781  | 361k  |         for (i=0; i<n; ++i)  | 
782  | 352k  |             xmlFree(search[i]);  | 
783  | 8.78k  |     }  | 
784  | 10.0k  |     if (replace_set != NULL) { | 
785  | 350k  |         for (i=0; i<n; ++i) { | 
786  | 342k  |             if (replace[i] != NULL)  | 
787  | 24.3k  |                 xmlFree(replace[i]);  | 
788  | 342k  |         }  | 
789  | 8.15k  |     }  | 
790  |  |  | 
791  | 10.0k  |     if (mem != NULL)  | 
792  | 7.79k  |         xmlFree(mem);  | 
793  |  |  | 
794  | 10.0k  | fail_malloc:  | 
795  | 10.5k  | done_empty_search:  | 
796  | 10.5k  |     xmlFree(string);  | 
797  |  |  | 
798  | 10.5k  | fail_string:  | 
799  | 10.5k  |     if (search_set != NULL)  | 
800  | 9.14k  |         xmlXPathFreeNodeSet(search_set);  | 
801  | 1.37k  |     else  | 
802  | 1.37k  |         xmlFree(search_str);  | 
803  |  |  | 
804  | 10.5k  | fail_search:  | 
805  | 10.5k  |     if (replace_set != NULL)  | 
806  | 8.49k  |         xmlXPathFreeNodeSet(replace_set);  | 
807  | 2.02k  |     else  | 
808  | 2.02k  |         xmlFree(replace_str);  | 
809  |  |  | 
810  | 10.5k  | fail_replace:  | 
811  | 10.5k  |     return;  | 
812  | 10.5k  | }  | 
813  |  |  | 
814  |  | /**  | 
815  |  |  * exsltStrRegister:  | 
816  |  |  *  | 
817  |  |  * Registers the EXSLT - Strings module  | 
818  |  |  */  | 
819  |  |  | 
820  |  | void  | 
821  | 3.38k  | exsltStrRegister (void) { | 
822  | 3.38k  |     xsltRegisterExtModuleFunction ((const xmlChar *) "tokenize",  | 
823  | 3.38k  |            EXSLT_STRINGS_NAMESPACE,  | 
824  | 3.38k  |            exsltStrTokenizeFunction);  | 
825  | 3.38k  |     xsltRegisterExtModuleFunction ((const xmlChar *) "split",  | 
826  | 3.38k  |            EXSLT_STRINGS_NAMESPACE,  | 
827  | 3.38k  |            exsltStrSplitFunction);  | 
828  | 3.38k  |     xsltRegisterExtModuleFunction ((const xmlChar *) "encode-uri",  | 
829  | 3.38k  |            EXSLT_STRINGS_NAMESPACE,  | 
830  | 3.38k  |            exsltStrEncodeUriFunction);  | 
831  | 3.38k  |     xsltRegisterExtModuleFunction ((const xmlChar *) "decode-uri",  | 
832  | 3.38k  |            EXSLT_STRINGS_NAMESPACE,  | 
833  | 3.38k  |            exsltStrDecodeUriFunction);  | 
834  | 3.38k  |     xsltRegisterExtModuleFunction ((const xmlChar *) "padding",  | 
835  | 3.38k  |            EXSLT_STRINGS_NAMESPACE,  | 
836  | 3.38k  |            exsltStrPaddingFunction);  | 
837  | 3.38k  |     xsltRegisterExtModuleFunction ((const xmlChar *) "align",  | 
838  | 3.38k  |            EXSLT_STRINGS_NAMESPACE,  | 
839  | 3.38k  |            exsltStrAlignFunction);  | 
840  | 3.38k  |     xsltRegisterExtModuleFunction ((const xmlChar *) "concat",  | 
841  | 3.38k  |            EXSLT_STRINGS_NAMESPACE,  | 
842  | 3.38k  |            exsltStrConcatFunction);  | 
843  | 3.38k  |     xsltRegisterExtModuleFunction ((const xmlChar *) "replace",  | 
844  | 3.38k  |            EXSLT_STRINGS_NAMESPACE,  | 
845  | 3.38k  |            exsltStrReplaceFunction);  | 
846  | 3.38k  | }  | 
847  |  |  | 
848  |  | /**  | 
849  |  |  * exsltStrXpathCtxtRegister:  | 
850  |  |  *  | 
851  |  |  * Registers the EXSLT - Strings module for use outside XSLT  | 
852  |  |  */  | 
853  |  | int  | 
854  |  | exsltStrXpathCtxtRegister (xmlXPathContextPtr ctxt, const xmlChar *prefix)  | 
855  | 0  | { | 
856  | 0  |     if (ctxt  | 
857  | 0  |         && prefix  | 
858  | 0  |         && !xmlXPathRegisterNs(ctxt,  | 
859  | 0  |                                prefix,  | 
860  | 0  |                                (const xmlChar *) EXSLT_STRINGS_NAMESPACE)  | 
861  | 0  |         && !xmlXPathRegisterFuncNS(ctxt,  | 
862  | 0  |                                    (const xmlChar *) "encode-uri",  | 
863  | 0  |                                    (const xmlChar *) EXSLT_STRINGS_NAMESPACE,  | 
864  | 0  |                                    exsltStrEncodeUriFunction)  | 
865  | 0  |         && !xmlXPathRegisterFuncNS(ctxt,  | 
866  | 0  |                                    (const xmlChar *) "decode-uri",  | 
867  | 0  |                                    (const xmlChar *) EXSLT_STRINGS_NAMESPACE,  | 
868  | 0  |                                    exsltStrDecodeUriFunction)  | 
869  | 0  |         && !xmlXPathRegisterFuncNS(ctxt,  | 
870  | 0  |                                    (const xmlChar *) "padding",  | 
871  | 0  |                                    (const xmlChar *) EXSLT_STRINGS_NAMESPACE,  | 
872  | 0  |                                    exsltStrPaddingFunction)  | 
873  | 0  |         && !xmlXPathRegisterFuncNS(ctxt,  | 
874  | 0  |                                    (const xmlChar *) "align",  | 
875  | 0  |                                    (const xmlChar *) EXSLT_STRINGS_NAMESPACE,  | 
876  | 0  |                                    exsltStrAlignFunction)  | 
877  | 0  |         && !xmlXPathRegisterFuncNS(ctxt,  | 
878  | 0  |                                    (const xmlChar *) "concat",  | 
879  | 0  |                                    (const xmlChar *) EXSLT_STRINGS_NAMESPACE,  | 
880  | 0  |                                    exsltStrConcatFunction)) { | 
881  | 0  |         return 0;  | 
882  | 0  |     }  | 
883  | 0  |     return -1;  | 
884  | 0  | }  |