+2012-04-12 Kent Tamura <tkent@chromium.org>
+
+ Calendar Picker: remove unnecessary code from calendarPicker.{css,js}
+ https://bugs.webkit.org/show_bug.cgi?id=83685
+
+ Reviewed by Kentaro Hara.
+
+ Remove the followings from input files:
+ - multi line comments /*...*/ (.js and .css)
+ - single line comment //... (.js)
+ - repeating whitespace (.js and .css)
+ - leading and trailing whitespace (.js and .css)
+ - empty lines (.js and .css)
+
+ This doesn't work for arbitrary JavaScript or CSS inputs, but
+ works well for expected input files like
+ css/make-css-file-arrays.pl
+
+ * make-file-arrays.py:
+ (strip_whitespace_and_comments):
+ (main):
+
2012-04-12 Sailesh Agrawal <sail@chromium.org>
Chromium: Fix scrollbar tickmark drawing on Mountain Lion
return (variable_name, content)
+def strip_whitespace_and_comments(file_name, content):
+ result = re.match(r".*\.([^.]+)", file_name)
+ if not result:
+ print "The file name has no extension:", file_name
+ sys.exit(1)
+ extension = result.group(1).lower()
+ multi_line_comment = re.compile(r"/\*.*?\*/", re.MULTILINE | re.DOTALL)
+ single_line_comment = re.compile(r"//.*$", re.MULTILINE)
+ repeating_space = re.compile(r"[ \t]+", re.MULTILINE)
+ leading_space = re.compile(r"^[ \t]+", re.MULTILINE)
+ trailing_space = re.compile(r"[ \t]+$", re.MULTILINE)
+ empty_line = re.compile(r"\n+")
+ if extension == "js":
+ content = multi_line_comment.sub("", content)
+ content = single_line_comment.sub("", content)
+ content = repeating_space.sub(" ", content)
+ content = leading_space.sub("", content)
+ content = trailing_space.sub("", content)
+ content = empty_line.sub("\n", content)
+ elif extension == "css":
+ content = multi_line_comment.sub("", content)
+ content = repeating_space.sub(" ", content)
+ content = leading_space.sub("", content)
+ content = trailing_space.sub("", content)
+ content = empty_line.sub("\n", content)
+ return content
+
+
def main():
parser = OptionParser()
parser.add_option("--out-h", dest="out_header")
for file_name in args:
(variable_name, content) = make_variable_name_and_read(file_name)
+ content = strip_whitespace_and_comments(file_name, content)
size = len(content)
header_file.write("extern const char %s[%d];\n" % (variable_name, size))
cpp_file.write("const char %s[%d] = {\n" % (variable_name, size))