From 8b13efc26d4a753490427a6db4c874844ea4a5de Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 30 Apr 2014 12:43:14 +0900 Subject: count skipped line numbers --- src/parse.y | 9 ++++++++- test/t/syntax.rb | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/parse.y b/src/parse.y index b0e324202..230d7659e 100644 --- a/src/parse.y +++ b/src/parse.y @@ -3475,6 +3475,10 @@ skips(parser_state *p, const char *s) for (;;) { c = nextc(p); if (c < 0) return c; + if (c == '\n') { + p->lineno++; + p->column = 0; + } if (c == *s) break; } s++; @@ -3482,7 +3486,10 @@ skips(parser_state *p, const char *s) int len = strlen(s); while (len--) { - nextc(p); + if (nextc(p) == '\n') { + p->lineno++; + p->column = 0; + } } return TRUE; } diff --git a/test/t/syntax.rb b/test/t/syntax.rb index a64000534..e105cd3d4 100644 --- a/test/t/syntax.rb +++ b/test/t/syntax.rb @@ -307,8 +307,9 @@ this is a comment that has =end with spaces after it =begin this is a comment this is a comment that has extra after =begin and =end with spaces after it =end + line = __LINE__ =begin this is a comment this is a comment that has extra after =begin and =end with tabs after it =end xxxxxxxxxxxxxxxxxxxxxxxxxx - true + assert_equal(line + 4, __LINE__) end -- cgit v1.2.3