Allow comments anywhere in the line

This commit is contained in:
md_5 2013-07-03 11:52:19 +10:00
parent 6d9552101f
commit 11d057e669

View File

@ -72,8 +72,8 @@ public class JarMapping {
} }
/** /**
* Add a class name prefix to the mapping ignore list. * Add a class name prefix to the mapping ignore list. Note: this only
* Note: this only applies before loading mappings, not after * applies before loading mappings, not after
*/ */
public void addExcludedPackage(String packageName) { public void addExcludedPackage(String packageName) {
SpecialSource.log("Protecting Package: " + packageName); SpecialSource.log("Protecting Package: " + packageName);
@ -256,7 +256,11 @@ public class JarMapping {
String line; String line;
while ((line = reader.readLine()) != null) { 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; continue;
} }
@ -369,8 +373,8 @@ public class JarMapping {
} }
if (packages.containsKey(oldPackageName) && !newPackageName.equals(packages.get(oldPackageName))) { if (packages.containsKey(oldPackageName) && !newPackageName.equals(packages.get(oldPackageName))) {
throw new IllegalArgumentException("Duplicate package mapping: " + oldPackageName + " ->" + newPackageName + throw new IllegalArgumentException("Duplicate package mapping: " + oldPackageName + " ->" + newPackageName
" but already mapped to "+packages.get(oldPackageName)+" in line="+line); + " but already mapped to " + packages.get(oldPackageName) + " in line=" + line);
} }
packages.put(oldPackageName, newPackageName); packages.put(oldPackageName, newPackageName);
@ -400,7 +404,7 @@ public class JarMapping {
} }
if (isExcludedPackage(oldClassName)) { if (isExcludedPackage(oldClassName)) {
SpecialSource.log("Ignored FD: " + oldClassName + "/" + oldFieldName + " -> " + newFieldName); SpecialSource.log("Ignored FD: " + oldClassName + "/" + oldFieldName + " -> " + newFieldName);
return; return;
} }
@ -435,7 +439,7 @@ public class JarMapping {
} }
if (isExcludedPackage(oldClassName)) { if (isExcludedPackage(oldClassName)) {
SpecialSource.log("Ignored MD: " + oldClassName + "/" + oldMethodName + " -> " + newMethodName); SpecialSource.log("Ignored MD: " + oldClassName + "/" + oldMethodName + " -> " + newMethodName);
return; return;
} }