The first element of the vector built by brk_string() is never

used so there is no need to stuff the value of .MAKE into it,
which btw isn't set for quite a while already.

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.239)
This commit is contained in:
Hartmut Brandt 2005-05-12 15:10:45 +00:00
parent 059649b9ce
commit 7ea02fbf54
2 changed files with 15 additions and 10 deletions

View File

@ -2822,7 +2822,6 @@ Job_ParseShell(char *line)
while (isspace((unsigned char)*line)) {
line++;
}
words = brk_string(line, &wordCount, TRUE);
memset(&newShell, 0, sizeof(newShell));
path = NULL;
@ -2831,8 +2830,9 @@ Job_ParseShell(char *line)
* Parse the specification by keyword but skip the first word - it
* is not set by brk_string.
*/
wordCount--;
words = brk_string(line, &wordCount, TRUE);
words++;
wordCount--;
for (argc = wordCount, argv = words; argc != 0; argc--, argv++) {
/*
@ -3310,6 +3310,11 @@ shellneed(char *cmd)
if (strpbrk(cmd, sh_meta) != NULL)
return (NULL);
/*
* Break the command into words to form an argument
* vector we can execute. brk_string sticks NULL
* in av[0], so we have to skip over it...
*/
av = brk_string(cmd, NULL, TRUE);
for (p = sh_builtin; *p != 0; p++)
if (strcmp(av[1], *p) == 0)

View File

@ -49,10 +49,11 @@ __FBSDID("$FreeBSD$");
#include "globals.h"
#include "str.h"
#include "util.h"
#include "var.h"
static char **argv, *buffer;
static int argmax, curlen;
static char **argv;
static char *buffer;
static int argmax;
static int curlen;
/*
* str_init --
@ -62,10 +63,10 @@ static int argmax, curlen;
void
str_init(void)
{
char *p1;
argv = emalloc(((argmax = 50) + 1) * sizeof(char *));
argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1);
argmax = 50;
argv = emalloc((argmax + 1) * sizeof(char *));
argv[0] = NULL;
}
/*-
@ -113,8 +114,7 @@ str_concat(const char *s1, const char *s2, int flags)
* are ignored.
*
* returns --
* Pointer to the array of pointers to the words. To make life easier,
* the first word is always the value of the .MAKE variable.
* Pointer to the array of pointers to the words.
*/
char **
brk_string(const char *str, int *store_argc, Boolean expand)