diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-07-02 23:24:52 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-07-02 23:26:09 +0200 |
commit | 646429e05e2f62250da80aa8d98111f3a9818e9a (patch) | |
tree | a7ce873385b5386fa3472c5d97f45db4c1f6977b | |
parent | a5d7b0f4f4e9728c3eb7a06d38227d9f3351e677 (diff) | |
download | busybox-w32-646429e05e2f62250da80aa8d98111f3a9818e9a.tar.gz busybox-w32-646429e05e2f62250da80aa8d98111f3a9818e9a.tar.bz2 busybox-w32-646429e05e2f62250da80aa8d98111f3a9818e9a.zip |
awk: use smaller regmatch_t arrays, they had 2 elements for no apparent reason
function old new delta
exec_builtin 1479 1434 -45
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/awk.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/editors/awk.c b/editors/awk.c index 9f14f0f9a..c06dd2304 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -1937,7 +1937,7 @@ static int awk_split(const char *s, node *spl, char **slist) | |||
1937 | n++; /* at least one field will be there */ | 1937 | n++; /* at least one field will be there */ |
1938 | do { | 1938 | do { |
1939 | int l; | 1939 | int l; |
1940 | regmatch_t pmatch[2]; // TODO: why [2]? [1] is enough... | 1940 | regmatch_t pmatch[1]; |
1941 | 1941 | ||
1942 | l = strcspn(s, c+2); /* len till next NUL or \n */ | 1942 | l = strcspn(s, c+2); /* len till next NUL or \n */ |
1943 | if (regexec1_nonempty(icase ? spl->r.ire : spl->l.re, s, pmatch) == 0 | 1943 | if (regexec1_nonempty(icase ? spl->r.ire : spl->l.re, s, pmatch) == 0 |
@@ -2166,7 +2166,7 @@ static int ptest(node *pattern) | |||
2166 | static int awk_getline(rstream *rsm, var *v) | 2166 | static int awk_getline(rstream *rsm, var *v) |
2167 | { | 2167 | { |
2168 | char *b; | 2168 | char *b; |
2169 | regmatch_t pmatch[2]; // TODO: why [2]? [1] is enough... | 2169 | regmatch_t pmatch[1]; |
2170 | int size, a, p, pp = 0; | 2170 | int size, a, p, pp = 0; |
2171 | int fd, so, eo, r, rp; | 2171 | int fd, so, eo, r, rp; |
2172 | char c, *m, *s; | 2172 | char c, *m, *s; |
@@ -2473,7 +2473,7 @@ static NOINLINE var *exec_builtin(node *op, var *res) | |||
2473 | node *an[4]; | 2473 | node *an[4]; |
2474 | var *av[4]; | 2474 | var *av[4]; |
2475 | const char *as[4]; | 2475 | const char *as[4]; |
2476 | regmatch_t pmatch[2]; | 2476 | regmatch_t pmatch[1]; |
2477 | regex_t sreg, *re; | 2477 | regex_t sreg, *re; |
2478 | node *spl; | 2478 | node *spl; |
2479 | uint32_t isr, info; | 2479 | uint32_t isr, info; |
@@ -3533,6 +3533,8 @@ int awk_main(int argc UNUSED_PARAM, char **argv) | |||
3533 | parse_program(llist_pop(&list_e)); | 3533 | parse_program(llist_pop(&list_e)); |
3534 | } | 3534 | } |
3535 | #endif | 3535 | #endif |
3536 | //FIXME: preserve order of -e and -f | ||
3537 | //TODO: implement -i LIBRARY and -E FILE too, they are easy-ish | ||
3536 | if (!(opt & (OPT_f | OPT_e))) { | 3538 | if (!(opt & (OPT_f | OPT_e))) { |
3537 | if (!*argv) | 3539 | if (!*argv) |
3538 | bb_show_usage(); | 3540 | bb_show_usage(); |