commit bash-20100121 snapshot

This commit is contained in:
Chet Ramey
2011-12-12 21:53:04 -05:00
parent 5cdaaf76ec
commit 68dfe178e9
37 changed files with 30685 additions and 78 deletions
+21 -9
View File
@@ -44,7 +44,7 @@ static SHELL_VAR *bind_array_var_internal __P((SHELL_VAR *, arrayind_t, char *,
static char *quote_assign __P((const char *));
static void quote_array_assignment_chars __P((WORD_LIST *));
static char *array_value_internal __P((char *, int, int, int *));
static char *array_value_internal __P((char *, int, int, int *, arrayind_t *));
/* Standard error message to use when encountering an invalid array subscript */
const char * const bash_badsub_errmsg = N_("bad array subscript");
@@ -658,6 +658,7 @@ unbind_array_element (var, sub)
return -1;
}
assoc_remove (assoc_cell (var), akey);
free (akey);
}
else
{
@@ -848,9 +849,10 @@ array_variable_part (s, subp, lenp)
is non-null it gets 1 if the array reference is name[*], 2 if the
reference is name[@], and 0 otherwise. */
static char *
array_value_internal (s, quoted, allow_all, rtype)
array_value_internal (s, quoted, allow_all, rtype, indp)
char *s;
int quoted, allow_all, *rtype;
arrayind_t *indp;
{
int len;
arrayind_t ind;
@@ -881,7 +883,7 @@ array_value_internal (s, quoted, allow_all, rtype)
err_badarraysub (s);
return ((char *)NULL);
}
else if (var == 0 || value_cell (var) == 0)
else if (var == 0 || value_cell (var) == 0) /* XXX - check for invisible_p(var) ? */
return ((char *)NULL);
else if (array_p (var) == 0 && assoc_p (var) == 0)
l = add_string_to_list (value_cell (var), (WORD_LIST *)NULL);
@@ -929,6 +931,8 @@ index_error:
}
return ((char *)NULL);
}
if (indp)
*indp = ind;
}
else if (assoc_p (var))
{
@@ -939,12 +943,15 @@ index_error:
goto index_error;
}
if (var == 0)
if (var == 0 || value_cell (var) == 0) /* XXX - check invisible_p(var) ? */
return ((char *)NULL);
if (array_p (var) == 0 && assoc_p (var) == 0)
return (ind == 0 ? value_cell (var) : (char *)NULL);
else if (assoc_p (var))
retval = assoc_reference (assoc_cell (var), akey);
{
retval = assoc_reference (assoc_cell (var), akey);
free (akey);
}
else
retval = array_reference (array_cell (var), ind);
}
@@ -955,11 +962,12 @@ index_error:
/* Return a string containing the elements described by the array and
subscript contained in S, obeying quoting for subscripts * and @. */
char *
array_value (s, quoted, rtype)
array_value (s, quoted, rtype, indp)
char *s;
int quoted, *rtype;
arrayind_t *indp;
{
return (array_value_internal (s, quoted, 1, rtype));
return (array_value_internal (s, quoted, 1, rtype, indp));
}
/* Return the value of the array indexing expression S as a single string.
@@ -967,11 +975,12 @@ array_value (s, quoted, rtype)
by other parts of the shell such as the arithmetic expression evaluator
in expr.c. */
char *
get_array_value (s, allow_all, rtype)
get_array_value (s, allow_all, rtype, indp)
char *s;
int allow_all, *rtype;
arrayind_t *indp;
{
return (array_value_internal (s, 0, allow_all, rtype));
return (array_value_internal (s, 0, allow_all, rtype, indp));
}
char *
@@ -990,6 +999,9 @@ array_keys (s, quoted)
if (var == 0 || ALL_ELEMENT_SUB (t[0]) == 0 || t[1] != ']')
return (char *)NULL;
if (var_isset (var) == 0 || invisible_p (var))
return (char *)NULL;
if (array_p (var) == 0 && assoc_p (var) == 0)
l = add_string_to_list ("0", (WORD_LIST *)NULL);
else if (assoc_p (var))