public final File base;
+ private boolean hadErrors = false;
+
public TranslationCollector(File base, File conf) {
this.base = base;
taint = new LinkedList<>();
scanTemplates();
scanCode(taint);
- System.out.println("Total Translatable Strings: " + translations.size());
+ System.err.println("Total Translatable Strings: " + translations.size());
TreeSet<TranslationEntry> trs = new TreeSet<>(translations.values());
writePOFile(out, trs);
-
}
public void add(String text, String line) {
}
private void scanCode(LinkedList<TaintSource> taint) throws Error {
- PrintWriter out = new PrintWriter(System.out);
+ PrintWriter out = new PrintWriter(System.err);
Main m = new Main(out, out, false, null, null);
File[] fs = recurse(new File(new File(new File(base, "src"), "org"), "cacert"), new LinkedList<File>(), ".java").toArray(new File[0]);
String[] t = new String[fs.length + 3];
err++;
}
if (OUTPUT_WARNINGS || problem.isError()) {
- System.out.println(problem);
+ System.err.println(problem);
StringBuilder prob = new StringBuilder();
prob.append(parsedUnit.compilationResult.fileName);
prob.append(":");
prob.append(problem.getSourceLineNumber());
- System.out.println(prob.toString());
+ System.err.println(prob.toString());
}
}
if (err > 0) {
}
if (parsedUnit.types == null) {
- System.out.println("No types");
+ System.err.println("No types");
} else {
TranslationCollectingVisitor v = new TranslationCollectingVisitor(parsedUnit, taint.toArray(new TaintSource[taint.size()]), this);
for (TypeDeclaration td : parsedUnit.types) {
td.traverse(v, td.scope);
}
+ hadErrors |= v.hadErrors();
}
parsedUnits[i] = parsedUnit;
}
private LinkedList<TaintSource> taint;
public static void main(String[] args) throws IOException {
- new TranslationCollector(new File(args[1]), new File(args[0])).run(new File(args[2]));
+ TranslationCollector tc = new TranslationCollector(new File(args[1]), new File(args[0]));
+ tc.run(new File(args[2]));
+ if (tc.hadErrors) {
+ System.exit(1);
+ } else {
+ System.exit(0);
+ }
}
public static void writePOFile(File target, Collection<TranslationEntry> strings) throws IOException {