changeset 66:f8507e5ed84c

Recognize directive lines only when the # is exactly in column 0. This is the traditional behavior and Joerg's convinced me it's important to retain it.
author David A. Holland
date Sun, 31 Mar 2013 10:47:08 -0400
parents 161edab0d361
children ca5e4e0237f5
files directive.c tests/Makefile tests/t21.c tests/t21.good
diffstat 4 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/directive.c	Sun Mar 31 02:18:24 2013 -0400
+++ b/directive.c	Sun Mar 31 10:47:08 2013 -0400
@@ -571,12 +571,11 @@
 		p->column += acomm;
 	}
 
-	/* check if we have a directive line */
-	skip = strspn(line + acomm, ws);
-	if (acomm == 0 && line[skip] == '#') {
+	/* check if we have a directive line (# exactly in column 0) */
+	if (acomm == 0 && line[0] == '#') {
 		char ch;
 
-		skip = skip + 1 + strspn(line + skip + 1, ws);
+		skip = 1 + strspn(line + 1, ws);
 		assert(skip <= text);
 		p->column += skip;
 		assert(line[len] == '\0');
--- a/tests/Makefile	Sun Mar 31 02:18:24 2013 -0400
+++ b/tests/Makefile	Sun Mar 31 10:47:08 2013 -0400
@@ -3,7 +3,7 @@
 
 TESTS=\
 	t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 t16 \
-	t17 t18 t19 t20
+	t17 t18 t19 t20 t21
 
 all: run-tests .WAIT show-diffs
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t21.c	Sun Mar 31 10:47:08 2013 -0400
@@ -0,0 +1,3 @@
+# define FOO BAR
+ #undef FOO /* would be wrong */
+FOO
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t21.good	Sun Mar 31 10:47:08 2013 -0400
@@ -0,0 +1,2 @@
+ #undef BAR 
+BAR