From 11d057e6692f11c9cfa214e42a65c3d69850ffaf Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 3 Jul 2013 11:52:19 +1000 Subject: [PATCH] Allow comments anywhere in the line --- .../net/md_5/specialsource/JarMapping.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/md_5/specialsource/JarMapping.java b/src/main/java/net/md_5/specialsource/JarMapping.java index c7bdac3..bf6d71b 100644 --- a/src/main/java/net/md_5/specialsource/JarMapping.java +++ b/src/main/java/net/md_5/specialsource/JarMapping.java @@ -72,8 +72,8 @@ public class JarMapping { } /** - * Add a class name prefix to the mapping ignore list. - * Note: this only applies before loading mappings, not after + * Add a class name prefix to the mapping ignore list. Note: this only + * applies before loading mappings, not after */ public void addExcludedPackage(String packageName) { SpecialSource.log("Protecting Package: " + packageName); @@ -256,7 +256,11 @@ public class JarMapping { String line; while ((line = reader.readLine()) != null) { - if (line.startsWith("#") || line.isEmpty()) { + int commentIndex = line.indexOf('#'); + if (commentIndex != -1) { + line = line.substring(0, commentIndex); + } + if (line.isEmpty()) { continue; } @@ -369,8 +373,8 @@ public class JarMapping { } if (packages.containsKey(oldPackageName) && !newPackageName.equals(packages.get(oldPackageName))) { - throw new IllegalArgumentException("Duplicate package mapping: " + oldPackageName + " ->" + newPackageName + - " but already mapped to "+packages.get(oldPackageName)+" in line="+line); + throw new IllegalArgumentException("Duplicate package mapping: " + oldPackageName + " ->" + newPackageName + + " but already mapped to " + packages.get(oldPackageName) + " in line=" + line); } packages.put(oldPackageName, newPackageName); @@ -400,7 +404,7 @@ public class JarMapping { } if (isExcludedPackage(oldClassName)) { - SpecialSource.log("Ignored FD: " + oldClassName + "/" + oldFieldName + " -> " + newFieldName); + SpecialSource.log("Ignored FD: " + oldClassName + "/" + oldFieldName + " -> " + newFieldName); return; } @@ -435,7 +439,7 @@ public class JarMapping { } if (isExcludedPackage(oldClassName)) { - SpecialSource.log("Ignored MD: " + oldClassName + "/" + oldMethodName + " -> " + newMethodName); + SpecialSource.log("Ignored MD: " + oldClassName + "/" + oldMethodName + " -> " + newMethodName); return; }