aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/anarres/cpp/Preprocessor.java2
-rw-r--r--src/test/resources/lines.c9
-rw-r--r--src/test/resources/lines1.h18
-rw-r--r--src/test/resources/lines2.h10
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
+