diff options
author | Paul Smith <psmith@gnu.org> | 1999-10-15 07:00:58 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 1999-10-15 07:00:58 +0000 |
commit | 3e26bde6dbc9a8a46d5a1a694e6810e689cbd25a (patch) | |
tree | 20d000099ba9c0723a3c4d8925adba97aee4f2dc /read.c | |
parent | c71200d0229f75fe99d508dd3aea013ceba4d32e (diff) | |
download | gunmake-3e26bde6dbc9a8a46d5a1a694e6810e689cbd25a.tar.gz |
* Fix PR/1394.
* Apply changes from Paul Eggert.
* Many other cleanups (index/rindex --> strchr/strrchr, etc.)
Diffstat (limited to 'read.c')
-rw-r--r-- | read.c | 60 |
1 files changed, 31 insertions, 29 deletions
@@ -177,9 +177,9 @@ read_all_makefiles (makefiles) while ((name = find_next_token (&p, &length)) != 0) { - name = xstrdup (name); if (*p != '\0') *p++ = '\0'; + name = xstrdup (name); if (read_makefile (name, RM_NO_DEFAULT_GOAL|RM_INCLUDED|RM_DONTCARE) < 2) free (name); @@ -478,7 +478,7 @@ read_makefile (filename, flags) /* Compare a word, both length and contents. */ #define word1eq(s, l) (len == l && strneq (s, p, l)) p = collapsed; - while (isspace (*p)) + while (isspace ((unsigned char)*p)) ++p; if (*p == '\0') /* This line is completely empty. */ @@ -488,7 +488,7 @@ read_makefile (filename, flags) * ":" here since we compare tokens by length (so "export" will never * be equal to "export:"). */ - for (p2 = p+1; *p2 != '\0' && !isspace(*p2); ++p2) + for (p2 = p+1; *p2 != '\0' && !isspace ((unsigned char)*p2); ++p2) {} len = p2 - p; @@ -496,7 +496,7 @@ read_makefile (filename, flags) since it can't be a preprocessor token--this allows targets named `ifdef', `export', etc. */ reading_target = 0; - while (isspace (*p2)) + while (isspace ((unsigned char)*p2)) ++p2; if (*p2 == '\0') p2 = NULL; @@ -546,7 +546,7 @@ read_makefile (filename, flags) with trailing blanks stripped (comments have already been removed), so it could be a complex variable/function reference that might contain blanks. */ - p = index (p2, '\0'); + p = strchr (p2, '\0'); while (isblank (p[-1])) --p; do_define (p2, p - p2, o_file, infile, &fileinfo); @@ -573,7 +573,7 @@ read_makefile (filename, flags) with trailing blanks stripped (comments have already been removed), so it could be a complex variable/function reference that might contain blanks. */ - p = index (p2, '\0'); + p = strchr (p2, '\0'); while (isblank (p[-1])) --p; do_define (p2, p - p2, o_override, infile, &fileinfo); @@ -837,8 +837,8 @@ read_makefile (filename, flags) are whitespace and a left paren. If others are possible, they should be added to the string in the call to index. */ while (colonp && (colonp[1] == '/' || colonp[1] == '\\') && - colonp > p2 && isalpha(colonp[-1]) && - (colonp == p2 + 1 || index(" \t(", colonp[-2]) != 0)) + colonp > p2 && isalpha ((unsigned char)colonp[-1]) && + (colonp == p2 + 1 || strchr (" \t(", colonp[-2]) != 0)) colonp = find_char_unquote(colonp + 1, ":", 0); #endif if (colonp != 0) @@ -957,7 +957,7 @@ read_makefile (filename, flags) } /* Is this a static pattern rule: `target: %targ: %dep; ...'? */ - p = index (p2, ':'); + p = strchr (p2, ':'); while (p != 0 && p[-1] == '\\') { register char *q = &p[-1]; @@ -965,7 +965,7 @@ read_makefile (filename, flags) while (*q-- == '\\') backslash = !backslash; if (backslash) - p = index (p + 1, ':'); + p = strchr (p + 1, ':'); else break; } @@ -982,7 +982,8 @@ read_makefile (filename, flags) The rule is that it's only a target, if there are TWO :'s OR a space around the :. */ - if (p && !(isspace(p[1]) || !p[1] || isspace(p[-1]))) + if (p && !(isspace ((unsigned char)p[1]) || !p[1] + || isspace ((unsigned char)p[-1]))) p = 0; #endif #if defined (WINDOWS32) || defined (__MSDOS__) @@ -990,9 +991,9 @@ read_makefile (filename, flags) check_again = 0; /* For MSDOS and WINDOWS32, skip a "C:\..." or a "C:/..." */ if (p != 0 && (p[1] == '\\' || p[1] == '/') && - isalpha(p[-1]) && - (p == p2 + 1 || index(" \t:(", p[-2]) != 0)) { - p = index(p + 1, ':'); + isalpha ((unsigned char)p[-1]) && + (p == p2 + 1 || strchr (" \t:(", p[-2]) != 0)) { + p = strchr (p + 1, ':'); check_again = 1; } } while (check_again); @@ -1741,9 +1742,9 @@ record_files (filenames, pattern, pattern_percent, deps, cmds_started, /* See if this is first target seen whose name does not start with a `.', unless it contains a slash. */ if (default_goal_file == 0 && set_default - && (*name != '.' || index (name, '/') != 0 + && (*name != '.' || strchr (name, '/') != 0 #if defined(__MSDOS__) || defined(WINDOWS32) - || index (name, '\\') != 0 + || strchr (name, '\\') != 0 #endif )) { @@ -1806,7 +1807,7 @@ find_char_unquote (string, stopchars, blank) while (1) { - while (*p != '\0' && index (stopchars, *p) == 0 + while (*p != '\0' && strchr (stopchars, *p) == 0 && (!blank || !isblank (*p))) ++p; if (*p == '\0') @@ -1905,8 +1906,9 @@ parse_file_seq (stringp, stopchar, size, strip) *p =' '; #endif #ifdef _AMIGA - if (stopchar == ':' && p && *p == ':' && - !(isspace(p[1]) || !p[1] || isspace(p[-1]))) + if (stopchar == ':' && p && *p == ':' + && !(isspace ((unsigned char)p[1]) || !p[1] + || isspace ((unsigned char)p[-1]))) { p = find_char_unquote (p+1, stopchars, 1); } @@ -1917,8 +1919,8 @@ parse_file_seq (stringp, stopchar, size, strip) Note that tokens separated by spaces should be treated as separate tokens since make doesn't allow path names with spaces */ if (stopchar == ':') - while (p != 0 && !isspace(*p) && - (p[1] == '\\' || p[1] == '/') && isalpha (p[-1])) + while (p != 0 && !isspace ((unsigned char)*p) && + (p[1] == '\\' || p[1] == '/') && isalpha ((unsigned char)p[-1])) p = find_char_unquote (p + 1, stopchars, 1); #endif if (p == 0) @@ -2000,14 +2002,14 @@ parse_file_seq (stringp, stopchar, size, strip) while (new1 != 0) if (new1->name[0] != '(' /* Don't catch "(%)" and suchlike. */ && new1->name[strlen (new1->name) - 1] == ')' - && index (new1->name, '(') == 0) + && strchr (new1->name, '(') == 0) { /* NEW1 ends with a `)' but does not contain a `('. Look back for an elt with an opening `(' but no closing `)'. */ struct nameseq *n = new1->next, *lastn = new1; char *paren = 0; - while (n != 0 && (paren = index (n->name, '(')) == 0) + while (n != 0 && (paren = strchr (n->name, '(')) == 0) { lastn = n; n = n->next; @@ -2288,7 +2290,7 @@ get_next_mword (buffer, delim, startp, length) } default: - if (delim && index(delim, c)) + if (delim && strchr (delim, c)) wtype = w_static; break; } @@ -2325,9 +2327,9 @@ get_next_mword (buffer, delim, startp, length) /* A word CAN include a colon in its drive spec. The drive spec is allowed either at the beginning of a word, or as part of the archive member name, like in "libfoo.a(d:/foo/bar.o)". */ - if (!(p - beg >= 2 && - (*p == '/' || *p == '\\') && isalpha (p[-2]) && - (p - beg == 2 || p[-3] == '('))) + if (!(p - beg >= 2 + && (*p == '/' || *p == '\\') && isalpha ((unsigned char)p[-2]) + && (p - beg == 2 || p[-3] == '('))) #endif goto done_word; @@ -2379,7 +2381,7 @@ get_next_mword (buffer, delim, startp, length) break; default: - if (delim && index(delim, c)) + if (delim && strchr (delim, c)) goto done_word; break; } @@ -2550,7 +2552,7 @@ tilde_expand (name) else { struct passwd *pwent; - char *userend = index (name + 1, '/'); + char *userend = strchr (name + 1, '/'); if (userend != 0) *userend = '\0'; pwent = getpwnam (name + 1); |