changeset 174:09cfad6772de

Some minor cosmetic changes relating to ei->itemtype.
author David A. Holland
date Fri, 12 Jun 2015 02:21:28 -0400
parents 6ff17ab68b16
children ffdb0b73856f
files macro.c
diffstat 1 files changed, 18 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/macro.c	Fri Jun 12 02:15:43 2015 -0400
+++ b/macro.c	Fri Jun 12 02:21:28 2015 -0400
@@ -39,10 +39,10 @@
 #include "output.h"
 
 struct expansionitem {
-	enum { EI_PARAM, EI_STRING, EI_FILE, EI_LINE } itemtype;
+	enum { EI_STRING, EI_PARAM, EI_FILE, EI_LINE } itemtype;
 	union {
-		char *string;
-		unsigned param;
+		char *string;		/* EI_STRING */
+		unsigned param;		/* EI_PARAM */
 	};
 };
 DECLARRAY(expansionitem, static UNUSED);
@@ -132,8 +132,14 @@
 void
 expansionitem_destroy(struct expansionitem *ei)
 {
-	if (ei->itemtype == EI_STRING) {
+	switch (ei->itemtype) {
+	    case EI_STRING:
 		dostrfree(ei->string);
+		break;
+	    case EI_PARAM:
+	    case EI_FILE:
+	    case EI_LINE:
+		break;
 	}
 	dofree(ei, sizeof(*ei));
 }
@@ -815,17 +821,17 @@
 	for (i=0; i<num; i++) {
 		ei = expansionitemarray_get(&es->curmacro->expansion, i);
 		switch (ei->itemtype) {
-		case EI_STRING:
+		    case EI_STRING:
 			len += strlen(ei->string);
 			break;
-		case EI_PARAM:
+		    case EI_PARAM:
 			arg = stringarray_get(&es->args, ei->param);
 			len += strlen(arg);
 			break;
-		case EI_FILE:
+		    case EI_FILE:
 			len += strlen(place_getname(p)) + 2;
 			break;
-		case EI_LINE:
+		    case EI_LINE:
 			len += snprintf(numbuf, sizeof(numbuf), "%u", p->line);
 			break;
 		}
@@ -836,19 +842,19 @@
 	for (i=0; i<num; i++) {
 		ei = expansionitemarray_get(&es->curmacro->expansion, i);
 		switch (ei->itemtype) {
-		case EI_STRING:
+		    case EI_STRING:
 			strcat(ret, ei->string);
 			break;
-		case EI_PARAM:
+		    case EI_PARAM:
 			arg = stringarray_get(&es->args, ei->param);
 			strcat(ret, arg);
 			break;
-		case EI_FILE:
+		    case EI_FILE:
 			strcat(ret, "\"");
 			strcat(ret, place_getname(p));
 			strcat(ret, "\"");
 			break;
-		case EI_LINE:
+		    case EI_LINE:
 			snprintf(numbuf, sizeof(numbuf), "%u", p->line);
 			strcat(ret, numbuf);
 			break;