| OLD | NEW |
| 1 /* | 1 /* |
| 2 * parserInternals.c : Internal routines (and obsolete ones) needed for the | 2 * parserInternals.c : Internal routines (and obsolete ones) needed for the |
| 3 * XML and HTML parsers. | 3 * XML and HTML parsers. |
| 4 * | 4 * |
| 5 * See Copyright for the status of this software. | 5 * See Copyright for the status of this software. |
| 6 * | 6 * |
| 7 * daniel@veillard.com | 7 * daniel@veillard.com |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 #define IN_LIBXML | 10 #define IN_LIBXML |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 * change the input functions when discovering the character encoding | 930 * change the input functions when discovering the character encoding |
| 931 * of a given entity. | 931 * of a given entity. |
| 932 * | 932 * |
| 933 * Returns 0 in case of success, -1 otherwise | 933 * Returns 0 in case of success, -1 otherwise |
| 934 */ | 934 */ |
| 935 int | 935 int |
| 936 xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc) | 936 xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc) |
| 937 { | 937 { |
| 938 xmlCharEncodingHandlerPtr handler; | 938 xmlCharEncodingHandlerPtr handler; |
| 939 int len = -1; | 939 int len = -1; |
| 940 int ret; |
| 940 | 941 |
| 941 if (ctxt == NULL) return(-1); | 942 if (ctxt == NULL) return(-1); |
| 942 switch (enc) { | 943 switch (enc) { |
| 943 case XML_CHAR_ENCODING_ERROR: | 944 case XML_CHAR_ENCODING_ERROR: |
| 944 __xmlErrEncoding(ctxt, XML_ERR_UNKNOWN_ENCODING, | 945 __xmlErrEncoding(ctxt, XML_ERR_UNKNOWN_ENCODING, |
| 945 "encoding unknown\n", NULL, NULL); | 946 "encoding unknown\n", NULL, NULL); |
| 946 return(-1); | 947 return(-1); |
| 947 case XML_CHAR_ENCODING_NONE: | 948 case XML_CHAR_ENCODING_NONE: |
| 948 /* let's assume it's UTF-8 without the XML decl */ | 949 /* let's assume it's UTF-8 without the XML decl */ |
| 949 ctxt->charset = XML_CHAR_ENCODING_UTF8; | 950 ctxt->charset = XML_CHAR_ENCODING_UTF8; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 "encoding not supported %s\n", | 1091 "encoding not supported %s\n", |
| 1091 BAD_CAST "EUC-JP", NULL); | 1092 BAD_CAST "EUC-JP", NULL); |
| 1092 break; | 1093 break; |
| 1093 default: | 1094 default: |
| 1094 break; | 1095 break; |
| 1095 } | 1096 } |
| 1096 } | 1097 } |
| 1097 if (handler == NULL) | 1098 if (handler == NULL) |
| 1098 return(-1); | 1099 return(-1); |
| 1099 ctxt->charset = XML_CHAR_ENCODING_UTF8; | 1100 ctxt->charset = XML_CHAR_ENCODING_UTF8; |
| 1100 return(xmlSwitchToEncodingInt(ctxt, handler, len)); | 1101 ret = xmlSwitchToEncodingInt(ctxt, handler, len); |
| 1102 if ((ret < 0) || (ctxt->errNo == XML_I18N_CONV_FAILED)) { |
| 1103 /* |
| 1104 » * on encoding conversion errors, stop the parser |
| 1105 » */ |
| 1106 xmlStopParser(ctxt); |
| 1107 » ctxt->errNo = XML_I18N_CONV_FAILED; |
| 1108 } |
| 1109 return(ret); |
| 1101 } | 1110 } |
| 1102 | 1111 |
| 1103 /** | 1112 /** |
| 1104 * xmlSwitchInputEncoding: | 1113 * xmlSwitchInputEncoding: |
| 1105 * @ctxt: the parser context | 1114 * @ctxt: the parser context |
| 1106 * @input: the input stream | 1115 * @input: the input stream |
| 1107 * @handler: the encoding handler | 1116 * @handler: the encoding handler |
| 1108 * @len: the number of bytes to convert for the first line or -1 | 1117 * @len: the number of bytes to convert for the first line or -1 |
| 1109 * | 1118 * |
| 1110 * change the input functions when discovering the character encoding | 1119 * change the input functions when discovering the character encoding |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 } | 1452 } |
| 1444 return(NULL); | 1453 return(NULL); |
| 1445 } | 1454 } |
| 1446 input = xmlNewInputStream(ctxt); | 1455 input = xmlNewInputStream(ctxt); |
| 1447 if (input == NULL) { | 1456 if (input == NULL) { |
| 1448 return(NULL); | 1457 return(NULL); |
| 1449 } | 1458 } |
| 1450 if (entity->URI != NULL) | 1459 if (entity->URI != NULL) |
| 1451 input->filename = (char *) xmlStrdup((xmlChar *) entity->URI); | 1460 input->filename = (char *) xmlStrdup((xmlChar *) entity->URI); |
| 1452 input->base = entity->content; | 1461 input->base = entity->content; |
| 1462 if (entity->length == 0) |
| 1463 entity->length = xmlStrlen(entity->content); |
| 1453 input->cur = entity->content; | 1464 input->cur = entity->content; |
| 1454 input->length = entity->length; | 1465 input->length = entity->length; |
| 1455 input->end = &entity->content[input->length]; | 1466 input->end = &entity->content[input->length]; |
| 1456 return(input); | 1467 return(input); |
| 1457 } | 1468 } |
| 1458 | 1469 |
| 1459 /** | 1470 /** |
| 1460 * xmlNewStringInputStream: | 1471 * xmlNewStringInputStream: |
| 1461 * @ctxt: an XML parser context | 1472 * @ctxt: an XML parser context |
| 1462 * @buffer: an memory buffer | 1473 * @buffer: an memory buffer |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2131 xmlKeepBlanksDefault(int val) { | 2142 xmlKeepBlanksDefault(int val) { |
| 2132 int old = xmlKeepBlanksDefaultValue; | 2143 int old = xmlKeepBlanksDefaultValue; |
| 2133 | 2144 |
| 2134 xmlKeepBlanksDefaultValue = val; | 2145 xmlKeepBlanksDefaultValue = val; |
| 2135 if (!val) xmlIndentTreeOutput = 1; | 2146 if (!val) xmlIndentTreeOutput = 1; |
| 2136 return(old); | 2147 return(old); |
| 2137 } | 2148 } |
| 2138 | 2149 |
| 2139 #define bottom_parserInternals | 2150 #define bottom_parserInternals |
| 2140 #include "elfgcchack.h" | 2151 #include "elfgcchack.h" |
| OLD | NEW |