shithub: libmujs

Download patch

ref: e928c1410c38c4befb60f103c4246323f2a59e02
parent: 42683b9b4ac2701a296a472ff73783f34f746dc8
author: Tor Andersson <tor.andersson@artifex.com>
date: Sat Dec 28 07:55:44 EST 2013

Set newline flag if a token is preceded by a line terminator.

--- a/js-lex.c
+++ b/js-lex.c
@@ -346,6 +346,8 @@
 
 static int lex(js_State *J, const char **sp)
 {
+	J->newline = 0;
+
 	while (1) {
 		int c = GET();
 
@@ -357,7 +359,8 @@
 			if (c == '\r' && PEEK() == '\n')
 				NEXT();
 			J->yyline++;
-			return TK_NEWLINE;
+			J->newline = 1;
+			continue;
 		}
 
 		if (c == '/') {
--- a/js-parse.h
+++ b/js-parse.h
@@ -3,7 +3,7 @@
 
 enum {
 	TK_ERROR = 257,
-	TK_NEWLINE,
+
 	TK_IDENTIFIER,
 	TK_NUMBER,
 	TK_STRING,
--- a/js.h
+++ b/js.h
@@ -35,6 +35,7 @@
 	struct { int g, i, m; } yyflags;
 	int yyline;
 	int lasttoken;
+	int newline;
 	int strict;
 };