Changeset 263 for libyaml/trunk/src/scanner.c
- Timestamp:
- 12/27/07 07:05:17 (4 years ago)
- Files:
-
- 1 modified
-
libyaml/trunk/src/scanner.c (modified) (131 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libyaml/trunk/src/scanner.c
r243 r263 496 496 parser->mark.column ++, \ 497 497 parser->unread --, \ 498 parser-> buffer.pointer += WIDTH(parser->buffer))498 parser->input.pointer += WIDTH(parser->input)) 499 499 500 500 #define SKIP_LINE(parser) \ 501 (IS_CRLF(parser-> buffer) ?\501 (IS_CRLF(parser->input) ? \ 502 502 (parser->mark.index += 2, \ 503 503 parser->mark.column = 0, \ 504 504 parser->mark.line ++, \ 505 505 parser->unread -= 2, \ 506 parser-> buffer.pointer += 2) :\507 IS_BREAK(parser-> buffer) ?\506 parser->input.pointer += 2) : \ 507 IS_BREAK(parser->input) ? \ 508 508 (parser->mark.index ++, \ 509 509 parser->mark.column = 0, \ 510 510 parser->mark.line ++, \ 511 511 parser->unread --, \ 512 parser-> buffer.pointer += WIDTH(parser->buffer)) : 0)512 parser->input.pointer += WIDTH(parser->input)) : 0) 513 513 514 514 /* … … 518 518 #define READ(parser,string) \ 519 519 (STRING_EXTEND(parser,string) ? \ 520 (COPY(string,parser-> buffer),\520 (COPY(string,parser->input), \ 521 521 parser->mark.index ++, \ 522 522 parser->mark.column ++, \ … … 530 530 #define READ_LINE(parser,string) \ 531 531 (STRING_EXTEND(parser,string) ? \ 532 (((CHECK_AT(parser-> buffer,'\r',0)\533 && CHECK_AT(parser-> buffer,'\n',1)) ?/* CR LF -> LF */ \534 ( *((string).pointer++) = (yaml_char_t) '\n',\535 parser-> buffer.pointer += 2,\532 (((CHECK_AT(parser->input,'\r',0) \ 533 && CHECK_AT(parser->input,'\n',1)) ? /* CR LF -> LF */ \ 534 (JOIN_OCTET(string, (yaml_char_t) '\n'), \ 535 parser->input.pointer += 2, \ 536 536 parser->mark.index += 2, \ 537 537 parser->mark.column = 0, \ 538 538 parser->mark.line ++, \ 539 539 parser->unread -= 2) : \ 540 (CHECK_AT(parser-> buffer,'\r',0)\541 || CHECK_AT(parser-> buffer,'\n',0)) ?/* CR|LF -> LF */ \542 ( *((string).pointer++) = (yaml_char_t) '\n',\543 parser-> buffer.pointer ++,\540 (CHECK_AT(parser->input,'\r',0) \ 541 || CHECK_AT(parser->input,'\n',0)) ? /* CR|LF -> LF */ \ 542 (JOIN_OCTET(string,(yaml_char_t) '\n'), \ 543 parser->input.pointer ++, \ 544 544 parser->mark.index ++, \ 545 545 parser->mark.column = 0, \ 546 546 parser->mark.line ++, \ 547 547 parser->unread --) : \ 548 (CHECK_AT(parser-> buffer,'\xC2',0)\549 && CHECK_AT(parser-> buffer,'\x85',1)) ?/* NEL -> LF */ \550 ( *((string).pointer++) = (yaml_char_t) '\n',\551 parser-> buffer.pointer += 2,\548 (CHECK_AT(parser->input,'\xC2',0) \ 549 && CHECK_AT(parser->input,'\x85',1)) ? /* NEL -> LF */ \ 550 (JOIN_OCTET(string,(yaml_char_t) '\n'), \ 551 parser->input.pointer += 2, \ 552 552 parser->mark.index ++, \ 553 553 parser->mark.column = 0, \ 554 554 parser->mark.line ++, \ 555 555 parser->unread --) : \ 556 (CHECK_AT(parser-> buffer,'\xE2',0) &&\557 CHECK_AT(parser-> buffer,'\x80',1) &&\558 (CHECK_AT(parser-> buffer,'\xA8',2) ||\559 CHECK_AT(parser-> buffer,'\xA9',2))) ?/* LS|PS -> LS|PS */ \560 ( *((string).pointer++) = *(parser->buffer.pointer++),\561 *((string).pointer++) = *(parser->buffer.pointer++),\562 *((string).pointer++) = *(parser->buffer.pointer++),\556 (CHECK_AT(parser->input,'\xE2',0) && \ 557 CHECK_AT(parser->input,'\x80',1) && \ 558 (CHECK_AT(parser->input,'\xA8',2) || \ 559 CHECK_AT(parser->input,'\xA9',2))) ? /* LS|PS -> LS|PS */ \ 560 (COPY_OCTET(string,parser->input), \ 561 COPY_OCTET(string,parser->input), \ 562 COPY_OCTET(string,parser->input), \ 563 563 parser->mark.index ++, \ 564 564 parser->mark.column = 0, \ … … 575 575 576 576 /* 577 * Error handling.578 */579 580 static int581 yaml_parser_set_scanner_error(yaml_parser_t *parser, const char *context,582 yaml_mark_t context_mark, const char *problem);583 584 /*585 577 * High-level token API. 586 578 */ … … 751 743 /* No tokens after STREAM-END or error. */ 752 744 753 if (parser-> stream_end_produced || parser->error) {745 if (parser->is_stream_end_produced || parser->error.type) { 754 746 return 1; 755 747 } … … 757 749 /* Ensure that the tokens queue contains enough tokens. */ 758 750 759 if (!parser-> token_available) {751 if (!parser->is_token_available) { 760 752 if (!yaml_parser_fetch_more_tokens(parser)) 761 753 return 0; … … 765 757 766 758 *token = DEQUEUE(parser, parser->tokens); 767 parser-> token_available = 0;759 parser->is_token_available = 0; 768 760 parser->tokens_parsed ++; 769 761 770 762 if (token->type == YAML_STREAM_END_TOKEN) { 771 parser->stream_end_produced = 1; 772 } 773 774 return 1; 775 } 776 777 /* 778 * Set the scanner error and return 0. 779 */ 780 781 static int 782 yaml_parser_set_scanner_error(yaml_parser_t *parser, const char *context, 783 yaml_mark_t context_mark, const char *problem) 784 { 785 parser->error = YAML_SCANNER_ERROR; 786 parser->context = context; 787 parser->context_mark = context_mark; 788 parser->problem = problem; 789 parser->problem_mark = parser->mark; 790 791 return 0; 763 parser->is_stream_end_produced = 1; 764 } 765 766 return 1; 792 767 } 793 768 … … 820 795 else 821 796 { 822 yaml_simple_key_t *simple_key;797 size_t idx; 823 798 824 799 /* Check if any potential simple key may occupy the head position. */ … … 827 802 return 0; 828 803 829 for ( simple_key = parser->simple_keys.start;830 simple_key != parser->simple_keys.top; simple_key++) {831 if (simple_key-> possible804 for (idx = 0; idx < parser->simple_keys.length; idx++) { 805 yaml_simple_key_t *simple_key = parser->simple_keys.list + idx; 806 if (simple_key->is_possible 832 807 && simple_key->token_number == parser->tokens_parsed) { 833 808 need_more_tokens = 1; … … 848 823 } 849 824 850 parser-> token_available = 1;825 parser->is_token_available = 1; 851 826 852 827 return 1; … … 860 835 yaml_parser_fetch_next_token(yaml_parser_t *parser) 861 836 { 837 yaml_mark_t start_mark = parser->mark; 838 862 839 /* Ensure that the buffer is initialized. */ 863 840 … … 867 844 /* Check if we just started scanning. Fetch STREAM-START then. */ 868 845 869 if (!parser-> stream_start_produced)846 if (!parser->is_stream_start_produced) 870 847 return yaml_parser_fetch_stream_start(parser); 871 848 … … 895 872 /* Is it the end of the stream? */ 896 873 897 if (IS_Z(parser-> buffer))874 if (IS_Z(parser->input)) 898 875 return yaml_parser_fetch_stream_end(parser); 899 876 900 877 /* Is it a directive? */ 901 878 902 if (parser->mark.column == 0 && CHECK(parser-> buffer, '%'))879 if (parser->mark.column == 0 && CHECK(parser->input, '%')) 903 880 return yaml_parser_fetch_directive(parser); 904 881 … … 906 883 907 884 if (parser->mark.column == 0 908 && CHECK_AT(parser-> buffer, '-', 0)909 && CHECK_AT(parser-> buffer, '-', 1)910 && CHECK_AT(parser-> buffer, '-', 2)911 && IS_BLANKZ_AT(parser-> buffer, 3))885 && CHECK_AT(parser->input, '-', 0) 886 && CHECK_AT(parser->input, '-', 1) 887 && CHECK_AT(parser->input, '-', 2) 888 && IS_BLANKZ_AT(parser->input, 3)) 912 889 return yaml_parser_fetch_document_indicator(parser, 913 890 YAML_DOCUMENT_START_TOKEN); … … 916 893 917 894 if (parser->mark.column == 0 918 && CHECK_AT(parser-> buffer, '.', 0)919 && CHECK_AT(parser-> buffer, '.', 1)920 && CHECK_AT(parser-> buffer, '.', 2)921 && IS_BLANKZ_AT(parser-> buffer, 3))895 && CHECK_AT(parser->input, '.', 0) 896 && CHECK_AT(parser->input, '.', 1) 897 && CHECK_AT(parser->input, '.', 2) 898 && IS_BLANKZ_AT(parser->input, 3)) 922 899 return yaml_parser_fetch_document_indicator(parser, 923 900 YAML_DOCUMENT_END_TOKEN); … … 925 902 /* Is it the flow sequence start indicator? */ 926 903 927 if (CHECK(parser-> buffer, '['))904 if (CHECK(parser->input, '[')) 928 905 return yaml_parser_fetch_flow_collection_start(parser, 929 906 YAML_FLOW_SEQUENCE_START_TOKEN); … … 931 908 /* Is it the flow mapping start indicator? */ 932 909 933 if (CHECK(parser-> buffer, '{'))910 if (CHECK(parser->input, '{')) 934 911 return yaml_parser_fetch_flow_collection_start(parser, 935 912 YAML_FLOW_MAPPING_START_TOKEN); … … 937 914 /* Is it the flow sequence end indicator? */ 938 915 939 if (CHECK(parser-> buffer, ']'))916 if (CHECK(parser->input, ']')) 940 917 return yaml_parser_fetch_flow_collection_end(parser, 941 918 YAML_FLOW_SEQUENCE_END_TOKEN); … … 943 920 /* Is it the flow mapping end indicator? */ 944 921 945 if (CHECK(parser-> buffer, '}'))922 if (CHECK(parser->input, '}')) 946 923 return yaml_parser_fetch_flow_collection_end(parser, 947 924 YAML_FLOW_MAPPING_END_TOKEN); … … 949 926 /* Is it the flow entry indicator? */ 950 927 951 if (CHECK(parser-> buffer, ','))928 if (CHECK(parser->input, ',')) 952 929 return yaml_parser_fetch_flow_entry(parser); 953 930 954 931 /* Is it the block entry indicator? */ 955 932 956 if (CHECK(parser-> buffer, '-') && IS_BLANKZ_AT(parser->buffer, 1))933 if (CHECK(parser->input, '-') && IS_BLANKZ_AT(parser->input, 1)) 957 934 return yaml_parser_fetch_block_entry(parser); 958 935 959 936 /* Is it the key indicator? */ 960 937 961 if (CHECK(parser-> buffer, '?')962 && (parser->flow_level || IS_BLANKZ_AT(parser-> buffer, 1)))938 if (CHECK(parser->input, '?') 939 && (parser->flow_level || IS_BLANKZ_AT(parser->input, 1))) 963 940 return yaml_parser_fetch_key(parser); 964 941 965 942 /* Is it the value indicator? */ 966 943 967 if (CHECK(parser-> buffer, ':')968 && (parser->flow_level || IS_BLANKZ_AT(parser-> buffer, 1)))944 if (CHECK(parser->input, ':') 945 && (parser->flow_level || IS_BLANKZ_AT(parser->input, 1))) 969 946 return yaml_parser_fetch_value(parser); 970 947 971 948 /* Is it an alias? */ 972 949 973 if (CHECK(parser-> buffer, '*'))950 if (CHECK(parser->input, '*')) 974 951 return yaml_parser_fetch_anchor(parser, YAML_ALIAS_TOKEN); 975 952 976 953 /* Is it an anchor? */ 977 954 978 if (CHECK(parser-> buffer, '&'))955 if (CHECK(parser->input, '&')) 979 956 return yaml_parser_fetch_anchor(parser, YAML_ANCHOR_TOKEN); 980 957 981 958 /* Is it a tag? */ 982 959 983 if (CHECK(parser-> buffer, '!'))960 if (CHECK(parser->input, '!')) 984 961 return yaml_parser_fetch_tag(parser); 985 962 986 963 /* Is it a literal scalar? */ 987 964 988 if (CHECK(parser-> buffer, '|') && !parser->flow_level)965 if (CHECK(parser->input, '|') && !parser->flow_level) 989 966 return yaml_parser_fetch_block_scalar(parser, 1); 990 967 991 968 /* Is it a folded scalar? */ 992 969 993 if (CHECK(parser-> buffer, '>') && !parser->flow_level)970 if (CHECK(parser->input, '>') && !parser->flow_level) 994 971 return yaml_parser_fetch_block_scalar(parser, 0); 995 972 996 973 /* Is it a single-quoted scalar? */ 997 974 998 if (CHECK(parser-> buffer, '\''))975 if (CHECK(parser->input, '\'')) 999 976 return yaml_parser_fetch_flow_scalar(parser, 1); 1000 977 1001 978 /* Is it a double-quoted scalar? */ 1002 979 1003 if (CHECK(parser-> buffer, '"'))980 if (CHECK(parser->input, '"')) 1004 981 return yaml_parser_fetch_flow_scalar(parser, 0); 1005 982 … … 1023 1000 */ 1024 1001 1025 if (!(IS_BLANKZ(parser-> buffer) || CHECK(parser->buffer, '-')1026 || CHECK(parser-> buffer, '?') || CHECK(parser->buffer, ':')1027 || CHECK(parser-> buffer, ',') || CHECK(parser->buffer, '[')1028 || CHECK(parser-> buffer, ']') || CHECK(parser->buffer, '{')1029 || CHECK(parser-> buffer, '}') || CHECK(parser->buffer, '#')1030 || CHECK(parser-> buffer, '&') || CHECK(parser->buffer, '*')1031 || CHECK(parser-> buffer, '!') || CHECK(parser->buffer, '|')1032 || CHECK(parser-> buffer, '>') || CHECK(parser->buffer, '\'')1033 || CHECK(parser-> buffer, '"') || CHECK(parser->buffer, '%')1034 || CHECK(parser-> buffer, '@') || CHECK(parser->buffer, '`')) ||1035 (CHECK(parser-> buffer, '-') && !IS_BLANK_AT(parser->buffer, 1)) ||1002 if (!(IS_BLANKZ(parser->input) || CHECK(parser->input, '-') 1003 || CHECK(parser->input, '?') || CHECK(parser->input, ':') 1004 || CHECK(parser->input, ',') || CHECK(parser->input, '[') 1005 || CHECK(parser->input, ']') || CHECK(parser->input, '{') 1006 || CHECK(parser->input, '}') || CHECK(parser->input, '#') 1007 || CHECK(parser->input, '&') || CHECK(parser->input, '*') 1008 || CHECK(parser->input, '!') || CHECK(parser->input, '|') 1009 || CHECK(parser->input, '>') || CHECK(parser->input, '\'') 1010 || CHECK(parser->input, '"') || CHECK(parser->input, '%') 1011 || CHECK(parser->input, '@') || CHECK(parser->input, '`')) || 1012 (CHECK(parser->input, '-') && !IS_BLANK_AT(parser->input, 1)) || 1036 1013 (!parser->flow_level && 1037 (CHECK(parser-> buffer, '?') || CHECK(parser->buffer, ':'))1038 && !IS_BLANKZ_AT(parser-> buffer, 1)))1014 (CHECK(parser->input, '?') || CHECK(parser->input, ':')) 1015 && !IS_BLANKZ_AT(parser->input, 1))) 1039 1016 return yaml_parser_fetch_plain_scalar(parser); 1040 1017 … … 1043 1020 */ 1044 1021 1045 return yaml_parser_set_scanner_error(parser,1046 "while scanning for the next token", parser->mark,1047 "found character that cannot start any token" );1022 return SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 1023 "while scanning for the next token", start_mark, 1024 "found character that cannot start any token", parser->mark); 1048 1025 } 1049 1026 … … 1056 1033 yaml_parser_stale_simple_keys(yaml_parser_t *parser) 1057 1034 { 1058 yaml_simple_key_t *simple_key;1035 size_t idx; 1059 1036 1060 1037 /* Check for a potential simple key for each flow level. */ 1061 1038 1062 for (simple_key = parser->simple_keys.start; 1063 simple_key != parser->simple_keys.top; simple_key ++) 1039 for (idx = 0; idx < parser->simple_keys.length; idx ++) 1064 1040 { 1041 yaml_simple_key_t *simple_key = parser->simple_keys.list + idx; 1042 1065 1043 /* 1066 1044 * The specification requires that a simple key … … 1070 1048 */ 1071 1049 1072 if (simple_key-> possible1050 if (simple_key->is_possible 1073 1051 && (simple_key->mark.line < parser->mark.line 1074 1052 || simple_key->mark.index+1024 < parser->mark.index)) { … … 1076 1054 /* Check if the potential simple key to be removed is required. */ 1077 1055 1078 if (simple_key-> required) {1079 return yaml_parser_set_scanner_error(parser,1056 if (simple_key->is_required) { 1057 return SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 1080 1058 "while scanning a simple key", simple_key->mark, 1081 "could not found expected ':'" );1059 "could not found expected ':'", parser->mark); 1082 1060 } 1083 1061 1084 simple_key-> possible = 0;1062 simple_key->is_possible = 0; 1085 1063 } 1086 1064 } … … 1103 1081 */ 1104 1082 1105 int required = (!parser->flow_level1083 int is_required = (!parser->flow_level 1106 1084 && parser->indent == (int)parser->mark.column); 1107 1085 … … 1111 1089 */ 1112 1090 1113 assert(parser-> simple_key_allowed || !required);/* Impossible. */1091 assert(parser->is_simple_key_allowed || !is_required); /* Impossible. */ 1114 1092 1115 1093 /* … … 1117 1095 */ 1118 1096 1119 if (parser-> simple_key_allowed)1097 if (parser->is_simple_key_allowed) 1120 1098 { 1121 yaml_simple_key_t simple_key = { 1, required,1099 yaml_simple_key_t simple_key = { 1, is_required, 1122 1100 parser->tokens_parsed + parser->tokens.tail - parser->tokens.head, 1123 1101 { 0, 0, 0 } }; … … 1126 1104 if (!yaml_parser_remove_simple_key(parser)) return 0; 1127 1105 1128 *(parser->simple_keys.top-1)= simple_key;1106 parser->simple_keys.list[parser->simple_keys.length-1] = simple_key; 1129 1107 } 1130 1108 … … 1139 1117 yaml_parser_remove_simple_key(yaml_parser_t *parser) 1140 1118 { 1141 yaml_simple_key_t *simple_key = parser->simple_keys.top-1; 1142 1143 if (simple_key->possible) 1119 yaml_simple_key_t *simple_key = 1120 parser->simple_keys.list + parser->simple_keys.length - 1; 1121 1122 if (simple_key->is_possible) 1144 1123 { 1145 1124 /* If the key is required, it is an error. */ 1146 1125 1147 if (simple_key-> required) {1148 return yaml_parser_set_scanner_error(parser,1126 if (simple_key->is_required) { 1127 return SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 1149 1128 "while scanning a simple key", simple_key->mark, 1150 "could not found expected ':'" );1129 "could not found expected ':'", parser->mark); 1151 1130 } 1152 1131 } … … 1154 1133 /* Remove the key from the stack. */ 1155 1134 1156 simple_key-> possible = 0;1135 simple_key->is_possible = 0; 1157 1136 1158 1137 return 1; … … 1302 1281 /* A simple key is allowed at the beginning of the stream. */ 1303 1282 1304 parser-> simple_key_allowed = 1;1283 parser->is_simple_key_allowed = 1; 1305 1284 1306 1285 /* We have started. */ 1307 1286 1308 parser-> stream_start_produced = 1;1287 parser->is_stream_start_produced = 1; 1309 1288 1310 1289 /* Create the STREAM-START token and append it to the queue. */ … … 1345 1324 return 0; 1346 1325 1347 parser-> simple_key_allowed = 0;1326 parser->is_simple_key_allowed = 0; 1348 1327 1349 1328 /* Create the STREAM-END token and append it to the queue. */ … … 1376 1355 return 0; 1377 1356 1378 parser-> simple_key_allowed = 0;1357 parser->is_simple_key_allowed = 0; 1379 1358 1380 1359 /* Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. */ … … 1414 1393 return 0; 1415 1394 1416 parser-> simple_key_allowed = 0;1395 parser->is_simple_key_allowed = 0; 1417 1396 1418 1397 /* Consume the token. */ … … 1461 1440 /* A simple key may follow the indicators '[' and '{'. */ 1462 1441 1463 parser-> simple_key_allowed = 1;1442 parser->is_simple_key_allowed = 1; 1464 1443 1465 1444 /* Consume the token. */ … … 1504 1483 /* No simple keys after the indicators ']' and '}'. */ 1505 1484 1506 parser-> simple_key_allowed = 0;1485 parser->is_simple_key_allowed = 0; 1507 1486 1508 1487 /* Consume the token. */ … … 1541 1520 /* Simple keys are allowed after ','. */ 1542 1521 1543 parser-> simple_key_allowed = 1;1522 parser->is_simple_key_allowed = 1; 1544 1523 1545 1524 /* Consume the token. */ … … 1575 1554 /* Check if we are allowed to start a new entry. */ 1576 1555 1577 if (!parser->simple_key_allowed) { 1578 return yaml_parser_set_scanner_error(parser, NULL, parser->mark, 1579 "block sequence entries are not allowed in this context"); 1556 if (!parser->is_simple_key_allowed) { 1557 return SCANNER_ERROR_INIT(parser, 1558 "block sequence entries are not allowed in this context", 1559 parser->mark); 1580 1560 } 1581 1561 … … 1602 1582 /* Simple keys are allowed after '-'. */ 1603 1583 1604 parser-> simple_key_allowed = 1;1584 parser->is_simple_key_allowed = 1; 1605 1585 1606 1586 /* Consume the token. */ … … 1636 1616 /* Check if we are allowed to start a new key (not nessesary simple). */ 1637 1617 1638 if (!parser-> simple_key_allowed) {1639 return yaml_parser_set_scanner_error(parser, NULL, parser->mark,1640 "mapping keys are not allowed in this context" );1618 if (!parser->is_simple_key_allowed) { 1619 return SCANNER_ERROR_INIT(parser, 1620 "mapping keys are not allowed in this context", parser->mark); 1641 1621 } 1642 1622 … … 1655 1635 /* Simple keys are allowed after '?' in the block context. */ 1656 1636 1657 parser-> simple_key_allowed = (!parser->flow_level);1637 parser->is_simple_key_allowed = (!parser->flow_level); 1658 1638 1659 1639 /* Consume the token. */ … … 1682 1662 yaml_mark_t start_mark, end_mark; 1683 1663 yaml_token_t token; 1684 yaml_simple_key_t *simple_key = parser->simple_keys.top-1; 1664 yaml_simple_key_t *simple_key = 1665 parser->simple_keys.list + parser->simple_keys.length - 1; 1685 1666 1686 1667 /* Have we found a simple key? */ 1687 1668 1688 if (simple_key-> possible)1669 if (simple_key->is_possible) 1689 1670 { 1690 1671 … … 1706 1687 /* Remove the simple key. */ 1707 1688 1708 simple_key-> possible = 0;1689 simple_key->is_possible = 0; 1709 1690 1710 1691 /* A simple key cannot follow another simple key. */ 1711 1692 1712 parser-> simple_key_allowed = 0;1693 parser->is_simple_key_allowed = 0; 1713 1694 } 1714 1695 else … … 1722 1703 /* Check if we are allowed to start a complex value. */ 1723 1704 1724 if (!parser->simple_key_allowed) { 1725 return yaml_parser_set_scanner_error(parser, NULL, parser->mark, 1726 "mapping values are not allowed in this context"); 1705 if (!parser->is_simple_key_allowed) { 1706 return SCANNER_ERROR_INIT(parser, 1707 "mapping values are not allowed in this context", 1708 parser->mark); 1727 1709 } 1728 1710 … … 1736 1718 /* Simple keys after ':' are allowed in the block context. */ 1737 1719 1738 parser-> simple_key_allowed = (!parser->flow_level);1720 parser->is_simple_key_allowed = (!parser->flow_level); 1739 1721 } 1740 1722 … … 1771 1753 /* A simple key cannot follow an anchor or an alias. */ 1772 1754 1773 parser-> simple_key_allowed = 0;1755 parser->is_simple_key_allowed = 0; 1774 1756 1775 1757 /* Create the ALIAS or ANCHOR token and append it to the queue. */ … … 1801 1783 /* A simple key cannot follow a tag. */ 1802 1784 1803 parser-> simple_key_allowed = 0;1785 parser->is_simple_key_allowed = 0; 1804 1786 1805 1787 /* Create the TAG token and append it to the queue. */ … … 1832 1814 /* A simple key may follow a block scalar. */ 1833 1815 1834 parser-> simple_key_allowed = 1;1816 parser->is_simple_key_allowed = 1; 1835 1817 1836 1818 /* Create the SCALAR token and append it to the queue. */ … … 1863 1845 /* A simple key cannot follow a flow scalar. */ 1864 1846 1865 parser-> simple_key_allowed = 0;1847 parser->is_simple_key_allowed = 0; 1866 1848 1867 1849 /* Create the SCALAR token and append it to the queue. */ … … 1894 1876 /* A simple key cannot follow a flow scalar. */ 1895 1877 1896 parser-> simple_key_allowed = 0;1878 parser->is_simple_key_allowed = 0; 1897 1879 1898 1880 /* Create the SCALAR token and append it to the queue. */ … … 1924 1906 if (!CACHE(parser, 1)) return 0; 1925 1907 1926 if (parser->mark.column == 0 && IS_BOM(parser-> buffer))1908 if (parser->mark.column == 0 && IS_BOM(parser->input)) 1927 1909 SKIP(parser); 1928 1910 … … 1939 1921 if (!CACHE(parser, 1)) return 0; 1940 1922 1941 while (CHECK(parser-> buffer,' ') ||1942 ((parser->flow_level || !parser-> simple_key_allowed) &&1943 CHECK(parser-> buffer, '\t'))) {1923 while (CHECK(parser->input,' ') || 1924 ((parser->flow_level || !parser->is_simple_key_allowed) && 1925 CHECK(parser->input, '\t'))) { 1944 1926 SKIP(parser); 1945 1927 if (!CACHE(parser, 1)) return 0; … … 1948 1930 /* Eat a comment until a line break. */ 1949 1931 1950 if (CHECK(parser-> buffer, '#')) {1951 while (!IS_BREAKZ(parser-> buffer)) {1932 if (CHECK(parser->input, '#')) { 1933 while (!IS_BREAKZ(parser->input)) { 1952 1934 SKIP(parser); 1953 1935 if (!CACHE(parser, 1)) return 0; … … 1957 1939 /* If it is a line break, eat it. */ 1958 1940 1959 if (IS_BREAK(parser-> buffer))1941 if (IS_BREAK(parser->input)) 1960 1942 { 1961 1943 if (!CACHE(parser, 2)) return 0; … … 1965 1947 1966 1948 if (!parser->flow_level) { 1967 parser-> simple_key_allowed = 1;1949 parser->is_simple_key_allowed = 1; 1968 1950 } 1969 1951 } … … 2048 2030 else 2049 2031 { 2050 yaml_parser_set_scanner_error(parser, "while scanning a directive", 2051 start_mark, "found uknown directive name"); 2032 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2033 "while scanning a directive", start_mark, 2034 "found uknown directive name", parser->mark); 2052 2035 goto error; 2053 2036 } … … 2057 2040 if (!CACHE(parser, 1)) goto error; 2058 2041 2059 while (IS_BLANK(parser-> buffer)) {2042 while (IS_BLANK(parser->input)) { 2060 2043 SKIP(parser); 2061 2044 if (!CACHE(parser, 1)) goto error; 2062 2045 } 2063 2046 2064 if (CHECK(parser-> buffer, '#')) {2065 while (!IS_BREAKZ(parser-> buffer)) {2047 if (CHECK(parser->input, '#')) { 2048 while (!IS_BREAKZ(parser->input)) { 2066 2049 SKIP(parser); 2067 2050 if (!CACHE(parser, 1)) goto error; … … 2071 2054 /* Check if we are at the end of the line. */ 2072 2055 2073 if (!IS_BREAKZ(parser->buffer)) { 2074 yaml_parser_set_scanner_error(parser, "while scanning a directive", 2075 start_mark, "did not found expected comment or line break"); 2056 if (!IS_BREAKZ(parser->input)) { 2057 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2058 "while scanning a directive", start_mark, 2059 "did not found expected comment or line break", parser->mark); 2076 2060 goto error; 2077 2061 } … … 2079 2063 /* Eat a line break. */ 2080 2064 2081 if (IS_BREAK(parser-> buffer)) {2065 if (IS_BREAK(parser->input)) { 2082 2066 if (!CACHE(parser, 2)) goto error; 2083 2067 SKIP_LINE(parser); … … 2111 2095 yaml_string_t string = NULL_STRING; 2112 2096 2113 if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error; 2097 if (!STRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 2098 goto error; 2114 2099 2115 2100 /* Consume the directive name. */ … … 2117 2102 if (!CACHE(parser, 1)) goto error; 2118 2103 2119 while (IS_ALPHA(parser-> buffer))2104 while (IS_ALPHA(parser->input)) 2120 2105 { 2121 2106 if (!READ(parser, string)) goto error; … … 2125 2110 /* Check if the name is empty. */ 2126 2111 2127 if (string.start == string.pointer) { 2128 yaml_parser_set_scanner_error(parser, "while scanning a directive", 2129 start_mark, "cannot found expected directive name"); 2112 if (!string.pointer) { 2113 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2114 "while scanning a directive", start_mark, 2115 "cannot found expected directive name", parser->mark); 2130 2116 goto error; 2131 2117 } … … 2133 2119 /* Check for an blank character after the name. */ 2134 2120 2135 if (!IS_BLANKZ(parser->buffer)) { 2136 yaml_parser_set_scanner_error(parser, "while scanning a directive", 2137 start_mark, "found unexpected non-alphabetical character"); 2121 if (!IS_BLANKZ(parser->input)) { 2122 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2123 "while scanning a directive", start_mark, 2124 "found unexpected non-alphabetical character", parser->mark); 2138 2125 goto error; 2139 2126 } 2140 2127 2141 *name = string. start;2128 *name = string.buffer; 2142 2129 2143 2130 return 1; … … 2164 2151 if (!CACHE(parser, 1)) return 0; 2165 2152 2166 while (IS_BLANK(parser-> buffer)) {2153 while (IS_BLANK(parser->input)) { 2167 2154 SKIP(parser); 2168 2155 if (!CACHE(parser, 1)) return 0; … … 2176 2163 /* Eat '.'. */ 2177 2164 2178 if (!CHECK(parser->buffer, '.')) { 2179 return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", 2180 start_mark, "did not find expected digit or '.' character"); 2165 if (!CHECK(parser->input, '.')) { 2166 return SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2167 "while scanning a %YAML directive", start_mark, 2168 "did not find expected digit or '.' character", parser->mark); 2181 2169 } 2182 2170 … … 2214 2202 if (!CACHE(parser, 1)) return 0; 2215 2203 2216 while (IS_DIGIT(parser-> buffer))2204 while (IS_DIGIT(parser->input)) 2217 2205 { 2218 2206 /* Check if the number is too long. */ 2219 2207 2220 2208 if (++length > MAX_NUMBER_LENGTH) { 2221 return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", 2222 start_mark, "found extremely long version number"); 2223 } 2224 2225 value = value*10 + AS_DIGIT(parser->buffer); 2209 return SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2210 "while scanning a %YAML directive", start_mark, 2211 "found extremely long version number", parser->mark); 2212 } 2213 2214 value = value*10 + AS_DIGIT(parser->input); 2226 2215 2227 2216 SKIP(parser); … … 2233 2222 2234 2223 if (!length) { 2235 return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", 2236 start_mark, "did not find expected version number"); 2224 return SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2225 "while scanning a %YAML directive", start_mark, 2226 "did not find expected version number", parser->mark); 2237 2227 } 2238 2228 … … 2261 2251 if (!CACHE(parser, 1)) goto error; 2262 2252 2263 while (IS_BLANK(parser-> buffer)) {2253 while (IS_BLANK(parser->input)) { 2264 2254 SKIP(parser); 2265 2255 if (!CACHE(parser, 1)) goto error; … … 2275 2265 if (!CACHE(parser, 1)) goto error; 2276 2266 2277 if (!IS_BLANK(parser->buffer)) { 2278 yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", 2279 start_mark, "did not find expected whitespace"); 2267 if (!IS_BLANK(parser->input)) { 2268 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2269 "while scanning a %TAG directive", start_mark, 2270 "did not find expected whitespace", parser->mark); 2280 2271 goto error; 2281 2272 } … … 2283 2274 /* Eat whitespaces. */ 2284 2275 2285 while (IS_BLANK(parser-> buffer)) {2276 while (IS_BLANK(parser->input)) { 2286 2277 SKIP(parser); 2287 2278 if (!CACHE(parser, 1)) goto error; … … 2297 2288 if (!CACHE(parser, 1)) goto error; 2298 2289 2299 if (!IS_BLANKZ(parser->buffer)) { 2300 yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", 2301 start_mark, "did not find expected whitespace or line break"); 2290 if (!IS_BLANKZ(parser->input)) { 2291 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2292 "while scanning a %TAG directive", start_mark, 2293 "did not find expected whitespace or line break", parser->mark); 2302 2294 goto error; 2303 2295 } … … 2322 2314 yaml_string_t string = NULL_STRING; 2323 2315 2324 if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error; 2316 if (!STRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 2317 goto error; 2325 2318 2326 2319 /* Eat the indicator character. */ … … 2334 2327 if (!CACHE(parser, 1)) goto error; 2335 2328 2336 while (IS_ALPHA(parser-> buffer)) {2329 while (IS_ALPHA(parser->input)) { 2337 2330 if (!READ(parser, string)) goto error; 2338 2331 if (!CACHE(parser, 1)) goto error; … … 2349 2342 */ 2350 2343 2351 if (!length || !(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '?') 2352 || CHECK(parser->buffer, ':') || CHECK(parser->buffer, ',') 2353 || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '}') 2354 || CHECK(parser->buffer, '%') || CHECK(parser->buffer, '@') 2355 || CHECK(parser->buffer, '`'))) { 2356 yaml_parser_set_scanner_error(parser, type == YAML_ANCHOR_TOKEN ? 2357 "while scanning an anchor" : "while scanning an alias", start_mark, 2358 "did not find expected alphabetic or numeric character"); 2344 if (!length || !(IS_BLANKZ(parser->input) || CHECK(parser->input, '?') 2345 || CHECK(parser->input, ':') || CHECK(parser->input, ',') 2346 || CHECK(parser->input, ']') || CHECK(parser->input, '}') 2347 || CHECK(parser->input, '%') || CHECK(parser->input, '@') 2348 || CHECK(parser->input, '`'))) { 2349 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, type == YAML_ANCHOR_TOKEN ? 2350 "while scanning an anchor" : "while scanning an alias", 2351 start_mark, 2352 "did not find expected alphabetic or numeric character", 2353 parser->mark); 2359 2354 goto error; 2360 2355 } … … 2363 2358 2364 2359 if (type == YAML_ANCHOR_TOKEN) { 2365 ANCHOR_TOKEN_INIT(*token, string. start, start_mark, end_mark);2360 ANCHOR_TOKEN_INIT(*token, string.buffer, start_mark, end_mark); 2366 2361 } 2367 2362 else { 2368 ALIAS_TOKEN_INIT(*token, string. start, start_mark, end_mark);2363 ALIAS_TOKEN_INIT(*token, string.buffer, start_mark, end_mark); 2369 2364 } 2370 2365 … … 2393 2388 if (!CACHE(parser, 2)) goto error; 2394 2389 2395 if (CHECK_AT(parser-> buffer, '<', 1))2390 if (CHECK_AT(parser->input, '<', 1)) 2396 2391 { 2397 2392 /* Set the handle to '' */ … … 2413 2408 /* Check for '>' and eat it. */ 2414 2409 2415 if (!CHECK(parser->buffer, '>')) { 2416 yaml_parser_set_scanner_error(parser, "while scanning a tag", 2417 start_mark, "did not find the expected '>'"); 2410 if (!CHECK(parser->input, '>')) { 2411 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2412 "while scanning a tag", start_mark, 2413 "did not find the expected '>'", parser->mark); 2418 2414 goto error; 2419 2415 } … … 2471 2467 if (!CACHE(parser, 1)) goto error; 2472 2468 2473 if (!IS_BLANKZ(parser->buffer)) { 2474 yaml_parser_set_scanner_error(parser, "while scanning a tag", 2475 start_mark, "did not found expected whitespace or line break"); 2469 if (!IS_BLANKZ(parser->input)) { 2470 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2471 "while scanning a tag", start_mark, 2472 "did not found expected whitespace or line break", parser->mark); 2476 2473 goto error; 2477 2474 } … … 2501 2498 yaml_string_t string = NULL_STRING; 2502 2499 2503 if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error; 2500 if (!STRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 2501 goto error; 2504 2502 2505 2503 /* Check the initial '!' character. */ … … 2507 2505 if (!CACHE(parser, 1)) goto error; 2508 2506 2509 if (!CHECK(parser-> buffer, '!')) {2510 yaml_parser_set_scanner_error(parser, directive ?2507 if (!CHECK(parser->input, '!')) { 2508 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, directive ? 2511 2509 "while scanning a tag directive" : "while scanning a tag", 2512 start_mark, "did not find expected '!'" );2510 start_mark, "did not find expected '!'", parser->mark); 2513 2511 goto error; 2514 2512 } … … 2522 2520 if (!CACHE(parser, 1)) goto error; 2523 2521 2524 while (IS_ALPHA(parser-> buffer))2522 while (IS_ALPHA(parser->input)) 2525 2523 { 2526 2524 if (!READ(parser, string)) goto error; … … 2530 2528 /* Check if the trailing character is '!' and copy it. */ 2531 2529 2532 if (CHECK(parser-> buffer, '!'))2530 if (CHECK(parser->input, '!')) 2533 2531 { 2534 2532 if (!READ(parser, string)) goto error; … … 2542 2540 */ 2543 2541 2544 if (directive && !(string.start[0] == '!' && string.start[1] == '\0')) { 2545 yaml_parser_set_scanner_error(parser, "while parsing a tag directive", 2546 start_mark, "did not find expected '!'"); 2542 if (directive && 2543 !(string.buffer[0] == '!' && string.buffer[1] == '\0')) { 2544 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2545 "while parsing a tag directive", start_mark, 2546 "did not find expected '!'", parser->mark); 2547 2547 goto error; 2548 2548 } 2549 2549 } 2550 2550 2551 *handle = string. start;2551 *handle = string.buffer; 2552 2552 2553 2553 return 1; … … 2569 2569 yaml_string_t string = NULL_STRING; 2570 2570 2571 if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error; 2571 if (!STRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 2572 goto error; 2572 2573 2573 2574 /* Resize the string to include the head. */ 2574 2575 2575 while (string. end - string.start <= (int)length) {2576 if (!yaml_string_extend(&string. start, &string.pointer, &string.end)) {2577 parser->error = YAML_MEMORY_ERROR;2576 while (string.capacity <= length) { 2577 if (!yaml_string_extend(&string.buffer, &string.capacity)) { 2578 MEMORY_ERROR_INIT(parser); 2578 2579 goto error; 2579 2580 } … … 2587 2588 2588 2589 if (length > 1) { 2589 memcpy(string. start, head+1, length-1);2590 memcpy(string.buffer, head+1, length-1); 2590 2591 string.pointer += length-1; 2591 2592 } … … 2603 2604 */ 2604 2605 2605 while (IS_ALPHA(parser-> buffer) || CHECK(parser->buffer, ';')2606 || CHECK(parser-> buffer, '/') || CHECK(parser->buffer, '?')2607 || CHECK(parser-> buffer, ':') || CHECK(parser->buffer, '@')2608 || CHECK(parser-> buffer, '&') || CHECK(parser->buffer, '=')2609 || CHECK(parser-> buffer, '+') || CHECK(parser->buffer, '$')2610 || CHECK(parser-> buffer, ',') || CHECK(parser->buffer, '.')2611 || CHECK(parser-> buffer, '!') || CHECK(parser->buffer, '~')2612 || CHECK(parser-> buffer, '*') || CHECK(parser->buffer, '\'')2613 || CHECK(parser-> buffer, '(') || CHECK(parser->buffer, ')')2614 || CHECK(parser-> buffer, '[') || CHECK(parser->buffer, ']')2615 || CHECK(parser-> buffer, '%'))2606 while (IS_ALPHA(parser->input) || CHECK(parser->input, ';') 2607 || CHECK(parser->input, '/') || CHECK(parser->input, '?') 2608 || CHECK(parser->input, ':') || CHECK(parser->input, '@') 2609 || CHECK(parser->input, '&') || CHECK(parser->input, '=') 2610 || CHECK(parser->input, '+') || CHECK(parser->input, '$') 2611 || CHECK(parser->input, ',') || CHECK(parser->input, '.') 2612 || CHECK(parser->input, '!') || CHECK(parser->input, '~') 2613 || CHECK(parser->input, '*') || CHECK(parser->input, '\'') 2614 || CHECK(parser->input, '(') || CHECK(parser->input, ')') 2615 || CHECK(parser->input, '[') || CHECK(parser->input, ']') 2616 || CHECK(parser->input, '%')) 2616 2617 { 2617 2618 /* Check if it is a URI-escape sequence. */ 2618 2619 2619 if (CHECK(parser-> buffer, '%')) {2620 if (CHECK(parser->input, '%')) { 2620 2621 if (!yaml_parser_scan_uri_escapes(parser, 2621 2622 directive, start_mark, &string)) goto error; … … 2635 2636 goto error; 2636 2637 2637 yaml_parser_set_scanner_error(parser, directive ?2638 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, directive ? 2638 2639 "while parsing a %TAG directive" : "while parsing a tag", 2639 start_mark, "did not find expected tag URI" );2640 start_mark, "did not find expected tag URI", parser->mark); 2640 2641 goto error; 2641 2642 } 2642 2643 2643 *uri = string. start;2644 *uri = string.buffer; 2644 2645 2645 2646 return 1; … … 2663 2664 2664 2665 do { 2665 2666 2666 unsigned char octet = 0; 2667 2667 … … 2670 2670 if (!CACHE(parser, 3)) return 0; 2671 2671 2672 if (!(CHECK(parser-> buffer, '%')2673 && IS_HEX_AT(parser-> buffer, 1)2674 && IS_HEX_AT(parser-> buffer, 2))) {2675 return yaml_parser_set_scanner_error(parser, directive ?2672 if (!(CHECK(parser->input, '%') 2673 && IS_HEX_AT(parser->input, 1) 2674 && IS_HEX_AT(parser->input, 2))) { 2675 return SCANNER_ERROR_WITH_CONTEXT_INIT(parser, directive ? 2676 2676 "while parsing a %TAG directive" : "while parsing a tag", 2677 start_mark, "did not find URI escaped octet" );2677 start_mark, "did not find URI escaped octet", parser->mark); 2678 2678 } 2679 2679 2680 2680 /* Get the octet. */ 2681 2681 2682 octet = (AS_HEX_AT(parser-> buffer, 1) << 4) + AS_HEX_AT(parser->buffer, 2);2682 octet = (AS_HEX_AT(parser->input, 1) << 4) + AS_HEX_AT(parser->input, 2); 2683 2683 2684 2684 /* If it is the leading octet, determine the length of the UTF-8 sequence. */ … … 2691 2691 (octet & 0xF8) == 0xF0 ? 4 : 0; 2692 2692 if (!width) { 2693 return yaml_parser_set_scanner_error(parser, directive ?2693 return SCANNER_ERROR_WITH_CONTEXT_INIT(parser, directive ? 2694 2694 "while parsing a %TAG directive" : "while parsing a tag", 2695 start_mark, "found an incorrect leading UTF-8 octet"); 2695 start_mark, "found an incorrect leading UTF-8 octet", 2696 parser->mark); 2696 2697 } 2697 2698 } … … 2701 2702 2702 2703 if ((octet & 0xC0) != 0x80) { 2703 return yaml_parser_set_scanner_error(parser, directive ?2704 return SCANNER_ERROR_WITH_CONTEXT_INIT(parser, directive ? 2704 2705 "while parsing a %TAG directive" : "while parsing a tag", 2705 start_mark, "found an incorrect trailing UTF-8 octet"); 2706 start_mark, "found an incorrect trailing UTF-8 octet", 2707 parser->mark); 2706 2708 } 2707 2709 } … … 2709 2711 /* Copy the octet and move the pointers. */ 2710 2712 2711 *(string->pointer++) = octet;2713 JOIN_OCTET(*string, octet); 2712 2714 SKIP(parser); 2713 2715 SKIP(parser); … … 2738 2740 int trailing_blank = 0; 2739 2741 2740 if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error; 2741 if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error; 2742 if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error; 2742 if (!STRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 2743 goto error; 2744 if (!STRING_INIT(parser, leading_break, INITIAL_STRING_CAPACITY)) 2745 goto error; 2746 if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_CAPACITY)) 2747 goto error; 2743 2748 2744 2749 /* Eat the indicator '|' or '>'. */ … … 2754 2759 /* Check for a chomping indicator. */ 2755 2760 2756 if (CHECK(parser-> buffer, '+') || CHECK(parser->buffer, '-'))2761 if (CHECK(parser->input, '+') || CHECK(parser->input, '-')) 2757 2762 { 2758 2763 /* Set the chomping method and eat the indicator. */ 2759 2764 2760 chomping = CHECK(parser-> buffer, '+') ? +1 : -1;2765 chomping = CHECK(parser->input, '+') ? +1 : -1; 2761 2766 2762 2767 SKIP(parser); … … 2766 2771 if (!CACHE(parser, 1)) goto error; 2767 2772 2768 if (IS_DIGIT(parser-> buffer))2773 if (IS_DIGIT(parser->input)) 2769 2774 { 2770 2775 /* Check that the intendation is greater than 0. */ 2771 2776 2772 if (CHECK(parser->buffer, '0')) { 2773 yaml_parser_set_scanner_error(parser, "while scanning a block scalar", 2774 start_mark, "found an intendation indicator equal to 0"); 2777 if (CHECK(parser->input, '0')) { 2778 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2779 "while scanning a block scalar", start_mark, 2780 "found an intendation indicator equal to 0", parser->mark); 2775 2781 goto error; 2776 2782 } … … 2778 2784 /* Get the intendation level and eat the indicator. */ 2779 2785 2780 increment = AS_DIGIT(parser-> buffer);2786 increment = AS_DIGIT(parser->input); 2781 2787 2782 2788 SKIP(parser); … … 2786 2792 /* Do the same as above, but in the opposite order. */ 2787 2793 2788 else if (IS_DIGIT(parser-> buffer))2794 else if (IS_DIGIT(parser->input)) 2789 2795 { 2790 if (CHECK(parser->buffer, '0')) { 2791 yaml_parser_set_scanner_error(parser, "while scanning a block scalar", 2792 start_mark, "found an intendation indicator equal to 0"); 2796 if (CHECK(parser->input, '0')) { 2797 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2798 "while scanning a block scalar", start_mark, 2799 "found an intendation indicator equal to 0", parser->mark); 2793 2800 goto error; 2794 2801 } 2795 2802 2796 increment = AS_DIGIT(parser-> buffer);2803 increment = AS_DIGIT(parser->input); 2797 2804 2798 2805 SKIP(parser); … … 2800 2807 if (!CACHE(parser, 1)) goto error; 2801 2808 2802 if (CHECK(parser-> buffer, '+') || CHECK(parser->buffer, '-')) {2803 chomping = CHECK(parser-> buffer, '+') ? +1 : -1;2809 if (CHECK(parser->input, '+') || CHECK(parser->input, '-')) { 2810 chomping = CHECK(parser->input, '+') ? +1 : -1; 2804 2811 2805 2812 SKIP(parser); … … 2811 2818 if (!CACHE(parser, 1)) goto error; 2812 2819 2813 while (IS_BLANK(parser-> buffer)) {2820 while (IS_BLANK(parser->input)) { 2814 2821 SKIP(parser); 2815 2822 if (!CACHE(parser, 1)) goto error; 2816 2823 } 2817 2824 2818 if (CHECK(parser-> buffer, '#')) {2819 while (!IS_BREAKZ(parser-> buffer)) {2825 if (CHECK(parser->input, '#')) { 2826 while (!IS_BREAKZ(parser->input)) { 2820 2827 SKIP(parser); 2821 2828 if (!CACHE(parser, 1)) goto error; … … 2825 2832 /* Check if we are at the end of the line. */ 2826 2833 2827 if (!IS_BREAKZ(parser->buffer)) { 2828 yaml_parser_set_scanner_error(parser, "while scanning a block scalar", 2829 start_mark, "did not found expected comment or line break"); 2834 if (!IS_BREAKZ(parser->input)) { 2835 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2836 "while scanning a block scalar", start_mark, 2837 "did not found expected comment or line break", parser->mark); 2830 2838 goto error; 2831 2839 } … … 2833 2841 /* Eat a line break. */ 2834 2842 2835 if (IS_BREAK(parser-> buffer)) {2843 if (IS_BREAK(parser->input)) { 2836 2844 if (!CACHE(parser, 2)) goto error; 2837 2845 SKIP_LINE(parser); … … 2855 2863 if (!CACHE(parser, 1)) goto error; 2856 2864 2857 while ((int)parser->mark.column == indent && !IS_Z(parser-> buffer))2865 while ((int)parser->mark.column == indent && !IS_Z(parser->input)) 2858 2866 { 2859 2867 /* … … 2863 2871 /* Is it a trailing whitespace? */ 2864 2872 2865 trailing_blank = IS_BLANK(parser-> buffer);2873 trailing_blank = IS_BLANK(parser->input); 2866 2874 2867 2875 /* Check if we need to fold the leading line break. */ 2868 2876 2869 if (!literal && (*leading_break. start== '\n')2877 if (!literal && (*leading_break.buffer == '\n') 2870 2878 && !leading_blank && !trailing_blank) 2871 2879 { 2872 2880 /* Do we need to join the lines by space? */ 2873 2881 2874 if (*trailing_breaks. start== '\0') {2882 if (*trailing_breaks.buffer == '\0') { 2875 2883 if (!STRING_EXTEND(parser, string)) goto error; 2876 *(string.pointer ++) = ' ';2884 JOIN_OCTET(string, ' '); 2877 2885 } 2878 2886 … … 2891 2899 /* Is it a leading whitespace? */ 2892 2900 2893 leading_blank = IS_BLANK(parser-> buffer);2901 leading_blank = IS_BLANK(parser->input); 2894 2902 2895 2903 /* Consume the current line. */ 2896 2904 2897 while (!IS_BREAKZ(parser-> buffer)) {2905 while (!IS_BREAKZ(parser->input)) { 2898 2906 if (!READ(parser, string)) goto error; 2899 2907 if (!CACHE(parser, 1)) goto error; … … 2923 2931 /* Create a token. */ 2924 2932 2925 SCALAR_TOKEN_INIT(*token, string. start, string.pointer-string.start,2933 SCALAR_TOKEN_INIT(*token, string.buffer, string.pointer, 2926 2934 literal ? YAML_LITERAL_SCALAR_STYLE : YAML_FOLDED_SCALAR_STYLE, 2927 2935 start_mark, end_mark); … … 2963 2971 2964 2972 while ((!*indent || (int)parser->mark.column < *indent) 2965 && IS_SPACE(parser-> buffer)) {2973 && IS_SPACE(parser->input)) { 2966 2974 SKIP(parser); 2967 2975 if (!CACHE(parser, 1)) return 0; … … 2974 2982 2975 2983 if ((!*indent || (int)parser->mark.column < *indent) 2976 && IS_TAB(parser->buffer)) { 2977 return yaml_parser_set_scanner_error(parser, "while scanning a block scalar", 2978 start_mark, "found a tab character where an intendation space is expected"); 2984 && IS_TAB(parser->input)) { 2985 return SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 2986 "while scanning a block scalar", start_mark, 2987 "found a tab character where an intendation space is expected", 2988 parser->mark); 2979 2989 } 2980 2990 2981 2991 /* Have we found a non-empty line? */ 2982 2992 2983 if (!IS_BREAK(parser-> buffer)) break;2993 if (!IS_BREAK(parser->input)) break; 2984 2994 2985 2995 /* Consume the line break. */ … … 3019 3029 int leading_blanks; 3020 3030 3021 if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error; 3022 if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error; 3023 if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error; 3024 if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error; 3031 if (!STRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 3032 goto error; 3033 if (!STRING_INIT(parser, leading_break, INITIAL_STRING_CAPACITY)) 3034 goto error; 3035 if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_CAPACITY)) 3036 goto error; 3037 if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_CAPACITY)) 3038 goto error; 3025 3039 3026 3040 /* Eat the left quote. */ … … 3039 3053 3040 3054 if (parser->mark.column == 0 && 3041 ((CHECK_AT(parser-> buffer, '-', 0) &&3042 CHECK_AT(parser-> buffer, '-', 1) &&3043 CHECK_AT(parser-> buffer, '-', 2)) ||3044 (CHECK_AT(parser-> buffer, '.', 0) &&3045 CHECK_AT(parser-> buffer, '.', 1) &&3046 CHECK_AT(parser-> buffer, '.', 2))) &&3047 IS_BLANKZ_AT(parser-> buffer, 3))3055 ((CHECK_AT(parser->input, '-', 0) && 3056 CHECK_AT(parser->input, '-', 1) && 3057 CHECK_AT(parser->input, '-', 2)) || 3058 (CHECK_AT(parser->input, '.', 0) && 3059 CHECK_AT(parser->input, '.', 1) && 3060 CHECK_AT(parser->input, '.', 2))) && 3061 IS_BLANKZ_AT(parser->input, 3)) 3048 3062 { 3049 yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", 3050 start_mark, "found unexpected document indicator"); 3063 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 3064 "while scanning a quoted scalar", start_mark, 3065 "found unexpected document indicator", parser->mark); 3051 3066 goto error; 3052 3067 } … … 3054 3069 /* Check for EOF. */ 3055 3070 3056 if (IS_Z(parser->buffer)) { 3057 yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", 3058 start_mark, "found unexpected end of stream"); 3071 if (IS_Z(parser->input)) { 3072 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 3073 "while scanning a quoted scalar", start_mark, 3074 "found unexpected end of stream", parser->mark); 3059 3075 goto error; 3060 3076 } … … 3066 3082 leading_blanks = 0; 3067 3083 3068 while (!IS_BLANKZ(parser-> buffer))3084 while (!IS_BLANKZ(parser->input)) 3069 3085 { 3070 3086 /* Check for an escaped single quote. */ 3071 3087 3072 if (single && CHECK_AT(parser-> buffer, '\'', 0)3073 && CHECK_AT(parser-> buffer, '\'', 1))3088 if (single && CHECK_AT(parser->input, '\'', 0) 3089 && CHECK_AT(parser->input, '\'', 1)) 3074 3090 { 3075 3091 if (!STRING_EXTEND(parser, string)) goto error; 3076 *(string.pointer++) = '\'';3092 JOIN_OCTET(string, '\''); 3077 3093 SKIP(parser); 3078 3094 SKIP(parser); … … 3081 3097 /* Check for the right quote. */ 3082 3098 3083 else if (CHECK(parser-> buffer, single ? '\'' : '"'))3099 else if (CHECK(parser->input, single ? '\'' : '"')) 3084 3100 { 3085 3101 break; … … 3088 3104 /* Check for an escaped line break. */ 3089 3105 3090 else if (!single && CHECK(parser-> buffer, '\\')3091 && IS_BREAK_AT(parser-> buffer, 1))3106 else if (!single && CHECK(parser->input, '\\') 3107 && IS_BREAK_AT(parser->input, 1)) 3092 3108 { 3093 3109 if (!CACHE(parser, 3)) goto error; … … 3100 3116 /* Check for an escape sequence. */ 3101 3117 3102 else if (!single && CHECK(parser-> buffer, '\\'))3118 else if (!single && CHECK(parser->input, '\\')) 3103 3119 { 3104 3120 size_t code_length = 0; … … 3108 3124 /* Check the escape character. */ 3109 3125 3110 switch ( parser->buffer.pointer[1])3126 switch (OCTET_AT(parser->input, 1)) 3111 3127 { 3112 3128 case '0': 3113 *(string.pointer++) = '\0';3129 JOIN_OCTET(string, '\0'); 3114 3130 break; 3115 3131 3116 3132 case 'a': 3117 *(string.pointer++) = '\x07';3133 JOIN_OCTET(string, '\x07'); 3118 3134 break; 3119 3135 3120 3136 case 'b': 3121 *(string.pointer++) = '\x08';3137 JOIN_OCTET(string, '\x08'); 3122 3138 break; 3123 3139 3124 3140 case 't': 3125 3141 case '\t': 3126 *(string.pointer++) = '\x09';3142 JOIN_OCTET(string, '\x09'); 3127 3143 break; 3128 3144 3129 3145 case 'n': 3130 *(string.pointer++) = '\x0A';3146 JOIN_OCTET(string, '\x0A'); 3131 3147 break; 3132 3148 3133 3149 case 'v': 3134 *(string.pointer++) = '\x0B';3150 JOIN_OCTET(string, '\x0B'); 3135 3151 break; 3136 3152 3137 3153 case 'f': 3138 *(string.pointer++) = '\x0C';3154 JOIN_OCTET(string, '\x0C'); 3139 3155 break; 3140 3156 3141 3157 case 'r': 3142 *(string.pointer++) = '\x0D';3158 JOIN_OCTET(string, '\x0D'); 3143 3159 break; 3144 3160 3145 3161 case 'e': 3146 *(string.pointer++) = '\x1B';3162 JOIN_OCTET(string, '\x1B'); 3147 3163 break; 3148 3164 3149 3165 case ' ': 3150 *(string.pointer++) = '\x20';3166 JOIN_OCTET(string, '\x20'); 3151 3167 break; 3152 3168 3153 3169 case '"': 3154 *(string.pointer++) = '"';3170 JOIN_OCTET(string, '"'); 3155 3171 break; 3156 3172 3157 3173 case '\'': 3158 *(string.pointer++) = '\'';3174 JOIN_OCTET(string, '\''); 3159 3175 break; 3160 3176 3161 3177 case '\\': 3162 *(string.pointer++) = '\\';3178 JOIN_OCTET(string, '\\'); 3163 3179 break; 3164 3180 3165 3181 case 'N': /* NEL (#x85) */ 3166 *(string.pointer++) = '\xC2';3167 *(string.pointer++) = '\x85';3182 JOIN_OCTET(string, '\xC2'); 3183 JOIN_OCTET(string, '\x85'); 3168 3184 break; 3169 3185 3170 3186 case '_': /* #xA0 */ 3171 *(string.pointer++) = '\xC2';3172 *(string.pointer++) = '\xA0';3187 JOIN_OCTET(string, '\xC2'); 3188 JOIN_OCTET(string, '\xA0'); 3173 3189 break; 3174 3190 3175 3191 case 'L': /* LS (#x2028) */ 3176 *(string.pointer++) = '\xE2';3177 *(string.pointer++) = '\x80';3178 *(string.pointer++) = '\xA8';3192 JOIN_OCTET(string, '\xE2'); 3193 JOIN_OCTET(string, '\x80'); 3194 JOIN_OCTET(string, '\xA8'); 3179 3195 break; 3180 3196 3181 3197 case 'P': /* PS (#x2029) */ 3182 *(string.pointer++) = '\xE2';3183 *(string.pointer++) = '\x80';3184 *(string.pointer++) = '\xA9';3198 JOIN_OCTET(string, '\xE2'); 3199 JOIN_OCTET(string, '\x80'); 3200 JOIN_OCTET(string, '\xA9'); 3185 3201 break; 3186 3202 … … 3198 3214 3199 3215 default: 3200 yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", 3201 start_mark, "found unknown escape character"); 3216 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 3217 "while parsing a quoted scalar", start_mark, 3218 "found unknown escape character", parser->mark); 3202 3219 goto error; 3203 3220 } … … 3211 3228 { 3212 3229 unsigned int value = 0; 3213 size_t k;3230 size_t idx; 3214 3231 3215 3232 /* Scan the character value. */ … … 3217 3234 if (!CACHE(parser, code_length)) goto error; 3218 3235 3219 for (k = 0; k < code_length; k ++) { 3220 if (!IS_HEX_AT(parser->buffer, k)) { 3221 yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", 3222 start_mark, "did not find expected hexdecimal number"); 3236 for (idx = 0; idx < code_length; idx ++) { 3237 if (!IS_HEX_AT(parser->input, idx)) { 3238 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 3239 "while parsing a quoted scalar", start_mark, 3240 "did not find expected hexdecimal number", 3241 parser->mark); 3223 3242 goto error; 3224 3243 } 3225 value = (value << 4) + AS_HEX_AT(parser-> buffer, k);3244 value = (value << 4) + AS_HEX_AT(parser->input, idx); 3226 3245 } 3227 3246 … … 3229 3248 3230 3249 if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) { 3231 yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", 3232 start_mark, "found invalid Unicode character escape code"); 3250 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 3251 "while parsing a quoted scalar", start_mark, 3252 "found invalid Unicode character escape code", 3253 parser->mark); 3233 3254 goto error; 3234 3255 } 3235 3256 3236 3257 if (value <= 0x7F) { 3237 *(string.pointer++) = value;3258 JOIN_OCTET(string, value); 3238 3259 } 3239 3260 else if (value <= 0x7FF) { 3240 *(string.pointer++) = 0xC0 + (value >> 6);3241 *(string.pointer++) = 0x80 + (value & 0x3F);3261 JOIN_OCTET(string, 0xC0 + (value >> 6)); 3262 JOIN_OCTET(string, 0x80 + (value & 0x3F)); 3242 3263 } 3243 3264 else if (value <= 0xFFFF) { 3244 *(string.pointer++) = 0xE0 + (value >> 12);3245 *(string.pointer++) = 0x80 + ((value >> 6) & 0x3F);3246 *(string.pointer++) = 0x80 + (value & 0x3F);3265 JOIN_OCTET(string, 0xE0 + (value >> 12)); 3266 JOIN_OCTET(string, 0x80 + ((value >> 6) & 0x3F)); 3267 JOIN_OCTET(string, 0x80 + (value & 0x3F)); 3247 3268 } 3248 3269 else { 3249 *(string.pointer++) = 0xF0 + (value >> 18);3250 *(string.pointer++) = 0x80 + ((value >> 12) & 0x3F);3251 *(string.pointer++) = 0x80 + ((value >> 6) & 0x3F);3252 *(string.pointer++) = 0x80 + (value & 0x3F);3270 JOIN_OCTET(string, 0xF0 + (value >> 18)); 3271 JOIN_OCTET(string, 0x80 + ((value >> 12) & 0x3F)); 3272 JOIN_OCTET(string, 0x80 + ((value >> 6) & 0x3F)); 3273 JOIN_OCTET(string, 0x80 + (value & 0x3F)); 3253 3274 } 3254 3275 3255 3276 /* Advance the pointer. */ 3256 3277 3257 for ( k = 0; k < code_length; k++) {3278 for (idx = 0; idx < code_length; idx ++) { 3258 3279 SKIP(parser); 3259 3280 } … … 3273 3294 /* Check if we are at the end of the scalar. */ 3274 3295 3275 if (CHECK(parser-> buffer, single ? '\'' : '"'))3296 if (CHECK(parser->input, single ? '\'' : '"')) 3276 3297 break; 3277 3298 … … 3280 3301 if (!CACHE(parser, 1)) goto error; 3281 3302 3282 while (IS_BLANK(parser-> buffer) || IS_BREAK(parser->buffer))3303 while (IS_BLANK(parser->input) || IS_BREAK(parser->input)) 3283 3304 { 3284 if (IS_BLANK(parser-> buffer))3305 if (IS_BLANK(parser->input)) 3285 3306 { 3286 3307 /* Consume a space or a tab character. */ … … 3319 3340 /* Do we need to fold line breaks? */ 3320 3341 3321 if (leading_break. start[0] == '\n') {3322 if (trailing_breaks. start[0] == '\0') {3342 if (leading_break.buffer[0] == '\n') { 3343 if (trailing_breaks.buffer[0] == '\0') { 3323 3344 if (!STRING_EXTEND(parser, string)) goto error; 3324 *(string.pointer++) = ' ';3345 JOIN_OCTET(string, ' '); 3325 3346 } 3326 3347 else { … … 3352 3373 /* Create a token. */ 3353 3374 3354 SCALAR_TOKEN_INIT(*token, string. start, string.pointer-string.start,3375 SCALAR_TOKEN_INIT(*token, string.buffer, string.pointer, 3355 3376 single ? YAML_SINGLE_QUOTED_SCALAR_STYLE : YAML_DOUBLE_QUOTED_SCALAR_STYLE, 3356 3377 start_mark, end_mark); … … 3387 3408 int indent = parser->indent+1; 3388 3409 3389 if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error; 3390 if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error; 3391 if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error; 3392 if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error; 3410 if (!STRING_INIT(parser, string, INITIAL_STRING_CAPACITY)) 3411 goto error; 3412 if (!STRING_INIT(parser, leading_break, INITIAL_STRING_CAPACITY)) 3413 goto error; 3414 if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_CAPACITY)) 3415 goto error; 3416 if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_CAPACITY)) 3417 goto error; 3393 3418 3394 3419 start_mark = end_mark = parser->mark; … … 3403 3428 3404 3429 if (parser->mark.column == 0 && 3405 ((CHECK_AT(parser-> buffer, '-', 0) &&3406 CHECK_AT(parser-> buffer, '-', 1) &&3407 CHECK_AT(parser-> buffer, '-', 2)) ||3408 (CHECK_AT(parser-> buffer, '.', 0) &&3409 CHECK_AT(parser-> buffer, '.', 1) &&3410 CHECK_AT(parser-> buffer, '.', 2))) &&3411 IS_BLANKZ_AT(parser-> buffer, 3)) break;3430 ((CHECK_AT(parser->input, '-', 0) && 3431 CHECK_AT(parser->input, '-', 1) && 3432 CHECK_AT(parser->input, '-', 2)) || 3433 (CHECK_AT(parser->input, '.', 0) && 3434 CHECK_AT(parser->input, '.', 1) && 3435 CHECK_AT(parser->input, '.', 2))) && 3436 IS_BLANKZ_AT(parser->input, 3)) break; 3412 3437 3413 3438 /* Check for a comment. */ 3414 3439 3415 if (CHECK(parser-> buffer, '#'))3440 if (CHECK(parser->input, '#')) 3416 3441 break; 3417 3442 3418 3443 /* Consume non-blank characters. */ 3419 3444 3420 while (!IS_BLANKZ(parser-> buffer))3445 while (!IS_BLANKZ(parser->input)) 3421 3446 { 3422 3447 /* Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". */ 3423 3448 3424 3449 if (parser->flow_level 3425 && CHECK(parser->buffer, ':') 3426 && !IS_BLANKZ_AT(parser->buffer, 1)) { 3427 yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", 3428 start_mark, "found unexpected ':'"); 3450 && CHECK(parser->input, ':') 3451 && !IS_BLANKZ_AT(parser->input, 1)) { 3452 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 3453 "while scanning a plain scalar", start_mark, 3454 "found unexpected ':'", parser->mark); 3429 3455 goto error; 3430 3456 } … … 3432 3458 /* Check for indicators that may end a plain scalar. */ 3433 3459 3434 if ((CHECK(parser-> buffer, ':') && IS_BLANKZ_AT(parser->buffer, 1))3460 if ((CHECK(parser->input, ':') && IS_BLANKZ_AT(parser->input, 1)) 3435 3461 || (parser->flow_level && 3436 (CHECK(parser-> buffer, ',') || CHECK(parser->buffer, ':')3437 || CHECK(parser-> buffer, '?') || CHECK(parser->buffer, '[')3438 || CHECK(parser-> buffer, ']') || CHECK(parser->buffer, '{')3439 || CHECK(parser-> buffer, '}'))))3462 (CHECK(parser->input, ',') || CHECK(parser->input, ':') 3463 || CHECK(parser->input, '?') || CHECK(parser->input, '[') 3464 || CHECK(parser->input, ']') || CHECK(parser->input, '{') 3465 || CHECK(parser->input, '}')))) 3440 3466 break; 3441 3467 3442 3468 /* Check if we need to join whitespaces and breaks. */ 3443 3469 3444 if (leading_blanks || whitespaces. start != whitespaces.pointer)3470 if (leading_blanks || whitespaces.pointer > 0) 3445 3471 { 3446 3472 if (leading_blanks) … … 3448 3474 /* Do we need to fold line breaks? */ 3449 3475 3450 if (leading_break. start[0] == '\n') {3451 if (trailing_breaks. start[0] == '\0') {3476 if (leading_break.buffer[0] == '\n') { 3477 if (trailing_breaks.buffer[0] == '\0') { 3452 3478 if (!STRING_EXTEND(parser, string)) goto error; 3453 *(string.pointer++) = ' ';3479 JOIN_OCTET(string, ' '); 3454 3480 } 3455 3481 else { … … 3486 3512 /* Is it the end? */ 3487 3513 3488 if (!(IS_BLANK(parser-> buffer) || IS_BREAK(parser->buffer)))3514 if (!(IS_BLANK(parser->input) || IS_BREAK(parser->input))) 3489 3515 break; 3490 3516 … … 3493 3519 if (!CACHE(parser, 1)) goto error; 3494 3520 3495 while (IS_BLANK(parser-> buffer) || IS_BREAK(parser->buffer))3521 while (IS_BLANK(parser->input) || IS_BREAK(parser->input)) 3496 3522 { 3497 if (IS_BLANK(parser-> buffer))3523 if (IS_BLANK(parser->input)) 3498 3524 { 3499 3525 /* Check for tab character that abuse intendation. */ 3500 3526 3501 3527 if (leading_blanks && (int)parser->mark.column < indent 3502 && IS_TAB(parser->buffer)) { 3503 yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", 3504 start_mark, "found a tab character that violate intendation"); 3528 && IS_TAB(parser->input)) { 3529 SCANNER_ERROR_WITH_CONTEXT_INIT(parser, 3530 "while scanning a plain scalar", start_mark, 3531 "found a tab character that violate intendation", 3532 parser->mark); 3505 3533 goto error; 3506 3534 } … … 3543 3571 /* Create a token. */ 3544 3572 3545 SCALAR_TOKEN_INIT(*token, string. start, string.pointer-string.start,3573 SCALAR_TOKEN_INIT(*token, string.buffer, string.pointer, 3546 3574 YAML_PLAIN_SCALAR_STYLE, start_mark, end_mark); 3547 3575 3548 /* Note that we change the ' simple_key_allowed' flag. */3576 /* Note that we change the 'is_simple_key_allowed' flag. */ 3549 3577 3550 3578 if (leading_blanks) { 3551 parser-> simple_key_allowed = 1;3579 parser->is_simple_key_allowed = 1; 3552 3580 } 3553 3581
