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>
This commit is contained in:
parent
4d902ea9de
commit
a5d7b0f4f4
@ -2679,7 +2679,8 @@ static int is_assignment(const char *expr)
|
|||||||
{
|
{
|
||||||
char *exprc, *val;
|
char *exprc, *val;
|
||||||
|
|
||||||
if (!isalnum_(*expr) || (val = strchr(expr, '=')) == NULL) {
|
val = (char*)endofname(expr);
|
||||||
|
if (val == (char*)expr || *val != '=') {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2699,7 +2700,6 @@ static rstream *next_input_file(void)
|
|||||||
#define rsm (G.next_input_file__rsm)
|
#define rsm (G.next_input_file__rsm)
|
||||||
#define files_happen (G.next_input_file__files_happen)
|
#define files_happen (G.next_input_file__files_happen)
|
||||||
|
|
||||||
FILE *F;
|
|
||||||
const char *fname, *ind;
|
const char *fname, *ind;
|
||||||
|
|
||||||
if (rsm.F)
|
if (rsm.F)
|
||||||
@ -2712,20 +2712,19 @@ static rstream *next_input_file(void)
|
|||||||
if (files_happen)
|
if (files_happen)
|
||||||
return NULL;
|
return NULL;
|
||||||
fname = "-";
|
fname = "-";
|
||||||
F = stdin;
|
rsm.F = stdin;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ind = getvar_s(incvar(intvar[ARGIND]));
|
ind = getvar_s(incvar(intvar[ARGIND]));
|
||||||
fname = getvar_s(findvar(iamarray(intvar[ARGV]), ind));
|
fname = getvar_s(findvar(iamarray(intvar[ARGV]), ind));
|
||||||
if (fname && *fname && !is_assignment(fname)) {
|
if (fname && *fname && !is_assignment(fname)) {
|
||||||
F = xfopen_stdin(fname);
|
rsm.F = xfopen_stdin(fname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
files_happen = TRUE;
|
files_happen = TRUE;
|
||||||
setvar_s(intvar[FILENAME], fname);
|
setvar_s(intvar[FILENAME], fname);
|
||||||
rsm.F = F;
|
|
||||||
return &rsm;
|
return &rsm;
|
||||||
#undef rsm
|
#undef rsm
|
||||||
#undef files_happen
|
#undef files_happen
|
||||||
|
Loading…
x
Reference in New Issue
Block a user