aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2013-02-06 20:02:05 +0200
committerArnold D. Robbins <arnold@skeeve.com>2013-02-06 20:02:05 +0200
commit8cb65a2e6865322136c6876de4a461331198145d (patch)
tree91c65490f7ef711761f0ee748eca30dd3299245f
parent422a9f84f8bc91f267a176e737dfc2d7670d540b (diff)
downloadegawk-8cb65a2e6865322136c6876de4a461331198145d.tar.gz
egawk-8cb65a2e6865322136c6876de4a461331198145d.tar.bz2
egawk-8cb65a2e6865322136c6876de4a461331198145d.zip
Clean up code for sprintf checking for zero args.
-rw-r--r--ChangeLog5
-rw-r--r--builtin.c9
2 files changed, 10 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b40a50f..5f7f665e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/builtin.c b/builtin.c
index db51dbdc..62b6b2f3 100644
--- a/builtin.c
+++ b/builtin.c
@@ -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);