From 8cb65a2e6865322136c6876de4a461331198145d Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 6 Feb 2013 20:02:05 +0200 Subject: Clean up code for sprintf checking for zero args. --- builtin.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'builtin.c') 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); -- cgit v1.2.3