shithub: scc

Download patch

ref: a05cda6f2efb61fe4b42e43a2ee76f80492a4e27
parent: 57ed804790202655d6ab2ee8f2dd3a6aac75b9b5
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue May 26 05:30:09 EDT 2015

Add predefined macros

C standard defines some predefined macros that are always
present in any implementation of the language. This version
of the compiler support:
	- __STDC__
	- __DATE__
	- __TIME__
	- __STDC_HOSTED__
	- __STDC_VERSION__
	- __LINE__
	- __FILE__

At this moment __STDC__ is 1, even when we are not 100%
compatible with the standard (and we don't want to be),
but in the majority of cases the small differencies are
not signigficatives, so it is more or less safe to
declare it. In the same way, __STDC_VERSION__ is set
to 199409L, that is the value for C90 with 94
ammendents.

--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -193,7 +193,7 @@
  * is the macro definition, where @dd@ indicates the
  * parameter number dd
  */
-#define BUFSIZE ((INPUTSIZ > FILENAME_MAX+5) ? INPUTSIZ : FILENAME_MAX+5)
+#define BUFSIZE ((INPUTSIZ > FILENAME_MAX+2) ? INPUTSIZ : FILENAME_MAX+5)
 bool
 expand(Symbol *sym)
 {
@@ -202,14 +202,14 @@
 	char c, *bp, *arg, *s = sym->u.s;
 
 	if (sym == symfile) {
-		sprintf(buffer, "-1#\"%s\"", getfname());
+		sprintf(buffer, "\"%s\"", getfname());
 		strcpy(addinput(NULL, symfile), buffer);
-		return 0;
+		return 1;
 	}
 	if (sym == symline) {
-		sprintf(buffer, "-1#%d", getfline());
+		sprintf(buffer, "%d", getfline());
 		strcpy(addinput(NULL, symline), buffer);
-		return 0;
+		return 1;
 	}
 
 	lastmacro = sym;