diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-04-09 16:13:32 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-04-09 16:15:01 -0700 |
commit | 2d698b6e42d8dca191ac795ef5dba3bf62496eec (patch) | |
tree | ac5e0b67043c50f49160e9fe407435706cf30444 /builtins/printf.def | |
parent | f1250933e4a2ac09a3d0b25b3877068e12f44da5 (diff) | |
download | vyatta-bash-2d698b6e42d8dca191ac795ef5dba3bf62496eec.tar.gz vyatta-bash-2d698b6e42d8dca191ac795ef5dba3bf62496eec.zip |
Integrate bash 3.2 version
This is merge of current Debian stable (Lenny) version of Bash
with Vyatta changes.
Diffstat (limited to 'builtins/printf.def')
-rw-r--r-- | builtins/printf.def | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/builtins/printf.def b/builtins/printf.def index e4e3170..0e1d4aa 100644 --- a/builtins/printf.def +++ b/builtins/printf.def @@ -91,6 +91,7 @@ extern int errno; do { \ char *b = 0; \ int nw; \ + clearerr (stdout); \ if (have_fieldwidth && have_precision) \ nw = asprintf(&b, f, fieldwidth, precision, func); \ else if (have_fieldwidth) \ @@ -106,6 +107,12 @@ extern int errno; (void)vbadd (b, nw); \ else \ (void)fputs (b, stdout); \ + if (ferror (stdout)) \ + { \ + sh_wrerror (); \ + clearerr (stdout); \ + return (EXECUTION_FAILURE); \ + } \ free (b); \ } \ } while (0) @@ -132,6 +139,11 @@ extern int errno; vbuf = 0; \ } \ fflush (stdout); \ + if (ferror (stdout)) \ + { \ + clearerr (stdout); \ + return (EXECUTION_FAILURE); \ + } \ return (value); \ } \ while (0) @@ -407,7 +419,9 @@ printf_builtin (list) r = 0; p = getstr (); - if (ansic_shouldquote (p)) + if (p && *p == 0) /* XXX - getstr never returns null */ + xp = savestring ("''"); + else if (ansic_shouldquote (p)) xp = ansic_quote (p, 0, (int *)0); else xp = sh_backslash_quote (p); @@ -816,7 +830,7 @@ vbadd (buf, blen) #ifdef DEBUG if (strlen (vbuf) != vblen) - internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, strlen (vbuf)); + internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf)); #endif return vbuf; |