Changeset 114090 in webkit


Ignore:
Timestamp:
Apr 12, 2012 11:33:14 PM (12 years ago)
Author:
tkent@chromium.org
Message:

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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r114088 r114090  
     12012-04-12  Kent Tamura  <tkent@chromium.org>
     2
     3        Calendar Picker: remove unnecessary code from calendarPicker.{css,js}
     4        https://bugs.webkit.org/show_bug.cgi?id=83685
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Remove the followings from input files:
     9         - multi line comments /*...*/ (.js and .css)
     10         - single line comment //... (.js)
     11         - repeating whitespace (.js and .css)
     12         - leading and trailing whitespace (.js and .css)
     13         - empty lines (.js and .css)
     14
     15        This doesn't work for arbitrary JavaScript or CSS inputs, but
     16        works well for expected input files like
     17        css/make-css-file-arrays.pl
     18
     19        * make-file-arrays.py:
     20        (strip_whitespace_and_comments):
     21        (main):
     22
    1232012-04-12  Sailesh Agrawal  <sail@chromium.org>
    224
  • trunk/Source/WebCore/make-file-arrays.py

    r113838 r114090  
    4848
    4949
     50def strip_whitespace_and_comments(file_name, content):
     51    result = re.match(r".*\.([^.]+)", file_name)
     52    if not result:
     53        print "The file name has no extension:", file_name
     54        sys.exit(1)
     55    extension = result.group(1).lower()
     56    multi_line_comment = re.compile(r"/\*.*?\*/", re.MULTILINE | re.DOTALL)
     57    single_line_comment = re.compile(r"//.*$", re.MULTILINE)
     58    repeating_space = re.compile(r"[ \t]+", re.MULTILINE)
     59    leading_space = re.compile(r"^[ \t]+", re.MULTILINE)
     60    trailing_space = re.compile(r"[ \t]+$", re.MULTILINE)
     61    empty_line = re.compile(r"\n+")
     62    if extension == "js":
     63        content = multi_line_comment.sub("", content)
     64        content = single_line_comment.sub("", content)
     65        content = repeating_space.sub(" ", content)
     66        content = leading_space.sub("", content)
     67        content = trailing_space.sub("", content)
     68        content = empty_line.sub("\n", content)
     69    elif extension == "css":
     70        content = multi_line_comment.sub("", content)
     71        content = repeating_space.sub(" ", content)
     72        content = leading_space.sub("", content)
     73        content = trailing_space.sub("", content)
     74        content = empty_line.sub("\n", content)
     75    return content
     76
     77
    5078def main():
    5179    parser = OptionParser()
     
    75103    for file_name in args:
    76104        (variable_name, content) = make_variable_name_and_read(file_name)
     105        content = strip_whitespace_and_comments(file_name, content)
    77106        size = len(content)
    78107        header_file.write("extern const char %s[%d];\n" % (variable_name, size))
Note: See TracChangeset for help on using the changeset viewer.