sh: Remove prefix() function. Use strncmp() instead.
This commit is contained in:
parent
ce44e5f776
commit
e61ae4ffc8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=268920
@ -365,7 +365,7 @@ find_command(const char *name, struct cmdentry *entry, int act,
|
|||||||
for (;(fullname = padvance(&path, name)) != NULL; stunalloc(fullname)) {
|
for (;(fullname = padvance(&path, name)) != NULL; stunalloc(fullname)) {
|
||||||
idx++;
|
idx++;
|
||||||
if (pathopt) {
|
if (pathopt) {
|
||||||
if (prefix("func", pathopt)) {
|
if (strncmp(pathopt, "func", 4) == 0) {
|
||||||
/* handled below */
|
/* handled below */
|
||||||
} else {
|
} else {
|
||||||
continue; /* ignore unimplemented options */
|
continue; /* ignore unimplemented options */
|
||||||
|
@ -562,6 +562,7 @@ getjob_nonotfound(const char *name)
|
|||||||
{
|
{
|
||||||
int jobno;
|
int jobno;
|
||||||
struct job *found, *jp;
|
struct job *found, *jp;
|
||||||
|
size_t namelen;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -603,10 +604,12 @@ currentjob: if ((jp = getcurjob(NULL)) == NULL)
|
|||||||
if (found != NULL)
|
if (found != NULL)
|
||||||
return (found);
|
return (found);
|
||||||
} else {
|
} else {
|
||||||
|
namelen = strlen(name);
|
||||||
found = NULL;
|
found = NULL;
|
||||||
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
|
for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) {
|
||||||
if (jp->used && jp->nprocs > 0
|
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)
|
if (found)
|
||||||
error("%s: ambiguous", name);
|
error("%s: ambiguous", name);
|
||||||
found = jp;
|
found = jp;
|
||||||
|
@ -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
|
* Convert a string of digits to an integer, printing an error message on
|
||||||
* failure.
|
* failure.
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int prefix(const char *, const char *);
|
|
||||||
int number(const char *);
|
int number(const char *);
|
||||||
int is_number(const char *);
|
int is_number(const char *);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user