Use plain stat instead of safe_stat.

(find_semicolon): Function removed.
(read_makefile): Don't use find_semicolon or remove_comments for rule lines.
Use find_char_unquote directly and handle quoted comments properly.
(multi_glob): Call dir_setup_glob on our glob_t and use GLOB_ALTDIRFUNC flag.
This commit is contained in:
Roland McGrath 1995-12-12 03:31:40 +00:00
parent bfa6ab6a0c
commit e9fcf7ea88

43
read.c
View File

@ -37,7 +37,6 @@ static int read_makefile ();
static unsigned int readline (), do_define ();
static int conditional_line ();
static void record_files ();
static char *find_semicolon ();
/* A `struct linebuffer' is a structure which holds a line of text.
@ -657,9 +656,16 @@ read_makefile (filename, flags)
record_waiting_files ();
/* Look for a semicolon in the unexpanded line. */
cmdleft = find_semicolon (lb.buffer);
if (cmdleft != 0)
/* Search the line for an unquoted ; that is not after an
unquoted #. */
cmdleft = find_char_unquote (lb.buffer, ";#", 0);
if (cmdleft != 0 && *cmdleft == '#')
{
/* We found a comment before a semicolon. */
*cmdleft = '\0';
cmdleft = 0;
}
else if (cmdleft != 0)
/* Found one. Cut the line short there before expanding it. */
*cmdleft = '\0';
@ -671,15 +677,12 @@ read_makefile (filename, flags)
if (cmdleft == 0)
/* Look for a semicolon in the expanded line. */
cmdleft = find_semicolon (p);
cmdleft = find_char_unquote (p, ";", 0);
if (cmdleft != 0)
/* Cut the line short at the semicolon. */
*cmdleft = '\0';
/* Remove comments from the line. */
remove_comments (p);
p2 = next_token (p);
if (*p2 == '\0')
{
@ -1491,19 +1494,6 @@ find_percent (pattern)
{
return find_char_unquote (pattern, "%", 0);
}
/* Search STRING for an unquoted ; that is not after an unquoted #. */
static char *
find_semicolon (string)
char *string;
{
char *match = find_char_unquote (string, ";#", 0);
if (match != 0 && *match == '#')
/* We found a comment before a semicolon. No match. */
match = 0;
return match;
}
/* Parse a string into a sequence of filenames represented as a
chain of struct nameseq's in reverse order and return that chain.
@ -1822,7 +1812,7 @@ construct_include_path (arg_dirs)
dir = expanded;
}
if (safe_stat (dir, &stbuf) == 0 && S_ISDIR (stbuf.st_mode))
if (stat (dir, &stbuf) == 0 && S_ISDIR (stbuf.st_mode))
{
if (idx == max - 1)
{
@ -1839,7 +1829,7 @@ construct_include_path (arg_dirs)
/* Now add at the end the standard default dirs. */
for (i = 0; default_include_directories[i] != 0; ++i)
if (safe_stat (default_include_directories[i], &stbuf) == 0
if (stat (default_include_directories[i], &stbuf) == 0
&& S_ISDIR (stbuf.st_mode))
dirs[idx++] = default_include_directories[i];
@ -1948,13 +1938,16 @@ multi_glob (chain, size)
struct nameseq *chain;
unsigned int size;
{
extern void dir_setup_glob ();
register struct nameseq *new = 0;
register struct nameseq *old;
struct nameseq *nexto;
glob_t gl;
dir_setup_glob (&gl);
for (old = chain; old != 0; old = nexto)
{
glob_t gl;
#ifndef NO_ARCHIVES
char *memname;
#endif
@ -1988,7 +1981,7 @@ multi_glob (chain, size)
memname = 0;
#endif
switch (glob (old->name, GLOB_NOCHECK, NULL, &gl))
switch (glob (old->name, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl))
{
case 0: /* Success. */
{