| OLD | NEW |
| 1 /* | 1 /* |
| 2 * xmlsave.c: Implemetation of the document serializer | 2 * xmlsave.c: Implemetation of the document serializer |
| 3 * | 3 * |
| 4 * See Copyright for the status of this software. | 4 * See Copyright for the status of this software. |
| 5 * | 5 * |
| 6 * daniel@veillard.com | 6 * daniel@veillard.com |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #define IN_LIBXML | 9 #define IN_LIBXML |
| 10 #include "libxml.h" | 10 #include "libxml.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 (*in == '\n') || (*in == '\t')) { | 241 (*in == '\n') || (*in == '\t')) { |
| 242 /* | 242 /* |
| 243 * default case, just copy ! | 243 * default case, just copy ! |
| 244 */ | 244 */ |
| 245 *out++ = *in++; | 245 *out++ = *in++; |
| 246 continue; | 246 continue; |
| 247 } else if (*in >= 0x80) { | 247 } else if (*in >= 0x80) { |
| 248 /* | 248 /* |
| 249 * We assume we have UTF-8 input. | 249 * We assume we have UTF-8 input. |
| 250 */ | 250 */ |
| 251 » if (outend - out < 10) break; | 251 » if (outend - out < 11) break; |
| 252 | 252 |
| 253 if (*in < 0xC0) { | 253 if (*in < 0xC0) { |
| 254 xmlSaveErr(XML_SAVE_NOT_UTF8, NULL, NULL); | 254 xmlSaveErr(XML_SAVE_NOT_UTF8, NULL, NULL); |
| 255 in++; | 255 in++; |
| 256 goto error; | 256 goto error; |
| 257 } else if (*in < 0xE0) { | 257 } else if (*in < 0xE0) { |
| 258 if (inend - in < 2) break; | 258 if (inend - in < 2) break; |
| 259 val = (in[0]) & 0x1F; | 259 val = (in[0]) & 0x1F; |
| 260 val <<= 6; | 260 val <<= 6; |
| 261 val |= (in[1]) & 0x3F; | 261 val |= (in[1]) & 0x3F; |
| (...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1921 if (base != cur) | 1921 if (base != cur) |
| 1922 xmlBufferAdd(buf, base, cur - base); | 1922 xmlBufferAdd(buf, base, cur - base); |
| 1923 xmlBufferAdd(buf, BAD_CAST "&", 5); | 1923 xmlBufferAdd(buf, BAD_CAST "&", 5); |
| 1924 cur++; | 1924 cur++; |
| 1925 base = cur; | 1925 base = cur; |
| 1926 } else if ((*cur >= 0x80) && ((doc == NULL) || | 1926 } else if ((*cur >= 0x80) && ((doc == NULL) || |
| 1927 (doc->encoding == NULL))) { | 1927 (doc->encoding == NULL))) { |
| 1928 /* | 1928 /* |
| 1929 * We assume we have UTF-8 content. | 1929 * We assume we have UTF-8 content. |
| 1930 */ | 1930 */ |
| 1931 unsigned char tmp[10]; | 1931 unsigned char tmp[12]; |
| 1932 int val = 0, l = 1; | 1932 int val = 0, l = 1; |
| 1933 | 1933 |
| 1934 if (base != cur) | 1934 if (base != cur) |
| 1935 xmlBufferAdd(buf, base, cur - base); | 1935 xmlBufferAdd(buf, base, cur - base); |
| 1936 if (*cur < 0xC0) { | 1936 if (*cur < 0xC0) { |
| 1937 xmlSaveErr(XML_SAVE_NOT_UTF8, (xmlNodePtr) attr, NULL); | 1937 xmlSaveErr(XML_SAVE_NOT_UTF8, (xmlNodePtr) attr, NULL); |
| 1938 if (doc != NULL) | 1938 if (doc != NULL) |
| 1939 doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1"); | 1939 doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1"); |
| 1940 xmlSerializeHexCharRef(tmp, *cur); | 1940 xmlSerializeHexCharRef(tmp, *cur); |
| 1941 xmlBufferAdd(buf, (xmlChar *) tmp, -1); | 1941 xmlBufferAdd(buf, (xmlChar *) tmp, -1); |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2540 */ | 2540 */ |
| 2541 int | 2541 int |
| 2542 xmlSaveFile(const char *filename, xmlDocPtr cur) { | 2542 xmlSaveFile(const char *filename, xmlDocPtr cur) { |
| 2543 return(xmlSaveFormatFileEnc(filename, cur, NULL, 0)); | 2543 return(xmlSaveFormatFileEnc(filename, cur, NULL, 0)); |
| 2544 } | 2544 } |
| 2545 | 2545 |
| 2546 #endif /* LIBXML_OUTPUT_ENABLED */ | 2546 #endif /* LIBXML_OUTPUT_ENABLED */ |
| 2547 | 2547 |
| 2548 #define bottom_xmlsave | 2548 #define bottom_xmlsave |
| 2549 #include "elfgcchack.h" | 2549 #include "elfgcchack.h" |
| OLD | NEW |