1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Minor cleanup: make brk_string to return argc only if the pointer to it

was non-NULL. This let's us eliminated an otherwise unused variable.

shellneeded can never return -1 so there is no need to check for it and
hence no need for a variable to hold the returned value.

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (partly)
This commit is contained in:
Hartmut Brandt 2005-02-04 12:30:54 +00:00
parent acd5b69dd1
commit 435916b011
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=141269
2 changed files with 6 additions and 15 deletions

View File

@ -187,7 +187,7 @@ CompatInterrupt (int signo)
*
* Results:
* Returns 1 if a specified line must be executed by the shell,
* 0 if it can be run via execve, and -1 if the command is a no-op.
* and 0 if it can be run via execve.
*
* Side Effects:
* None.
@ -202,7 +202,7 @@ shellneed(char *cmd)
int ac;
av = brk_string(cmd, &ac, TRUE);
for(p = sh_builtin; *p != 0; p++)
for (p = sh_builtin; *p != 0; p++)
if (strcmp(av[1], *p) == 0)
return (1);
return (0);
@ -237,9 +237,6 @@ Compat_RunCommand(void *cmdp, void *gnp)
ReturnStatus rstat; /* Status of fork */
LstNode *cmdNode; /* Node where current command is located */
char **av; /* Argument vector for thing to exec */
int argc; /* Number of arguments in av or 0 if not
* dynamically allocated */
int internal; /* Various values.. */
char *cmd = cmdp;
GNode *gn = gnp;
@ -345,25 +342,18 @@ Compat_RunCommand(void *cmdp, void *gnp)
shargv[2] = cmd;
shargv[3] = NULL;
av = shargv;
argc = 0;
} else if ((internal = shellneed(cmd))) {
} else if (shellneed(cmd)) {
/*
* This command must be passed by the shell for other reasons..
* or.. possibly not at all.
*/
static char *shargv[4];
if (internal == -1) {
/* Command does not need to be executed */
return (0);
}
shargv[0] = shellPath;
shargv[1] = (errCheck ? "-ec" : "-c");
shargv[2] = cmd;
shargv[3] = NULL;
av = shargv;
argc = 0;
} else {
/*
* No meta-characters, so no need to exec a shell. Break the command
@ -371,7 +361,7 @@ Compat_RunCommand(void *cmdp, void *gnp)
* brk_string sticks our name in av[0], so we have to
* skip over it...
*/
av = brk_string(cmd, &argc, TRUE);
av = brk_string(cmd, NULL, TRUE);
av += 1;
}

View File

@ -226,7 +226,8 @@ brk_string(char *str, int *store_argc, Boolean expand)
*t++ = (char)ch;
}
done: argv[argc] = NULL;
*store_argc = argc;
if (store_argc != NULL)
*store_argc = argc;
return (argv);
}