shithub: scc

Download patch

ref: 7ae0c4ae76b0c372e6c8bb622bd8527b74159a39
parent: 0292d84f3feaf3337dba488fe975708adb50a64f
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon May 25 08:54:35 EDT 2015

Remove useless return value in cpp functions

All the functions always returrned 1, so it was very stupid
to have this value, which was useful in other versions of the
preprocessor.

--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -309,7 +309,7 @@
 	return s;
 }
 
-static bool
+static void
 define(char *s)
 {
 	char *t;
@@ -316,7 +316,7 @@
 	Symbol *sym;
 
 	if (cppoff)
-		return 1;
+		return;
 	if (!iden(&s))
 		error("#define must have an identifier as parameter");
 
@@ -331,16 +331,16 @@
 	for (t = s + strlen(s) + 1; isspace(*--t); *t = '\0')
 		/* nothing */;
 	mkdefine(s, sym);
-	return 1;
+	return;
 }
 
-static bool
+static void
 include(char *s)
 {
 	char delim, c, *p, *file;
 
 	if (cppoff)
-		return 1;
+		return;
 	if ((c = *s++) == '>')
 		delim = '>';
 	else if (c == '"')
@@ -352,7 +352,7 @@
 		goto bad_include;
 	cleanup(s);
 	if (delim == '"' && addinput(file))
-		return 1;
+		return;
 	abort();
 
 not_found:
@@ -361,7 +361,7 @@
 	error("#include expects \"FILENAME\" or <FILENAME>");
 }
 
-static bool
+static void
 line(char *s)
 {
 	char *file;
@@ -368,7 +368,7 @@
 	long n;
 
 	if (cppoff)
-		return 1;
+		return;
 	if ((n = strtol(s, &s, 10)) <= 0 || n > USHRT_MAX)
 		error("first parameter of #line is not a positive integer");
 
@@ -386,7 +386,7 @@
 	case '\0':
 	end_string:
 		setfline(n-1);
-		return 1;
+		return;
 	default:
 	bad_file:
 		error("second parameter of #line is not a valid filename");
@@ -393,23 +393,23 @@
 	}
 }
 
-static bool
+static void
 pragma(char *s)
 {
 	if (cppoff)
-		return 1;
-	return 1;
+		return;
+	return;
 }
 
-static bool
+static void
 usererr(char *s)
 {
 	if (cppoff)
-		return 1;
+		return;
 	error("#error %s", s);
 }
 
-static bool
+static void
 ifclause(char *s, int isdef)
 {
 	Symbol *sym;
@@ -426,22 +426,22 @@
 	if (!(ifstatus[n] = (sym->flags & ISDEFINED) != 0 == isdef))
 		++cppoff;
 
-	return 1;
+	return;
 }
 
-static bool
+static void
 ifdef(char *s)
 {
-	return ifclause(s, 1);
+	ifclause(s, 1);
 }
 
-static bool
+static void
 ifndef(char *s)
 {
-	return ifclause(s, 0);
+	ifclause(s, 0);
 }
 
-static bool
+static void
 endif(char *s)
 {
 	if (numif == 0)
@@ -449,10 +449,10 @@
 	cleanup(s);
 	if (!ifstatus[--numif])
 		--cppoff;
-	return 1;
+	return;
 }
 
-static bool
+static void
 elseclause(char *s)
 {
 	struct ifstatus *ip;
@@ -462,7 +462,7 @@
 	cleanup(s);
 	cppoff += (ifstatus[numif-1] ^= 1) ? -1 : 1;
 
-	return 1;
+	return;
 }
 
 bool
@@ -470,7 +470,7 @@
 {
 	static struct {
 		char *name;
-		bool (*fun)(char *);
+		void (*fun)(char *);
 	} *bp, cmds[] =  {
 		"define", define,
 		"include", include,
@@ -493,7 +493,8 @@
 	for (bp = cmds; bp->name; ++bp) {
 		if (strcmp(bp->name, yytext))
 			continue;
-		return (*bp->fun)(s);
+		(*bp->fun)(s);
+		return 1;
 	}
 incorrect:
 	error("invalid preprocessor directive #%s", yytext);