diff options
author | TimePath <[email protected]> | 2014-12-28 20:40:06 +1100 |
---|---|---|
committer | Shevek <[email protected]> | 2014-12-30 19:05:54 -0800 |
commit | f511c467c74077d4254ebc69656edf2d818030dc (patch) | |
tree | 896b2a4b2ae655b95f27a59b34827e5ac09be442 /src/main | |
parent | a3306f269ec75a617f7bf4ee6a292a961ba2c1f5 (diff) |
Trim whitespace from macro parameters when a new line is detected. Fixes #25
Signed-off-by: Shevek <[email protected]>
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/anarres/cpp/MacroTokenSource.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/java/org/anarres/cpp/MacroTokenSource.java b/src/main/java/org/anarres/cpp/MacroTokenSource.java index 5874584..07c388c 100644 --- a/src/main/java/org/anarres/cpp/MacroTokenSource.java +++ b/src/main/java/org/anarres/cpp/MacroTokenSource.java @@ -78,9 +78,13 @@ import static org.anarres.cpp.Token.*; private void concat(StringBuilder buf, Argument arg) { Iterator<Token> it = arg.iterator(); + boolean newline = false; while (it.hasNext()) { Token tok = it.next(); - buf.append(tok.getText()); + String text = tok.getText(); + if (text.contains("\n")) newline = true; + if (newline) text = text.trim(); + buf.append(text); } } |