Changeset 216
- Timestamp:
- 07/30/06 08:49:17 (7 years ago)
- Location:
- libyaml/trunk
- Files:
-
- 4 edited
-
src/api.c (modified) (2 diffs)
-
src/emitter.c (modified) (15 diffs)
-
src/parser.c (modified) (1 diff)
-
tests/Makefile.am (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libyaml/trunk/src/api.c
r215 r216 392 392 yaml_event_delete(&DEQUEUE(emitter, emitter->events)); 393 393 } 394 QUEUE_DEL(emitter, emitter->events); 394 395 STACK_DEL(emitter, emitter->indents); 395 396 while (!STACK_EMPTY(empty, emitter->tag_directives)) { … … 745 746 746 747 DOCUMENT_START_EVENT_INIT(*event, version_directive_copy, 747 tag_directives_copy.start, tag_directives_copy. end,748 tag_directives_copy.start, tag_directives_copy.top, 748 749 implicit, mark, mark); 749 750 -
libyaml/trunk/src/emitter.c
r215 r216 291 291 if (!yaml_emitter_state_machine(emitter, emitter->events.head)) 292 292 return 0; 293 DEQUEUE(emitter, emitter->events);293 yaml_event_delete(&DEQUEUE(emitter, emitter->events)); 294 294 } 295 295 … … 688 688 emitter->state = YAML_EMIT_DOCUMENT_START_STATE; 689 689 690 while (!STACK_EMPTY(emitter, emitter->tag_directives)) { 691 yaml_tag_directive_t tag_directive = POP(emitter, 692 emitter->tag_directives); 693 yaml_free(tag_directive.handle); 694 yaml_free(tag_directive.prefix); 695 } 696 690 697 return 1; 691 698 } … … 696 703 697 704 /* 705 * 698 706 * Expect a flow item node. 699 707 */ … … 729 737 } 730 738 739 if (!first) { 740 if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0)) 741 return 0; 742 } 743 731 744 if (emitter->canonical || emitter->column > emitter->best_width) { 732 745 if (!yaml_emitter_write_indent(emitter)) 733 746 return 0; 734 747 } 735 if ( PUSH(emitter, emitter->states, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE))748 if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE)) 736 749 return 0; 737 750 … … 1179 1192 if (style == YAML_LITERAL_SCALAR_STYLE || style == YAML_FOLDED_SCALAR_STYLE) 1180 1193 { 1181 if (!emitter->scalar_data.block_allowed) 1194 if (!emitter->scalar_data.block_allowed 1195 || emitter->flow_level || emitter->simple_key_context) 1182 1196 style = YAML_DOUBLE_QUOTED_SCALAR_STYLE; 1183 1197 } … … 1341 1355 handle.pointer ++; 1342 1356 1343 while (handle.pointer !=handle.end-1) {1357 while (handle.pointer < handle.end-1) { 1344 1358 if (!IS_ALPHA(handle)) { 1345 1359 return yaml_emitter_set_emitter_error(emitter, … … 1381 1395 MOVE(string); 1382 1396 } 1397 1398 emitter->anchor_data.anchor = string.start; 1399 emitter->anchor_data.anchor_length = string.end - string.start; 1400 emitter->anchor_data.alias = alias; 1401 1402 return 1; 1383 1403 } 1384 1404 … … 1400 1420 1401 1421 for (tag_directive = emitter->tag_directives.start; 1402 tag_directive != emitter->tag_directives. end; tag_directive ++) {1422 tag_directive != emitter->tag_directives.top; tag_directive ++) { 1403 1423 size_t prefix_length = strlen((char *)tag_directive->prefix); 1404 1424 if (prefix_length < (string.end - string.start) … … 1587 1607 } 1588 1608 1609 if ((spaces || breaks) && string.pointer == string.end-1) 1610 { 1611 if (spaces && breaks) { 1612 mixed_breaks_spaces = 1; 1613 } 1614 else if (spaces) { 1615 if (leading) { 1616 leading_spaces = 1; 1617 } 1618 trailing_spaces = 1; 1619 } 1620 else if (breaks) { 1621 if (leading) { 1622 leading_breaks = 1; 1623 } 1624 trailing_breaks = 1; 1625 } 1626 } 1627 1589 1628 preceeded_by_space = IS_BLANKZ(string); 1590 1629 MOVE(string); … … 1840 1879 value = *(string.pointer++); 1841 1880 if (!PUT(emitter, '%')) return 0; 1842 if (!PUT(emitter, (value >> 8)1843 + ((value >> 8) < 10 ? '0' : 'A' - 10)))1881 if (!PUT(emitter, (value >> 4) 1882 + ((value >> 4) < 10 ? '0' : 'A' - 10))) 1844 1883 return 0; 1845 1884 if (!PUT(emitter, (value & 0x0F) … … 2084 2123 width = 8; 2085 2124 } 2086 for (k = width*4; k >= 0; k -= 4) { 2087 if (!PUT(emitter, (value >> k) & 0x0F)) return 0; 2125 for (k = (width-1)*4; k >= 0; k -= 4) { 2126 int digit = (value >> k) & 0x0F; 2127 if (!PUT(emitter, digit + (digit < 10 ? '0' : 'A'-10))) 2128 return 0; 2088 2129 } 2089 2130 } … … 2130 2171 if (string.start == string.pointer) 2131 2172 return -1; 2132 while ((string.pointer[-1] & 0xC0) == 0x80){2173 do { 2133 2174 string.pointer --; 2134 } 2175 } while ((*string.pointer & 0xC0) == 0x80); 2135 2176 if (!IS_BREAK(string)) 2136 2177 return -1; 2137 2178 if (string.start == string.pointer) 2138 2179 return 0; 2139 while ((string.pointer[-1] & 0xC0) == 0x80){2180 do { 2140 2181 string.pointer --; 2141 } 2182 } while ((*string.pointer & 0xC0) == 0x80); 2142 2183 if (!IS_BREAK(string)) 2143 2184 return 0; … … 2179 2220 } 2180 2221 2181 if (!yaml_emitter_write_indent(emitter)) return 0;2182 2183 2222 return 1; 2184 2223 } … … 2190 2229 yaml_string_t string = STRING(value, length); 2191 2230 int chomp = yaml_emitter_determine_chomping(emitter, string); 2192 int breaks = 0;2193 int leading_spaces = 1;2231 int breaks = 1; 2232 int leading_spaces = 0; 2194 2233 2195 2234 if (!yaml_emitter_write_indicator(emitter, … … 2235 2274 } 2236 2275 2237 if (!yaml_emitter_write_indent(emitter)) return 0; 2238 2239 return 1; 2240 } 2241 2276 return 1; 2277 } 2278 -
libyaml/trunk/src/parser.c
r213 r216 1253 1253 } 1254 1254 if (token->data.version_directive.major != 1 1255 &&token->data.version_directive.minor != 1) {1255 || token->data.version_directive.minor != 1) { 1256 1256 yaml_parser_set_parser_error(parser, 1257 1257 "found incompatible YAML document", token->start_mark); -
libyaml/trunk/tests/Makefile.am
r208 r216 2 2 LDADD = $(top_builddir)/src/libyaml.la 3 3 TESTS = test-version test-reader 4 check_PROGRAMS = test-version test-reader run-scanner run-parser 4 check_PROGRAMS = test-version test-reader run-scanner run-parser run-emitter
Note: See TracChangeset
for help on using the changeset viewer.
