diff macro.c @ 175:ffdb0b73856f

Suppress blank lines later. Fixes the rest of the bizarre spacing behavior described in changeset 82cc6fa54b01. Expand t39 to cover more cases, too.
author David A. Holland
date Fri, 12 Jun 2015 02:38:04 -0400
parents 09cfad6772de
children 6119608a9817
line wrap: on
line diff
--- a/macro.c	Fri Jun 12 02:21:28 2015 -0400
+++ b/macro.c	Fri Jun 12 02:38:04 2015 -0400
@@ -1246,11 +1246,22 @@
 	doexpand(&mainstate, p, buf, len);
 	switch (mainstate.state) {
 	    case ES_NORMAL:
-		output(p, "\n", 1);
+		/*
+		 * If we were sent a blank line, don't emit a newline
+		 * for it. This matches the prior behavior of tradcpp.
+		 */
+		if (len > 0) {
+			output(p, "\n", 1);
+		}
 		break;
 	    case ES_WANTLPAREN:
 	    case ES_NOARG:
 	    case ES_HAVEARG:
+		/*
+		 * Apparently to match gcc's -traditional behavior we
+		 * need to emit a space for each newline that appears
+		 * while processing macro args.
+		 */
 		expand_got_ws(&mainstate, p, " ", 1);
 		break;
 	}