changeset 145:a403605d3166

Fix handling of macros in quoted strings. Add some more tests; edit CHANGES a bit.
author David A. Holland
date Sat, 13 Jul 2013 14:19:59 -0400
parents 7ab3d0c09cd8
children 15f51ed08ecf
files CHANGES TODO macro.c tests/Makefile tests/t26.c tests/t26.good tests/t32.c tests/t32.good tests/t33.c tests/t33.good
diffstat 10 files changed, 56 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES	Sat Jul 13 13:54:07 2013 -0400
+++ b/CHANGES	Sat Jul 13 14:19:59 2013 -0400
@@ -1,9 +1,12 @@
 pending
    - Fix stupid build problem introduced in 0.3.1.
-   - Accept and ignore -m32. I thought this had already been done, but
-     apparently not.
+   - Accept and ignore -m32, which imake issues willy-nilly on a bunch
+     of platforms. I thought this had already been done, but apparently
+     not.
    - Don't use the <err.h> functions. There are still people out there
-     using legacy systems that are missing them.
+     using legacy systems missing them.
+   - Sort out some more issues pertaining to handling quoted strings.
+   - Add some more tests.
 
 release 0.3.1 (20130709)
    - Don't leak memory and assert if a bad command-line option comes
--- a/TODO	Sat Jul 13 13:54:07 2013 -0400
+++ b/TODO	Sat Jul 13 14:19:59 2013 -0400
@@ -21,4 +21,3 @@
 	- "#if 0 && 1/0" should not crash; fix eval method.
 	- an unterminated comment is reported as "no newline at end of file"
 	  (which isn't fatal by default)
-	- the behavior of t26 is different here and in gcc -E -traditional
--- a/macro.c	Sat Jul 13 13:54:07 2013 -0400
+++ b/macro.c	Sat Jul 13 14:19:59 2013 -0400
@@ -1088,7 +1088,7 @@
 			x = len;
 		}
 
-		if (x > 0) {
+		if (!inquote && x > 0) {
 			expand_got_word(es, p, buf, x);
 			buf += x;
 			len -= x;
--- a/tests/Makefile	Sat Jul 13 13:54:07 2013 -0400
+++ b/tests/Makefile	Sat Jul 13 14:19:59 2013 -0400
@@ -3,7 +3,8 @@
 
 TESTS=\
 	t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 t16 \
-	t17 t18 t19 t20 t21 t22 t23 t24 t25 t26 t27 t28 t29 t30 t31
+	t17 t18 t19 t20 t21 t22 t23 t24 t25 t26 t27 t28 t29 t30 t31 t32 \
+	t33
 
 all: run-tests .WAIT show-diffs
 
--- a/tests/t26.c	Sat Jul 13 13:54:07 2013 -0400
+++ b/tests/t26.c	Sat Jul 13 14:19:59 2013 -0400
@@ -1,2 +1,4 @@
 #define FOO foo
+FOO
 "FOO"
+'FOO'
--- a/tests/t26.good	Sat Jul 13 13:54:07 2013 -0400
+++ b/tests/t26.good	Sat Jul 13 14:19:59 2013 -0400
@@ -1,1 +1,3 @@
-"foo"
+foo
+"FOO"
+'FOO'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t32.c	Sat Jul 13 14:19:59 2013 -0400
@@ -0,0 +1,21 @@
+#define foo(x) "x"
+#define bar(x) 'x'
+#define baz frob
+foo(3)
+bar(3)
+foo(baz)
+bar(baz)
+"baz"
+'baz'
+"foo(baz)"
+"bar(baz)"
+
+#define foo2(x) foo(x)
+#define bar2(x) bar(x)
+foo2(baz)
+bar2(baz)
+
+#define foo3(x) foo2(x)
+#define bar3(x) bar2(x)
+foo3(baz)
+bar3(baz)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t32.good	Sat Jul 13 14:19:59 2013 -0400
@@ -0,0 +1,12 @@
+"3"
+'3'
+"baz"
+'baz'
+"baz"
+'baz'
+"foo(baz)"
+"bar(baz)"
+"baz"
+'baz'
+"baz"
+'baz'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t33.c	Sat Jul 13 14:19:59 2013 -0400
@@ -0,0 +1,6 @@
+/* make sure that R gets defined and doesn't end up part of a string */
+#define Q "
+#define R r
+#define S "
+R
+Q
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t33.good	Sat Jul 13 14:19:59 2013 -0400
@@ -0,0 +1,3 @@
+
+r
+"