From f5b2e6b149d13213b7f72df0e2b02d3f86b74ee1 Mon Sep 17 00:00:00 2001 From: why Date: Mon, 19 May 2003 16:37:20 +0000 Subject: [PATCH] * lib/syck.c, lib/syck.h, lib/token.c, lib/gram.c: count line numbers only if line pointer has increased. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 ++ ext/syck/gram.c | 17 ++++--- ext/syck/syck.c | 3 ++ ext/syck/syck.h | 2 +- ext/syck/token.c | 119 ++++++++++++++++++++++++----------------------- 5 files changed, 77 insertions(+), 69 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3b9376155..a4a1cacbcc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon May 19 16:47:00 2003 why the lucky stiff + + * lib/syck.c, lib/syck.h, lib/token.c, lib/gram.c: count line numbers + only if line pointer has increased. + Tue May 20 00:45:40 2003 Yukihiro Matsumoto * dir.c (push_braces): do not push_braces() unless rbrace is found. diff --git a/ext/syck/gram.c b/ext/syck/gram.c index 493991a81d..310e6e129b 100644 --- a/ext/syck/gram.c +++ b/ext/syck/gram.c @@ -319,8 +319,8 @@ static const unsigned short yyrline[] = 83, 84, 102, 103, 106, 109, 112, 113, 121, 126, 134, 147, 154, 159, 160, 161, 162, 163, 169, 173, 180, 186, 190, 195, 204, 208, 214, 218, 228, 233, - 241, 256, 257, 265, 266, 278, 285, 295, 303, 307, - 313, 314 + 241, 256, 257, 265, 266, 278, 285, 294, 302, 306, + 312, 313 }; #endif @@ -1286,13 +1286,12 @@ yyreduce: case 46: #line 286 "gram.y" { - apply_seq_in_map( (SyckParser *)parser, yyvsp[-1].nodeData ); yyval.nodeData = yyvsp[-1].nodeData; } break; case 47: -#line 296 "gram.y" +#line 295 "gram.y" { yyval.nodeData = syck_new_map( syck_hdlr_add_node( (SyckParser *)parser, yyvsp[-2].nodeData ), @@ -1301,21 +1300,21 @@ yyreduce: break; case 48: -#line 304 "gram.y" +#line 303 "gram.y" { yyval.nodeData = yyvsp[-1].nodeData; } break; case 49: -#line 308 "gram.y" +#line 307 "gram.y" { yyval.nodeData = syck_alloc_map(); } break; case 51: -#line 315 "gram.y" +#line 314 "gram.y" { syck_map_update( yyvsp[-2].nodeData, yyvsp[0].nodeData ); syck_free_node( yyvsp[0].nodeData ); @@ -1327,7 +1326,7 @@ yyreduce: } /* Line 1016 of /usr/local/share/bison/yacc.c. */ -#line 1331 "y.tab.c" +#line 1330 "y.tab.c" yyvsp -= yylen; yyssp -= yylen; @@ -1546,7 +1545,7 @@ yyreturn: } -#line 322 "gram.y" +#line 321 "gram.y" void diff --git a/ext/syck/syck.c b/ext/syck/syck.c index 36e95fd80a..89aa804e44 100644 --- a/ext/syck/syck.c +++ b/ext/syck/syck.c @@ -136,6 +136,7 @@ syck_parser_reset_cursor( SyckParser *p ) p->cursor = NULL; p->lineptr = NULL; + p->linectptr = NULL; p->token = NULL; p->toktmp = NULL; p->marker = NULL; @@ -397,6 +398,7 @@ syck_move_tokens( SyckParser *p ) p->toktmp -= count; p->limit -= count; p->lineptr -= count; + p->linectptr -= count; } return skip; } @@ -408,6 +410,7 @@ syck_check_limit( SyckParser *p, long len ) { p->cursor = p->buffer; p->lineptr = p->buffer; + p->linectptr = p->buffer; p->marker = p->buffer; } p->limit = p->buffer + len; diff --git a/ext/syck/syck.h b/ext/syck/syck.h index 7b4f78714e..6bba91bb54 100644 --- a/ext/syck/syck.h +++ b/ext/syck/syck.h @@ -155,7 +155,7 @@ struct _syck_parser { // Custom buffer size size_t bufsize; // Buffer pointers - char *buffer, *lineptr, *toktmp, *token, *cursor, *marker, *limit; + char *buffer, *linectptr, *lineptr, *toktmp, *token, *cursor, *marker, *limit; // Line counter int linect; // Last token from yylex() diff --git a/ext/syck/token.c b/ext/syck/token.c index 8ca144f1bb..16638cc5bc 100644 --- a/ext/syck/token.c +++ b/ext/syck/token.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.5 on Thu May 15 15:42:01 2003 */ +/* Generated by re2c 0.5 on Mon May 19 10:41:31 2003 */ #line 1 "token.re" /* * token.re @@ -26,6 +26,7 @@ #define YYTOKEN parser->token #define YYTOKTMP parser->toktmp #define YYLINEPTR parser->lineptr +#define YYLINECTPTR parser->linectptr #define YYLINE parser->linect #define YYFILL(n) syck_parser_read(parser) @@ -38,7 +39,7 @@ /* * Track line numbers */ -#define NEWLINE(ptr) YYLINE++; YYLINEPTR = ptr + 1 +#define NEWLINE(ptr) YYLINEPTR = ptr + 1; if ( YYLINEPTR > YYLINECTPTR ) { YYLINE++; YYLINECTPTR = YYLINEPTR; } /* * I like seeing the level operations as macros... @@ -189,7 +190,7 @@ yylex( YYSTYPE *yylval, SyckParser *parser ) return t; } -#line 205 +#line 206 if ( YYLINEPTR != YYCURSOR ) @@ -255,19 +256,19 @@ yy2: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if(yych == '-') goto yy15; yy3: -#line 246 +#line 247 { YYPOS(0); goto Document; } yy4: yych = *++YYCURSOR; yy5: -#line 232 +#line 233 { eat_comments( parser ); goto Header; } yy6: yych = *++YYCURSOR; yy7: -#line 236 +#line 237 { SyckLevel *lvl = CURRENT_LEVEL(); ENSURE_IEND(lvl, -1); return 0; @@ -275,7 +276,7 @@ yy7: yy8: yych = *++YYCURSOR; goto yy12; yy9: -#line 241 +#line 242 { int indt_len; GOBBLE_UP_INDENT( indt_len, YYTOKEN ); goto Header; @@ -307,7 +308,7 @@ yy18: ++YYCURSOR; yych = *YYCURSOR; yy19: if(yybm[0+yych] & 128) goto yy18; yy20: -#line 218 +#line 219 { SyckLevel *lvl = CURRENT_LEVEL(); if ( lvl->status == syck_lvl_header ) { @@ -327,7 +328,7 @@ yy21: ++YYCURSOR; yy22: if(yych == '\n') goto yy21; goto yy20; } -#line 250 +#line 251 Document: @@ -433,7 +434,7 @@ yy23: yy25: yych = *++YYCURSOR; goto yy77; yy26: -#line 264 +#line 265 { // Isolate spaces int indt_len; GOBBLE_UP_INDENT( indt_len, YYTOKEN ); @@ -450,7 +451,7 @@ yy26: } yy27: yych = *++YYCURSOR; yy28: -#line 279 +#line 280 { ENSURE_IOPEN(lvl, 0, 1); lvl = CURRENT_LEVEL(); ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline); @@ -458,7 +459,7 @@ yy28: } yy29: yych = *++YYCURSOR; yy30: -#line 285 +#line 286 { POP_LEVEL(); return YYTOKEN[0]; } @@ -466,7 +467,7 @@ yy31: yych = *++YYCURSOR; if(yych == '\n') goto yy74; if(yych == ' ') goto yy71; yy32: -#line 334 +#line 335 { ENSURE_IOPEN(lvl, 0, 1); goto Plain; } @@ -484,15 +485,15 @@ yy35: yych = *++YYCURSOR; goto yy32; yy36: yych = *++YYCURSOR; yy37: -#line 311 +#line 312 { goto TransferMethod; } yy38: yych = *++YYCURSOR; yy39: -#line 313 +#line 314 { goto SingleQuote; } yy40: yych = *++YYCURSOR; yy41: -#line 315 +#line 316 { goto DoubleQuote; } yy42: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); @@ -513,18 +514,18 @@ yy42: yyaccept = 0; } yy43: yych = *++YYCURSOR; yy44: -#line 324 +#line 325 { eat_comments( parser ); goto Document; } yy45: yych = *++YYCURSOR; goto yy51; yy46: -#line 328 +#line 329 { goto Document; } yy47: yych = *++YYCURSOR; yy48: -#line 330 +#line 331 { ENSURE_IEND(lvl, -1); return 0; } @@ -559,7 +560,7 @@ yy55: ++YYCURSOR; yych = *YYCURSOR; yy56: if(yych == ' ') goto yy55; yy57: -#line 317 +#line 318 { if ( *( YYCURSOR - 1 ) == '\n' ) { YYCURSOR--; @@ -576,7 +577,7 @@ yy60: ++YYCURSOR; yych = *YYCURSOR; yy61: if(yybm[0+yych] & 64) goto yy60; yy62: -#line 307 +#line 308 { yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); return ALIAS; } @@ -587,7 +588,7 @@ yy64: if(yych <= '-') goto yy65; if(yych == '`') goto yy65; if(yych <= 'z') goto yy63; yy65: -#line 303 +#line 304 { yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); return ANCHOR; } @@ -596,7 +597,7 @@ yy66: ++YYCURSOR; yych = *YYCURSOR; yy67: if(yych == ' ') goto yy66; yy68: -#line 293 +#line 294 { ENSURE_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1); FORCE_NEXT_TOKEN(IOPEN); if ( *( YYCURSOR - 1 ) == '\n' ) @@ -616,7 +617,7 @@ yy71: ++YYCURSOR; yych = *YYCURSOR; yy72: if(yych == ' ') goto yy71; yy73: -#line 289 +#line 290 { YYPOS(1); return YYTOKEN[0]; } @@ -636,7 +637,7 @@ yy78: ++YYCURSOR; yy79: if(yybm[0+yych] & 128) goto yy78; goto yy26; } -#line 338 +#line 339 } @@ -704,14 +705,14 @@ yy83: yyaccept = 0; if(yych == '`') goto yy84; if(yych <= 'z') goto yy90; yy84: -#line 351 +#line 352 { YYCURSOR = YYTOKTMP; return DOCSEP; } yy85: yych = *++YYCURSOR; goto yy89; yy86: -#line 349 +#line 350 { goto Directive; } yy87: yych = *++YYCURSOR; goto yy84; @@ -733,10 +734,10 @@ yy93: ++YYCURSOR; yych = *YYCURSOR; yy94: if(yybm[0+yych] & 128) goto yy93; yy95: -#line 347 +#line 348 { goto Directive; } } -#line 354 +#line 355 } @@ -819,7 +820,7 @@ yy96: yy98: yych = *++YYCURSOR; goto yy122; yy99: -#line 374 +#line 375 { int indt_len; SyckLevel *lvl; char *tok = YYTOKTMP; @@ -838,11 +839,11 @@ yy100: yych = *++YYCURSOR; if(yych == '\n') goto yy119; if(yych == ' ') goto yy116; yy101: -#line 403 +#line 404 { goto Plain2; } yy102: yych = *++YYCURSOR; yy103: -#line 391 +#line 392 { if ( plvl->status != syck_lvl_inline ) goto Plain2; RETURN_IMPLICIT(multiLine); } @@ -852,18 +853,18 @@ yy104: yych = *++YYCURSOR; goto yy101; yy105: yych = *++YYCURSOR; yy106: -#line 395 +#line 396 { RETURN_IMPLICIT(multiLine); } yy107: yych = *++YYCURSOR; if(yych == '#') goto yy110; yy108: -#line 401 +#line 402 { goto Plain3; } yy109: yych = *++YYCURSOR; goto yy101; yy110: yych = *++YYCURSOR; yy111: -#line 397 +#line 398 { eat_comments( parser ); RETURN_IMPLICIT(multiLine); } @@ -882,7 +883,7 @@ yy116: ++YYCURSOR; yych = *YYCURSOR; yy117: if(yych == ' ') goto yy116; yy118: -#line 389 +#line 390 { RETURN_IMPLICIT(multiLine); } yy119: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -900,7 +901,7 @@ yy123: ++YYCURSOR; yy124: if(yybm[0+yych] & 128) goto yy123; goto yy99; } -#line 405 +#line 406 } @@ -965,7 +966,7 @@ yy125: yy127: yych = *++YYCURSOR; goto yy137; yy128: -#line 419 +#line 420 { int indt_len; int nl_count = 0; SyckLevel *lvl; @@ -1004,7 +1005,7 @@ yy128: yy129: yych = *++YYCURSOR; if(yych == '\'') goto yy134; yy130: -#line 459 +#line 460 { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); @@ -1022,13 +1023,13 @@ yy131: yych = *++YYCURSOR; goto yy130; yy132: yych = *++YYCURSOR; yy133: -#line 473 +#line 474 { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto SingleQuote2; } yy134: yych = *++YYCURSOR; yy135: -#line 455 +#line 456 { QUOTECAT(qstr, qcapa, qidx, '\''); goto SingleQuote2; } @@ -1043,7 +1044,7 @@ yy138: ++YYCURSOR; yy139: if(yybm[0+yych] & 128) goto yy138; goto yy128; } -#line 477 +#line 478 } @@ -1113,7 +1114,7 @@ yy140: yy142: yych = *++YYCURSOR; goto yy158; yy143: -#line 495 +#line 496 { int indt_len; int nl_count = 0; SyckLevel *lvl; @@ -1185,13 +1186,13 @@ yy144: yyaccept = 0; } } yy145: -#line 570 +#line 571 { QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1)); goto DoubleQuote2; } yy146: yych = *++YYCURSOR; yy147: -#line 556 +#line 557 { SyckLevel *lvl; SyckNode *n = syck_alloc_str(); lvl = CURRENT_LEVEL(); @@ -1220,14 +1221,14 @@ yy152: YYCURSOR = YYMARKER; } yy153: yych = *++YYCURSOR; yy154: -#line 551 +#line 552 { keep_nl = 0; YYCURSOR--; goto DoubleQuote2; } yy155: yych = *++YYCURSOR; yy156: -#line 535 +#line 536 { char ch = *( YYCURSOR - 1 ); switch ( ch ) { @@ -1254,7 +1255,7 @@ yy159: ++YYCURSOR; yy160: if(yybm[0+yych] & 128) goto yy159; goto yy143; } -#line 574 +#line 575 } @@ -1315,7 +1316,7 @@ yy161: yy163:yy164: yych = *++YYCURSOR; goto yy172; yy165: -#line 583 +#line 584 { SyckLevel *lvl; YYCURSOR = YYTOKTMP; if ( YYCURSOR == YYTOKEN + 1 ) @@ -1365,7 +1366,7 @@ yy166: yych = *++YYCURSOR; goto yy170; yy167: yych = *++YYCURSOR; yy168: -#line 629 +#line 630 { goto TransferMethod; } yy169: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -1378,7 +1379,7 @@ yy171: ++YYCURSOR; yy172: if(yybm[0+yych] & 128) goto yy171; goto yy165; } -#line 631 +#line 632 } @@ -1471,7 +1472,7 @@ yy173: yy175: yych = *++YYCURSOR; goto yy184; yy176: -#line 673 +#line 674 { int indt_len; GOBBLE_UP_INDENT( indt_len, YYTOKTMP ); lvl = CURRENT_LEVEL(); @@ -1504,7 +1505,7 @@ yy176: } yy177: yych = *++YYCURSOR; yy178: -#line 705 +#line 706 { lvl = CURRENT_LEVEL(); YYCURSOR--; yylval->nodeData = syck_new_str2( YYTOKEN, YYCURSOR - YYTOKEN ); @@ -1514,7 +1515,7 @@ yy178: } yy179: yych = *++YYCURSOR; yy180: -#line 713 +#line 714 { lvl = CURRENT_LEVEL(); if ( lvl->status != syck_lvl_block ) { @@ -1525,7 +1526,7 @@ yy180: } yy181: yych = *++YYCURSOR; yy182: -#line 722 +#line 723 { goto ScalarBlock2; } yy183: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -1538,7 +1539,7 @@ yy185: ++YYCURSOR; yy186: if(yybm[0+yych] & 128) goto yy185; goto yy176; } -#line 724 +#line 725 } @@ -1600,7 +1601,7 @@ yy187: goto yy192; yy189: yych = *++YYCURSOR; yy190: -#line 740 +#line 741 { SyckLevel *lvl = CURRENT_LEVEL(); YYCURSOR = tok; return; @@ -1609,7 +1610,7 @@ yy191: yych = *++YYCURSOR; goto yy195; yy192: yych = *++YYCURSOR; yy193: -#line 745 +#line 746 { goto Comment; } yy194: ++YYCURSOR; @@ -1618,7 +1619,7 @@ yy194: ++YYCURSOR; yy195: if(yybm[0+yych] & 128) goto yy194; goto yy190; } -#line 748 +#line 749 }