changeset 162:82cc6fa54b01

newline during a macro invocation counts as space. Behavior differs from GCC in that empty lines in the argument list are still suppressed.
author Joerg Sonnenberger <joerg@bec.de>
date Fri, 27 Feb 2015 02:53:12 +0100
parents 4a4b3d5c41fa
children e1dfa3f90b6c
files macro.c tests/Makefile tests/t39.c tests/t39.good
diffstat 4 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/macro.c	Fri Feb 27 02:48:26 2015 +0100
+++ b/macro.c	Fri Feb 27 02:53:12 2015 +0100
@@ -1258,7 +1258,16 @@
 macro_sendline(struct place *p, char *buf, size_t len)
 {
 	doexpand(&mainstate, p, buf, len);
-	output(p, "\n", 1);
+	switch (mainstate.state) {
+	    case ES_NORMAL:
+		output(p, "\n", 1);
+		break;
+	    case ES_WANTLPAREN:
+	    case ES_NOARG:
+	    case ES_HAVEARG:
+		expand_got_ws(&mainstate, p, " ", 1);
+		break;
+	}
 }
 
 void
--- a/tests/Makefile	Fri Feb 27 02:48:26 2015 +0100
+++ b/tests/Makefile	Fri Feb 27 02:53:12 2015 +0100
@@ -4,7 +4,7 @@
 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 t32 \
-	t33 t34 t35 t36 t37 t38
+	t33 t34 t35 t36 t37 t38 t39
 
 all: run-tests .WAIT show-diffs
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t39.c	Fri Feb 27 02:53:12 2015 +0100
@@ -0,0 +1,3 @@
+#define m(a,b) a::b
+=m(123,
+456)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/t39.good	Fri Feb 27 02:53:12 2015 +0100
@@ -0,0 +1,1 @@
+=123:: 456