index -> strchr and rindex -> strrchr to reduce the number of gratuitous
diffes with NetBSD/OpenBSD. These changes seem to predate the NetBSD/OpenBSD split, so it is hard to give proper credit for them. Obtained from: OpenBSD.
This commit is contained in:
parent
812e4da7a8
commit
f8eb25da54
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27635
@ -200,7 +200,7 @@ readjob()
|
||||
}
|
||||
(void) strncpy(dfname, cp, sizeof dfname-1);
|
||||
dfname[sizeof dfname-1] = '\0';
|
||||
if (index(dfname, '/'))
|
||||
if (strchr(dfname, '/'))
|
||||
frecverr("readjob: %s: illegal path name",
|
||||
dfname);
|
||||
(void) readfile(dfname, size);
|
||||
|
@ -1052,7 +1052,7 @@ doarg(job)
|
||||
* Look for a job item consisting of system name, colon, number
|
||||
* (example: ucbarpa:114)
|
||||
*/
|
||||
if ((cp = index(job, ':')) != NULL) {
|
||||
if ((cp = strchr(job, ':')) != NULL) {
|
||||
machine = job;
|
||||
*cp++ = '\0';
|
||||
job = cp;
|
||||
|
@ -653,7 +653,7 @@ print(format, file)
|
||||
printer, format);
|
||||
return(ERROR);
|
||||
}
|
||||
if ((av[0] = rindex(prog, '/')) != NULL)
|
||||
if ((av[0] = strrchr(prog, '/')) != NULL)
|
||||
av[0]++;
|
||||
else
|
||||
av[0] = prog;
|
||||
@ -882,7 +882,7 @@ sendfile(type, file, format)
|
||||
syslog(LOG_ERR, "mkstemp: %m");
|
||||
return(ERROR);
|
||||
}
|
||||
if ((av[0] = rindex(IF, '/')) == NULL)
|
||||
if ((av[0] = strrchr(IF, '/')) == NULL)
|
||||
av[0] = IF;
|
||||
else
|
||||
av[0]++;
|
||||
@ -1193,7 +1193,7 @@ sendmail(user, bombed)
|
||||
closelog();
|
||||
for (i = 3, dtablesize = getdtablesize(); i < dtablesize; i++)
|
||||
(void) close(i);
|
||||
if ((cp = rindex(_PATH_SENDMAIL, '/')) != NULL)
|
||||
if ((cp = strrchr(_PATH_SENDMAIL, '/')) != NULL)
|
||||
cp++;
|
||||
else
|
||||
cp = _PATH_SENDMAIL;
|
||||
@ -1385,7 +1385,7 @@ openpr()
|
||||
char *cp;
|
||||
|
||||
if (!remote && *LP) {
|
||||
if (cp = index(LP, '@'))
|
||||
if (cp = strchr(LP, '@'))
|
||||
opennet(cp);
|
||||
else
|
||||
opentty();
|
||||
@ -1416,7 +1416,7 @@ openpr()
|
||||
for (i = 3, dtablesize = getdtablesize();
|
||||
i < dtablesize; i++)
|
||||
(void) close(i);
|
||||
if ((cp = rindex(OF, '/')) == NULL)
|
||||
if ((cp = strrchr(OF, '/')) == NULL)
|
||||
cp = OF;
|
||||
else
|
||||
cp++;
|
||||
|
@ -200,7 +200,7 @@ readjob()
|
||||
}
|
||||
(void) strncpy(dfname, cp, sizeof dfname-1);
|
||||
dfname[sizeof dfname-1] = '\0';
|
||||
if (index(dfname, '/'))
|
||||
if (strchr(dfname, '/'))
|
||||
frecverr("readjob: %s: illegal path name",
|
||||
dfname);
|
||||
(void) readfile(dfname, size);
|
||||
|
@ -45,7 +45,7 @@ static char copyright[] =
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "From: @(#)lpr.c 8.4 (Berkeley) 4/28/95"
|
||||
"\n$Id: lpr.c,v 1.16 1997/07/08 21:03:16 dima Exp $\n";
|
||||
"\n$Id: lpr.c,v 1.17 1997/07/23 00:49:37 imp Exp $\n";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -296,7 +296,7 @@ main(argc, argv)
|
||||
if (argc == 0)
|
||||
jobname = "stdin";
|
||||
else
|
||||
jobname = (arg = rindex(argv[0], '/')) ? arg+1 : argv[0];
|
||||
jobname = (arg = strrchr(argv[0], '/')) ? arg+1 : argv[0];
|
||||
}
|
||||
card('J', jobname);
|
||||
card('C', class);
|
||||
@ -456,7 +456,7 @@ linked(file)
|
||||
continue;
|
||||
case '.':
|
||||
if (file[2] == '/') {
|
||||
if ((cp = rindex(buf, '/')) != NULL)
|
||||
if ((cp = strrchr(buf, '/')) != NULL)
|
||||
*cp = '\0';
|
||||
file += 3;
|
||||
continue;
|
||||
@ -602,7 +602,7 @@ test(file)
|
||||
}
|
||||
(void) close(fd);
|
||||
if (rflag) {
|
||||
if ((cp = rindex(file, '/')) == NULL) {
|
||||
if ((cp = strrchr(file, '/')) == NULL) {
|
||||
if (checkwriteperm(file,".") == 0)
|
||||
return(1);
|
||||
} else {
|
||||
|
@ -221,8 +221,8 @@ account(acct)
|
||||
;
|
||||
ic = atoi(cp2);
|
||||
*cp2 = '\0';
|
||||
if (mflag && index(cp, ':'))
|
||||
cp = index(cp, ':') + 1;
|
||||
if (mflag && strchr(cp, ':'))
|
||||
cp = strchr(cp, ':') + 1;
|
||||
hp = lookup(cp);
|
||||
if (hp == NULL) {
|
||||
if (!allflag)
|
||||
|
@ -653,7 +653,7 @@ print(format, file)
|
||||
printer, format);
|
||||
return(ERROR);
|
||||
}
|
||||
if ((av[0] = rindex(prog, '/')) != NULL)
|
||||
if ((av[0] = strrchr(prog, '/')) != NULL)
|
||||
av[0]++;
|
||||
else
|
||||
av[0] = prog;
|
||||
@ -882,7 +882,7 @@ sendfile(type, file, format)
|
||||
syslog(LOG_ERR, "mkstemp: %m");
|
||||
return(ERROR);
|
||||
}
|
||||
if ((av[0] = rindex(IF, '/')) == NULL)
|
||||
if ((av[0] = strrchr(IF, '/')) == NULL)
|
||||
av[0] = IF;
|
||||
else
|
||||
av[0]++;
|
||||
@ -1193,7 +1193,7 @@ sendmail(user, bombed)
|
||||
closelog();
|
||||
for (i = 3, dtablesize = getdtablesize(); i < dtablesize; i++)
|
||||
(void) close(i);
|
||||
if ((cp = rindex(_PATH_SENDMAIL, '/')) != NULL)
|
||||
if ((cp = strrchr(_PATH_SENDMAIL, '/')) != NULL)
|
||||
cp++;
|
||||
else
|
||||
cp = _PATH_SENDMAIL;
|
||||
@ -1385,7 +1385,7 @@ openpr()
|
||||
char *cp;
|
||||
|
||||
if (!remote && *LP) {
|
||||
if (cp = index(LP, '@'))
|
||||
if (cp = strchr(LP, '@'))
|
||||
opennet(cp);
|
||||
else
|
||||
opentty();
|
||||
@ -1416,7 +1416,7 @@ openpr()
|
||||
for (i = 3, dtablesize = getdtablesize();
|
||||
i < dtablesize; i++)
|
||||
(void) close(i);
|
||||
if ((cp = rindex(OF, '/')) == NULL)
|
||||
if ((cp = strrchr(OF, '/')) == NULL)
|
||||
cp = OF;
|
||||
else
|
||||
cp++;
|
||||
|
Loading…
Reference in New Issue
Block a user