diff options
author | Shevek <[email protected]> | 2014-09-10 16:10:52 -0700 |
---|---|---|
committer | Shevek <[email protected]> | 2014-09-10 19:07:35 -0700 |
commit | bcc3a2b96b0e8b8b03dad0babd7103903cc9df3f (patch) | |
tree | 09a2833189524f55e5a6c149cc0e4650a6e5a5f0 /src/main/java/org/anarres/cpp/Preprocessor.java | |
parent | aefac8ce01aee2f538db413d5812613facee9c55 (diff) |
NetBeans refactorings to standardize codebase.
Diffstat (limited to 'src/main/java/org/anarres/cpp/Preprocessor.java')
-rw-r--r-- | src/main/java/org/anarres/cpp/Preprocessor.java | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/main/java/org/anarres/cpp/Preprocessor.java b/src/main/java/org/anarres/cpp/Preprocessor.java index 3569b86..43fba89 100644 --- a/src/main/java/org/anarres/cpp/Preprocessor.java +++ b/src/main/java/org/anarres/cpp/Preprocessor.java @@ -19,7 +19,6 @@ package org.anarres.cpp; import java.io.Closeable; import java.io.File; import java.io.IOException; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -27,16 +26,15 @@ import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Stack; - +import java.util.TreeMap; import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import static org.anarres.cpp.Token.*; import static org.anarres.cpp.PreprocessorCommand.*; +import static org.anarres.cpp.Token.*; /** * A C Preprocessor. @@ -587,7 +585,7 @@ public class Preprocessor implements Closeable { .append(" \""); /* XXX This call to escape(name) is correct but ugly. */ if (name == null) - buf.append("<unnamed-source>"); + buf.append("<no file>"); else MacroTokenSource.escape(buf, name); buf.append("\"").append(extra).append("\n"); @@ -792,12 +790,8 @@ public class Preprocessor implements Closeable { return false; } - /* - * for (Argument a : args) - * a.expand(this); - */ - for (int i = 0; i < args.size(); i++) { - args.get(i).expand(this); + for (Argument a : args) { + a.expand(this); } // System.out.println("Macro " + m + " args " + args); @@ -1537,7 +1531,7 @@ public class Preprocessor implements Closeable { lhs = value.longValue(); break; case CHARACTER: - lhs = (long) ((Character) tok.getValue()).charValue(); + lhs = ((Character) tok.getValue()).charValue(); break; case IDENTIFIER: if (warnings.contains(Warning.UNDEF)) @@ -2079,15 +2073,8 @@ public class Preprocessor implements Closeable { s = s.getParent(); } - Map<String, Macro> macros = getMacros(); - List<String> keys = new ArrayList<String>( - macros.keySet() - ); - Collections.sort(keys); - Iterator<String> mt = keys.iterator(); - while (mt.hasNext()) { - String key = mt.next(); - Macro macro = getMacro(key); + Map<String, Macro> macros = new TreeMap<String, Macro>(getMacros()); + for (Macro macro : macros.values()) { buf.append("#").append("macro ").append(macro).append("\n"); } |