diff options
author | jbj <devnull@localhost> | 2001-01-03 20:19:27 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-01-03 20:19:27 +0000 |
commit | 23fcf67cb51b54c4c1f23188ee355dbcbfba0a28 (patch) | |
tree | f8d1a8a5a523fd6f60760b2930f99f1f18349091 /build | |
parent | fd2c1d927f4a13e0507ab929a009decdbb90c01e (diff) | |
download | rpm-23fcf67cb51b54c4c1f23188ee355dbcbfba0a28.tar.gz rpm-23fcf67cb51b54c4c1f23188ee355dbcbfba0a28.tar.bz2 rpm-23fcf67cb51b54c4c1f23188ee355dbcbfba0a28.zip |
- fix: avoid locale issues with strcasecmp/strncasecmp (#23199).
- remove almost all explicit uses of stderr in rpmlib using rpmError().
CVS patchset: 4406
CVS date: 2001/01/03 20:19:27
Diffstat (limited to 'build')
-rw-r--r-- | build/parsePreamble.c | 40 | ||||
-rw-r--r-- | build/parseSpec.c | 9 |
2 files changed, 15 insertions, 34 deletions
diff --git a/build/parsePreamble.c b/build/parsePreamble.c index 3294d4135..8c64b66d0 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -80,16 +80,11 @@ static int parseSimplePart(char *line, /*@out@*/char **name, /*@out@*/int *flag) return (strtok(NULL, " \t\n")) ? 1 : 0; } -static int parseYesNo(char *s) +static inline int parseYesNo(const char *s) { - if (!s || (s[0] == 'n' || s[0] == 'N') || - !strcasecmp(s, "false") || - !strcasecmp(s, "off") || - !strcmp(s, "0")) { - return 0; - } - - return 1; + return ((!s || (s[0] == 'n' || s[0] == 'N' || s[0] == '0') || + !xstrcasecmp(s, "false") || !xstrcasecmp(s, "off")) + ? 0 : 1); } struct tokenBits { @@ -163,26 +158,17 @@ static inline char * findLastChar(char * s) static int isMemberInEntry(Header header, const char *name, int tag) { - char **names; + const char ** names; int count; - /* - * XXX The strcasecmp below is necessary so the old (rpm < 2.90) style - * XXX os-from-uname (e.g. "Linux") is compatible with the new - * XXX os-from-platform (e.g "linux" from "sparc-*-linux"). - */ - if (headerGetEntry(header, tag, NULL, (void **)&names, &count)) { - while (count--) { - if (!strcasecmp(names[count], name)) { - FREE(names); - return 1; - } - } - FREE(names); - return 0; + if (!headerGetEntry(header, tag, NULL, (void **)&names, &count)) + return -1; + while (count--) { + if (!xstrcasecmp(names[count], name)) + break; } - - return -1; + FREE(names); + return (count >= 0 ? 1 : 0); } static int checkForValidArchitectures(Spec spec) @@ -694,7 +680,7 @@ static int findPreambleTag(Spec spec, /*@out@*/int *tag, /*@out@*/char **macro, initPreambleList(); for (p = preambleList; p->token; p++) { - if (!strncasecmp(spec->line, p->token, p->len)) + if (!xstrncasecmp(spec->line, p->token, p->len)) break; } if (p->token == NULL) diff --git a/build/parseSpec.c b/build/parseSpec.c index b27d62360..7c728c5e8 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -53,7 +53,7 @@ rpmParseState isPart(const char *line) for (p = partList; p->token != NULL; p++) { char c; - if (strncasecmp(line, p->token, p->len)) + if (xstrncasecmp(line, p->token, p->len)) continue; c = *(line + p->len); if (c == '\0' || isspace(c)) @@ -75,12 +75,7 @@ static int matchTok(const char *token, const char *line) SKIPNONSPACE(be); if (be == b) break; - /* - * XXX The strncasecmp below is necessary so the old (rpm < 2.90) style - * XXX os-from-uname (e.g. "Linux") is compatible with the new - * XXX os-from-platform (e.g "linux" from "sparc-*-linux"). - */ - if (toklen != (be-b) || strncasecmp(token, b, (be-b))) + if (toklen != (be-b) || xstrncasecmp(token, b, (be-b))) continue; rc = 1; break; |