aboutsummaryrefslogtreecommitdiffstats
path: root/builtins
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-11-21 20:57:16 -0500
committerChet Ramey <chet.ramey@case.edu>2011-11-21 20:57:16 -0500
commit30d188c2932d6ef609d894fefeb7e7b03ccff463 (patch)
tree51fa285584cb0f99c7a4d64b0b56d355a747b3e2 /builtins
parent0001803f0b9523c94fa2ede48eaecb047fef4524 (diff)
downloadandroid_external_bash-30d188c2932d6ef609d894fefeb7e7b03ccff463.tar.gz
android_external_bash-30d188c2932d6ef609d894fefeb7e7b03ccff463.tar.bz2
android_external_bash-30d188c2932d6ef609d894fefeb7e7b03ccff463.zip
Bash-4.1 patchlevel 11
Diffstat (limited to 'builtins')
-rw-r--r--builtins/declare.def2
-rw-r--r--builtins/fc.def22
-rw-r--r--builtins/printf.def4
-rw-r--r--builtins/read.def5
4 files changed, 26 insertions, 7 deletions
diff --git a/builtins/declare.def b/builtins/declare.def
index a0ce605..811d8e6 100644
--- a/builtins/declare.def
+++ b/builtins/declare.def
@@ -512,7 +512,7 @@ declare_internal (list, local_var)
{
/* let bind_{array,assoc}_variable take care of this. */
if (assoc_p (var))
- bind_assoc_variable (var, name, "0", value, aflags);
+ bind_assoc_variable (var, name, savestring ("0"), value, aflags);
else
bind_array_variable (name, 0, value, aflags);
}
diff --git a/builtins/fc.def b/builtins/fc.def
index a378d9d..71f468f 100644
--- a/builtins/fc.def
+++ b/builtins/fc.def
@@ -303,6 +303,16 @@ fc_builtin (list)
rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
last_hist = i - rh - hist_last_line_added;
+ /* XXX */
+ if (i == last_hist && hlist[last_hist] == 0)
+ while (last_hist >= 0 && hlist[last_hist] == 0)
+ last_hist--;
+ if (last_hist < 0)
+ {
+ sh_erange ((char *)NULL, _("history specification"));
+ return (EXECUTION_FAILURE);
+ }
+
if (list)
{
histbeg = fc_gethnum (list->word->word, hlist);
@@ -465,7 +475,7 @@ fc_gethnum (command, hlist)
HIST_ENTRY **hlist;
{
int sign, n, clen, rh;
- register int i, j;
+ register int i, j, last_hist;
register char *s;
sign = 1;
@@ -485,7 +495,15 @@ fc_gethnum (command, hlist)
has been enabled (interactive or not) should use it in the last_hist
calculation as if it were on. */
rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
- i -= rh + hist_last_line_added;
+ last_hist = i - rh - hist_last_line_added;
+
+ if (i == last_hist && hlist[last_hist] == 0)
+ while (last_hist >= 0 && hlist[last_hist] == 0)
+ last_hist--;
+ if (last_hist < 0)
+ return (-1);
+
+ i = last_hist;
/* No specification defaults to most recent command. */
if (command == NULL)
diff --git a/builtins/printf.def b/builtins/printf.def
index e447633..277566f 100644
--- a/builtins/printf.def
+++ b/builtins/printf.def
@@ -117,7 +117,7 @@ extern int errno;
else if (have_fieldwidth) \
nw = vflag ? vbprintf (f, fieldwidth, func) : printf (f, fieldwidth, func); \
else if (have_precision) \
- nw = vflag ? vbprintf (f, precision, func) : printf (f, fieldwidth, func); \
+ nw = vflag ? vbprintf (f, precision, func) : printf (f, precision, func); \
else \
nw = vflag ? vbprintf (f, func) : printf (f, func); \
tw += nw; \
@@ -172,7 +172,7 @@ extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__
#endif
#if !HAVE_VSNPRINTF
-extern int vsnprintf __P((char *, size_t, const char *, ...)) __attribute__((__format__ (printf, 3, 4)));
+extern int vsnprintf __P((char *, size_t, const char *, va_list)) __attribute__((__format__ (printf, 3, 0)));
#endif
static void printf_erange __P((char *));
diff --git a/builtins/read.def b/builtins/read.def
index 1ef9142..20860be 100644
--- a/builtins/read.def
+++ b/builtins/read.def
@@ -615,14 +615,15 @@ add_char:
if (unbuffered_read == 0)
zsyncfd (fd);
- interrupt_immediately--;
- terminate_immediately--;
discard_unwind_frame ("read_builtin");
retval = eof ? EXECUTION_FAILURE : EXECUTION_SUCCESS;
assign_vars:
+ interrupt_immediately--;
+ terminate_immediately--;
+
#if defined (ARRAY_VARS)
/* If -a was given, take the string read, break it into a list of words,
an assign them to `arrayname' in turn. */