Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: tools/js2c.py

Issue 215052: * Remove non-Open Source code from Douglas Crockford.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/uri.js ('k') | tools/jsmin.py » ('j') | tools/jsmin.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/js2c.py
===================================================================
--- tools/js2c.py (revision 2941)
+++ tools/js2c.py (working copy)
@@ -52,20 +52,6 @@
return lines
-def CompressScript(lines, do_jsmin):
- # If we're not expecting this code to be user visible, we can run it through
- # a more aggressive minifier.
- if do_jsmin:
- return jsmin.jsmin(lines)
-
- # Remove stuff from the source that we don't want to appear when
- # people print the source code using Function.prototype.toString().
- # Note that we could easily compress the scripts mode but don't
- # since we want it to remain readable.
- lines = RemoveCommentsAndTrailingWhitespace(lines)
- return lines
-
-
def ReadFile(filename):
file = open(filename, "rt")
try:
@@ -295,16 +281,18 @@
# Build source code lines
source_lines = [ ]
+
+ minifier = jsmin.JavaScriptMinifier()
+
source_lines_empty = []
for module in modules:
filename = str(module)
delay = filename.endswith('-delay.js')
lines = ReadFile(filename)
- do_jsmin = lines.find('// jsminify this file, js2c: jsmin') != -1
lines = ExpandConstants(lines, consts)
lines = ExpandMacros(lines, macros)
Validate(lines, filename)
- lines = CompressScript(lines, do_jsmin)
+ lines = minifier.JSMinify(lines)
data = ToCArray(lines)
id = (os.path.split(filename)[1])[:-3]
if delay: id = id[:-6]
« no previous file with comments | « src/uri.js ('k') | tools/jsmin.py » ('j') | tools/jsmin.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698