diff options
author | Denys Vlasenko | 2021-06-30 12:42:39 +0200 |
---|---|---|
committer | Denys Vlasenko | 2021-06-30 12:42:39 +0200 |
commit | ca9278ee5855a91a5521960d3743809f47ed27b8 (patch) | |
tree | 2e12183874ba8f0b03dafde12f1be13323e5c993 | |
parent | d1507101695f6bad35a61c4770b7d3913597ac16 (diff) | |
download | busybox-ca9278ee5855a91a5521960d3743809f47ed27b8.zip busybox-ca9278ee5855a91a5521960d3743809f47ed27b8.tar.gz |
awk: rewrite "print" logic a bit to make it clearer
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/awk.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/editors/awk.c b/editors/awk.c index c05d5d6..0fbca04 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -2792,7 +2792,7 @@ static var *evaluate(node *op, var *res) if (!op1) { fputs(getvar_s(intvar[F0]), F); } else { - while (op1) { + for (;;) { var *v = evaluate(nextarg(&op1), v1); if (v->type & VF_NUMBER) { fmt_num(g_buf, MAXVARFMT, getvar_s(intvar[OFMT]), @@ -2801,13 +2801,12 @@ static var *evaluate(node *op, var *res) } else { fputs(getvar_s(v), F); } - - if (op1) - fputs(getvar_s(intvar[OFS]), F); + if (!op1) + break; + fputs(getvar_s(intvar[OFS]), F); } } fputs(getvar_s(intvar[ORS]), F); - } else { /* OC_PRINTF */ char *s = awk_printf(op1, &len); #if ENABLE_FEATURE_AWK_GNU_EXTENSIONS |