sergioadevita / jarjar

Automatically exported from code.google.com/p/jarjar
0 stars 0 forks source link

Jarjar rules file syntax should support comments #53

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
There doesn't seem to be a syntax for comments in rules files.  Blank lines are 
disallowed, too.  Rules can be tricky, and it would be useful to allow grouping 
them with blank lines and documenting them with comments.

Suggested patch:

Index: src/main/com/tonicsystems/jarjar/RulesFileParser.java
===================================================================
--- src/main/com/tonicsystems/jarjar/RulesFileParser.java   (revision 138)
+++ src/main/com/tonicsystems/jarjar/RulesFileParser.java   (working copy)
@@ -32,6 +32,11 @@
         return parse(new java.io.StringReader(value));
     }

+    private static String stripComment(String in) {
+      int p = in.indexOf("#");
+      return p < 0 ? in : in.substring(0, p);
+    }
+
     private static List<PatternElement> parse(Reader r) throws IOException {
       try {
         List<PatternElement> patterns = new ArrayList<PatternElement>();
@@ -39,6 +44,9 @@
         int c = 1;
         String line;
         while ((line = br.readLine()) != null) {
+            line = stripComment(line);
+            if (line.isEmpty())
+                continue;
             String[] parts = line.split("\\s+");
             if (parts.length < 2)
                 error(c, parts);

Original issue reported on code.google.com by oh...@google.com on 2 Jul 2012 at 8:02

GoogleCodeExporter commented 8 years ago
This was fixed in 1.4

Original comment by max.r...@gmail.com on 1 Nov 2012 at 4:39