[git commit] awk: rewrite "print" logic a bit to make it clearer
Denys Vlasenko
vda.linux at googlemail.com
Wed Jun 30 10:42:39 UTC 2021
commit: https://git.busybox.net/busybox/commit/?id=ca9278ee5855a91a5521960d3743809f47ed27b8
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
editors/awk.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/editors/awk.c b/editors/awk.c
index c05d5d651..0fbca0433 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
More information about the busybox-cvs
mailing list