Update to the new library 'json2'
[euphorik.git] / tools / jsmin.js
index a49c2bf..95c275b 100644 (file)
@@ -1,3 +1,5 @@
+#!/usr/bin/env rhino
+\r
 /* jsmin.js - 2006-08-31
 Author: Franck Marcia
 This work is an adaptation of jsminc.c published by Douglas Crockford.
@@ -121,6 +123,16 @@ function jsmin(comment, input, level) {
        function next() {
 
                var c = get();
+      
+      if (c === ";" && peek() === ";") {
+         for (;;) {
+            c = get();
+            if (c <= '\n') {
+               return c;
+            }
+         }
+      }
+    
                if (c == '/') {
                        switch (peek()) {
                        case '/':
@@ -314,16 +326,17 @@ function jsmin(comment, input, level) {
        return comment + ret;
 
 }
-
-(function (a) {
-    if (!a[0]) {
-        print("Usage: jsmin.js file.js");
-        quit(1);
-    }
-    var input = readFile(a[0]);
-    if (!input) {
-        print("jslint: Couldn't open file '" + a[0] + "'.");
-        quit(1);
-    }
-   print(jsmin(input));
+\r
+importPackage(java.io);
+(function (a) {\r
+   // in is a reserved javascript word, so we need to use [] for access\r
+   var readingIn = new BufferedReader(new InputStreamReader(java.lang.System["in"]));\r
+   var sInput = "";\r
+   var str = "";\r
+   while(str != null) {\r
+      sInput += str + '\n';
+      \r
+      str = readingIn.readLine();\r
+   }
+   print(jsmin(sInput));
 })(arguments);
\ No newline at end of file