From d6814050dd42298abb02e3fee2856174e02f01fa Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Thu, 14 May 2015 12:03:54 -0700 Subject: [PATCH 1/7] Give a good error message if an invalid regular expression is found. --- lib/parse.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/parse.js b/lib/parse.js index e65c4faa..70ee2e80 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -480,7 +480,13 @@ function tokenizer($TEXT, filename, html5_comments) { regexp += ch; } var mods = read_name(); - return token("regexp", new RegExp(regexp, mods)); + var r; + try { + r = new RegExp(regexp, mods); + } catch(e) { + parse_error("Invalid regular expression"); + } + return token("regexp", r); }); function read_operator(prefix) { From 9854deb626874f06107db196b87afcf2dc49b035 Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Thu, 14 May 2015 12:27:56 -0700 Subject: [PATCH 2/7] Re-use the caught exception's error message in the parse error call. --- lib/parse.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/parse.js b/lib/parse.js index 70ee2e80..ab72ad2d 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -480,13 +480,11 @@ function tokenizer($TEXT, filename, html5_comments) { regexp += ch; } var mods = read_name(); - var r; try { - r = new RegExp(regexp, mods); + return token("regexp", new RegExp(regexp, mods)); } catch(e) { - parse_error("Invalid regular expression"); + parse_error(e.message); } - return token("regexp", r); }); function read_operator(prefix) { From 881bda7f59cd62f1123fafa2da817b8dc618c19f Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 14 Apr 2015 23:17:41 +0300 Subject: [PATCH 3/7] Make node.js 0.8 the minimum supported version. Node.js 0.4 and 0.6 are ancient; things don't work there. Update Travis CI configuration accordingly. Note, that the npm update in Travis is needed for 0.8 only at the moment. --- .travis.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e046b8f..c33b24d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ before_install: "npm install -g npm" node_js: - "iojs" - "0.12" - - "0.11" - "0.10" + - "0.8" matrix: fast_finish: true sudo: false diff --git a/package.json b/package.json index 88bcc646..0bf1de09 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "license": "BSD", "version": "2.4.24", "engines": { - "node": ">=0.4.0" + "node": ">=0.8.0" }, "maintainers": [ "Mihai Bazon (http://lisperator.net/)" From f8684f418a1801927fcdf9a205817fe07ff89720 Mon Sep 17 00:00:00 2001 From: Richard van Velzen Date: Wed, 29 Jul 2015 15:24:45 +0200 Subject: [PATCH 4/7] Replace util.puts in run-tests with console.log See d2dda34b2a8de310f26a26e58ed28275ba5ecc7f --- test/run-tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/run-tests.js b/test/run-tests.js index 215f6af8..d97e5cf1 100755 --- a/test/run-tests.js +++ b/test/run-tests.js @@ -31,7 +31,7 @@ function tmpl() { function log() { var txt = tmpl.apply(this, arguments); - sys.puts(txt); + console.log("%s", txt); } function log_directory(dir) { From 170e8b519e64463a39d293480e52f97b64d8ab89 Mon Sep 17 00:00:00 2001 From: Richard van Velzen Date: Wed, 29 Jul 2015 17:57:18 +0200 Subject: [PATCH 5/7] Fix semicolon printing when restricting max line length Fixes #755 --- lib/output.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/output.js b/lib/output.js index 1d67b1b9..44d5df6e 100644 --- a/lib/output.js +++ b/lib/output.js @@ -161,6 +161,8 @@ function OutputStream(options) { str = String(str); var ch = str.charAt(0); if (might_need_semicolon) { + might_need_semicolon = false; + if ((!ch || ";}".indexOf(ch) < 0) && !/[;]$/.test(last)) { if (options.semicolons || requireSemicolonChars(ch)) { OUTPUT += ";"; @@ -171,11 +173,14 @@ function OutputStream(options) { current_pos++; current_line++; current_col = 0; + + // reset the semicolon flag, since we didn't print one now and + // might still have to later + might_need_semicolon = true; } if (!options.beautify) might_need_space = false; } - might_need_semicolon = false; } if (!options.beautify && options.preserve_line && stack[stack.length - 1]) { From 3afad58a93903257e8e3cb0a7b90ff79212f46bd Mon Sep 17 00:00:00 2001 From: Richard van Velzen Date: Thu, 30 Jul 2015 15:57:18 +0200 Subject: [PATCH 6/7] Revert "Fix semicolon printing when restricting max line length" This reverts commit 170e8b519e64463a39d293480e52f97b64d8ab89. --- lib/output.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/output.js b/lib/output.js index 44d5df6e..1d67b1b9 100644 --- a/lib/output.js +++ b/lib/output.js @@ -161,8 +161,6 @@ function OutputStream(options) { str = String(str); var ch = str.charAt(0); if (might_need_semicolon) { - might_need_semicolon = false; - if ((!ch || ";}".indexOf(ch) < 0) && !/[;]$/.test(last)) { if (options.semicolons || requireSemicolonChars(ch)) { OUTPUT += ";"; @@ -173,14 +171,11 @@ function OutputStream(options) { current_pos++; current_line++; current_col = 0; - - // reset the semicolon flag, since we didn't print one now and - // might still have to later - might_need_semicolon = true; } if (!options.beautify) might_need_space = false; } + might_need_semicolon = false; } if (!options.beautify && options.preserve_line && stack[stack.length - 1]) { From 66761d7ecfade3c81c09f9b77afc5b71b3b59f9e Mon Sep 17 00:00:00 2001 From: Richard van Velzen Date: Wed, 29 Jul 2015 17:57:18 +0200 Subject: [PATCH 7/7] Fix semicolon printing when restricting max line length Fixes #755 --- lib/output.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/output.js b/lib/output.js index 1d67b1b9..396c6a29 100644 --- a/lib/output.js +++ b/lib/output.js @@ -161,6 +161,8 @@ function OutputStream(options) { str = String(str); var ch = str.charAt(0); if (might_need_semicolon) { + might_need_semicolon = false; + if ((!ch || ";}".indexOf(ch) < 0) && !/[;]$/.test(last)) { if (options.semicolons || requireSemicolonChars(ch)) { OUTPUT += ";"; @@ -171,11 +173,17 @@ function OutputStream(options) { current_pos++; current_line++; current_col = 0; + + if (/^\s+$/.test(str)) { + // reset the semicolon flag, since we didn't print one + // now and might still have to later + might_need_semicolon = true; + } } + if (!options.beautify) might_need_space = false; } - might_need_semicolon = false; } if (!options.beautify && options.preserve_line && stack[stack.length - 1]) {