<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[168597] releases/WebKitGTK/webkit-2.4/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/168597">168597</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-05-11 00:47:10 -0700 (Sun, 11 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/168523">r168523</a> - jsmin.py license header confusing, mentions non-free license
https://bugs.webkit.org/show_bug.cgi?id=123665

Reviewed by Darin Adler.

Pull the most recent version from upstream, which has a clear
license.

Source/JavaScriptCore:
* inspector/scripts/jsmin.py:

Source/WebInspectorUI:
* Scripts/jsmin.py:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit24SourceJavaScriptCoreChangeLog">releases/WebKitGTK/webkit-2.4/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceJavaScriptCoreinspectorscriptsjsminpy">releases/WebKitGTK/webkit-2.4/Source/JavaScriptCore/inspector/scripts/jsmin.py</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebInspectorUIChangeLog">releases/WebKitGTK/webkit-2.4/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit24SourceWebInspectorUIScriptsjsminpy">releases/WebKitGTK/webkit-2.4/Source/WebInspectorUI/Scripts/jsmin.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit24SourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/JavaScriptCore/ChangeLog (168596 => 168597)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/JavaScriptCore/ChangeLog        2014-05-11 07:01:15 UTC (rev 168596)
+++ releases/WebKitGTK/webkit-2.4/Source/JavaScriptCore/ChangeLog        2014-05-11 07:47:10 UTC (rev 168597)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-05-09  Alberto Garcia  &lt;berto@igalia.com&gt;
+
+        jsmin.py license header confusing, mentions non-free license
+        https://bugs.webkit.org/show_bug.cgi?id=123665
+
+        Reviewed by Darin Adler.
+
+        Pull the most recent version from upstream, which has a clear
+        license.
+
+        * inspector/scripts/jsmin.py:
+
</ins><span class="cx"> 2014-04-19  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make it easier to check if an integer sum would overflow
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceJavaScriptCoreinspectorscriptsjsminpy"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/JavaScriptCore/inspector/scripts/jsmin.py (168596 => 168597)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/JavaScriptCore/inspector/scripts/jsmin.py        2014-05-11 07:01:15 UTC (rev 168596)
+++ releases/WebKitGTK/webkit-2.4/Source/JavaScriptCore/inspector/scripts/jsmin.py        2014-05-11 07:47:10 UTC (rev 168597)
</span><span class="lines">@@ -1,222 +1,238 @@
</span><del>-#!/usr/bin/python
-
</del><span class="cx"> # This code is original from jsmin by Douglas Crockford, it was translated to
</span><del>-# Python by Baruch Even. The original code had the following copyright and
-# license.
</del><ins>+# Python by Baruch Even. It was rewritten by Dave St.Germain for speed.
</ins><span class="cx"> #
</span><del>-# /* jsmin.c
-#    2007-05-22
</del><ins>+# The MIT License (MIT)
</ins><span class="cx"> #
</span><del>-# Copyright (c) 2002 Douglas Crockford  (www.crockford.com)
</del><ins>+# Copyright (c) 2013 Dave St.Germain
</ins><span class="cx"> #
</span><del>-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the &quot;Software&quot;), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-# of the Software, and to permit persons to whom the Software is furnished to do
-# so, subject to the following conditions:
</del><ins>+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the &quot;Software&quot;), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
</ins><span class="cx"> #
</span><del>-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
</del><ins>+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
</ins><span class="cx"> #
</span><del>-# The Software shall be used for Good, not Evil.
-#
</del><span class="cx"> # THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
</span><span class="cx"> # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
</span><span class="cx"> # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</span><span class="cx"> # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
</span><span class="cx"> # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
</span><del>-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-# */
</del><ins>+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
</ins><span class="cx"> 
</span><del>-# Import StringIO from either the StringIO module (Python 2.x) or the io module (Python 3.x).
-try:
-    from StringIO import StringIO
-except ImportError:
-    from io import StringIO
</del><span class="cx"> 
</span><del>-def jsmin(js):
-    ins = StringIO(js)
-    outs = StringIO()
-    JavascriptMinify().minify(ins, outs)
-    str = outs.getvalue()
-    if len(str) &gt; 0 and str[0] == '\n':
-        str = str[1:]
-    return str
</del><ins>+import sys
+is_3 = sys.version_info &gt;= (3, 0)
+if is_3:
+    import io
+else:
+    import StringIO
+    try:
+        import cStringIO
+    except ImportError:
+        cStringIO = None
</ins><span class="cx"> 
</span><del>-def isAlphanum(c):
-    &quot;&quot;&quot;return true if the character is a letter, digit, underscore,
-           dollar sign, or non-ASCII character.
-    &quot;&quot;&quot;
-    return ((c &gt;= 'a' and c &lt;= 'z') or (c &gt;= '0' and c &lt;= '9') or
-            (c &gt;= 'A' and c &lt;= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) &gt; 126));
</del><span class="cx"> 
</span><del>-class UnterminatedComment(Exception):
-    pass
</del><ins>+__all__ = ['jsmin', 'JavascriptMinify']
+__version__ = '2.0.9'
</ins><span class="cx"> 
</span><del>-class UnterminatedStringLiteral(Exception):
-    pass
</del><span class="cx"> 
</span><del>-class UnterminatedRegularExpression(Exception):
-    pass
</del><ins>+def jsmin(js):
+    &quot;&quot;&quot;
+    returns a minified version of the javascript string
+    &quot;&quot;&quot;
+    if not is_3:
+        if cStringIO and not isinstance(js, unicode):
+            # strings can use cStringIO for a 3x performance
+            # improvement, but unicode (in python2) cannot
+            klass = cStringIO.StringIO
+        else:
+            klass = StringIO.StringIO
+    else:
+        klass = io.StringIO
+    ins = klass(js)
+    outs = klass()
+    JavascriptMinify(ins, outs).minify()
+    return outs.getvalue()
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> class JavascriptMinify(object):
</span><ins>+    &quot;&quot;&quot;
+    Minify an input stream of javascript, writing
+    to an output stream
+    &quot;&quot;&quot;
</ins><span class="cx"> 
</span><del>-    def _outA(self):
-        self.outstream.write(self.theA)
-    def _outB(self):
-        self.outstream.write(self.theB)
</del><ins>+    def __init__(self, instream=None, outstream=None):
+        self.ins = instream
+        self.outs = outstream
</ins><span class="cx"> 
</span><del>-    def _get(self):
-        &quot;&quot;&quot;return the next character from stdin. Watch out for lookahead. If
-           the character is a control character, translate it to a space or
-           linefeed.
-        &quot;&quot;&quot;
-        c = self.theLookahead
-        self.theLookahead = None
-        if c == None:
-            c = self.instream.read(1)
-        if c &gt;= ' ' or c == '\n':
-            return c
-        if c == '': # EOF
-            return '\000'
-        if c == '\r':
-            return '\n'
-        return ' '
</del><ins>+    def minify(self, instream=None, outstream=None):
+        if instream and outstream:
+            self.ins, self.outs = instream, outstream
</ins><span class="cx"> 
</span><del>-    def _peek(self):
-        self.theLookahead = self._get()
-        return self.theLookahead
</del><ins>+        self.is_return = False
+        self.return_buf = ''
</ins><span class="cx"> 
</span><del>-    def _next(self):
-        &quot;&quot;&quot;get the next character, excluding comments. peek() is used to see
-           if an unescaped '/' is followed by a '/' or '*'.
-        &quot;&quot;&quot;
-        c = self._get()
-        if c == '/' and self.theA != '\\':
-            p = self._peek()
-            if p == '/':
-                c = self._get()
-                while c &gt; '\n':
-                    c = self._get()
-                return c
-            if p == '*':
-                c = self._get()
-                while 1:
-                    c = self._get()
-                    if c == '*':
-                        if self._peek() == '/':
-                            self._get()
-                            return ' '
-                    if c == '\000':
-                        raise UnterminatedComment()
</del><ins>+        def write(char):
+            # all of this is to support literal regular expressions.
+            # sigh
+            if char in 'return':
+                self.return_buf += char
+                self.is_return = self.return_buf == 'return'
+            self.outs.write(char)
+            if self.is_return:
+                self.return_buf = ''
</ins><span class="cx"> 
</span><del>-        return c
</del><ins>+        read = self.ins.read
</ins><span class="cx"> 
</span><del>-    def _action(self, action):
-        &quot;&quot;&quot;do something! What you do is determined by the argument:
-           1   Output A. Copy B to A. Get the next B.
-           2   Copy B to A. Get the next B. (Delete A).
-           3   Get the next B. (Delete B).
-           action treats a string as a single character. Wow!
-           action recognizes a regular expression if it is preceded by ( or , or =.
-        &quot;&quot;&quot;
-        if action &lt;= 1:
-            self._outA()
</del><ins>+        space_strings = &quot;abcdefghijklmnopqrstuvwxyz&quot;\
+        &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$\\&quot;
+        starters, enders = '{[(+-', '}])+-&quot;\''
+        newlinestart_strings = starters + space_strings
+        newlineend_strings = enders + space_strings
+        do_newline = False
+        do_space = False
+        escape_slash_count = 0
+        doing_single_comment = False
+        previous_before_comment = ''
+        doing_multi_comment = False
+        in_re = False
+        in_quote = ''
+        quote_buf = []
</ins><span class="cx"> 
</span><del>-        if action &lt;= 2:
-            self.theA = self.theB
-            if self.theA == &quot;'&quot; or self.theA == '&quot;':
-                while 1:
-                    self._outA()
-                    self.theA = self._get()
-                    if self.theA == self.theB:
-                        break
-                    if self.theA &lt;= '\n':
-                        raise UnterminatedStringLiteral()
-                    if self.theA == '\\':
-                        self._outA()
-                        self.theA = self._get()
</del><ins>+        previous = read(1)
+        if previous == '\\':
+            escape_slash_count += 1
+        next1 = read(1)
+        if previous == '/':
+            if next1 == '/':
+                doing_single_comment = True
+            elif next1 == '*':
+                doing_multi_comment = True
+                previous = next1
+                next1 = read(1)
+            else:
+                write(previous)
+        elif not previous:
+            return
+        elif previous &gt;= '!':
+            if previous in &quot;'\&quot;&quot;:
+                in_quote = previous
+            write(previous)
+            previous_non_space = previous
+        else:
+            previous_non_space = ' '
+        if not next1:
+            return
</ins><span class="cx"> 
</span><ins>+        while 1:
+            next2 = read(1)
+            if not next2:
+                last = next1.strip()
+                if not (doing_single_comment or doing_multi_comment)\
+                    and last not in ('', '/'):
+                    if in_quote:
+                        write(''.join(quote_buf))
+                    write(last)
+                break
+            if doing_multi_comment:
+                if next1 == '*' and next2 == '/':
+                    doing_multi_comment = False
+                    next2 = read(1)
+            elif doing_single_comment:
+                if next1 in '\r\n':
+                    doing_single_comment = False
+                    while next2 in '\r\n':
+                        next2 = read(1)
+                        if not next2:
+                            break
+                    if previous_before_comment in ')}]':
+                        do_newline = True
+                    elif previous_before_comment in space_strings:
+                        write('\n')
+            elif in_quote:
+                quote_buf.append(next1)
</ins><span class="cx"> 
</span><del>-        if action &lt;= 3:
-            self.theB = self._next()
-            if self.theB == '/' and (self.theA == '(' or self.theA == ',' or
-                                     self.theA == '=' or self.theA == ':' or
-                                     self.theA == '[' or self.theA == '?' or
-                                     self.theA == '!' or self.theA == '&amp;' or
-                                     self.theA == '|' or self.theA == ';' or
-                                     self.theA == '{' or self.theA == '}' or
-                                     self.theA == '\n'):
-                self._outA()
-                self._outB()
-                while 1:
-                    self.theA = self._get()
-                    if self.theA == '/':
-                        break
-                    elif self.theA == '\\':
-                        self._outA()
-                        self.theA = self._get()
-                    elif self.theA &lt;= '\n':
-                        raise UnterminatedRegularExpression()
-                    self._outA()
-                self.theB = self._next()
</del><ins>+                if next1 == in_quote:
+                    numslashes = 0
+                    for c in reversed(quote_buf[:-1]):
+                        if c != '\\':
+                            break
+                        else:
+                            numslashes += 1
+                    if numslashes % 2 == 0:
+                        in_quote = ''
+                        write(''.join(quote_buf))
+            elif next1 in '\r\n':
+                if previous_non_space in newlineend_strings \
+                    or previous_non_space &gt; '~':
+                    while 1:
+                        if next2 &lt; '!':
+                            next2 = read(1)
+                            if not next2:
+                                break
+                        else:
+                            if next2 in newlinestart_strings \
+                                or next2 &gt; '~' or next2 == '/':
+                                do_newline = True
+                            break
+            elif next1 &lt; '!' and not in_re:
+                if (previous_non_space in space_strings \
+                    or previous_non_space &gt; '~') \
+                    and (next2 in space_strings or next2 &gt; '~'):
+                    do_space = True
+                elif previous_non_space in '-+' and next2 == previous_non_space:
+                    # protect against + ++ or - -- sequences
+                    do_space = True
+                elif self.is_return and next2 == '/':
+                    # returning a regex...
+                    write(' ')
+            elif next1 == '/':
+                if do_space:
+                    write(' ')
+                if in_re:
+                    if previous != '\\' or (not escape_slash_count % 2) or next2 in 'gimy':
+                        in_re = False
+                    write('/')
+                elif next2 == '/':
+                    doing_single_comment = True
+                    previous_before_comment = previous_non_space
+                elif next2 == '*':
+                    doing_multi_comment = True
+                    previous = next1
+                    next1 = next2
+                    next2 = read(1)
+                else:
+                    in_re = previous_non_space in '(,=:[?!&amp;|' or self.is_return  # literal regular expression
+                    write('/')
+            else:
+                if do_space:
+                    do_space = False
+                    write(' ')
+                if do_newline:
+                    write('\n')
+                    do_newline = False
</ins><span class="cx"> 
</span><ins>+                write(next1)
+                if not in_re and next1 in &quot;'\&quot;&quot;:
+                    in_quote = next1
+                    quote_buf = []
</ins><span class="cx"> 
</span><del>-    def _jsmin(self):
-        &quot;&quot;&quot;Copy the input to the output, deleting the characters which are
-           insignificant to JavaScript. Comments will be removed. Tabs will be
-           replaced with spaces. Carriage returns will be replaced with linefeeds.
-           Most spaces and linefeeds will be removed.
-        &quot;&quot;&quot;
-        self.theA = '\n'
-        self._action(3)
</del><ins>+            previous = next1
+            next1 = next2
</ins><span class="cx"> 
</span><del>-        while self.theA != '\000':
-            if self.theA == ' ':
-                if isAlphanum(self.theB):
-                    self._action(1)
-                else:
-                    self._action(2)
-            elif self.theA == '\n':
-                if self.theB in ['{', '[', '(', '+', '-']:
-                    self._action(1)
-                elif self.theB == ' ':
-                    self._action(3)
-                else:
-                    if isAlphanum(self.theB):
-                        self._action(1)
-                    else:
-                        self._action(2)
</del><ins>+            if previous &gt;= '!':
+                previous_non_space = previous
+
+            if previous == '\\':
+                escape_slash_count += 1
</ins><span class="cx">             else:
</span><del>-                if self.theB == ' ':
-                    if isAlphanum(self.theA):
-                        self._action(1)
-                    else:
-                        self._action(3)
-                elif self.theB == '\n':
-                    if self.theA in ['}', ']', ')', '+', '-', '&quot;', '\'']:
-                        self._action(1)
-                    else:
-                        if isAlphanum(self.theA):
-                            self._action(1)
-                        else:
-                            self._action(3)
-                else:
-                    self._action(1)
</del><ins>+                escape_slash_count = 0
</ins><span class="cx"> 
</span><del>-    def minify(self, instream, outstream):
-        self.instream = instream
-        self.outstream = outstream
-        self.theA = '\n'
-        self.theB = None
-        self.theLookahead = None
-
-        self._jsmin()
-        self.instream.close()
-
</del><span class="cx"> if __name__ == '__main__':
</span><del>-    import sys
-    jsm = JavascriptMinify()
-    jsm.minify(sys.stdin, sys.stdout)
</del><ins>+    minifier = JavascriptMinify(sys.stdin, sys.stdout)
+    minifier.minify()
+    sys.stdout.write('\n')
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebInspectorUI/ChangeLog (168596 => 168597)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebInspectorUI/ChangeLog        2014-05-11 07:01:15 UTC (rev 168596)
+++ releases/WebKitGTK/webkit-2.4/Source/WebInspectorUI/ChangeLog        2014-05-11 07:47:10 UTC (rev 168597)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-05-09  Alberto Garcia  &lt;berto@igalia.com&gt;
+
+        jsmin.py license header confusing, mentions non-free license
+        https://bugs.webkit.org/show_bug.cgi?id=123665
+
+        Reviewed by Darin Adler.
+
+        Pull the most recent version from upstream, which has a clear
+        license.
+
+        * Scripts/jsmin.py:
+
</ins><span class="cx"> 2014-01-30  Diego Pino Garcia  &lt;dpino@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Implement open/close Console window shortcut
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit24SourceWebInspectorUIScriptsjsminpy"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.4/Source/WebInspectorUI/Scripts/jsmin.py (168596 => 168597)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.4/Source/WebInspectorUI/Scripts/jsmin.py        2014-05-11 07:01:15 UTC (rev 168596)
+++ releases/WebKitGTK/webkit-2.4/Source/WebInspectorUI/Scripts/jsmin.py        2014-05-11 07:47:10 UTC (rev 168597)
</span><span class="lines">@@ -1,218 +1,238 @@
</span><del>-#!/usr/bin/python
-
</del><span class="cx"> # This code is original from jsmin by Douglas Crockford, it was translated to
</span><del>-# Python by Baruch Even. The original code had the following copyright and
-# license.
</del><ins>+# Python by Baruch Even. It was rewritten by Dave St.Germain for speed.
</ins><span class="cx"> #
</span><del>-# /* jsmin.c
-#    2007-05-22
</del><ins>+# The MIT License (MIT)
</ins><span class="cx"> #
</span><del>-# Copyright (c) 2002 Douglas Crockford  (www.crockford.com)
</del><ins>+# Copyright (c) 2013 Dave St.Germain
</ins><span class="cx"> #
</span><del>-# Permission is hereby granted, free of charge, to any person obtaining a copy of
-# this software and associated documentation files (the &quot;Software&quot;), to deal in
-# the Software without restriction, including without limitation the rights to
-# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-# of the Software, and to permit persons to whom the Software is furnished to do
-# so, subject to the following conditions:
</del><ins>+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the &quot;Software&quot;), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
</ins><span class="cx"> #
</span><del>-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
</del><ins>+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
</ins><span class="cx"> #
</span><del>-# The Software shall be used for Good, not Evil.
-#
</del><span class="cx"> # THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
</span><span class="cx"> # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
</span><span class="cx"> # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</span><span class="cx"> # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
</span><span class="cx"> # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
</span><del>-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-# */
</del><ins>+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
</ins><span class="cx"> 
</span><del>-from StringIO import StringIO
</del><span class="cx"> 
</span><del>-def jsmin(js):
-    ins = StringIO(js)
-    outs = StringIO()
-    JavascriptMinify().minify(ins, outs)
-    str = outs.getvalue()
-    if len(str) &gt; 0 and str[0] == '\n':
-        str = str[1:]
-    return str
</del><ins>+import sys
+is_3 = sys.version_info &gt;= (3, 0)
+if is_3:
+    import io
+else:
+    import StringIO
+    try:
+        import cStringIO
+    except ImportError:
+        cStringIO = None
</ins><span class="cx"> 
</span><del>-def isAlphanum(c):
-    &quot;&quot;&quot;return true if the character is a letter, digit, underscore,
-           dollar sign, or non-ASCII character.
-    &quot;&quot;&quot;
-    return ((c &gt;= 'a' and c &lt;= 'z') or (c &gt;= '0' and c &lt;= '9') or
-            (c &gt;= 'A' and c &lt;= 'Z') or c == '_' or c == '$' or c == '\\' or (c is not None and ord(c) &gt; 126));
</del><span class="cx"> 
</span><del>-class UnterminatedComment(Exception):
-    pass
</del><ins>+__all__ = ['jsmin', 'JavascriptMinify']
+__version__ = '2.0.9'
</ins><span class="cx"> 
</span><del>-class UnterminatedStringLiteral(Exception):
-    pass
</del><span class="cx"> 
</span><del>-class UnterminatedRegularExpression(Exception):
-    pass
</del><ins>+def jsmin(js):
+    &quot;&quot;&quot;
+    returns a minified version of the javascript string
+    &quot;&quot;&quot;
+    if not is_3:
+        if cStringIO and not isinstance(js, unicode):
+            # strings can use cStringIO for a 3x performance
+            # improvement, but unicode (in python2) cannot
+            klass = cStringIO.StringIO
+        else:
+            klass = StringIO.StringIO
+    else:
+        klass = io.StringIO
+    ins = klass(js)
+    outs = klass()
+    JavascriptMinify(ins, outs).minify()
+    return outs.getvalue()
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> class JavascriptMinify(object):
</span><ins>+    &quot;&quot;&quot;
+    Minify an input stream of javascript, writing
+    to an output stream
+    &quot;&quot;&quot;
</ins><span class="cx"> 
</span><del>-    def _outA(self):
-        self.outstream.write(self.theA)
-    def _outB(self):
-        self.outstream.write(self.theB)
</del><ins>+    def __init__(self, instream=None, outstream=None):
+        self.ins = instream
+        self.outs = outstream
</ins><span class="cx"> 
</span><del>-    def _get(self):
-        &quot;&quot;&quot;return the next character from stdin. Watch out for lookahead. If
-           the character is a control character, translate it to a space or
-           linefeed.
-        &quot;&quot;&quot;
-        c = self.theLookahead
-        self.theLookahead = None
-        if c == None:
-            c = self.instream.read(1)
-        if c &gt;= ' ' or c == '\n':
-            return c
-        if c == '': # EOF
-            return '\000'
-        if c == '\r':
-            return '\n'
-        return ' '
</del><ins>+    def minify(self, instream=None, outstream=None):
+        if instream and outstream:
+            self.ins, self.outs = instream, outstream
</ins><span class="cx"> 
</span><del>-    def _peek(self):
-        self.theLookahead = self._get()
-        return self.theLookahead
</del><ins>+        self.is_return = False
+        self.return_buf = ''
</ins><span class="cx"> 
</span><del>-    def _next(self):
-        &quot;&quot;&quot;get the next character, excluding comments. peek() is used to see
-           if an unescaped '/' is followed by a '/' or '*'.
-        &quot;&quot;&quot;
-        c = self._get()
-        if c == '/' and self.theA != '\\':
-            p = self._peek()
-            if p == '/':
-                c = self._get()
-                while c &gt; '\n':
-                    c = self._get()
-                return c
-            if p == '*':
-                c = self._get()
-                while 1:
-                    c = self._get()
-                    if c == '*':
-                        if self._peek() == '/':
-                            self._get()
-                            return ' '
-                    if c == '\000':
-                        raise UnterminatedComment()
</del><ins>+        def write(char):
+            # all of this is to support literal regular expressions.
+            # sigh
+            if char in 'return':
+                self.return_buf += char
+                self.is_return = self.return_buf == 'return'
+            self.outs.write(char)
+            if self.is_return:
+                self.return_buf = ''
</ins><span class="cx"> 
</span><del>-        return c
</del><ins>+        read = self.ins.read
</ins><span class="cx"> 
</span><del>-    def _action(self, action):
-        &quot;&quot;&quot;do something! What you do is determined by the argument:
-           1   Output A. Copy B to A. Get the next B.
-           2   Copy B to A. Get the next B. (Delete A).
-           3   Get the next B. (Delete B).
-           action treats a string as a single character. Wow!
-           action recognizes a regular expression if it is preceded by ( or , or =.
-        &quot;&quot;&quot;
-        if action &lt;= 1:
-            self._outA()
</del><ins>+        space_strings = &quot;abcdefghijklmnopqrstuvwxyz&quot;\
+        &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$\\&quot;
+        starters, enders = '{[(+-', '}])+-&quot;\''
+        newlinestart_strings = starters + space_strings
+        newlineend_strings = enders + space_strings
+        do_newline = False
+        do_space = False
+        escape_slash_count = 0
+        doing_single_comment = False
+        previous_before_comment = ''
+        doing_multi_comment = False
+        in_re = False
+        in_quote = ''
+        quote_buf = []
</ins><span class="cx"> 
</span><del>-        if action &lt;= 2:
-            self.theA = self.theB
-            if self.theA == &quot;'&quot; or self.theA == '&quot;':
-                while 1:
-                    self._outA()
-                    self.theA = self._get()
-                    if self.theA == self.theB:
-                        break
-                    if self.theA &lt;= '\n':
-                        raise UnterminatedStringLiteral()
-                    if self.theA == '\\':
-                        self._outA()
-                        self.theA = self._get()
</del><ins>+        previous = read(1)
+        if previous == '\\':
+            escape_slash_count += 1
+        next1 = read(1)
+        if previous == '/':
+            if next1 == '/':
+                doing_single_comment = True
+            elif next1 == '*':
+                doing_multi_comment = True
+                previous = next1
+                next1 = read(1)
+            else:
+                write(previous)
+        elif not previous:
+            return
+        elif previous &gt;= '!':
+            if previous in &quot;'\&quot;&quot;:
+                in_quote = previous
+            write(previous)
+            previous_non_space = previous
+        else:
+            previous_non_space = ' '
+        if not next1:
+            return
</ins><span class="cx"> 
</span><ins>+        while 1:
+            next2 = read(1)
+            if not next2:
+                last = next1.strip()
+                if not (doing_single_comment or doing_multi_comment)\
+                    and last not in ('', '/'):
+                    if in_quote:
+                        write(''.join(quote_buf))
+                    write(last)
+                break
+            if doing_multi_comment:
+                if next1 == '*' and next2 == '/':
+                    doing_multi_comment = False
+                    next2 = read(1)
+            elif doing_single_comment:
+                if next1 in '\r\n':
+                    doing_single_comment = False
+                    while next2 in '\r\n':
+                        next2 = read(1)
+                        if not next2:
+                            break
+                    if previous_before_comment in ')}]':
+                        do_newline = True
+                    elif previous_before_comment in space_strings:
+                        write('\n')
+            elif in_quote:
+                quote_buf.append(next1)
</ins><span class="cx"> 
</span><del>-        if action &lt;= 3:
-            self.theB = self._next()
-            if self.theB == '/' and (self.theA == '(' or self.theA == ',' or
-                                     self.theA == '=' or self.theA == ':' or
-                                     self.theA == '[' or self.theA == '?' or
-                                     self.theA == '!' or self.theA == '&amp;' or
-                                     self.theA == '|' or self.theA == ';' or
-                                     self.theA == '{' or self.theA == '}' or
-                                     self.theA == '\n'):
-                self._outA()
-                self._outB()
-                while 1:
-                    self.theA = self._get()
-                    if self.theA == '/':
-                        break
-                    elif self.theA == '\\':
-                        self._outA()
-                        self.theA = self._get()
-                    elif self.theA &lt;= '\n':
-                        raise UnterminatedRegularExpression()
-                    self._outA()
-                self.theB = self._next()
</del><ins>+                if next1 == in_quote:
+                    numslashes = 0
+                    for c in reversed(quote_buf[:-1]):
+                        if c != '\\':
+                            break
+                        else:
+                            numslashes += 1
+                    if numslashes % 2 == 0:
+                        in_quote = ''
+                        write(''.join(quote_buf))
+            elif next1 in '\r\n':
+                if previous_non_space in newlineend_strings \
+                    or previous_non_space &gt; '~':
+                    while 1:
+                        if next2 &lt; '!':
+                            next2 = read(1)
+                            if not next2:
+                                break
+                        else:
+                            if next2 in newlinestart_strings \
+                                or next2 &gt; '~' or next2 == '/':
+                                do_newline = True
+                            break
+            elif next1 &lt; '!' and not in_re:
+                if (previous_non_space in space_strings \
+                    or previous_non_space &gt; '~') \
+                    and (next2 in space_strings or next2 &gt; '~'):
+                    do_space = True
+                elif previous_non_space in '-+' and next2 == previous_non_space:
+                    # protect against + ++ or - -- sequences
+                    do_space = True
+                elif self.is_return and next2 == '/':
+                    # returning a regex...
+                    write(' ')
+            elif next1 == '/':
+                if do_space:
+                    write(' ')
+                if in_re:
+                    if previous != '\\' or (not escape_slash_count % 2) or next2 in 'gimy':
+                        in_re = False
+                    write('/')
+                elif next2 == '/':
+                    doing_single_comment = True
+                    previous_before_comment = previous_non_space
+                elif next2 == '*':
+                    doing_multi_comment = True
+                    previous = next1
+                    next1 = next2
+                    next2 = read(1)
+                else:
+                    in_re = previous_non_space in '(,=:[?!&amp;|' or self.is_return  # literal regular expression
+                    write('/')
+            else:
+                if do_space:
+                    do_space = False
+                    write(' ')
+                if do_newline:
+                    write('\n')
+                    do_newline = False
</ins><span class="cx"> 
</span><ins>+                write(next1)
+                if not in_re and next1 in &quot;'\&quot;&quot;:
+                    in_quote = next1
+                    quote_buf = []
</ins><span class="cx"> 
</span><del>-    def _jsmin(self):
-        &quot;&quot;&quot;Copy the input to the output, deleting the characters which are
-           insignificant to JavaScript. Comments will be removed. Tabs will be
-           replaced with spaces. Carriage returns will be replaced with linefeeds.
-           Most spaces and linefeeds will be removed.
-        &quot;&quot;&quot;
-        self.theA = '\n'
-        self._action(3)
</del><ins>+            previous = next1
+            next1 = next2
</ins><span class="cx"> 
</span><del>-        while self.theA != '\000':
-            if self.theA == ' ':
-                if isAlphanum(self.theB):
-                    self._action(1)
-                else:
-                    self._action(2)
-            elif self.theA == '\n':
-                if self.theB in ['{', '[', '(', '+', '-']:
-                    self._action(1)
-                elif self.theB == ' ':
-                    self._action(3)
-                else:
-                    if isAlphanum(self.theB):
-                        self._action(1)
-                    else:
-                        self._action(2)
</del><ins>+            if previous &gt;= '!':
+                previous_non_space = previous
+
+            if previous == '\\':
+                escape_slash_count += 1
</ins><span class="cx">             else:
</span><del>-                if self.theB == ' ':
-                    if isAlphanum(self.theA):
-                        self._action(1)
-                    else:
-                        self._action(3)
-                elif self.theB == '\n':
-                    if self.theA in ['}', ']', ')', '+', '-', '&quot;', '\'']:
-                        self._action(1)
-                    else:
-                        if isAlphanum(self.theA):
-                            self._action(1)
-                        else:
-                            self._action(3)
-                else:
-                    self._action(1)
</del><ins>+                escape_slash_count = 0
</ins><span class="cx"> 
</span><del>-    def minify(self, instream, outstream):
-        self.instream = instream
-        self.outstream = outstream
-        self.theA = '\n'
-        self.theB = None
-        self.theLookahead = None
-
-        self._jsmin()
-        self.instream.close()
-
</del><span class="cx"> if __name__ == '__main__':
</span><del>-    import sys
-    jsm = JavascriptMinify()
-    jsm.minify(sys.stdin, sys.stdout)
</del><ins>+    minifier = JavascriptMinify(sys.stdin, sys.stdout)
+    minifier.minify()
+    sys.stdout.write('\n')
</ins></span></pre>
</div>
</div>

</body>
</html>