Provide better escape for // comments in minifier. Closes #6
In weinre.build/scripts/build-target-scripts.py, we minify the
resulting target-script.js file to target-script-min.js.
Unfortunately, it was treating a regexp as a // comment.
Fixed it for now by changing the regex to use a lookahead
assumption.
diff --git a/weinre.build/scripts/build-target-scripts.py b/weinre.build/scripts/build-target-scripts.py
index 9fe8ed3..d206ef9 100644
--- a/weinre.build/scripts/build-target-scripts.py
+++ b/weinre.build/scripts/build-target-scripts.py
@@ -109,10 +109,10 @@
#
#--------------------------------------------------------------------
def min(script):
- patternCommentC = re.compile(r"\/\*.*?\*\/", re.MULTILINE + re.DOTALL)
- patternCommentCPP = re.compile(r"\/\/.*?$", re.MULTILINE)
- patternIndent = re.compile(r"^\s*", re.MULTILINE)
- patternBlankLine = re.compile(r"^\s*\n", re.MULTILINE)
+ patternCommentC = re.compile(r"/\*.*?\*/", re.MULTILINE + re.DOTALL)
+ patternCommentCPP = re.compile(r"(?<!\\)//.*?$", re.MULTILINE)
+ patternIndent = re.compile(r"^\s*", re.MULTILINE)
+ patternBlankLine = re.compile(r"^\s*\n", re.MULTILINE)
script = patternCommentC.sub( "", script)
script = patternCommentCPP.sub( "", script)