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.
Projecttikitu/jsmin
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
| 70 | 70 | break | |
| 71 | 71 | if previous_before_comment in ')}]': | |
| 72 | 72 | do_newline = True | |
| 73 | + | elif previous_before_comment in space_strings: | |
| 74 | + | write('\n') | |
| 73 | 75 | elif in_quote: | |
| 74 | 76 | quote_buf.append(next1) | |
| 75 | 77 | ||
| ⋯ | |||
| 102 | 104 | and (next2 in space_strings or next2 > '~'): | |
| 103 | 105 | do_space = True | |
| 104 | 106 | 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 | |
| 111 | 116 | 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 '(,=:[?!&|' | |
| 116 | 118 | write('/') | |
| 117 | 119 | else: | |
| 118 | 120 | if do_space: | |
The check that tells the two apart
fail→pass·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
- 2014-10-27Fix for issue #14: handle ECMAScript/Harmony backticks.
- 2013-10-18JavascriptMinify
- 2013-05-10JavascriptMinify