diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2013-02-06 20:02:05 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2013-02-06 20:02:05 +0200 |
commit | 8cb65a2e6865322136c6876de4a461331198145d (patch) | |
tree | 91c65490f7ef711761f0ee748eca30dd3299245f | |
parent | 422a9f84f8bc91f267a176e737dfc2d7670d540b (diff) | |
download | egawk-8cb65a2e6865322136c6876de4a461331198145d.tar.gz egawk-8cb65a2e6865322136c6876de4a461331198145d.tar.bz2 egawk-8cb65a2e6865322136c6876de4a461331198145d.zip |
Clean up code for sprintf checking for zero args.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | builtin.c | 9 |
2 files changed, 10 insertions, 4 deletions
@@ -1,3 +1,8 @@ +2013-02-06 Arnold D. Robbins <arnold@skeeve.com> + + * builtin.c (printf_common): Move nargs > 0 check into assert. + (do_sprintf): Add nargs check and fatal message to here. + 2013-01-31 Arnold D. Robbins <arnold@skeeve.com> * regcomp.c, regex.c, regex_internal.c, regexec.c: Update @@ -1392,10 +1392,7 @@ printf_common(int nargs) int i; NODE *r, *tmp; - if (nargs == 0) - fatal(_("[s]printf called with no arguments")); - - assert(nargs <= max_args); + assert(nargs > 0 && nargs <= max_args); for (i = 1; i <= nargs; i++) { tmp = args_array[nargs - i] = POP(); if (tmp->type == Node_var_array) { @@ -1418,6 +1415,10 @@ NODE * do_sprintf(int nargs) { NODE *r; + + if (nargs == 0) + fatal(_("sprintf: no arguments")); + r = printf_common(nargs); if (r == NULL) gawk_exit(EXIT_FATAL); |