(find_char_unquote): Make second arg a string of stop chars instead of a

single stop char.  Stop when any char in the string is hit.
All callers changed.
(find_semicolon): Pass stop chars "#;" to one find_char_unquote call,
instead of using two calls.  If the match is not a ; but a #, return zero.
This commit is contained in:
Roland McGrath 1995-03-10 20:33:40 +00:00
parent d9f063656b
commit 13d0eeb8e5

37
read.c
View File

@ -1437,9 +1437,9 @@ record_files (filenames, pattern, pattern_percent, deps, commands_started,
one, or nil if there are none. */ one, or nil if there are none. */
char * char *
find_char_unquote (string, stopchar, blank) find_char_unquote (string, stopchars, blank)
char *string; char *string;
int stopchar; char *stopchars;
int blank; int blank;
{ {
unsigned int string_len = strlen (string); unsigned int string_len = strlen (string);
@ -1447,19 +1447,12 @@ find_char_unquote (string, stopchar, blank)
while (1) while (1)
{ {
if (blank) while (*p != '\0' && index (stopchars, *p) == 0
{ && (!blank || !isblank (*p)))
while (*p != '\0' && *p != stopchar && !isblank (*p)) ++p;
++p; if (*p == '\0')
if (*p == '\0') break;
break;
}
else
{
p = index (p, stopchar);
if (p == 0)
break;
}
if (p > string && p[-1] == '\\') if (p > string && p[-1] == '\\')
{ {
/* Search for more backslashes. */ /* Search for more backslashes. */
@ -1493,7 +1486,7 @@ char *
find_percent (pattern) find_percent (pattern)
char *pattern; char *pattern;
{ {
return find_char_unquote (pattern, '%', 0); return find_char_unquote (pattern, "%", 0);
} }
/* Search STRING for an unquoted ; that is not after an unquoted #. */ /* Search STRING for an unquoted ; that is not after an unquoted #. */
@ -1502,8 +1495,11 @@ static char *
find_semicolon (string) find_semicolon (string)
char *string; char *string;
{ {
return (find_char_unquote (string, '#', 0) == 0 char *match = find_char_unquote (string, ";#", 0);
? find_char_unquote (string, ';', 0) : 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 /* Parse a string into a sequence of filenames represented as a
@ -1531,6 +1527,9 @@ parse_file_seq (stringp, stopchar, size, strip)
register char *p = *stringp; register char *p = *stringp;
char *q; char *q;
char *name; char *name;
char stopchars[2];
stopchars[0] = stopchar;
stopchars[1] = '\0';
while (1) while (1)
{ {
@ -1542,7 +1541,7 @@ parse_file_seq (stringp, stopchar, size, strip)
break; break;
/* Yes, find end of next name. */ /* Yes, find end of next name. */
q = p; q = p;
p = find_char_unquote (q, stopchar, 1); p = find_char_unquote (q, stopchars, 1);
#ifdef __MSDOS__ #ifdef __MSDOS__
/* For MS-DOS, skip a "C:\...". */ /* For MS-DOS, skip a "C:\...". */
if (stopchar == ':' && p != 0 && p[1] == '\\' && isalpha (p[-1])) if (stopchar == ':' && p != 0 && p[1] == '\\' && isalpha (p[-1]))