< prev index next >

make/jdk/src/classes/build/tools/spp/Spp.java

Print this page

        

@@ -23,10 +23,12 @@
  * questions.
  */
 
 package build.tools.spp;
 
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.util.*;
 import java.util.regex.*;
 
 /*
  * Spp: A simple regex-based stream preprocessor based on Mark Reinhold's

@@ -67,17 +69,23 @@
     public static void main(String args[]) throws Exception {
         Map<String, String> vars = new HashMap<>();
         Set<String> keys = new HashSet<>();
         boolean be = false;
         boolean el = true;
+                String inputFile = null;
+                String outputFile = null;
 
         for (String arg:args) {
             if (arg.startsWith("-D")) {
                 int i = arg.indexOf('=');
                 vars.put(arg.substring(2, i),arg.substring(i+1));
             } else if (arg.startsWith("-K")) {
                 keys.add(arg.substring(2));
+            } else if (arg.startsWith("-i")) {
+                inputFile = arg.substring(2);
+            } else if (arg.startsWith("-o")) {
+                outputFile = arg.substring(2);
             } else if ("-be".equals(arg)) {
                 be = true;
             } else if ("-nel".equals(arg)) {
                 el = false;
             } else {

@@ -85,15 +93,15 @@
                 System.exit(-1);
             }
         }
 
         StringBuffer out = new StringBuffer();
-        new Spp().spp(new Scanner(System.in),
+        new Spp().spp(new Scanner(new FileInputStream(inputFile)),
                       out, "",
                       keys, vars, be, el,
                       false);
-        System.out.print(out.toString());
+        new FileOutputStream(outputFile, true).write(out.toString().getBytes());
     }
 
     static final String LNSEP = System.getProperty("line.separator");
     static final String KEY = "([a-zA-Z0-9]+)";
     static final String VAR = "([a-zA-Z0-9_\\-]+)";
< prev index next >