From c79a7b5055f00c652bc093356396def3bd2de543 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Tue, 5 Oct 2010 00:23:04 -0400 Subject: [PATCH] removing dollar-prefixed local vars (let's keep 'em for globals only) --- lib/lexer.js | 4 ++-- src/lexer.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index 5d23d077..027d3e33 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -569,8 +569,8 @@ return str.replace(MULTILINER, heredoc ? '\\n' : ''); }; Lexer.prototype.makeString = function(body, quote, heredoc) { - body = body.replace(/\\([\s\S])/g, function($amp, $1) { - return ('\n' === $1 || quote === $1) ? $1 : $amp; + body = body.replace(/\\([\s\S])/g, function(match, contents) { + return ('\n' === contents || quote === contents) ? contents : match; }); body = body.replace(RegExp("" + quote, "g"), '\\$&'); return quote + this.escapeLines(body, heredoc) + quote; diff --git a/src/lexer.coffee b/src/lexer.coffee index c7cf730b..4f411cb5 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -490,8 +490,8 @@ exports.Lexer = class Lexer # Constructs a string token by escaping quotes and newlines. makeString: (body, quote, heredoc) -> - body = body.replace /\\([\s\S])/g, ($amp, $1) -> - if $1 in ['\n', quote] then $1 else $amp + body = body.replace /\\([\s\S])/g, (match, contents) -> + if contents in ['\n', quote] then contents else match body = body.replace /// #{quote} ///g, '\\$&' quote + @escapeLines(body, heredoc) + quote