diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-07-11 12:00:31 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-07-11 12:00:31 +0200 |
commit | 3d57a8490738d9febaa4496eba791e4fbfc91826 (patch) | |
tree | b421de22c2859dd18f34e99905ac38baba4d41d9 | |
parent | 49c3ce64f092fd5434fc67056f312bd32f82bae3 (diff) | |
download | busybox-w32-3d57a8490738d9febaa4496eba791e4fbfc91826.tar.gz busybox-w32-3d57a8490738d9febaa4496eba791e4fbfc91826.tar.bz2 busybox-w32-3d57a8490738d9febaa4496eba791e4fbfc91826.zip |
awk: undo TI_PRINT, it introduced a bug (print with any redirect acting as printf)
function old new delta
evaluate 3329 3337 +8
Patch by Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/awk.c | 8 | ||||
-rwxr-xr-x | testsuite/awk.tests | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/editors/awk.c b/editors/awk.c index 755e68fc7..0aa7c0804 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -462,8 +462,7 @@ static const uint32_t tokeninfo[] ALIGN4 = { | |||
462 | 0, | 462 | 0, |
463 | 0, /* \n */ | 463 | 0, /* \n */ |
464 | ST_IF, ST_DO, ST_FOR, OC_BREAK, | 464 | ST_IF, ST_DO, ST_FOR, OC_BREAK, |
465 | #define TI_PRINT OC_PRINT | 465 | OC_CONTINUE, OC_DELETE|Rx, OC_PRINT, |
466 | OC_CONTINUE, OC_DELETE|Rx, TI_PRINT, | ||
467 | OC_PRINTF, OC_NEXT, OC_NEXTFILE, | 466 | OC_PRINTF, OC_NEXT, OC_NEXTFILE, |
468 | OC_RETURN|Vx, OC_EXIT|Nx, | 467 | OC_RETURN|Vx, OC_EXIT|Nx, |
469 | ST_WHILE, | 468 | ST_WHILE, |
@@ -2944,7 +2943,10 @@ static var *evaluate(node *op, var *res) | |||
2944 | F = rsm->F; | 2943 | F = rsm->F; |
2945 | } | 2944 | } |
2946 | 2945 | ||
2947 | if (opinfo == TI_PRINT) { | 2946 | /* Can't just check 'opinfo == OC_PRINT' here, parser ORs |
2947 | * additional bits to opinfos of print/printf with redirects | ||
2948 | */ | ||
2949 | if ((opinfo & OPCLSMASK) == OC_PRINT) { | ||
2948 | if (!op1) { | 2950 | if (!op1) { |
2949 | fputs(getvar_s(intvar[F0]), F); | 2951 | fputs(getvar_s(intvar[F0]), F); |
2950 | } else { | 2952 | } else { |
diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 770d8ffce..6b23b91cb 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests | |||
@@ -450,4 +450,9 @@ testing "awk exit N propagates through END's exit" \ | |||
450 | "42\n" \ | 450 | "42\n" \ |
451 | '' '' | 451 | '' '' |
452 | 452 | ||
453 | testing "awk print + redirect" \ | ||
454 | "awk 'BEGIN { print \"STDERR %s\" >\"/dev/stderr\" }' 2>&1" \ | ||
455 | "STDERR %s\n" \ | ||
456 | '' '' | ||
457 | |||
453 | exit $FAILCOUNT | 458 | exit $FAILCOUNT |