From 74f2ad2c0bbe0e4c1d52d54265db2663c18bdb80 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 11 Jan 2014 16:51:48 +0100 Subject: [PATCH] Count lines in block comments as well. --- jslex.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jslex.c b/jslex.c index 46573a5..6a70bec 100644 --- a/jslex.c +++ b/jslex.c @@ -170,10 +170,15 @@ static inline void lexlinecomment(const char **sp) } } -static inline int lexcomment(const char **sp) +static inline int lexcomment(js_State *J, const char **sp) { while (1) { int c = GET(); + if (isnewline(c)) { + if (c == '\r' && PEEK() == '\n') + NEXT(); + J->line++; + } if (c == '*') { while (c == '*') c = GET(); @@ -434,7 +439,7 @@ static int lex(js_State *J, const char **sp) lexlinecomment(sp); continue; } else if (LOOK('*')) { - if (lexcomment(sp)) + if (lexcomment(J, sp)) return jsP_error(J, "multi-line comment not terminated"); continue; } else if (isregexpcontext(J->lasttoken)) {