ref: b5557403903f5e92a35ae7505ae38f345f5d29b2
parent: e0eed9f03d22464740c57d5baea245791ef84f23
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue May 26 05:47:25 EDT 2015
Add system dependend include paths File included that enclosed with <> are searched in a location that is implementation dependant.
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -1,5 +1,8 @@
#define INPUTSIZ 120
+#ifndef PREFIX
+#define PREFIX "/usr/"
+#endif
/*
* Definition of structures
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -383,7 +383,13 @@
static void
include(char *s)
{
- char delim, c, *p, *file;
+ char **bp, delim, c, *p, *file, buff[FILENAME_MAX];
+ char *sysinclude[] = {
+ PREFIX"/include/",
+ PREFIX"/local/include/",
+ NULL
+ };
+ size_t filelen, dirlen;
if (cppoff)
return;
@@ -399,10 +405,19 @@
cleanup(s);
if (delim == '"' && addinput(file, NULL))
return;
- abort();
-not_found:
- error("included file '%s' not found", s);
+ filelen = strlen(file);
+ for (bp = sysinclude; *bp; ++bp) {
+ dirlen = strlen(*bp);
+ if (dirlen + filelen > FILENAME_MAX)
+ continue;
+ memcpy(buff, *bp, dirlen);
+ memcpy(buff+dirlen, file, filelen);
+ if (addinput(buff, NULL))
+ return;
+ }
+ error("included file '%s' not found", file);
+
bad_include:
error("#include expects \"FILENAME\" or <FILENAME>");
}