summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1995-03-10 20:33:40 +0000
committerRoland McGrath <roland@redhat.com>1995-03-10 20:33:40 +0000
commit13d0eeb8e5406f03f4b5269cfdccd2ac2c81f1c5 (patch)
treef5525b9976c7fca32ccb0f790fe102667c0297db /read.c
parentd9f063656b0b3f2f4da4b67471314478b27b4373 (diff)
downloadgunmake-13d0eeb8e5406f03f4b5269cfdccd2ac2c81f1c5.tar.gz
(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.
Diffstat (limited to 'read.c')
-rw-r--r--read.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/read.c b/read.c
index 3903f78..5808044 100644
--- a/read.c
+++ b/read.c
@@ -1437,9 +1437,9 @@ record_files (filenames, pattern, pattern_percent, deps, commands_started,
one, or nil if there are none. */
char *
-find_char_unquote (string, stopchar, blank)
+find_char_unquote (string, stopchars, blank)
char *string;
- int stopchar;
+ char *stopchars;
int blank;
{
unsigned int string_len = strlen (string);
@@ -1447,19 +1447,12 @@ find_char_unquote (string, stopchar, blank)
while (1)
{
- if (blank)
- {
- while (*p != '\0' && *p != stopchar && !isblank (*p))
- ++p;
- if (*p == '\0')
- break;
- }
- else
- {
- p = index (p, stopchar);
- if (p == 0)
- break;
- }
+ while (*p != '\0' && index (stopchars, *p) == 0
+ && (!blank || !isblank (*p)))
+ ++p;
+ if (*p == '\0')
+ break;
+
if (p > string && p[-1] == '\\')
{
/* Search for more backslashes. */
@@ -1493,7 +1486,7 @@ char *
find_percent (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 #. */
@@ -1502,8 +1495,11 @@ static char *
find_semicolon (string)
char *string;
{
- return (find_char_unquote (string, '#', 0) == 0
- ? find_char_unquote (string, ';', 0) : 0);
+ 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
@@ -1531,6 +1527,9 @@ parse_file_seq (stringp, stopchar, size, strip)
register char *p = *stringp;
char *q;
char *name;
+ char stopchars[2];
+ stopchars[0] = stopchar;
+ stopchars[1] = '\0';
while (1)
{
@@ -1542,7 +1541,7 @@ parse_file_seq (stringp, stopchar, size, strip)
break;
/* Yes, find end of next name. */
q = p;
- p = find_char_unquote (q, stopchar, 1);
+ p = find_char_unquote (q, stopchars, 1);
#ifdef __MSDOS__
/* For MS-DOS, skip a "C:\...". */
if (stopchar == ':' && p != 0 && p[1] == '\\' && isalpha (p[-1]))