Permalink
Browse files

Merge pull request #13 from aag/master

Updates to keep in sync with jsmin.c
  • Loading branch information...
2 parents 8689392 + b85bf4f commit 6025086f2a4cfa8b23611967a524b0409f8eff81 @rgrove committed May 4, 2012
Showing with 26 additions and 4 deletions.
  1. +14 −3 jsmin.php
  2. +4 −0 test/setup.php
  3. +2 −1 test/test.php
  4. +6 −0 test/utf8-with-bom.js
View
@@ -40,9 +40,10 @@
* @author Ryan Grove <ryan@wonko.com>
* @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
* @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
+ * @copyright 2012 Adam Goforth <aag@adamgoforth.com> (Updates)
* @license http://opensource.org/licenses/mit-license.php MIT License
- * @version 1.1.1 (2008-03-02)
- * @link https://github.com/rgrove/jsmin-php/
+ * @version 1.1.2 (2012-05-01)
+ * @link https://github.com/rgrove/jsmin-php
*/
class JSMin {
@@ -227,9 +228,17 @@ protected function isAlphaNum($c) {
*
* @uses action()
* @uses isAlphaNum()
+ * @uses get()
+ * @uses peek()
* @return string
*/
protected function min() {
+ if (0 == strncmp($this->peek(), "\xef", 1)) {
+ $this->get();
+ $this->get();
+ $this->get();
+ }
+
$this->a = "\n";
$this->action(self::ACTION_DELETE_A_B);
@@ -250,6 +259,8 @@ protected function min() {
case '(':
case '+':
case '-':
+ case '!':
+ case '~':
$this->action(self::ACTION_KEEP_A);
break;
@@ -372,4 +383,4 @@ protected function peek() {
// -- Exceptions ---------------------------------------------------------------
class JSMinException extends Exception {}
-?>
+?>
View
@@ -27,4 +27,8 @@
file_put_contents(__DIR__ . "/libs/$name.js", file_get_contents($url));
}
+// Copy utf-8 file to the libs directory
+echo "Copying UTF-8 file with BOM...\n";
+copy(__DIR__ . '/utf8-with-bom.js', __DIR__ . '/libs/utf8-with-bom.js');
+
echo "Done\n";
View
@@ -8,7 +8,8 @@
'ext',
'jquery',
'mootools',
- 'yui'
+ 'yui',
+ 'utf8-with-bom'
);
foreach ($libs as $lib) {
View
@@ -0,0 +1,6 @@
+var foo = function() {
+ var bar = 2
+ !bar
+ ~bar
+ return bar
+};

0 comments on commit 6025086

Please sign in to comment.