One function

JavascriptMinify in tikitu/jsmin

The author described this change as Fix for #2, #3: single line comments broken. It counts as a record because the check below fails on the code as it stood at a45d6e6cf and passes on 181628ebd, with nothing else changed between the two runs.

Fix saved2013-05-13
Sharing licenceMIT · LICENSE.txt
Change size+12 10

What the code was meant to do, written into the code itself as a docstring

Minify an input stream of javascript, writing to an output stream

The change

7070 break
7171 if previous_before_comment in ')}]':
7272 do_newline = True
73+ elif previous_before_comment in space_strings:
74+ write('\n')
7375 elif in_quote:
7476 quote_buf.append(next1)
7577
102104 and (next2 in space_strings or next2 > '~'):
103105 do_space = True
104106 elif next1 == '/':
105- if (previous in ';,\n\r{}' or previous < '!') and next2 in '/*':
106- if next2 == '/':
107- doing_single_comment = True
108- previous_before_comment = previous_non_space
109- elif next2 == '*':
110- doing_multi_comment = True
107+ if in_re:
108+ if previous != '\\':
109+ in_re = False
110+ write('/')
111+ elif next2 == '/':
112+ doing_single_comment = True
113+ previous_before_comment = previous_non_space
114+ elif next2 == '*':
115+ doing_multi_comment = True
111116 else:
112- if not in_re:
113- in_re = previous_non_space in '(,=:[?!&|'
114- elif previous_non_space != '\\':
115- in_re = not in_re
117+ in_re = previous_non_space in '(,=:[?!&|'
116118 write('/')
117119 else:
118120 if do_space:

The check that tells the two apart

failpass·jsmin/test.py::JsTests::testCommentInObj2

Check file jsmin/test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before ita45d6e6cfa8b57d6aff97ed7e6ce0ca0618d946b
Broken version dated2013-05-10
Modulejsmin.__init__
Units changedJavascriptMinify
Fingerprintaf9f2feff37922b4
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in tikitu/jsmin