1 diff --git a/gettext-tools/gnulib-lib/libxml/valid.c b/gettext-tools/gnulib-lib/libxml/valid.c
2 index 22ade700..182c9d5c 100644
3 --- a/gettext-tools/gnulib-lib/libxml/valid.c
4 +++ b/gettext-tools/gnulib-lib/libxml/valid.c
5 @@ -936,6 +936,36 @@ xmlFreeValidCtxt(xmlValidCtxtPtr cur) {
7 #endif /* LIBXML_VALID_ENABLED */
10 + * xmlValidNormalizeString:
13 + * Normalize a string in-place.
16 +xmlValidNormalizeString(xmlChar *str) {
25 + while (*src == 0x20) src++;
28 + while (*src == 0x20) src++;
40 * xmlNewDocElementContent:
42 @@ -2593,6 +2623,24 @@ xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
43 (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
44 xmlFree((char *)(str));
47 +xmlIsStreaming(xmlValidCtxtPtr ctxt) {
48 + xmlParserCtxtPtr pctxt;
53 + * These magic values are also abused to detect whether we're validating
54 + * while parsing a document. In this case, userData points to the parser
57 + if ((ctxt->finishDtd != XML_CTXT_FINISH_DTD_0) &&
58 + (ctxt->finishDtd != XML_CTXT_FINISH_DTD_1))
60 + pctxt = ctxt->userData;
61 + return(pctxt->parseMode == XML_PARSE_READER);
67 @@ -2636,7 +2684,7 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
71 - if (value == NULL) {
72 + if ((value == NULL) || (value[0] == 0)) {
76 @@ -2667,7 +2715,7 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
78 ret->value = xmlStrdup(value);
80 - if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
81 + if (xmlIsStreaming(ctxt)) {
83 * Operating in streaming mode, attr is gonna disapear
85 @@ -2806,6 +2854,7 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
86 ID = xmlNodeListGetString(doc, attr->children, 1);
89 + xmlValidNormalizeString(ID);
91 id = xmlHashLookup(table, ID);
92 if (id == NULL || id->attr != attr) {
93 @@ -2995,7 +3044,7 @@ xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
96 ret->value = xmlStrdup(value);
97 - if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
98 + if (xmlIsStreaming(ctxt)) {
100 * Operating in streaming mode, attr is gonna disapear
102 @@ -4014,8 +4063,7 @@ xmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
104 xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
105 xmlNodePtr elem, const xmlChar *name, const xmlChar *value) {
106 - xmlChar *ret, *dst;
107 - const xmlChar *src;
109 xmlAttributePtr attrDecl = NULL;
112 @@ -4056,19 +4104,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
113 ret = xmlStrdup(value);
118 - while (*src == 0x20) src++;
119 - while (*src != 0) {
120 - if (*src == 0x20) {
121 - while (*src == 0x20) src++;
129 + xmlValidNormalizeString(ret);
130 if ((doc->standalone) && (extsubset == 1) && (!xmlStrEqual(value, ret))) {
131 xmlErrValidNode(ctxt, elem, XML_DTD_NOT_STANDALONE,
132 "standalone: %s on %s value had to be normalized based on external subset declaration\n",
133 @@ -4100,8 +4136,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
135 xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
136 const xmlChar *name, const xmlChar *value) {
137 - xmlChar *ret, *dst;
138 - const xmlChar *src;
140 xmlAttributePtr attrDecl = NULL;
142 if (doc == NULL) return(NULL);
143 @@ -4131,19 +4166,7 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
144 ret = xmlStrdup(value);
149 - while (*src == 0x20) src++;
150 - while (*src != 0) {
151 - if (*src == 0x20) {
152 - while (*src == 0x20) src++;
160 + xmlValidNormalizeString(ret);
164 diff --git a/gnulib-local/lib/libxml/valid.c b/gnulib-local/lib/libxml/valid.c
165 index 22ade700..85b67bc1 100644
166 --- a/gnulib-local/lib/libxml/valid.c
167 +++ b/gnulib-local/lib/libxml/valid.c
168 @@ -936,6 +936,35 @@ xmlFreeValidCtxt(xmlValidCtxtPtr cur) {
170 #endif /* LIBXML_VALID_ENABLED */
173 + * xmlValidNormalizeString:
176 + * Normalize a string in-place.
179 +xmlValidNormalizeString(xmlChar *str) {
181 + const xmlChar *src;
188 + while (*src == 0x20) src++;
189 + while (*src != 0) {
190 + if (*src == 0x20) {
191 + while (*src == 0x20) src++;
202 * xmlNewDocElementContent:
204 @@ -2593,6 +2622,24 @@ xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
205 (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
206 xmlFree((char *)(str));
209 +xmlIsStreaming(xmlValidCtxtPtr ctxt) {
210 + xmlParserCtxtPtr pctxt;
215 + * These magic values are also abused to detect whether we're validating
216 + * while parsing a document. In this case, userData points to the parser
219 + if ((ctxt->finishDtd != XML_CTXT_FINISH_DTD_0) &&
220 + (ctxt->finishDtd != XML_CTXT_FINISH_DTD_1))
222 + pctxt = ctxt->userData;
223 + return(pctxt->parseMode == XML_PARSE_READER);
229 @@ -2636,7 +2683,7 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
233 - if (value == NULL) {
234 + if ((value == NULL) || (value[0] == 0)) {
238 @@ -2667,7 +2714,7 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
240 ret->value = xmlStrdup(value);
242 - if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
243 + if (xmlIsStreaming(ctxt)) {
245 * Operating in streaming mode, attr is gonna disapear
247 @@ -2806,6 +2853,7 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
248 ID = xmlNodeListGetString(doc, attr->children, 1);
251 + xmlValidNormalizeString(ID);
253 id = xmlHashLookup(table, ID);
254 if (id == NULL || id->attr != attr) {
255 @@ -2995,7 +3043,7 @@ xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
256 * fill the structure.
258 ret->value = xmlStrdup(value);
259 - if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
260 + if (xmlIsStreaming(ctxt)) {
262 * Operating in streaming mode, attr is gonna disapear
264 @@ -4014,8 +4062,7 @@ xmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
266 xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
267 xmlNodePtr elem, const xmlChar *name, const xmlChar *value) {
268 - xmlChar *ret, *dst;
269 - const xmlChar *src;
271 xmlAttributePtr attrDecl = NULL;
274 @@ -4056,19 +4103,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
275 ret = xmlStrdup(value);
280 - while (*src == 0x20) src++;
281 - while (*src != 0) {
282 - if (*src == 0x20) {
283 - while (*src == 0x20) src++;
291 + xmlValidNormalizeString(ret);
292 if ((doc->standalone) && (extsubset == 1) && (!xmlStrEqual(value, ret))) {
293 xmlErrValidNode(ctxt, elem, XML_DTD_NOT_STANDALONE,
294 "standalone: %s on %s value had to be normalized based on external subset declaration\n",
295 @@ -4100,8 +4135,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
297 xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
298 const xmlChar *name, const xmlChar *value) {
299 - xmlChar *ret, *dst;
300 - const xmlChar *src;
302 xmlAttributePtr attrDecl = NULL;
304 if (doc == NULL) return(NULL);
305 @@ -4131,19 +4165,7 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
306 ret = xmlStrdup(value);
311 - while (*src == 0x20) src++;
312 - while (*src != 0) {
313 - if (*src == 0x20) {
314 - while (*src == 0x20) src++;
322 + xmlValidNormalizeString(ret);
326 diff --git a/libtextstyle/lib/libxml/valid.c b/libtextstyle/lib/libxml/valid.c
327 index 22ade700..182c9d5c 100644
328 --- a/libtextstyle/lib/libxml/valid.c
329 +++ b/libtextstyle/lib/libxml/valid.c
330 @@ -936,6 +936,36 @@ xmlFreeValidCtxt(xmlValidCtxtPtr cur) {
332 #endif /* LIBXML_VALID_ENABLED */
335 + * xmlValidNormalizeString:
338 + * Normalize a string in-place.
341 +xmlValidNormalizeString(xmlChar *str) {
343 + const xmlChar *src;
350 + while (*src == 0x20) src++;
351 + while (*src != 0) {
352 + if (*src == 0x20) {
353 + while (*src == 0x20) src++;
365 * xmlNewDocElementContent:
367 @@ -2593,6 +2623,24 @@ xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
368 (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
369 xmlFree((char *)(str));
372 +xmlIsStreaming(xmlValidCtxtPtr ctxt) {
373 + xmlParserCtxtPtr pctxt;
378 + * These magic values are also abused to detect whether we're validating
379 + * while parsing a document. In this case, userData points to the parser
382 + if ((ctxt->finishDtd != XML_CTXT_FINISH_DTD_0) &&
383 + (ctxt->finishDtd != XML_CTXT_FINISH_DTD_1))
385 + pctxt = ctxt->userData;
386 + return(pctxt->parseMode == XML_PARSE_READER);
392 @@ -2636,7 +2684,7 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
396 - if (value == NULL) {
397 + if ((value == NULL) || (value[0] == 0)) {
401 @@ -2667,7 +2715,7 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
403 ret->value = xmlStrdup(value);
405 - if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
406 + if (xmlIsStreaming(ctxt)) {
408 * Operating in streaming mode, attr is gonna disapear
410 @@ -2806,6 +2854,7 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
411 ID = xmlNodeListGetString(doc, attr->children, 1);
414 + xmlValidNormalizeString(ID);
416 id = xmlHashLookup(table, ID);
417 if (id == NULL || id->attr != attr) {
418 @@ -2995,7 +3044,7 @@ xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
419 * fill the structure.
421 ret->value = xmlStrdup(value);
422 - if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
423 + if (xmlIsStreaming(ctxt)) {
425 * Operating in streaming mode, attr is gonna disapear
427 @@ -4014,8 +4063,7 @@ xmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
429 xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
430 xmlNodePtr elem, const xmlChar *name, const xmlChar *value) {
431 - xmlChar *ret, *dst;
432 - const xmlChar *src;
434 xmlAttributePtr attrDecl = NULL;
437 @@ -4056,19 +4104,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
438 ret = xmlStrdup(value);
443 - while (*src == 0x20) src++;
444 - while (*src != 0) {
445 - if (*src == 0x20) {
446 - while (*src == 0x20) src++;
454 + xmlValidNormalizeString(ret);
455 if ((doc->standalone) && (extsubset == 1) && (!xmlStrEqual(value, ret))) {
456 xmlErrValidNode(ctxt, elem, XML_DTD_NOT_STANDALONE,
457 "standalone: %s on %s value had to be normalized based on external subset declaration\n",
458 @@ -4100,8 +4136,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
460 xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
461 const xmlChar *name, const xmlChar *value) {
462 - xmlChar *ret, *dst;
463 - const xmlChar *src;
465 xmlAttributePtr attrDecl = NULL;
467 if (doc == NULL) return(NULL);
468 @@ -4131,19 +4166,7 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
469 ret = xmlStrdup(value);
474 - while (*src == 0x20) src++;
475 - while (*src != 0) {
476 - if (*src == 0x20) {
477 - while (*src == 0x20) src++;
485 + xmlValidNormalizeString(ret);