diff options
author | Martijn van Duren <martijn@cvs.openbsd.org> | 2018-09-17 16:00:20 +0000 |
---|---|---|
committer | Martijn van Duren <martijn@cvs.openbsd.org> | 2018-09-17 16:00:20 +0000 |
commit | dcbb691c127251bbdb748652e2da444c0c5fd5b0 (patch) | |
tree | 886557beceb16799a643af0be543ef28ec898a0d /bin/csh | |
parent | 5505dec671be5c77fdf906fe64db738575dba646 (diff) |
Replace any() with strchr(3).
OK millert@ and miko@
Diffstat (limited to 'bin/csh')
-rw-r--r-- | bin/csh/dol.c | 14 | ||||
-rw-r--r-- | bin/csh/exec.c | 8 | ||||
-rw-r--r-- | bin/csh/exp.c | 7 | ||||
-rw-r--r-- | bin/csh/extern.h | 3 | ||||
-rw-r--r-- | bin/csh/lex.c | 20 | ||||
-rw-r--r-- | bin/csh/misc.c | 13 | ||||
-rw-r--r-- | bin/csh/parse.c | 12 | ||||
-rw-r--r-- | bin/csh/set.c | 7 | ||||
-rw-r--r-- | bin/csh/time.c | 5 |
9 files changed, 40 insertions, 49 deletions
diff --git a/bin/csh/dol.c b/bin/csh/dol.c index 593b1ba3e88..efe27bdc5e1 100644 --- a/bin/csh/dol.c +++ b/bin/csh/dol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dol.c,v 1.22 2018/09/08 01:28:39 miko Exp $ */ +/* $OpenBSD: dol.c,v 1.23 2018/09/17 16:00:19 martijn Exp $ */ /* $NetBSD: dol.c,v 1.8 1995/09/27 00:38:38 jtc Exp $ */ /*- @@ -541,7 +541,7 @@ Dgetdol(void) for (i = 0; Isdigit(*np); i = i * 10 + *np++ - '0') continue; - if ((i < 0 || i > upb) && !any("-*", *np)) { + if ((i < 0 || i > upb) && !strchr("-*", *np)) { dolerror(vp->v_name); return; } @@ -642,7 +642,7 @@ fixDolMod(void) dolmod[dolnmod++] = delim; if (!delim || letter(delim) - || Isdigit(delim) || any(" \t\n", delim)) { + || Isdigit(delim) || strchr(" \t\n", delim)) { seterror(ERR_BADSUBST); break; } @@ -657,7 +657,7 @@ fixDolMod(void) } continue; } - if (!any("htrqxes", c)) + if (!strchr("htrqxes", c)) stderror(ERR_BADMOD, c); dolmod[dolnmod++] = c; if (c == 'q') @@ -691,7 +691,7 @@ setDolp(Char *cp) delim = dolmod[++i]; if (!delim || letter(delim) - || Isdigit(delim) || any(" \t\n", delim)) { + || Isdigit(delim) || strchr(" \t\n", delim)) { seterror(ERR_BADSUBST); break; } @@ -901,7 +901,7 @@ heredoc(Char *term) /* \ quotes \ $ ` here */ if (c == '\\') { c = DgetC(0); - if (!any("$\\`", c)) + if (!strchr("$\\`", c)) unDgetC(c | QUOTE), c = '\\'; else c |= QUOTE; @@ -918,7 +918,7 @@ heredoc(Char *term) * If any ` in line do command substitution */ mbp = mbuf; - if (any(short2str(mbp), '`')) { + if (strchr(short2str(mbp), '`')) { /* * 1 arg to dobackp causes substitution to be literal. Words are * broken only at newlines so that all blanks and tabs are diff --git a/bin/csh/exec.c b/bin/csh/exec.c index fe12855f7a2..774eaa314df 100644 --- a/bin/csh/exec.c +++ b/bin/csh/exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec.c,v 1.19 2015/12/26 13:48:38 mestre Exp $ */ +/* $OpenBSD: exec.c,v 1.20 2018/09/17 16:00:19 martijn Exp $ */ /* $NetBSD: exec.c,v 1.9 1996/09/30 20:03:54 christos Exp $ */ /*- @@ -137,7 +137,7 @@ doexec(Char **v, struct command *t) blkfree(pv); pexerr(); } - slash = any(short2str(expath), '/'); + slash = (bool) strchr(short2str(expath), '/'); /* * Glob the argument list, if necessary. Otherwise trim off the quote bits. @@ -492,7 +492,7 @@ iscommand(Char *name) Char **pv; Char *sav; struct varent *v; - bool slash = any(short2str(name), '/'); + bool slash = (bool) strchr(short2str(name), '/'); int hashval = 0, hashval1, i; v = adrof(STRpath); @@ -680,7 +680,7 @@ tellmewhat(struct wordent *lexp, Char *str, int len) if ((i = iscommand(sp->word)) != 0) { Char **pv; struct varent *v; - bool slash = any(short2str(sp->word), '/'); + bool slash = (bool) strchr(short2str(sp->word), '/'); v = adrof(STRpath); if (v == 0 || v->vec[0] == 0 || slash) diff --git a/bin/csh/exp.c b/bin/csh/exp.c index 33c4d817f91..9ed891047c6 100644 --- a/bin/csh/exp.c +++ b/bin/csh/exp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exp.c,v 1.16 2015/12/26 13:48:38 mestre Exp $ */ +/* $OpenBSD: exp.c,v 1.17 2018/09/17 16:00:19 martijn Exp $ */ /* $NetBSD: exp.c,v 1.6 1995/03/21 09:02:51 cgd Exp $ */ /*- @@ -36,6 +36,7 @@ #include <stdlib.h> #include <unistd.h> #include <stdarg.h> +#include <string.h> #include "csh.h" #include "extern.h" @@ -238,7 +239,7 @@ exp3a(Char ***vp, bool ignore) p1 = exp4(vp, ignore); op = **vp; - if (op && any("<>", op[0]) && op[0] == op[1]) { + if (op && strchr("<>", op[0]) && op[0] == op[1]) { (*vp)++; p2 = exp3a(vp, ignore); if (op[0] == '<') @@ -392,7 +393,7 @@ exp6(Char ***vp, bool ignore) if (isa(**vp, ANYOP)) return (Strsave(STRNULL)); cp = *(*vp)++; - if (*cp == '-' && any("erwxfdzopls", cp[1])) { + if (*cp == '-' && strchr("erwxfdzopls", cp[1])) { struct stat stb; if (cp[2] != '\0') diff --git a/bin/csh/extern.h b/bin/csh/extern.h index 8cc67947a80..8a72e9e499f 100644 --- a/bin/csh/extern.h +++ b/bin/csh/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.27 2018/09/15 12:15:32 miko Exp $ */ +/* $OpenBSD: extern.h,v 1.28 2018/09/17 16:00:19 martijn Exp $ */ /* $NetBSD: extern.h,v 1.8 1996/10/31 23:50:54 christos Exp $ */ /*- @@ -181,7 +181,6 @@ void unreadc(int); /* * misc.c */ -int any(char *, int); Char **blkcat(Char **, Char **); Char **blkcpy(Char **, Char **); Char **blkend(Char **); diff --git a/bin/csh/lex.c b/bin/csh/lex.c index 542708c2e7c..a26d0a79448 100644 --- a/bin/csh/lex.c +++ b/bin/csh/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.25 2017/08/30 07:54:54 anton Exp $ */ +/* $OpenBSD: lex.c,v 1.26 2018/09/17 16:00:19 martijn Exp $ */ /* $NetBSD: lex.c,v 1.9 1995/09/27 00:38:46 jtc Exp $ */ /*- @@ -406,7 +406,7 @@ getdol(void) np = name, *np++ = '$'; c = sc = getC(DOEXCL); - if (any("\t \n", c)) { + if (strchr("\t \n", c)) { ungetD(c); ungetC('$' | QUOTE); return; @@ -550,7 +550,7 @@ getdol(void) *np++ = delim; if (!delim || letter(delim) - || Isdigit(delim) || any(" \t\n", delim)) { + || Isdigit(delim) || strchr(" \t\n", delim)) { seterror(ERR_BADSUBST); break; } @@ -565,7 +565,7 @@ getdol(void) } c = 's'; } - if (!any("htrqxes", c)) { + if (!strchr("htrqxes", c)) { if ((amodflag || gmodflag) && c == '\n') stderror(ERR_VARSYN); /* strike */ seterror(ERR_VARMOD, c); @@ -651,7 +651,7 @@ getexcl(int sc) goto subst; } c = getC(0); - if (!any(":^$*-%", c)) + if (!strchr(":^$*-%", c)) goto subst; left = right = -1; if (c == ':') { @@ -744,7 +744,7 @@ getsub(struct wordent *en) case 's': delim = getC(0); - if (letter(delim) || Isdigit(delim) || any(" \t\n", delim)) { + if (letter(delim) || Isdigit(delim) || strchr(" \t\n", delim)) { unreadc(delim); lhsb[0] = 0; seterror(ERR_BADSUBST); @@ -957,7 +957,7 @@ domod(Char *cp, int type) case 'h': case 't': - if (!any(short2str(cp), '/')) + if (!strchr(short2str(cp), '/')) return (type == 't' ? Strsave(cp) : 0); wp = Strend(cp); while (*--wp != '/') @@ -1067,7 +1067,7 @@ getsel(int *al, int *ar, int dol) if (first) { c = getC(0); unreadc(c); - if (any("-$*", c)) + if (strchr("-$*", c)) return (1); } if (*al > *ar || *ar > dol) { @@ -1122,14 +1122,14 @@ gethent(int sc) /* FALLSTHROUGH */ default: - if (any("(=~", c)) { + if (strchr("(=~", c)) { unreadc(c); ungetC(HIST); return (0); } np = lhsb; event = 0; - while (!cmap(c, _ESC | _META | _QF | _QB) && !any("${}:", c)) { + while (!cmap(c, _ESC | _META | _QF | _QB) && !strchr("${}:", c)) { if (event != -1 && Isdigit(c)) event = event * 10 + c - '0'; else diff --git a/bin/csh/misc.c b/bin/csh/misc.c index f6030765c92..0c508c442e1 100644 --- a/bin/csh/misc.c +++ b/bin/csh/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.21 2018/09/15 12:15:32 miko Exp $ */ +/* $OpenBSD: misc.c,v 1.22 2018/09/17 16:00:19 martijn Exp $ */ /* $NetBSD: misc.c,v 1.6 1995/03/21 09:03:09 cgd Exp $ */ /*- @@ -42,17 +42,6 @@ static int fdcmp(int); static int renum(int, int); -int -any(char *s, int c) -{ - if (!s) - return (0); /* Check for nil pointer */ - while (*s) - if (*s++ == c) - return (1); - return (0); -} - char * xstrdup(const char *s) { diff --git a/bin/csh/parse.c b/bin/csh/parse.c index 363fa94a0d3..d8cd4098ec0 100644 --- a/bin/csh/parse.c +++ b/bin/csh/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.12 2015/12/26 13:48:38 mestre Exp $ */ +/* $OpenBSD: parse.c,v 1.13 2018/09/17 16:00:19 martijn Exp $ */ /* $NetBSD: parse.c,v 1.6 1995/03/21 09:03:10 cgd Exp $ */ /*- @@ -89,7 +89,7 @@ static void asyntax(struct wordent *p1, struct wordent *p2) { while (p1 != p2) - if (any(";&\n", p1->word[0])) + if (strchr(";&\n", p1->word[0])) p1 = p1->next; else { asyn0(p1, p2); @@ -214,7 +214,7 @@ syntax(struct wordent *p1, struct wordent *p2, int flags) { while (p1 != p2) - if (any(";&\n", p1->word[0])) + if (strchr(";&\n", p1->word[0])) p1 = p1->next; else return (syn0(p1, p2, flags)); @@ -516,7 +516,7 @@ again: } if (p->next == p2) continue; - if (any(RELPAR, p->next->word[0])) + if (strchr(RELPAR, p->next->word[0])) continue; n--; continue; @@ -576,7 +576,7 @@ again: continue; } p = p->next; - if (any(RELPAR, p->word[0])) { + if (strchr(RELPAR, p->word[0])) { seterror(ERR_MISRED); continue; } @@ -596,7 +596,7 @@ again: continue; } p = p->next; - if (any(RELPAR, p->word[0])) { + if (strchr(RELPAR, p->word[0])) { seterror(ERR_MISRED); continue; } diff --git a/bin/csh/set.c b/bin/csh/set.c index eda0f3e3f55..0cece4f03ca 100644 --- a/bin/csh/set.c +++ b/bin/csh/set.c @@ -1,4 +1,4 @@ -/* $OpenBSD: set.c,v 1.19 2015/12/26 13:48:38 mestre Exp $ */ +/* $OpenBSD: set.c,v 1.20 2018/09/17 16:00:19 martijn Exp $ */ /* $NetBSD: set.c,v 1.8 1995/03/21 18:35:52 mycroft Exp $ */ /*- @@ -33,6 +33,7 @@ #include <sys/types.h> #include <stdlib.h> #include <stdarg.h> +#include <string.h> #include "csh.h" #include "extern.h" @@ -243,13 +244,13 @@ dolet(Char **v, struct command *t) } else { c = *p++; - if (any("+-", c)) { + if (strchr("+-", c)) { if (c != op || *p) stderror(ERR_NAME | ERR_UNKNOWNOP); p = Strsave(STR1); } else { - if (any("<>", op)) { + if (strchr("<>", op)) { if (c != op) stderror(ERR_NAME | ERR_UNKNOWNOP); c = *p++; diff --git a/bin/csh/time.c b/bin/csh/time.c index bf16de91096..b94ff2cb360 100644 --- a/bin/csh/time.c +++ b/bin/csh/time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: time.c,v 1.15 2017/07/22 09:37:21 anton Exp $ */ +/* $OpenBSD: time.c,v 1.16 2018/09/17 16:00:19 martijn Exp $ */ /* $NetBSD: time.c,v 1.7 1995/03/21 13:55:25 mycroft Exp $ */ /*- @@ -32,6 +32,7 @@ #include <sys/types.h> #include <stdarg.h> +#include <string.h> #include "csh.h" #include "extern.h" @@ -83,7 +84,7 @@ donice(Char **v, struct command *t) v++, cp = *v++; if (cp == 0) nval = 4; - else if (*v == 0 && any("+-", cp[0])) + else if (*v == 0 && strchr("+-", cp[0])) nval = getn(cp); (void) setpriority(PRIO_PROCESS, 0, nval); } |