sh: Remove prefix() function. Use strncmp() instead.

This commit is contained in:
Jilles Tjoelker 2014-07-20 12:06:52 +00:00
parent ce44e5f776
commit e61ae4ffc8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=268920
4 changed files with 5 additions and 18 deletions

View File

@ -365,7 +365,7 @@ find_command(const char *name, struct cmdentry *entry, int act,
for (;(fullname = padvance(&path, name)) != NULL; stunalloc(fullname)) {
idx++;
if (pathopt) {
if (prefix("func", pathopt)) {
if (strncmp(pathopt, "func", 4) == 0) {
/* handled below */
} else {
continue; /* ignore unimplemented options */

View File

@ -562,6 +562,7 @@ getjob_nonotfound(const char *name)
{
int jobno;
struct job *found, *jp;
size_t namelen;
pid_t pid;
int i;
@ -603,10 +604,12 @@ currentjob: if ((jp = getcurjob(NULL)) == NULL)
if (found != NULL)
return (found);
} else {
namelen = strlen(name);
found = NULL;
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
if (jp->used && jp->nprocs > 0
&& prefix(name + 1, jp->ps[0].cmd)) {
&& strncmp(jp->ps[0].cmd, name + 1,
namelen - 1) == 0) {
if (found)
error("%s: ambiguous", name);
found = jp;

View File

@ -60,21 +60,6 @@ char nullstr[1]; /* zero length string */
*/
/*
* prefix -- see if pfx is a prefix of string.
*/
int
prefix(const char *pfx, const char *string)
{
while (*pfx) {
if (*pfx++ != *string++)
return 0;
}
return 1;
}
/*
* Convert a string of digits to an integer, printing an error message on
* failure.

View File

@ -35,7 +35,6 @@
#include <string.h>
int prefix(const char *, const char *);
int number(const char *);
int is_number(const char *);