diff options
author | Chet Ramey <chet.ramey@case.edu> | 2015-01-15 10:20:04 -0500 |
---|---|---|
committer | Dan Pasanen <dan.pasanen@gmail.com> | 2015-02-19 15:36:12 -0600 |
commit | 2b8818c04d17ef1268001609123647df95d5d219 (patch) | |
tree | 3a5320e16e75a7ab3f328f3a391b96454657fe2d | |
parent | ecd891cf8b461375d693aa509c82467b11cf6b55 (diff) | |
download | android_external_bash-2b8818c04d17ef1268001609123647df95d5d219.tar.gz android_external_bash-2b8818c04d17ef1268001609123647df95d5d219.tar.bz2 android_external_bash-2b8818c04d17ef1268001609123647df95d5d219.zip |
Bash-4.3 patch 31
Change-Id: I454d87ada1ca933e5d734c40d8dcce3e6202ecb7
-rw-r--r-- | patchlevel.h | 2 | ||||
-rw-r--r-- | subst.h | 1 | ||||
-rw-r--r-- | variables.c | 32 |
3 files changed, 32 insertions, 3 deletions
diff --git a/patchlevel.h b/patchlevel.h index e5dde52..0ad46aa 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -25,6 +25,6 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 30 +#define PATCHLEVEL 31 #endif /* _PATCHLEVEL_H_ */ @@ -47,6 +47,7 @@ #define ASS_MKASSOC 0x0004 #define ASS_MKGLOBAL 0x0008 /* force global assignment */ #define ASS_NAMEREF 0x0010 /* assigning to nameref variable */ +#define ASS_FROMREF 0x0020 /* assigning from value of nameref variable */ /* Flags for the string extraction functions. */ #define SX_NOALLOC 0x0001 /* just skip; don't return substring */ diff --git a/variables.c b/variables.c index 5200d64..1f7be5e 100644 --- a/variables.c +++ b/variables.c @@ -2516,10 +2516,27 @@ bind_variable_internal (name, value, table, hflags, aflags) HASH_TABLE *table; int hflags, aflags; { - char *newval; + char *newname, *newval; SHELL_VAR *entry; +#if defined (ARRAY_VARS) + arrayind_t ind; + char *subp; + int sublen; +#endif + newname = 0; +#if defined (ARRAY_VARS) + if ((aflags & ASS_FROMREF) && (hflags & HASH_NOSRCH) == 0 && valid_array_reference (name)) + { + newname = array_variable_name (name, &subp, &sublen); + if (newname == 0) + return (SHELL_VAR *)NULL; /* XXX */ + entry = hash_lookup (newname, table); + } + else +#endif entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table); + /* Follow the nameref chain here if this is the global variables table */ if (entry && nameref_p (entry) && (invisible_p (entry) == 0) && table == global_variables->table) { @@ -2550,6 +2567,16 @@ bind_variable_internal (name, value, table, hflags, aflags) var_setvalue (entry, make_variable_value (entry, value, 0)); } } +#if defined (ARRAY_VARS) + else if (entry == 0 && newname) + { + entry = make_new_array_variable (newname); /* indexed array by default */ + if (entry == 0) + return entry; + ind = array_expand_index (name, subp, sublen); + bind_array_element (entry, ind, value, aflags); + } +#endif else if (entry == 0) { entry = make_new_variable (name, table); @@ -2670,7 +2697,8 @@ bind_variable (name, value, flags) normal. */ if (nameref_cell (nv) == 0) return (bind_variable_internal (nv->name, value, nvc->table, 0, flags)); - return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags)); + /* XXX - bug here with ref=array[index] */ + return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags|ASS_FROMREF)); } else v = nv; |