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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx | 487 * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx |
488 * | 488 * |
489 * Check for the 0x110000 limit too | 489 * Check for the 0x110000 limit too |
490 */ | 490 */ |
491 cur = ctxt->input->cur; | 491 cur = ctxt->input->cur; |
492 | 492 |
493 c = *cur; | 493 c = *cur; |
494 if (c & 0x80) { | 494 if (c & 0x80) { |
495 if (c == 0xC0) | 495 if (c == 0xC0) |
496 goto encoding_error; | 496 goto encoding_error; |
497 if (cur[1] == 0) | 497 if (cur[1] == 0) { |
498 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); | 498 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); |
| 499 cur = ctxt->input->cur; |
| 500 } |
499 if ((cur[1] & 0xc0) != 0x80) | 501 if ((cur[1] & 0xc0) != 0x80) |
500 goto encoding_error; | 502 goto encoding_error; |
501 if ((c & 0xe0) == 0xe0) { | 503 if ((c & 0xe0) == 0xe0) { |
502 unsigned int val; | 504 unsigned int val; |
503 | 505 |
504 if (cur[2] == 0) | 506 if (cur[2] == 0) { |
505 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); | 507 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); |
| 508 cur = ctxt->input->cur; |
| 509 } |
506 if ((cur[2] & 0xc0) != 0x80) | 510 if ((cur[2] & 0xc0) != 0x80) |
507 goto encoding_error; | 511 goto encoding_error; |
508 if ((c & 0xf0) == 0xf0) { | 512 if ((c & 0xf0) == 0xf0) { |
509 if (cur[3] == 0) | 513 if (cur[3] == 0) { |
510 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); | 514 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); |
| 515 cur = ctxt->input->cur; |
| 516 } |
511 if (((c & 0xf8) != 0xf0) || | 517 if (((c & 0xf8) != 0xf0) || |
512 ((cur[3] & 0xc0) != 0x80)) | 518 ((cur[3] & 0xc0) != 0x80)) |
513 goto encoding_error; | 519 goto encoding_error; |
514 /* 4-byte code */ | 520 /* 4-byte code */ |
515 ctxt->input->cur += 4; | 521 ctxt->input->cur += 4; |
516 val = (cur[0] & 0x7) << 18; | 522 val = (cur[0] & 0x7) << 18; |
517 val |= (cur[1] & 0x3f) << 12; | 523 val |= (cur[1] & 0x3f) << 12; |
518 val |= (cur[2] & 0x3f) << 6; | 524 val |= (cur[2] & 0x3f) << 6; |
519 val |= cur[3] & 0x3f; | 525 val |= cur[3] & 0x3f; |
520 } else { | 526 } else { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 * Check for the 0x110000 limit too | 639 * Check for the 0x110000 limit too |
634 */ | 640 */ |
635 const unsigned char *cur = ctxt->input->cur; | 641 const unsigned char *cur = ctxt->input->cur; |
636 unsigned char c; | 642 unsigned char c; |
637 unsigned int val; | 643 unsigned int val; |
638 | 644 |
639 c = *cur; | 645 c = *cur; |
640 if (c & 0x80) { | 646 if (c & 0x80) { |
641 if (((c & 0x40) == 0) || (c == 0xC0)) | 647 if (((c & 0x40) == 0) || (c == 0xC0)) |
642 goto encoding_error; | 648 goto encoding_error; |
643 » if (cur[1] == 0) | 649 » if (cur[1] == 0) { |
644 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); | 650 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); |
| 651 cur = ctxt->input->cur; |
| 652 } |
645 if ((cur[1] & 0xc0) != 0x80) | 653 if ((cur[1] & 0xc0) != 0x80) |
646 goto encoding_error; | 654 goto encoding_error; |
647 if ((c & 0xe0) == 0xe0) { | 655 if ((c & 0xe0) == 0xe0) { |
648 » » if (cur[2] == 0) | 656 » » if (cur[2] == 0) { |
649 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); | 657 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); |
| 658 cur = ctxt->input->cur; |
| 659 } |
650 if ((cur[2] & 0xc0) != 0x80) | 660 if ((cur[2] & 0xc0) != 0x80) |
651 goto encoding_error; | 661 goto encoding_error; |
652 if ((c & 0xf0) == 0xf0) { | 662 if ((c & 0xf0) == 0xf0) { |
653 » » if (cur[3] == 0) | 663 » » if (cur[3] == 0) { |
654 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); | 664 xmlParserInputGrow(ctxt->input, INPUT_CHUNK); |
| 665 cur = ctxt->input->cur; |
| 666 } |
655 if (((c & 0xf8) != 0xf0) || | 667 if (((c & 0xf8) != 0xf0) || |
656 ((cur[3] & 0xc0) != 0x80)) | 668 ((cur[3] & 0xc0) != 0x80)) |
657 goto encoding_error; | 669 goto encoding_error; |
658 /* 4-byte code */ | 670 /* 4-byte code */ |
659 *len = 4; | 671 *len = 4; |
660 val = (cur[0] & 0x7) << 18; | 672 val = (cur[0] & 0x7) << 18; |
661 val |= (cur[1] & 0x3f) << 12; | 673 val |= (cur[1] & 0x3f) << 12; |
662 val |= (cur[2] & 0x3f) << 6; | 674 val |= (cur[2] & 0x3f) << 6; |
663 val |= cur[3] & 0x3f; | 675 val |= cur[3] & 0x3f; |
664 if (val < 0x10000) | 676 if (val < 0x10000) |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 *out = (xmlChar) val; | 938 *out = (xmlChar) val; |
927 return 1; | 939 return 1; |
928 } | 940 } |
929 | 941 |
930 /************************************************************************ | 942 /************************************************************************ |
931 * * | 943 * * |
932 * Commodity functions to switch encodings * | 944 * Commodity functions to switch encodings * |
933 * * | 945 * * |
934 ************************************************************************/ | 946 ************************************************************************/ |
935 | 947 |
| 948 /* defined in encoding.c, not public */ |
| 949 int |
| 950 xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out, |
| 951 xmlBufferPtr in, int len); |
| 952 |
| 953 static int |
| 954 xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt, |
| 955 xmlCharEncodingHandlerPtr handler, int len); |
| 956 static int |
| 957 xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, |
| 958 xmlCharEncodingHandlerPtr handler, int len); |
936 /** | 959 /** |
937 * xmlSwitchEncoding: | 960 * xmlSwitchEncoding: |
938 * @ctxt: the parser context | 961 * @ctxt: the parser context |
939 * @enc: the encoding value (number) | 962 * @enc: the encoding value (number) |
940 * | 963 * |
941 * change the input functions when discovering the character encoding | 964 * change the input functions when discovering the character encoding |
942 * of a given entity. | 965 * of a given entity. |
943 * | 966 * |
944 * Returns 0 in case of success, -1 otherwise | 967 * Returns 0 in case of success, -1 otherwise |
945 */ | 968 */ |
946 int | 969 int |
947 xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc) | 970 xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc) |
948 { | 971 { |
949 xmlCharEncodingHandlerPtr handler; | 972 xmlCharEncodingHandlerPtr handler; |
| 973 int len = -1; |
950 | 974 |
951 if (ctxt == NULL) return(-1); | 975 if (ctxt == NULL) return(-1); |
952 switch (enc) { | 976 switch (enc) { |
953 case XML_CHAR_ENCODING_ERROR: | 977 case XML_CHAR_ENCODING_ERROR: |
954 __xmlErrEncoding(ctxt, XML_ERR_UNKNOWN_ENCODING, | 978 __xmlErrEncoding(ctxt, XML_ERR_UNKNOWN_ENCODING, |
955 "encoding unknown\n", NULL, NULL); | 979 "encoding unknown\n", NULL, NULL); |
956 return(-1); | 980 return(-1); |
957 case XML_CHAR_ENCODING_NONE: | 981 case XML_CHAR_ENCODING_NONE: |
958 /* let's assume it's UTF-8 without the XML decl */ | 982 /* let's assume it's UTF-8 without the XML decl */ |
959 ctxt->charset = XML_CHAR_ENCODING_UTF8; | 983 ctxt->charset = XML_CHAR_ENCODING_UTF8; |
(...skipping 23 matching lines...) Expand all Loading... |
983 *So the raw UTF16 Byte Order Mark | 1007 *So the raw UTF16 Byte Order Mark |
984 *has also been converted into | 1008 *has also been converted into |
985 *an UTF-8 BOM. Let's skip that BOM. | 1009 *an UTF-8 BOM. Let's skip that BOM. |
986 */ | 1010 */ |
987 if ((ctxt->input != NULL) && (ctxt->input->cur != NULL) && | 1011 if ((ctxt->input != NULL) && (ctxt->input->cur != NULL) && |
988 (ctxt->input->cur[0] == 0xEF) && | 1012 (ctxt->input->cur[0] == 0xEF) && |
989 (ctxt->input->cur[1] == 0xBB) && | 1013 (ctxt->input->cur[1] == 0xBB) && |
990 (ctxt->input->cur[2] == 0xBF)) { | 1014 (ctxt->input->cur[2] == 0xBF)) { |
991 ctxt->input->cur += 3; | 1015 ctxt->input->cur += 3; |
992 } | 1016 } |
993 » break ; | 1017 len = 90; |
994 » default: | 1018 » break; |
995 » break; | 1019 case XML_CHAR_ENCODING_UCS2: |
| 1020 len = 90; |
| 1021 » break; |
| 1022 case XML_CHAR_ENCODING_UCS4BE: |
| 1023 case XML_CHAR_ENCODING_UCS4LE: |
| 1024 case XML_CHAR_ENCODING_UCS4_2143: |
| 1025 case XML_CHAR_ENCODING_UCS4_3412: |
| 1026 len = 180; |
| 1027 » break; |
| 1028 case XML_CHAR_ENCODING_EBCDIC: |
| 1029 case XML_CHAR_ENCODING_8859_1: |
| 1030 case XML_CHAR_ENCODING_8859_2: |
| 1031 case XML_CHAR_ENCODING_8859_3: |
| 1032 case XML_CHAR_ENCODING_8859_4: |
| 1033 case XML_CHAR_ENCODING_8859_5: |
| 1034 case XML_CHAR_ENCODING_8859_6: |
| 1035 case XML_CHAR_ENCODING_8859_7: |
| 1036 case XML_CHAR_ENCODING_8859_8: |
| 1037 case XML_CHAR_ENCODING_8859_9: |
| 1038 case XML_CHAR_ENCODING_ASCII: |
| 1039 case XML_CHAR_ENCODING_2022_JP: |
| 1040 case XML_CHAR_ENCODING_SHIFT_JIS: |
| 1041 case XML_CHAR_ENCODING_EUC_JP: |
| 1042 len = 45; |
| 1043 » break; |
996 } | 1044 } |
997 handler = xmlGetCharEncodingHandler(enc); | 1045 handler = xmlGetCharEncodingHandler(enc); |
998 if (handler == NULL) { | 1046 if (handler == NULL) { |
999 /* | 1047 /* |
1000 * Default handlers. | 1048 * Default handlers. |
1001 */ | 1049 */ |
1002 switch (enc) { | 1050 switch (enc) { |
1003 case XML_CHAR_ENCODING_ASCII: | 1051 case XML_CHAR_ENCODING_ASCII: |
1004 /* default encoding, no conversion should be needed */ | 1052 /* default encoding, no conversion should be needed */ |
1005 ctxt->charset = XML_CHAR_ENCODING_UTF8; | 1053 ctxt->charset = XML_CHAR_ENCODING_UTF8; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 "encoding not supported %s\n", | 1124 "encoding not supported %s\n", |
1077 BAD_CAST "EUC-JP", NULL); | 1125 BAD_CAST "EUC-JP", NULL); |
1078 break; | 1126 break; |
1079 default: | 1127 default: |
1080 break; | 1128 break; |
1081 } | 1129 } |
1082 } | 1130 } |
1083 if (handler == NULL) | 1131 if (handler == NULL) |
1084 return(-1); | 1132 return(-1); |
1085 ctxt->charset = XML_CHAR_ENCODING_UTF8; | 1133 ctxt->charset = XML_CHAR_ENCODING_UTF8; |
1086 return(xmlSwitchToEncoding(ctxt, handler)); | 1134 return(xmlSwitchToEncodingInt(ctxt, handler, len)); |
1087 } | 1135 } |
1088 | 1136 |
1089 /** | 1137 /** |
1090 * xmlSwitchInputEncoding: | 1138 * xmlSwitchInputEncoding: |
1091 * @ctxt: the parser context | 1139 * @ctxt: the parser context |
1092 * @input: the input stream | 1140 * @input: the input stream |
1093 * @handler: the encoding handler | 1141 * @handler: the encoding handler |
| 1142 * @len: the number of bytes to convert for the first line or -1 |
1094 * | 1143 * |
1095 * change the input functions when discovering the character encoding | 1144 * change the input functions when discovering the character encoding |
1096 * of a given entity. | 1145 * of a given entity. |
1097 * | 1146 * |
1098 * Returns 0 in case of success, -1 otherwise | 1147 * Returns 0 in case of success, -1 otherwise |
1099 */ | 1148 */ |
1100 int | 1149 static int |
1101 xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, | 1150 xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, |
1102 xmlCharEncodingHandlerPtr handler) | 1151 xmlCharEncodingHandlerPtr handler, int len) |
1103 { | 1152 { |
1104 int nbchars; | 1153 int nbchars; |
1105 | 1154 |
1106 if (handler == NULL) | 1155 if (handler == NULL) |
1107 return (-1); | 1156 return (-1); |
1108 if (input == NULL) | 1157 if (input == NULL) |
1109 return (-1); | 1158 return (-1); |
1110 if (input->buf != NULL) { | 1159 if (input->buf != NULL) { |
1111 if (input->buf->encoder != NULL) { | 1160 if (input->buf->encoder != NULL) { |
1112 /* | 1161 /* |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 nbchars = xmlCharEncInFunc(input->buf->encoder, | 1238 nbchars = xmlCharEncInFunc(input->buf->encoder, |
1190 input->buf->buffer, | 1239 input->buf->buffer, |
1191 input->buf->raw); | 1240 input->buf->raw); |
1192 } else { | 1241 } else { |
1193 /* | 1242 /* |
1194 * convert just enough to get | 1243 * convert just enough to get |
1195 * '<?xml version="1.0" encoding="xxx"?>' | 1244 * '<?xml version="1.0" encoding="xxx"?>' |
1196 * parsed with the autodetected encoding | 1245 * parsed with the autodetected encoding |
1197 * into the parser reading buffer. | 1246 * into the parser reading buffer. |
1198 */ | 1247 */ |
1199 nbchars = xmlCharEncFirstLine(input->buf->encoder, | 1248 nbchars = xmlCharEncFirstLineInt(input->buf->encoder, |
1200 input->buf->buffer, | 1249 input->buf->buffer, |
1201 input->buf->raw); | 1250 input->buf->raw, |
| 1251 len); |
1202 } | 1252 } |
1203 if (nbchars < 0) { | 1253 if (nbchars < 0) { |
1204 xmlErrInternal(ctxt, | 1254 xmlErrInternal(ctxt, |
1205 "switching encoding: encoder error\n", | 1255 "switching encoding: encoder error\n", |
1206 NULL); | 1256 NULL); |
1207 return (-1); | 1257 return (-1); |
1208 } | 1258 } |
1209 input->buf->rawconsumed += use - input->buf->raw->use; | 1259 input->buf->rawconsumed += use - input->buf->raw->use; |
1210 input->base = input->cur = input->buf->buffer->content; | 1260 input->base = input->cur = input->buf->buffer->content; |
1211 input->end = &input->base[input->buf->buffer->use]; | 1261 input->end = &input->base[input->buf->buffer->use]; |
1212 | 1262 |
1213 } | 1263 } |
1214 return (0); | 1264 return (0); |
1215 } else if (input->length == 0) { | 1265 } else if (input->length == 0) { |
1216 /* | 1266 /* |
1217 * When parsing a static memory array one must know the | 1267 * When parsing a static memory array one must know the |
1218 * size to be able to convert the buffer. | 1268 * size to be able to convert the buffer. |
1219 */ | 1269 */ |
1220 xmlErrInternal(ctxt, "switching encoding : no input\n", NULL); | 1270 xmlErrInternal(ctxt, "switching encoding : no input\n", NULL); |
1221 return (-1); | 1271 return (-1); |
1222 } | 1272 } |
1223 return (0); | 1273 return (0); |
1224 } | 1274 } |
1225 | 1275 |
1226 /** | 1276 /** |
1227 * xmlSwitchToEncoding: | 1277 * xmlSwitchInputEncoding: |
1228 * @ctxt: the parser context | 1278 * @ctxt: the parser context |
| 1279 * @input: the input stream |
1229 * @handler: the encoding handler | 1280 * @handler: the encoding handler |
1230 * | 1281 * |
1231 * change the input functions when discovering the character encoding | 1282 * change the input functions when discovering the character encoding |
1232 * of a given entity. | 1283 * of a given entity. |
1233 * | 1284 * |
1234 * Returns 0 in case of success, -1 otherwise | 1285 * Returns 0 in case of success, -1 otherwise |
1235 */ | 1286 */ |
1236 int | 1287 int |
1237 xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler) | 1288 xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, |
1238 { | 1289 xmlCharEncodingHandlerPtr handler) { |
| 1290 return(xmlSwitchInputEncodingInt(ctxt, input, handler, -1)); |
| 1291 } |
| 1292 |
| 1293 /** |
| 1294 * xmlSwitchToEncodingInt: |
| 1295 * @ctxt: the parser context |
| 1296 * @handler: the encoding handler |
| 1297 * @len: the lenght to convert or -1 |
| 1298 * |
| 1299 * change the input functions when discovering the character encoding |
| 1300 * of a given entity, and convert only @len bytes of the output, this |
| 1301 * is needed on auto detect to allows any declared encoding later to |
| 1302 * convert the actual content after the xmlDecl |
| 1303 * |
| 1304 * Returns 0 in case of success, -1 otherwise |
| 1305 */ |
| 1306 static int |
| 1307 xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt, |
| 1308 xmlCharEncodingHandlerPtr handler, int len) { |
1239 int ret = 0; | 1309 int ret = 0; |
1240 | 1310 |
1241 if (handler != NULL) { | 1311 if (handler != NULL) { |
1242 if (ctxt->input != NULL) { | 1312 if (ctxt->input != NULL) { |
1243 » ret = xmlSwitchInputEncoding(ctxt, ctxt->input, handler); | 1313 » ret = xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, len); |
1244 } else { | 1314 } else { |
1245 xmlErrInternal(ctxt, "xmlSwitchToEncoding : no input\n", | 1315 xmlErrInternal(ctxt, "xmlSwitchToEncoding : no input\n", |
1246 NULL); | 1316 NULL); |
1247 return(-1); | 1317 return(-1); |
1248 } | 1318 } |
1249 /* | 1319 /* |
1250 * The parsing is now done in UTF8 natively | 1320 * The parsing is now done in UTF8 natively |
1251 */ | 1321 */ |
1252 ctxt->charset = XML_CHAR_ENCODING_UTF8; | 1322 ctxt->charset = XML_CHAR_ENCODING_UTF8; |
1253 } else | 1323 } else |
1254 return(-1); | 1324 return(-1); |
1255 return(ret); | 1325 return(ret); |
1256 } | 1326 } |
1257 | 1327 |
| 1328 /** |
| 1329 * xmlSwitchToEncoding: |
| 1330 * @ctxt: the parser context |
| 1331 * @handler: the encoding handler |
| 1332 * |
| 1333 * change the input functions when discovering the character encoding |
| 1334 * of a given entity. |
| 1335 * |
| 1336 * Returns 0 in case of success, -1 otherwise |
| 1337 */ |
| 1338 int |
| 1339 xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler) |
| 1340 { |
| 1341 return (xmlSwitchToEncodingInt(ctxt, handler, -1)); |
| 1342 } |
| 1343 |
1258 /************************************************************************ | 1344 /************************************************************************ |
1259 * * | 1345 * * |
1260 * Commodity functions to handle entities processing * | 1346 * Commodity functions to handle entities processing * |
1261 * * | 1347 * * |
1262 ************************************************************************/ | 1348 ************************************************************************/ |
1263 | 1349 |
1264 /** | 1350 /** |
1265 * xmlFreeInputStream: | 1351 * xmlFreeInputStream: |
1266 * @input: an xmlParserInputPtr | 1352 * @input: an xmlParserInputPtr |
1267 * | 1353 * |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 "Predefined entity %s without content !\n", | 1478 "Predefined entity %s without content !\n", |
1393 entity->name); | 1479 entity->name); |
1394 break; | 1480 break; |
1395 } | 1481 } |
1396 return(NULL); | 1482 return(NULL); |
1397 } | 1483 } |
1398 input = xmlNewInputStream(ctxt); | 1484 input = xmlNewInputStream(ctxt); |
1399 if (input == NULL) { | 1485 if (input == NULL) { |
1400 return(NULL); | 1486 return(NULL); |
1401 } | 1487 } |
1402 input->filename = (char *) entity->URI; | 1488 if (entity->URI != NULL) |
| 1489 » input->filename = (char *) xmlStrdup((xmlChar *) entity->URI); |
1403 input->base = entity->content; | 1490 input->base = entity->content; |
1404 input->cur = entity->content; | 1491 input->cur = entity->content; |
1405 input->length = entity->length; | 1492 input->length = entity->length; |
1406 input->end = &entity->content[input->length]; | 1493 input->end = &entity->content[input->length]; |
1407 return(input); | 1494 return(input); |
1408 } | 1495 } |
1409 | 1496 |
1410 /** | 1497 /** |
1411 * xmlNewStringInputStream: | 1498 * xmlNewStringInputStream: |
1412 * @ctxt: an XML parser context | 1499 * @ctxt: an XML parser context |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 } | 1749 } |
1663 ctxt->replaceEntities = xmlSubstituteEntitiesDefaultValue; | 1750 ctxt->replaceEntities = xmlSubstituteEntitiesDefaultValue; |
1664 ctxt->record_info = 0; | 1751 ctxt->record_info = 0; |
1665 ctxt->nbChars = 0; | 1752 ctxt->nbChars = 0; |
1666 ctxt->checkIndex = 0; | 1753 ctxt->checkIndex = 0; |
1667 ctxt->inSubset = 0; | 1754 ctxt->inSubset = 0; |
1668 ctxt->errNo = XML_ERR_OK; | 1755 ctxt->errNo = XML_ERR_OK; |
1669 ctxt->depth = 0; | 1756 ctxt->depth = 0; |
1670 ctxt->charset = XML_CHAR_ENCODING_UTF8; | 1757 ctxt->charset = XML_CHAR_ENCODING_UTF8; |
1671 ctxt->catalogs = NULL; | 1758 ctxt->catalogs = NULL; |
| 1759 ctxt->nbentities = 0; |
1672 xmlInitNodeInfoSeq(&ctxt->node_seq); | 1760 xmlInitNodeInfoSeq(&ctxt->node_seq); |
1673 return(0); | 1761 return(0); |
1674 } | 1762 } |
1675 | 1763 |
1676 /** | 1764 /** |
1677 * xmlFreeParserCtxt: | 1765 * xmlFreeParserCtxt: |
1678 * @ctxt: an XML parser context | 1766 * @ctxt: an XML parser context |
1679 * | 1767 * |
1680 * Free all the memory used by a parser context. However the parsed | 1768 * Free all the memory used by a parser context. However the parsed |
1681 * document in ctxt->myDoc is not freed. | 1769 * document in ctxt->myDoc is not freed. |
1682 */ | 1770 */ |
1683 | 1771 |
1684 void | 1772 void |
1685 xmlFreeParserCtxt(xmlParserCtxtPtr ctxt) | 1773 xmlFreeParserCtxt(xmlParserCtxtPtr ctxt) |
1686 { | 1774 { |
1687 xmlParserInputPtr input; | 1775 xmlParserInputPtr input; |
1688 | 1776 |
1689 if (ctxt == NULL) return; | 1777 if (ctxt == NULL) return; |
1690 | 1778 |
1691 while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */ | 1779 while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */ |
1692 xmlFreeInputStream(input); | 1780 xmlFreeInputStream(input); |
1693 } | 1781 } |
1694 if (ctxt->spaceTab != NULL) xmlFree(ctxt->spaceTab); | 1782 if (ctxt->spaceTab != NULL) xmlFree(ctxt->spaceTab); |
1695 if (ctxt->nameTab != NULL) xmlFree((xmlChar * *)ctxt->nameTab); | 1783 if (ctxt->nameTab != NULL) xmlFree((xmlChar * *)ctxt->nameTab); |
1696 if (ctxt->nodeTab != NULL) xmlFree(ctxt->nodeTab); | 1784 if (ctxt->nodeTab != NULL) xmlFree(ctxt->nodeTab); |
| 1785 if (ctxt->nodeInfoTab != NULL) xmlFree(ctxt->nodeInfoTab); |
1697 if (ctxt->inputTab != NULL) xmlFree(ctxt->inputTab); | 1786 if (ctxt->inputTab != NULL) xmlFree(ctxt->inputTab); |
1698 if (ctxt->version != NULL) xmlFree((char *) ctxt->version); | 1787 if (ctxt->version != NULL) xmlFree((char *) ctxt->version); |
1699 if (ctxt->encoding != NULL) xmlFree((char *) ctxt->encoding); | 1788 if (ctxt->encoding != NULL) xmlFree((char *) ctxt->encoding); |
1700 if (ctxt->extSubURI != NULL) xmlFree((char *) ctxt->extSubURI); | 1789 if (ctxt->extSubURI != NULL) xmlFree((char *) ctxt->extSubURI); |
1701 if (ctxt->extSubSystem != NULL) xmlFree((char *) ctxt->extSubSystem); | 1790 if (ctxt->extSubSystem != NULL) xmlFree((char *) ctxt->extSubSystem); |
1702 #ifdef LIBXML_SAX1_ENABLED | 1791 #ifdef LIBXML_SAX1_ENABLED |
1703 if ((ctxt->sax != NULL) && | 1792 if ((ctxt->sax != NULL) && |
1704 (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)) | 1793 (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)) |
1705 #else | 1794 #else |
1706 if (ctxt->sax != NULL) | 1795 if (ctxt->sax != NULL) |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 * if blanks sections are kept, indentation is not generated. | 2147 * if blanks sections are kept, indentation is not generated. |
2059 * | 2148 * |
2060 * Returns the last value for 0 for no substitution, 1 for substitution. | 2149 * Returns the last value for 0 for no substitution, 1 for substitution. |
2061 */ | 2150 */ |
2062 | 2151 |
2063 int | 2152 int |
2064 xmlKeepBlanksDefault(int val) { | 2153 xmlKeepBlanksDefault(int val) { |
2065 int old = xmlKeepBlanksDefaultValue; | 2154 int old = xmlKeepBlanksDefaultValue; |
2066 | 2155 |
2067 xmlKeepBlanksDefaultValue = val; | 2156 xmlKeepBlanksDefaultValue = val; |
2068 xmlIndentTreeOutput = !val; | 2157 if (!val) xmlIndentTreeOutput = 1; |
2069 return(old); | 2158 return(old); |
2070 } | 2159 } |
2071 | 2160 |
2072 #define bottom_parserInternals | 2161 #define bottom_parserInternals |
2073 #include "elfgcchack.h" | 2162 #include "elfgcchack.h" |
OLD | NEW |