Author: ed Date: Tue Jan 3 18:51:58 2012 New Revision: 229403 URL: http://svn.freebsd.org/changeset/base/229403
Log: Replace index() and rindex() calls with strchr() and strrchr(). The index() and rindex() functions were marked LEGACY in the 2001 revision of POSIX and were subsequently removed from the 2008 revision. The strchr() and strrchr() functions are part of the C standard. This makes the source code a lot more consistent, as most of these C files also call into other str*() routines. In fact, about a dozen already perform strchr() calls. Modified: head/games/fortune/fortune/fortune.c head/lib/libc/gen/exec.c head/lib/libc/gen/getttyent.c head/lib/libc/gen/timezone.c head/lib/libc/net/gethostbynis.c head/lib/libc/net/getnetbynis.c head/lib/libcam/camlib.c head/lib/libstand/bootp.c head/lib/libutil/quotafile.c head/libexec/mknetid/parse_group.c head/libexec/rlogind/rlogind.c head/sbin/bsdlabel/bsdlabel.c head/sbin/dump/main.c head/sbin/fsck_ffs/pass2.c head/sbin/ipfw/main.c head/sbin/shutdown/shutdown.c head/sys/boot/common/interp_parse.c head/sys/boot/ofw/common/main.c head/sys/boot/ofw/libofw/ofw_net.c head/usr.bin/cksum/cksum.c head/usr.bin/compress/compress.c head/usr.bin/finger/finger.c head/usr.bin/hexdump/display.c head/usr.bin/hexdump/hexdump.c head/usr.bin/hexdump/hexsyntax.c head/usr.bin/hexdump/parse.c head/usr.bin/locate/locate/fastfind.c head/usr.bin/locate/locate/util.c head/usr.bin/netstat/if.c head/usr.bin/netstat/inet.c head/usr.bin/netstat/inet6.c head/usr.bin/netstat/sctp.c head/usr.bin/rlogin/rlogin.c head/usr.bin/rpcgen/rpc_main.c head/usr.bin/systat/devs.c head/usr.bin/systat/netcmds.c head/usr.bin/systat/netstat.c head/usr.bin/tftp/main.c head/usr.bin/tr/str.c head/usr.bin/tset/map.c head/usr.bin/tset/term.c head/usr.bin/tset/wrterm.c head/usr.sbin/bootparamd/bootparamd/bootparamd.c head/usr.sbin/config/main.c head/usr.sbin/config/mkmakefile.c head/usr.sbin/inetd/inetd.c head/usr.sbin/ipfwpcap/ipfwpcap.c head/usr.sbin/mtree/spec.c head/usr.sbin/newsyslog/newsyslog.c head/usr.sbin/rwhod/rwhod.c head/usr.sbin/sade/variable.c Modified: head/games/fortune/fortune/fortune.c ============================================================================== --- head/games/fortune/fortune/fortune.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/games/fortune/fortune/fortune.c Tue Jan 3 18:51:58 2012 (r229403) @@ -683,7 +683,7 @@ all_forts(FILEDESC *fp, char *offensive) obscene->fd = fd; obscene->inf = NULL; obscene->path = offensive; - if ((sp = rindex(offensive, '/')) == NULL) + if ((sp = strrchr(offensive, '/')) == NULL) obscene->name = offensive; else obscene->name = ++sp; @@ -785,7 +785,7 @@ is_fortfile(const char *file, char **dat } } - if ((sp = rindex(file, '/')) == NULL) + if ((sp = strrchr(file, '/')) == NULL) sp = file; else sp++; @@ -797,7 +797,7 @@ is_fortfile(const char *file, char **dat DPRINTF(2, (stderr, "FALSE (check fortunes only)\n")); return (FALSE); } - if ((sp = rindex(sp, '.')) != NULL) { + if ((sp = strrchr(sp, '.')) != NULL) { sp++; for (i = 0; suflist[i] != NULL; i++) if (strcmp(sp, suflist[i]) == 0) { Modified: head/lib/libc/gen/exec.c ============================================================================== --- head/lib/libc/gen/exec.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/lib/libc/gen/exec.c Tue Jan 3 18:51:58 2012 (r229403) @@ -159,7 +159,7 @@ execvPe(const char *name, const char *pa eacces = 0; /* If it's an absolute or relative path name, it's easy. */ - if (index(name, '/')) { + if (strchr(name, '/')) { bp = name; cur = NULL; goto retry; Modified: head/lib/libc/gen/getttyent.c ============================================================================== --- head/lib/libc/gen/getttyent.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/lib/libc/gen/getttyent.c Tue Jan 3 18:51:58 2012 (r229403) @@ -78,7 +78,7 @@ getttyent(void) if (!fgets(p = line, lbsize, tf)) return (NULL); /* extend buffer if line was too big, and retry */ - while (!index(p, '\n') && !feof(tf)) { + while (!strchr(p, '\n') && !feof(tf)) { i = strlen(p); lbsize += MALLOCCHUNK; if ((p = realloc(line, lbsize)) == NULL) { @@ -148,7 +148,7 @@ getttyent(void) tty.ty_comment = p; if (*p == 0) tty.ty_comment = 0; - if ( (p = index(p, '\n')) ) + if ((p = strchr(p, '\n'))) *p = '\0'; return (&tty); } @@ -196,7 +196,7 @@ static char * value(char *p) { - return ((p = index(p, '=')) ? ++p : NULL); + return ((p = strchr(p, '=')) ? ++p : NULL); } int Modified: head/lib/libc/gen/timezone.c ============================================================================== --- head/lib/libc/gen/timezone.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/lib/libc/gen/timezone.c Tue Jan 3 18:51:58 2012 (r229403) @@ -59,7 +59,7 @@ timezone(int zone, int dst) *end; if ( (beg = getenv("TZNAME")) ) { /* set in environment */ - if ( (end = index(beg, ',')) ) {/* "PST,PDT" */ + if ((end = strchr(beg, ','))) { /* "PST,PDT" */ if (dst) return(++end); *end = '\0'; Modified: head/lib/libc/net/gethostbynis.c ============================================================================== --- head/lib/libc/net/gethostbynis.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/lib/libc/net/gethostbynis.c Tue Jan 3 18:51:58 2012 (r229403) @@ -91,7 +91,7 @@ _gethostbynis(const char *name, char *ma free(result); result = (char *)&ypbuf; - if ((cp = index(result, '\n'))) + if ((cp = strchr(result, '\n'))) *cp = '\0'; cp = strpbrk(result, " \t"); Modified: head/lib/libc/net/getnetbynis.c ============================================================================== --- head/lib/libc/net/getnetbynis.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/lib/libc/net/getnetbynis.c Tue Jan 3 18:51:58 2012 (r229403) @@ -80,7 +80,7 @@ _getnetbynis(const char *name, char *map free(result); result = (char *)&ypbuf; - if ((cp = index(result, '\n'))) + if ((cp = strchr(result, '\n'))) *cp = '\0'; cp = strpbrk(result, " \t"); Modified: head/lib/libcam/camlib.c ============================================================================== --- head/lib/libcam/camlib.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/lib/libcam/camlib.c Tue Jan 3 18:51:58 2012 (r229403) @@ -137,7 +137,7 @@ cam_get_device(const char *path, char *d */ if (*tmpstr == '/') { tmpstr2 = tmpstr; - tmpstr = (char *)rindex(tmpstr2, '/'); + tmpstr = strrchr(tmpstr2, '/'); if ((tmpstr != NULL) && (*tmpstr != '\0')) tmpstr++; } Modified: head/lib/libstand/bootp.c ============================================================================== --- head/lib/libstand/bootp.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/lib/libstand/bootp.c Tue Jan 3 18:51:58 2012 (r229403) @@ -703,13 +703,13 @@ setenv_(u_char *cp, u_char *ep, struct u_char *s = NULL; /* semicolon ? */ /* skip leading whitespace */ - while (*endv && index(" \t\n\r", *endv)) + while (*endv && strchr(" \t\n\r", *endv)) endv++; - vp = index(endv, '='); /* find name=value separator */ + vp = strchr(endv, '='); /* find name=value separator */ if (!vp) break; *vp++ = 0; - if (op->fmt == __ILIST && (s = index(vp, ';'))) + if (op->fmt == __ILIST && (s = strchr(vp, ';'))) *s++ = '\0'; setenv(endv, vp, 1); vp = s; /* prepare for next round */ Modified: head/lib/libutil/quotafile.c ============================================================================== --- head/lib/libutil/quotafile.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/lib/libutil/quotafile.c Tue Jan 3 18:51:58 2012 (r229403) @@ -84,7 +84,7 @@ hasquota(struct fstab *fs, int type, cha } strcpy(buf, fs->fs_mntops); for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) { - if ((cp = index(opt, '='))) + if ((cp = strchr(opt, '='))) *cp++ = '\0'; if (type == USRQUOTA && strcmp(opt, usrname) == 0) break; Modified: head/libexec/mknetid/parse_group.c ============================================================================== --- head/libexec/mknetid/parse_group.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/libexec/mknetid/parse_group.c Tue Jan 3 18:51:58 2012 (r229403) @@ -114,7 +114,7 @@ grscan(int search, int gid) return(0); bp = line; /* skip lines that are too big */ - if (!index(line, '\n')) { + if (!strchr(line, '\n')) { int ch; while ((ch = getc(_gr_fp)) != '\n' && ch != EOF) Modified: head/libexec/rlogind/rlogind.c ============================================================================== --- head/libexec/rlogind/rlogind.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/libexec/rlogind/rlogind.c Tue Jan 3 18:51:58 2012 (r229403) @@ -543,16 +543,17 @@ extern char **environ; void setup_term(int fd) { - char *cp = index(term+ENVSIZE, '/'); + char *cp; char *speed; struct termios tt, def; + cp = strchr(term + ENVSIZE, '/'); #ifndef notyet tcgetattr(fd, &tt); if (cp) { *cp++ = '\0'; speed = cp; - cp = index(speed, '/'); + cp = strchr(speed, '/'); if (cp) *cp++ = '\0'; cfsetspeed(&tt, atoi(speed)); @@ -567,7 +568,7 @@ setup_term(int fd) if (cp) { *cp++ = '\0'; speed = cp; - cp = index(speed, '/'); + cp = strchr(speed, '/'); if (cp) *cp++ = '\0'; tcgetattr(fd, &tt); Modified: head/sbin/bsdlabel/bsdlabel.c ============================================================================== --- head/sbin/bsdlabel/bsdlabel.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/sbin/bsdlabel/bsdlabel.c Tue Jan 3 18:51:58 2012 (r229403) @@ -782,12 +782,12 @@ getasciilabel(FILE *f, struct disklabel lp->d_sbsize = 0; /* XXX */ while (fgets(line, sizeof(line) - 1, f)) { lineno++; - if ((cp = index(line,'\n')) != 0) + if ((cp = strchr(line,'\n')) != 0) *cp = '\0'; cp = skip(line); if (cp == NULL) continue; - tp = index(cp, ':'); + tp = strchr(cp, ':'); if (tp == NULL) { fprintf(stderr, "line %d: syntax error\n", lineno); errors++; Modified: head/sbin/dump/main.c ============================================================================== --- head/sbin/dump/main.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/sbin/dump/main.c Tue Jan 3 18:51:58 2012 (r229403) @@ -290,7 +290,7 @@ main(int argc, char *argv[]) tape = strchr(host, ':'); *tape++ = '\0'; #ifdef RDUMP - if (index(tape, '\n')) { + if (strchr(tape, '\n')) { (void)fprintf(stderr, "invalid characters in tape\n"); exit(X_STARTUP); } Modified: head/sbin/fsck_ffs/pass2.c ============================================================================== --- head/sbin/fsck_ffs/pass2.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/sbin/fsck_ffs/pass2.c Tue Jan 3 18:51:58 2012 (r229403) @@ -613,7 +613,7 @@ fix_extraneous(struct inoinfo *inp, stru printf(" (IGNORED)\n"); return (0); } - if ((cp = rindex(oldname, '/')) == NULL) { + if ((cp = strchr(oldname, '/')) == NULL) { printf(" (IGNORED)\n"); return (0); } Modified: head/sbin/ipfw/main.c ============================================================================== --- head/sbin/ipfw/main.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/sbin/ipfw/main.c Tue Jan 3 18:51:58 2012 (r229403) @@ -122,9 +122,9 @@ ipfw_main(int oldac, char **oldav) break; if (copy) { arg[j++] = arg[i]; - copy = !index("," WHITESP, arg[i]); + copy = !strchr("," WHITESP, arg[i]); } else { - copy = !index(WHITESP, arg[i]); + copy = !strchr(WHITESP, arg[i]); if (copy) arg[j++] = arg[i]; } @@ -141,7 +141,7 @@ ipfw_main(int oldac, char **oldav) * processing, this is just the number of blanks plus 1. */ for (i = 0, ac = 1; i < l; i++) - if (index(WHITESP, arg[i]) != NULL) + if (strchr(WHITESP, arg[i]) != NULL) ac++; /* @@ -162,7 +162,7 @@ ipfw_main(int oldac, char **oldav) */ av_p = (char *)&av[ac+1]; for (ac = 1, i = j = 0; i < l; i++) { - if (index(WHITESP, arg[i]) != NULL || i == l-1) { + if (strchr(WHITESP, arg[i]) != NULL || i == l-1) { if (i == l-1) i++; bcopy(arg+j, av_p, i-j); @@ -240,7 +240,7 @@ ipfw_main(int oldac, char **oldav) " ipfw sysctl -a\n"); return 0; } - s = index(av[2], '='); + s = strchr(av[2], '='); if (s == NULL) { s = !strcmp(av[2], "-a") ? NULL : av[2]; sysctlbyname(s, NULL, NULL, NULL, 0); Modified: head/sbin/shutdown/shutdown.c ============================================================================== --- head/sbin/shutdown/shutdown.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/sbin/shutdown/shutdown.c Tue Jan 3 18:51:58 2012 (r229403) @@ -123,7 +123,7 @@ main(int argc, char **argv) * Test for the special case where the utility is called as * "poweroff", for which it runs 'shutdown -p now'. */ - if ((p = rindex(argv[0], '/')) == NULL) + if ((p = strrchr(argv[0], '/')) == NULL) p = argv[0]; else ++p; Modified: head/sys/boot/common/interp_parse.c ============================================================================== --- head/sys/boot/common/interp_parse.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/sys/boot/common/interp_parse.c Tue Jan 3 18:51:58 2012 (r229403) @@ -137,7 +137,7 @@ parse(int *argc, char ***argv, char *str case VAR: if (token) { - PARSE_FAIL((q = index(p, token)) == NULL); + PARSE_FAIL((q = strchr(p, token)) == NULL); } else { q = p; while (*q && !isspace(*q)) Modified: head/sys/boot/ofw/common/main.c ============================================================================== --- head/sys/boot/ofw/common/main.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/sys/boot/ofw/common/main.c Tue Jan 3 18:51:58 2012 (r229403) @@ -133,7 +133,7 @@ main(int (*openfirm)(void *)) printf("Memory: %lldKB\n", memsize() / 1024); OF_getprop(chosen, "bootpath", bootpath, 64); - ch = index(bootpath, ':'); + ch = strchr(bootpath, ':'); *ch = '\0'; printf("Booted from: %s\n", bootpath); Modified: head/sys/boot/ofw/libofw/ofw_net.c ============================================================================== --- head/sys/boot/ofw/libofw/ofw_net.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/sys/boot/ofw/libofw/ofw_net.c Tue Jan 3 18:51:58 2012 (r229403) @@ -185,7 +185,7 @@ ofwn_init(struct iodesc *desc, void *mac int pathlen; pathlen = OF_getprop(chosen, "bootpath", path, 64); - if ((ch = index(path, ':')) != NULL) + if ((ch = strchr(path, ':')) != NULL) *ch = '\0'; netdev = OF_finddevice(path); #ifdef __sparc64__ Modified: head/usr.bin/cksum/cksum.c ============================================================================== --- head/usr.bin/cksum/cksum.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/cksum/cksum.c Tue Jan 3 18:51:58 2012 (r229403) @@ -68,7 +68,7 @@ main(int argc, char **argv) int (*cfncn)(int, uint32_t *, off_t *); void (*pfncn)(char *, uint32_t, off_t); - if ((p = rindex(argv[0], '/')) == NULL) + if ((p = strrchr(argv[0], '/')) == NULL) p = argv[0]; else ++p; Modified: head/usr.bin/compress/compress.c ============================================================================== --- head/usr.bin/compress/compress.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/compress/compress.c Tue Jan 3 18:51:58 2012 (r229403) @@ -75,7 +75,7 @@ main(int argc, char *argv[]) char *p, newname[MAXPATHLEN]; cat = 0; - if ((p = rindex(argv[0], '/')) == NULL) + if ((p = strrchr(argv[0], '/')) == NULL) p = argv[0]; else ++p; @@ -141,7 +141,7 @@ main(int argc, char *argv[]) compress(*argv, "/dev/stdout", bits); break; } - if ((p = rindex(*argv, '.')) != NULL && + if ((p = strrchr(*argv, '.')) != NULL && !strcmp(p, ".Z")) { cwarnx("%s: name already has trailing .Z", *argv); @@ -164,7 +164,7 @@ main(int argc, char *argv[]) break; } len = strlen(*argv); - if ((p = rindex(*argv, '.')) == NULL || + if ((p = strrchr(*argv, '.')) == NULL || strcmp(p, ".Z")) { if (len > sizeof(newname) - 3) { cwarnx("%s: name too long", *argv); Modified: head/usr.bin/finger/finger.c ============================================================================== --- head/usr.bin/finger/finger.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/finger/finger.c Tue Jan 3 18:51:58 2012 (r229403) @@ -287,7 +287,7 @@ userlist(int argc, char **argv) /* Pull out all network requests. */ for (ap = p = argv, np = nargv; *p; ++p) - if (index(*p, '@')) + if (strchr(*p, '@')) *np++ = *p; else *ap++ = *p; Modified: head/usr.bin/hexdump/display.c ============================================================================== --- head/usr.bin/hexdump/display.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/hexdump/display.c Tue Jan 3 18:51:58 2012 (r229403) @@ -220,7 +220,7 @@ bpad(PR *pr) pr->cchar[0] = 's'; pr->cchar[1] = '\0'; for (p1 = pr->fmt; *p1 != '%'; ++p1); - for (p2 = ++p1; *p1 && index(spec, *p1); ++p1); + for (p2 = ++p1; *p1 && strchr(spec, *p1); ++p1); while ((*p2++ = *p1++)); } Modified: head/usr.bin/hexdump/hexdump.c ============================================================================== --- head/usr.bin/hexdump/hexdump.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/hexdump/hexdump.c Tue Jan 3 18:51:58 2012 (r229403) @@ -61,7 +61,7 @@ main(int argc, char *argv[]) (void)setlocale(LC_ALL, ""); - if (!(p = rindex(argv[0], 'o')) || strcmp(p, "od")) + if (!(p = strrchr(argv[0], 'o')) || strcmp(p, "od")) newsyntax(argc, &argv); else oldsyntax(argc, &argv); Modified: head/usr.bin/hexdump/hexsyntax.c ============================================================================== --- head/usr.bin/hexdump/hexsyntax.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/hexdump/hexsyntax.c Tue Jan 3 18:51:58 2012 (r229403) @@ -54,7 +54,7 @@ newsyntax(int argc, char ***argvp) char *p, **argv; argv = *argvp; - if ((p = rindex(argv[0], 'h')) != NULL && + if ((p = strrchr(argv[0], 'h')) != NULL && strcmp(p, "hd") == 0) { /* "Canonical" format, implies -C. */ add("\"%08.8_Ax\n\""); Modified: head/usr.bin/hexdump/parse.c ============================================================================== --- head/usr.bin/hexdump/parse.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/hexdump/parse.c Tue Jan 3 18:51:58 2012 (r229403) @@ -58,7 +58,7 @@ addfile(char *name) if ((fp = fopen(name, "r")) == NULL) err(1, "%s", name); while (fgets(buf, sizeof(buf), fp)) { - if (!(p = index(buf, '\n'))) { + if (!(p = strchr(buf, '\n'))) { warnx("line too long"); while ((ch = getchar()) != '\n' && ch != EOF); continue; @@ -167,7 +167,7 @@ size(FS *fs) * skip any special chars -- save precision in * case it's a %s format. */ - while (index(spec + 1, *++fmt)); + while (strchr(spec + 1, *++fmt)); if (*fmt == '.' && isdigit(*++fmt)) { prec = atoi(fmt); while (isdigit(*++fmt)); @@ -243,10 +243,10 @@ rewrite(FS *fs) if (fu->bcnt) { sokay = USEBCNT; /* Skip to conversion character. */ - for (++p1; index(spec, *p1); ++p1); + for (++p1; strchr(spec, *p1); ++p1); } else { /* Skip any special chars, field width. */ - while (index(spec + 1, *++p1)); + while (strchr(spec + 1, *++p1)); if (*p1 == '.' && isdigit(*++p1)) { sokay = USEPREC; prec = atoi(p1); Modified: head/usr.bin/locate/locate/fastfind.c ============================================================================== --- head/usr.bin/locate/locate/fastfind.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/locate/locate/fastfind.c Tue Jan 3 18:51:58 2012 (r229403) @@ -167,7 +167,7 @@ fastfind /* find optimal (last) char for searching */ for (p = pathpart; *p != '\0'; p++) - if (index(LOCATE_REG, *p) != NULL) + if (strchr(LOCATE_REG, *p) != NULL) break; if (*p == '\0') Modified: head/usr.bin/locate/locate/util.c ============================================================================== --- head/usr.bin/locate/locate/util.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/locate/locate/util.c Tue Jan 3 18:51:58 2012 (r229403) @@ -162,7 +162,7 @@ patprep(name) /* skip trailing metacharacters */ for (; p >= name; p--) - if (index(LOCATE_REG, *p) == NULL) + if (strchr(LOCATE_REG, *p) == NULL) break; /* @@ -172,7 +172,7 @@ patprep(name) * |----< p */ if (p >= name && - (index(p, '[') != NULL || index(p, ']') != NULL)) { + (strchr(p, '[') != NULL || strchr(p, ']') != NULL)) { for (p = name; *p != '\0'; p++) if (*p == ']' || *p == '[') break; @@ -183,7 +183,7 @@ patprep(name) * '*\*[a-z]' * |-------< p */ - if (p >= name && index(LOCATE_REG, *p) != NULL) + if (p >= name && strchr(LOCATE_REG, *p) != NULL) p = name - 1; } @@ -193,7 +193,7 @@ patprep(name) else { for (endmark = p; p >= name; p--) - if (index(LOCATE_REG, *p) != NULL) + if (strchr(LOCATE_REG, *p) != NULL) break; for (++p; (p <= endmark) && subp < (globfree + sizeof(globfree));) Modified: head/usr.bin/netstat/if.c ============================================================================== --- head/usr.bin/netstat/if.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/netstat/if.c Tue Jan 3 18:51:58 2012 (r229403) @@ -256,7 +256,7 @@ intpr(int interval1, u_long ifnetaddr, v ifnetaddr = (u_long)TAILQ_NEXT(&ifnet, if_link); if (interface != 0 && strcmp(name, interface) != 0) continue; - cp = index(name, '\0'); + cp = strchr(name, '\0'); if (pfunc) { (*pfunc)(name); Modified: head/usr.bin/netstat/inet.c ============================================================================== --- head/usr.bin/netstat/inet.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/netstat/inet.c Tue Jan 3 18:51:58 2012 (r229403) @@ -1247,7 +1247,7 @@ inetprint(struct in_addr *in, int port, sprintf(line, "%s.", inetname(in)); else sprintf(line, "%.*s.", (Aflag && !num_port) ? 12 : 16, inetname(in)); - cp = index(line, '\0'); + cp = strchr(line, '\0'); if (!num_port && port) sp = getservbyport((int)port, proto); if (sp || port == 0) Modified: head/usr.bin/netstat/inet6.c ============================================================================== --- head/usr.bin/netstat/inet6.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/netstat/inet6.c Tue Jan 3 18:51:58 2012 (r229403) @@ -1100,7 +1100,7 @@ inet6print(struct in6_addr *in6, int por sprintf(line, "%.*s.", Wflag ? 39 : (Aflag && !numeric) ? 12 : 16, inet6name(in6)); - cp = index(line, '\0'); + cp = strchr(line, '\0'); if (!numeric && port) GETSERVBYPORT6(port, proto, sp); if (sp || port == 0) @@ -1129,7 +1129,7 @@ inet6name(struct in6_addr *in6p) if (first && !numeric_addr) { first = 0; if (gethostname(domain, MAXHOSTNAMELEN) == 0 && - (cp = index(domain, '.'))) + (cp = strchr(domain, '.'))) (void) strcpy(domain, cp + 1); else domain[0] = 0; @@ -1138,7 +1138,7 @@ inet6name(struct in6_addr *in6p) if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) { hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6); if (hp) { - if ((cp = index(hp->h_name, '.')) && + if ((cp = strchr(hp->h_name, '.')) && !strcmp(cp + 1, domain)) *cp = 0; cp = hp->h_name; Modified: head/usr.bin/netstat/sctp.c ============================================================================== --- head/usr.bin/netstat/sctp.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/netstat/sctp.c Tue Jan 3 18:51:58 2012 (r229403) @@ -162,7 +162,7 @@ inet6name(struct in6_addr *in6p) if (first && !numeric_addr) { first = 0; if (gethostname(domain, MAXHOSTNAMELEN) == 0 && - (cp = index(domain, '.'))) + (cp = strchr(domain, '.'))) (void) strcpy(domain, cp + 1); else domain[0] = 0; @@ -171,7 +171,7 @@ inet6name(struct in6_addr *in6p) if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) { hp = gethostbyaddr((char *)in6p, sizeof(*in6p), AF_INET6); if (hp) { - if ((cp = index(hp->h_name, '.')) && + if ((cp = strchr(hp->h_name, '.')) && !strcmp(cp + 1, domain)) *cp = 0; cp = hp->h_name; @@ -209,7 +209,7 @@ sctp_print_address(union sctp_sockstore sprintf(line, "%.*s.", Wflag ? 39 : 16, ""); break; } - cp = index(line, '\0'); + cp = strchr(line, '\0'); if (!num_port && port) sp = getservbyport((int)port, "sctp"); if (sp || port == 0) Modified: head/usr.bin/rlogin/rlogin.c ============================================================================== --- head/usr.bin/rlogin/rlogin.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/rlogin/rlogin.c Tue Jan 3 18:51:58 2012 (r229403) @@ -142,7 +142,7 @@ main(int argc, char *argv[]) one = 1; host = localname = user = NULL; - if ((p = rindex(argv[0], '/'))) + if ((p = strrchr(argv[0], '/'))) ++p; else p = argv[0]; Modified: head/usr.bin/rpcgen/rpc_main.c ============================================================================== --- head/usr.bin/rpcgen/rpc_main.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/rpcgen/rpc_main.c Tue Jan 3 18:51:58 2012 (r229403) @@ -64,10 +64,6 @@ static void clnt_output(const char *, co static char *generate_guard(const char *); static void c_initialize(void); -#if !defined(__FreeBSD__) && !defined(__NetBSD__) -char * rindex(); -#endif - static void usage(void); static void options_usage(void); static int do_registers(int, const char **); @@ -233,7 +229,7 @@ extendfile(const char *path, const char const char *p; const char *file; - if ((file = rindex(path, '/')) == NULL) + if ((file = strrchr(path, '/')) == NULL) file = path; else file++; @@ -821,7 +817,7 @@ static void mkfile_output(struct command if (allfiles){ mkftemp = xmalloc(strlen("makefile.") + strlen(cmd->infile) + 1); - temp = (char *)rindex(cmd->infile, '.'); + temp = strrchr(cmd->infile, '.'); strcpy(mkftemp, "makefile."); (void) strncat(mkftemp, cmd->infile, (temp - cmd->infile)); Modified: head/usr.bin/systat/devs.c ============================================================================== --- head/usr.bin/systat/devs.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/systat/devs.c Tue Jan 3 18:51:58 2012 (r229403) @@ -265,7 +265,7 @@ dsselect(const char *args, devstat_selec specified_devices = (char **)malloc(sizeof(char *)); tmpstr = tmpstr1 = strdup(args); - cp = index(tmpstr1, '\n'); + cp = strchr(tmpstr1, '\n'); if (cp) *cp = '\0'; for (;;) { Modified: head/usr.bin/systat/netcmds.c ============================================================================== --- head/usr.bin/systat/netcmds.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/systat/netcmds.c Tue Jan 3 18:51:58 2012 (r229403) @@ -131,7 +131,7 @@ changeitems(const char *args, int onoff) struct in_addr in; tmpstr = tmpstr1 = strdup(args); - cp = index(tmpstr1, '\n'); + cp = strchr(tmpstr1, '\n'); if (cp) *cp = '\0'; for (;;tmpstr1 = cp) { Modified: head/usr.bin/systat/netstat.c ============================================================================== --- head/usr.bin/systat/netstat.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/systat/netstat.c Tue Jan 3 18:51:58 2012 (r229403) @@ -554,7 +554,7 @@ inetprint(struct sockaddr *sa, const cha break; } snprintf(line, sizeof(line), "%.*s.", 16, inetname(sa)); - cp = index(line, '\0'); + cp = strchr(line, '\0'); if (!nflag && port) sp = getservbyport(port, proto); if (sp || port == 0) @@ -564,7 +564,7 @@ inetprint(struct sockaddr *sa, const cha snprintf(cp, sizeof(line) - (cp - line), "%d", ntohs((u_short)port)); /* pad to full column to clear any garbage */ - cp = index(line, '\0'); + cp = strchr(line, '\0'); while (cp - line < 22) *cp++ = ' '; line[22] = '\0'; Modified: head/usr.bin/tftp/main.c ============================================================================== --- head/usr.bin/tftp/main.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/tftp/main.c Tue Jan 3 18:51:58 2012 (r229403) @@ -437,16 +437,16 @@ put(int argc, char *argv[]) return; } targ = argv[argc - 1]; - if (rindex(argv[argc - 1], ':')) { + if (strrchr(argv[argc - 1], ':')) { char *lcp; for (n = 1; n < argc - 1; n++) - if (index(argv[n], ':')) { + if (strchr(argv[n], ':')) { putusage(argv[0]); return; } lcp = argv[argc - 1]; - targ = rindex(lcp, ':'); + targ = strrchr(lcp, ':'); *targ++ = 0; if (lcp[0] == '[' && lcp[strlen(lcp) - 1] == ']') { lcp[strlen(lcp) - 1] = '\0'; @@ -477,7 +477,7 @@ put(int argc, char *argv[]) } /* this assumes the target is a directory */ /* on a remote unix system. hmmmm. */ - cp = index(targ, '\0'); + cp = strchr(targ, '\0'); *cp++ = '/'; for (n = 1; n < argc - 1; n++) { strcpy(cp, tail(argv[n])); @@ -532,7 +532,7 @@ get(int argc, char *argv[]) } if (!connected) { for (n = 1; n < argc ; n++) - if (rindex(argv[n], ':') == 0) { + if (strrchr(argv[n], ':') == 0) { printf("No remote host specified and " "no host given for file '%s'\n", argv[n]); getusage(argv[0]); @@ -540,7 +540,7 @@ get(int argc, char *argv[]) } } for (n = 1; n < argc ; n++) { - src = rindex(argv[n], ':'); + src = strrchr(argv[n], ':'); if (src == NULL) src = argv[n]; else { @@ -681,7 +681,7 @@ tail(char *filename) char *s; while (*filename) { - s = rindex(filename, '/'); + s = strrchr(filename, '/'); if (s == NULL) break; if (s[1]) Modified: head/usr.bin/tr/str.c ============================================================================== --- head/usr.bin/tr/str.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/tr/str.c Tue Jan 3 18:51:58 2012 (r229403) @@ -161,7 +161,7 @@ bracket(STR *s) repeat: if ((p = strpbrk(s->str + 2, "*]")) == NULL) return (0); - if (p[0] != '*' || index(p, ']') == NULL) + if (p[0] != '*' || strchr(p, ']') == NULL) return (0); s->str += 1; genseq(s); Modified: head/usr.bin/tset/map.c ============================================================================== --- head/usr.bin/tset/map.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/tset/map.c Tue Jan 3 18:51:58 2012 (r229403) @@ -132,7 +132,7 @@ next: if (*arg == ':') { goto badmopt; ++arg; } else { /* Optional baudrate. */ - arg = index(p = arg, ':'); + arg = strchr(p = arg, ':'); if (arg == NULL) goto badmopt; *arg++ = '\0'; Modified: head/usr.bin/tset/term.c ============================================================================== --- head/usr.bin/tset/term.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/tset/term.c Tue Jan 3 18:51:58 2012 (r229403) @@ -74,7 +74,7 @@ get_termcap_entry(char *userarg, char ** /* Try ttyname(3); check for dialup or other mapping. */ if ((ttypath = ttyname(STDERR_FILENO))) { - if ((p = rindex(ttypath, '/'))) + if ((p = strrchr(ttypath, '/'))) ++p; else p = ttypath; @@ -146,7 +146,7 @@ askuser(const char *dflt) return (dflt); } - if ((p = index(answer, '\n'))) + if ((p = strchr(answer, '\n'))) *p = '\0'; if (answer[0]) return (answer); Modified: head/usr.bin/tset/wrterm.c ============================================================================== --- head/usr.bin/tset/wrterm.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.bin/tset/wrterm.c Tue Jan 3 18:51:58 2012 (r229403) @@ -56,7 +56,7 @@ wrtermcap(char *bp) char *t, *sep; /* Find the end of the terminal names. */ - if ((t = index(bp, ':')) == NULL) + if ((t = strchr(bp, ':')) == NULL) errx(1, "termcap names not colon terminated"); *t++ = '\0'; Modified: head/usr.sbin/bootparamd/bootparamd/bootparamd.c ============================================================================== --- head/usr.sbin/bootparamd/bootparamd/bootparamd.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.sbin/bootparamd/bootparamd/bootparamd.c Tue Jan 3 18:51:58 2012 (r229403) @@ -114,7 +114,7 @@ bp_getfile_res * bp_getfile_arg *getfile; struct svc_req *req; { - char *where, *index(); + char *where; static bp_getfile_res res; if (debug) @@ -133,7 +133,7 @@ struct svc_req *req; askname[sizeof(askname)-1] = 0; if (getthefile(askname, getfile->file_id,buffer,sizeof(buffer))) { - if ( (where = index(buffer,':')) ) { + if ( (where = strchr(buffer,':')) ) { /* buffer is re-written to contain the name of the info of file */ strncpy(hostname, buffer, where - buffer); hostname[where - buffer] = '\0'; Modified: head/usr.sbin/config/main.c ============================================================================== --- head/usr.sbin/config/main.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.sbin/config/main.c Tue Jan 3 18:51:58 2012 (r229403) @@ -626,7 +626,7 @@ remember(const char *file) else s = ns(file); - if (index(s, '_') && strncmp(s, "opt_", 4) != 0) { + if (strchr(s, '_') && strncmp(s, "opt_", 4) != 0) { free(s); return; } Modified: head/usr.sbin/config/mkmakefile.c ============================================================================== --- head/usr.sbin/config/mkmakefile.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.sbin/config/mkmakefile.c Tue Jan 3 18:51:58 2012 (r229403) @@ -206,12 +206,12 @@ makehints(void) err(1, "%s", hint->hint_name); while (fgets(line, BUFSIZ, ifp) != 0) { /* zap trailing CR and/or LF */ - while ((s = rindex(line, '\n')) != NULL) + while ((s = strrchr(line, '\n')) != NULL) *s = '\0'; - while ((s = rindex(line, '\r')) != NULL) + while ((s = strrchr(line, '\r')) != NULL) *s = '\0'; /* remove # comments */ - s = index(line, '#'); + s = strchr(line, '#'); if (s) *s = '\0'; /* remove any whitespace and " characters */ @@ -268,12 +268,12 @@ makeenv(void) if (ifp) { while (fgets(line, BUFSIZ, ifp) != 0) { /* zap trailing CR and/or LF */ - while ((s = rindex(line, '\n')) != NULL) + while ((s = strrchr(line, '\n')) != NULL) *s = '\0'; - while ((s = rindex(line, '\r')) != NULL) + while ((s = strrchr(line, '\r')) != NULL) *s = '\0'; /* remove # comments */ - s = index(line, '#'); + s = strchr(line, '#'); if (s) *s = '\0'; /* remove any whitespace and " characters */ @@ -689,7 +689,7 @@ tail(char *fn) { char *cp; - cp = rindex(fn, '/'); + cp = strrchr(fn, '/'); if (cp == 0) return (fn); return (cp+1); Modified: head/usr.sbin/inetd/inetd.c ============================================================================== --- head/usr.sbin/inetd/inetd.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.sbin/inetd/inetd.c Tue Jan 3 18:51:58 2012 (r229403) @@ -1764,7 +1764,7 @@ more: sep->se_rpc_lowvers = 0; memcpy(&sep->se_ctrladdr4, bind_sa4, sizeof(sep->se_ctrladdr4)); - if ((versp = rindex(sep->se_service, '/'))) { + if ((versp = strrchr(sep->se_service, '/'))) { *versp++ = '\0'; switch (sscanf(versp, "%u-%u", &sep->se_rpc_lowvers, @@ -1936,7 +1936,7 @@ more: } else sep->se_group = NULL; sep->se_server = newstr(sskip(&cp)); - if ((sep->se_server_name = rindex(sep->se_server, '/'))) + if ((sep->se_server_name = strrchr(sep->se_server, '/'))) sep->se_server_name++; if (strcmp(sep->se_server, "internal") == 0) { struct biltin *bi; Modified: head/usr.sbin/ipfwpcap/ipfwpcap.c ============================================================================== --- head/usr.sbin/ipfwpcap/ipfwpcap.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.sbin/ipfwpcap/ipfwpcap.c Tue Jan 3 18:51:58 2012 (r229403) @@ -87,7 +87,7 @@ okay(int pn) char *p, numbuf[80]; if (pidfile[0] == '\0') { - p = rindex(prog, '/'); + p = strrchr(prog, '/'); p = (p == NULL) ? prog : p + 1; snprintf(pidfile, sizeof pidfile, Modified: head/usr.sbin/mtree/spec.c ============================================================================== --- head/usr.sbin/mtree/spec.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.sbin/mtree/spec.c Tue Jan 3 18:51:58 2012 (r229403) @@ -73,7 +73,7 @@ mtree_readspec(FILE *fi) continue; /* Find end of line. */ - if ((p = index(buf, '\n')) == NULL) + if ((p = strchr(buf, '\n')) == NULL) errx(1, "line %d too long", lineno); /* See if next line is continuation line. */ @@ -118,7 +118,7 @@ mtree_readspec(FILE *fi) continue; } - if (index(p, '/')) + if (strchr(p, '/')) errx(1, "line %d: slash character in file name", lineno); Modified: head/usr.sbin/newsyslog/newsyslog.c ============================================================================== --- head/usr.sbin/newsyslog/newsyslog.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.sbin/newsyslog/newsyslog.c Tue Jan 3 18:51:58 2012 (r229403) @@ -1710,7 +1710,7 @@ do_rotate(const struct conf_entry *ent) } else { /* relative */ /* get directory part of logfile */ strlcpy(dirpart, ent->log, sizeof(dirpart)); - if ((p = rindex(dirpart, '/')) == NULL) + if ((p = strrchr(dirpart, '/')) == NULL) dirpart[0] = '\0'; else *(p + 1) = '\0'; @@ -1722,7 +1722,7 @@ do_rotate(const struct conf_entry *ent) createdir(ent, dirpart); /* get filename part of logfile */ - if ((p = rindex(ent->log, '/')) == NULL) + if ((p = strrchr(ent->log, '/')) == NULL) strlcpy(namepart, ent->log, sizeof(namepart)); else strlcpy(namepart, p + 1, sizeof(namepart)); @@ -2255,7 +2255,7 @@ age_old_log(char *file) } else { /* relative */ /* get directory part of logfile */ strlcpy(tmp, file, sizeof(tmp)); - if ((p = rindex(tmp, '/')) == NULL) + if ((p = strrchr(tmp, '/')) == NULL) tmp[0] = '\0'; else *(p + 1) = '\0'; @@ -2265,7 +2265,7 @@ age_old_log(char *file) strlcat(tmp, "/", sizeof(tmp)); /* get filename part of logfile */ - if ((p = rindex(file, '/')) == NULL) + if ((p = strrchr(file, '/')) == NULL) strlcat(tmp, file, sizeof(tmp)); else strlcat(tmp, p + 1, sizeof(tmp)); Modified: head/usr.sbin/rwhod/rwhod.c ============================================================================== --- head/usr.sbin/rwhod/rwhod.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.sbin/rwhod/rwhod.c Tue Jan 3 18:51:58 2012 (r229403) @@ -227,7 +227,7 @@ main(int argc, char *argv[]) syslog(LOG_ERR, "gethostname: %m"); exit(1); } - if ((cp = index(myname, '.')) != NULL) + if ((cp = strchr(myname, '.')) != NULL) *cp = '\0'; strncpy(mywd.wd_hostname, myname, sizeof(mywd.wd_hostname) - 1); mywd.wd_hostname[sizeof(mywd.wd_hostname) - 1] = '\0'; Modified: head/usr.sbin/sade/variable.c ============================================================================== --- head/usr.sbin/sade/variable.c Tue Jan 3 18:49:39 2012 (r229402) +++ head/usr.sbin/sade/variable.c Tue Jan 3 18:51:58 2012 (r229403) @@ -83,7 +83,7 @@ variable_set(char *var, int dirty) else if (!*var) msgDebug("Warning: Zero length name & value passed to variable_set()\n"); SAFE_STRCPY(tmp, var); - if ((cp = index(tmp, '=')) == NULL) + if ((cp = strchr(tmp, '=')) == NULL) msgFatal("Invalid variable format: %s", var); *(cp++) = '\0'; make_variable(tmp, string_skipwhite(cp), dirty); @@ -123,7 +123,7 @@ variable_unset(char *var) Variable *vp; char name[512], *cp; - if ((cp = index(var, '=')) != NULL) + if ((cp = strchr(var, '=')) != NULL) sstrncpy(name, var, cp - var); else SAFE_STRCPY(name, var); @@ -189,14 +189,14 @@ variable_check2(char *data) if (data == NULL) return -1; SAFE_STRCPY(tmp, data); - if ((cp = index(tmp, '=')) != NULL) { + if ((cp = strchr(tmp, '=')) != NULL) { *(cp++) = '\0'; if (*cp == '"') { /* smash quotes if present */ ++cp; - if ((cp3 = index(cp, '"')) != NULL) + if ((cp3 = strchr(cp, '"')) != NULL) *cp3 = '\0'; } - else if ((cp3 = index(cp, ',')) != NULL) + else if ((cp3 = strchr(cp, ',')) != NULL) *cp3 = '\0'; cp2 = variable_get(tmp); if (cp2 != NULL) { @@ -305,7 +305,7 @@ pvariable_set(char *var) msgDebug("Warning: Zero length name & value passed to variable_set()\n"); /* Add a trivial namespace to whatever name the caller chooses. */ SAFE_STRCPY(tmp, "SYSINSTALL_PVAR"); - if (index(var, '=') == NULL) + if (strchr(var, '=') == NULL) msgFatal("Invalid variable format: %s", var); strlcat(tmp, var, 1024); p = strchr(tmp, '='); _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"