version 1.115, 2015/12/22 21:50:54 |
version 1.116, 2016/05/13 12:18:11 |
|
|
#define ParseReadLoopLine(linebuf) Parse_ReadUnparsedLine(linebuf, "for loop") |
#define ParseReadLoopLine(linebuf) Parse_ReadUnparsedLine(linebuf, "for loop") |
static bool handle_bsd_command(Buffer, Buffer, const char *); |
static bool handle_bsd_command(Buffer, Buffer, const char *); |
static char *strip_comments(Buffer, const char *); |
static char *strip_comments(Buffer, const char *); |
static char *resolve_include_filename(const char *, bool); |
static char *resolve_include_filename(const char *, const char *, bool); |
static void handle_include_file(const char *, const char *, bool, bool); |
static void handle_include_file(const char *, const char *, bool, bool); |
static bool lookup_bsd_include(const char *); |
static bool lookup_bsd_include(const char *); |
static void lookup_sysv_style_include(const char *, const char *, bool); |
static void lookup_sysv_style_include(const char *, const char *, bool); |
|
|
} |
} |
|
|
static char * |
static char * |
resolve_include_filename(const char *file, bool isSystem) |
resolve_include_filename(const char *file, const char *efile, bool isSystem) |
{ |
{ |
char *fullname; |
char *fullname; |
|
|
/* Look up system files on the system path first */ |
/* Look up system files on the system path first */ |
if (isSystem) { |
if (isSystem) { |
fullname = Dir_FindFileNoDot(file, systemIncludePath); |
fullname = Dir_FindFileNoDoti(file, efile, systemIncludePath); |
if (fullname) |
if (fullname) |
return fullname; |
return fullname; |
} |
} |
|
|
if (slash != NULL) { |
if (slash != NULL) { |
char *newName; |
char *newName; |
|
|
newName = Str_concati(fname, slash, file, |
newName = Str_concati(fname, slash, file, efile, '/'); |
strchr(file, '\0'), '/'); |
|
fullname = Dir_FindFile(newName, userIncludePath); |
fullname = Dir_FindFile(newName, userIncludePath); |
if (fullname == NULL) |
if (fullname == NULL) |
fullname = Dir_FindFile(newName, defaultPath); |
fullname = Dir_FindFile(newName, defaultPath); |
|
|
/* Now look first on the -I search path, then on the .PATH |
/* Now look first on the -I search path, then on the .PATH |
* search path, if not found in a -I directory. |
* search path, if not found in a -I directory. |
* XXX: Suffix specific? */ |
* XXX: Suffix specific? */ |
fullname = Dir_FindFile(file, userIncludePath); |
fullname = Dir_FindFilei(file, efile, userIncludePath); |
if (fullname) |
if (fullname) |
return fullname; |
return fullname; |
fullname = Dir_FindFile(file, defaultPath); |
fullname = Dir_FindFilei(file, efile, defaultPath); |
if (fullname) |
if (fullname) |
return fullname; |
return fullname; |
|
|
|
|
if (isSystem) |
if (isSystem) |
return NULL; |
return NULL; |
else |
else |
return Dir_FindFile(file, systemIncludePath); |
return Dir_FindFilei(file, efile, systemIncludePath); |
} |
} |
|
|
static void |
static void |
handle_include_file(const char *name, const char *ename, bool isSystem, |
handle_include_file(const char *file, const char *efile, bool isSystem, |
bool errIfNotFound) |
bool errIfNotFound) |
{ |
{ |
char *file; |
|
char *fullname; |
char *fullname; |
|
|
/* Substitute for any variables in the file name before trying to |
fullname = resolve_include_filename(file, efile, isSystem); |
* find the thing. */ |
|
file = Var_Substi(name, ename, NULL, false); |
|
|
|
fullname = resolve_include_filename(file, isSystem); |
|
if (fullname == NULL && errIfNotFound) |
if (fullname == NULL && errIfNotFound) |
Parse_Error(PARSE_FATAL, "Could not find %s", file); |
Parse_Error(PARSE_FATAL, "Could not find %.*s", |
free(file); |
(int)(efile - file), file); |
|
|
|
|
if (fullname != NULL) { |
if (fullname != NULL) { |
FILE *f; |
FILE *f; |
|
|
|
|
{ |
{ |
char endc; |
char endc; |
const char *efile; |
const char *efile; |
|
char *file2; |
bool isSystem; |
bool isSystem; |
|
|
/* find starting delimiter */ |
/* find starting delimiter */ |
|
|
return false; |
return false; |
} |
} |
} |
} |
handle_include_file(file, efile, isSystem, true); |
/* Substitute for any variables in the file name before trying to |
|
* find the thing. */ |
|
file2 = Var_Substi(file, efile, NULL, false); |
|
handle_include_file(file2, strchr(file2, '\0'), isSystem, true); |
|
free(file2); |
return true; |
return true; |
} |
} |
|
|
|
|
static void |
static void |
lookup_sysv_style_include(const char *file, const char *directive, |
lookup_sysv_style_include(const char *line, const char *directive, |
bool errIfMissing) |
bool errIfMissing) |
{ |
{ |
const char *efile; |
char *file; |
|
char *name; |
|
char *ename; |
|
bool okay = false; |
|
|
/* find beginning of name */ |
/* Substitute for any variables in the file name before trying to |
while (ISSPACE(*file)) |
* find the thing. */ |
file++; |
file = Var_Subst(line, NULL, false); |
if (*file == '\0') { |
|
Parse_Error(PARSE_FATAL, "Filename missing from \"%s\"", |
/* sys5 allows for list of files separated by spaces */ |
directive); |
name = file; |
return; |
while (1) { |
|
/* find beginning of name */ |
|
while (ISSPACE(*name)) |
|
name++; |
|
if (*name == '\0') |
|
break; |
|
for (ename = name; *ename != '\0' && !ISSPACE(*ename);) |
|
ename++; |
|
handle_include_file(name, ename, true, errIfMissing); |
|
okay = true; |
|
name = ename; |
} |
} |
/* sys5 delimits file up to next blank character or end of line */ |
|
for (efile = file; *efile != '\0' && !ISSPACE(*efile);) |
|
efile++; |
|
|
|
handle_include_file(file, efile, true, errIfMissing); |
free(file); |
|
if (!okay) { |
|
Parse_Error(PARSE_FATAL, "Filename missing from \"%s\"", |
|
directive); |
|
} |
} |
} |
|
|
|
|