aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-07-02 23:07:21 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-07-02 23:07:21 +0200
commita5d7b0f4f4e9728c3eb7a06d38227d9f3351e677 (patch)
treee0f0753152820bb0fee88f0b97085dc9a2b66244
parent4d902ea9def573cd15271177abbfa50fbf30c84f (diff)
downloadbusybox-w32-a5d7b0f4f4e9728c3eb7a06d38227d9f3351e677.tar.gz
busybox-w32-a5d7b0f4f4e9728c3eb7a06d38227d9f3351e677.tar.bz2
busybox-w32-a5d7b0f4f4e9728c3eb7a06d38227d9f3351e677.zip
awk: fix detection of VAR=VAL arguments
1NAME=VAL is not it, neither is VA.R=VAL function old new delta next_input_file 216 214 -2 is_assignment 115 91 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-26) Total: -26 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/awk.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 86cb7a95f..9f14f0f9a 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -2679,7 +2679,8 @@ static int is_assignment(const char *expr)
2679{ 2679{
2680 char *exprc, *val; 2680 char *exprc, *val;
2681 2681
2682 if (!isalnum_(*expr) || (val = strchr(expr, '=')) == NULL) { 2682 val = (char*)endofname(expr);
2683 if (val == (char*)expr || *val != '=') {
2683 return FALSE; 2684 return FALSE;
2684 } 2685 }
2685 2686
@@ -2699,7 +2700,6 @@ static rstream *next_input_file(void)
2699#define rsm (G.next_input_file__rsm) 2700#define rsm (G.next_input_file__rsm)
2700#define files_happen (G.next_input_file__files_happen) 2701#define files_happen (G.next_input_file__files_happen)
2701 2702
2702 FILE *F;
2703 const char *fname, *ind; 2703 const char *fname, *ind;
2704 2704
2705 if (rsm.F) 2705 if (rsm.F)
@@ -2712,20 +2712,19 @@ static rstream *next_input_file(void)
2712 if (files_happen) 2712 if (files_happen)
2713 return NULL; 2713 return NULL;
2714 fname = "-"; 2714 fname = "-";
2715 F = stdin; 2715 rsm.F = stdin;
2716 break; 2716 break;
2717 } 2717 }
2718 ind = getvar_s(incvar(intvar[ARGIND])); 2718 ind = getvar_s(incvar(intvar[ARGIND]));
2719 fname = getvar_s(findvar(iamarray(intvar[ARGV]), ind)); 2719 fname = getvar_s(findvar(iamarray(intvar[ARGV]), ind));
2720 if (fname && *fname && !is_assignment(fname)) { 2720 if (fname && *fname && !is_assignment(fname)) {
2721 F = xfopen_stdin(fname); 2721 rsm.F = xfopen_stdin(fname);
2722 break; 2722 break;
2723 } 2723 }
2724 } 2724 }
2725 2725
2726 files_happen = TRUE; 2726 files_happen = TRUE;
2727 setvar_s(intvar[FILENAME], fname); 2727 setvar_s(intvar[FILENAME], fname);
2728 rsm.F = F;
2729 return &rsm; 2728 return &rsm;
2730#undef rsm 2729#undef rsm
2731#undef files_happen 2730#undef files_happen