diff options
author | Shevek <[email protected]> | 2015-05-13 12:28:39 -0700 |
---|---|---|
committer | Shevek <[email protected]> | 2015-05-13 12:28:39 -0700 |
commit | 1bb60e9a9bc4f2f38958ca42e98134aa6dc13470 (patch) | |
tree | ae5a7d24586b9233e04e03b623fdd22a0888a744 /src | |
parent | e883399f0bb2c9a54c6d0e3565f0a753baa076b4 (diff) |
Fix #29 - line directives out by one on pop_source. Hard to unit test without a CONSUMER for #line directives.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/anarres/cpp/Preprocessor.java | 2 | ||||
-rw-r--r-- | src/test/resources/lines.c | 9 | ||||
-rw-r--r-- | src/test/resources/lines1.h | 18 | ||||
-rw-r--r-- | src/test/resources/lines2.h | 10 |
4 files changed, 38 insertions, 1 deletions
diff --git a/src/main/java/org/anarres/cpp/Preprocessor.java b/src/main/java/org/anarres/cpp/Preprocessor.java index a790813..59d8ba8 100644 --- a/src/main/java/org/anarres/cpp/Preprocessor.java +++ b/src/main/java/org/anarres/cpp/Preprocessor.java @@ -575,7 +575,7 @@ public class Preprocessor implements Closeable { /* We actually want 'did the nested source * contain a newline token', which isNumbered() * approximates. This is not perfect, but works. */ - return line_token(t.getLine() + 1, t.getName(), " 2"); + return line_token(t.getLine(), t.getName(), " 2"); } return null; diff --git a/src/test/resources/lines.c b/src/test/resources/lines.c new file mode 100644 index 0000000..e0fc75c --- /dev/null +++ b/src/test/resources/lines.c @@ -0,0 +1,9 @@ +lines-c-line-1 +#include <lines1.h> +lines-c-line-3 + +lines-c-line-5 + +#include <lines2.h> + +lines-c-line-9 diff --git a/src/test/resources/lines1.h b/src/test/resources/lines1.h new file mode 100644 index 0000000..934a3a9 --- /dev/null +++ b/src/test/resources/lines1.h @@ -0,0 +1,18 @@ + +lines1-h-line-2 + +/* multi +line +comment +*/ + +#include <lines2.h> +lines1-h-line-10 + +lines1-h-line-12 +#include <lines2.h> + +/* trailing multiline comment +with +more lines +*/ diff --git a/src/test/resources/lines2.h b/src/test/resources/lines2.h new file mode 100644 index 0000000..0a71f2f --- /dev/null +++ b/src/test/resources/lines2.h @@ -0,0 +1,10 @@ + +lines2-h-line-2 + +/* +comment + +blank and multiline*/ + +lines2-h-line-9 + |