shithub: scc

Download patch

ref: f823cb11acb2aa72f612d8ce702fd1cd1b851d14
parent: f071fe5eaccfa08807649ee69b8f8d7ee28a4505
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Aug 31 17:16:35 EDT 2015

Include stderr in DBG()

--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -218,12 +218,12 @@
 	if (!parsepars(arguments, arglist, atoi(s)))
 		return 0;
 	for (n = 0; n < atoi(s); ++n)
-		DBG(stderr, "MACRO par%d:%s\n", n, arglist[n]);
+		DBG("MACRO par%d:%s\n", n, arglist[n]);
 
 	elen = copymacro(buffer, s+3, INPUTSIZ-1, arglist);
 
 substitute:
-	DBG(stderr, "MACRO '%s' expanded to :'%s'\n", macroname, buffer);
+	DBG("MACRO '%s' expanded to :'%s'\n", macroname, buffer);
 	rlen = strlen(input->p);      /* rigth length */
 	llen = begin - input->line;   /* left length */
 	ilen = input->p - begin;      /* invocation length */
@@ -352,7 +352,7 @@
 	if (!getdefs(args, n, buff+3, LINESIZ-3))
 		goto delete;
 	sym->u.s = xstrdup(buff);
-	DBG(stderr, "MACRO '%s' defined as '%s'\n", sym->name, buff);
+	DBG("MACRO '%s' defined as '%s'\n", sym->name, buff);
 	return;
 
 delete:
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -407,7 +407,7 @@
 		tp->p.fields = NULL;
 		sym->type = tp;
 		tp->tag = sym;
-		DBG(stderr, "declared tag '%s' with ns = %d\n",
+		DBG("declared tag '%s' with ns = %d\n",
 		    (sym->name) ? sym->name : "anonymous", tp->ns);
 	}
 
@@ -546,7 +546,7 @@
 	sym->flags |= ISFIELD;
 	if (n == NR_FIELDS)
 		error("too much fields in struct/union");
-	DBG(stderr, "New field '%s' in namespace %d\n", name, structp->ns);
+	DBG("New field '%s' in namespace %d\n", name, structp->ns);
 	structp->p.fields = xrealloc(structp->p.fields, ++n * sizeof(*sym));
 	structp->p.fields[n-1] = sym;
 	structp->n.elem = n;
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -531,7 +531,7 @@
 		yytoken = operator();
 
 exit:
-	DBG(stderr, "TOKEN %s\n", yytext);
+	DBG("TOKEN %s\n", yytext);
 	return yytoken;
 }
 
--- a/inc/cc.h
+++ b/inc/cc.h
@@ -8,7 +8,7 @@
 #endif
 
 #ifndef NDEBUG
-#define DBG(...) fprintf(__VA_ARGS__)
+#define DBG(...) fprintf(stderr, __VA_ARGS__)
 #else
 #define DBG(...)
 #endif