diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-08-05 15:42:29 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-08-05 18:11:15 +0200 |
commit | 19358cc31317dca4642417066c1445ce00438e18 (patch) | |
tree | 08b922ba5bbfe026432dc814341bc855892f90dd /shell/hush.c | |
parent | fd6f295a98956b7f495ba09a56528ef9e0d51398 (diff) | |
download | busybox-w32-19358cc31317dca4642417066c1445ce00438e18.tar.gz busybox-w32-19358cc31317dca4642417066c1445ce00438e18.tar.bz2 busybox-w32-19358cc31317dca4642417066c1445ce00438e18.zip |
ash,hush: fold shell_builtin_read() way-too-many params into a struct param
function old new delta
getoptscmd 587 584 -3
readcmd 240 224 -16
shell_builtin_read 1426 1399 -27
builtin_read 210 182 -28
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-74) Total: -74 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/shell/hush.c b/shell/hush.c index 4c8814a01..3c19bceaa 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -10500,40 +10500,29 @@ static int FAST_FUNC builtin_type(char **argv) | |||
10500 | static int FAST_FUNC builtin_read(char **argv) | 10500 | static int FAST_FUNC builtin_read(char **argv) |
10501 | { | 10501 | { |
10502 | const char *r; | 10502 | const char *r; |
10503 | char *opt_n = NULL; | 10503 | struct builtin_read_params params; |
10504 | char *opt_p = NULL; | 10504 | |
10505 | char *opt_t = NULL; | 10505 | memset(¶ms, 0, sizeof(params)); |
10506 | char *opt_u = NULL; | ||
10507 | char *opt_d = NULL; /* optimized out if !BASH */ | ||
10508 | const char *ifs; | ||
10509 | int read_flags; | ||
10510 | 10506 | ||
10511 | /* "!": do not abort on errors. | 10507 | /* "!": do not abort on errors. |
10512 | * Option string must start with "sr" to match BUILTIN_READ_xxx | 10508 | * Option string must start with "sr" to match BUILTIN_READ_xxx |
10513 | */ | 10509 | */ |
10514 | read_flags = getopt32(argv, | 10510 | params.read_flags = getopt32(argv, |
10515 | #if BASH_READ_D | 10511 | #if BASH_READ_D |
10516 | "!srn:p:t:u:d:", &opt_n, &opt_p, &opt_t, &opt_u, &opt_d | 10512 | "!srn:p:t:u:d:", ¶ms.opt_n, ¶ms.opt_p, ¶ms.opt_t, ¶ms.opt_u, ¶ms.opt_d |
10517 | #else | 10513 | #else |
10518 | "!srn:p:t:u:", &opt_n, &opt_p, &opt_t, &opt_u | 10514 | "!srn:p:t:u:", ¶ms.opt_n, ¶ms.opt_p, ¶ms.opt_t, ¶ms.opt_u |
10519 | #endif | 10515 | #endif |
10520 | ); | 10516 | ); |
10521 | if (read_flags == (uint32_t)-1) | 10517 | if ((uint32_t)params.read_flags == (uint32_t)-1) |
10522 | return EXIT_FAILURE; | 10518 | return EXIT_FAILURE; |
10523 | argv += optind; | 10519 | argv += optind; |
10524 | ifs = get_local_var_value("IFS"); /* can be NULL */ | 10520 | params.argv = argv; |
10521 | params.setvar = set_local_var_from_halves; | ||
10522 | params.ifs = get_local_var_value("IFS"); /* can be NULL */ | ||
10525 | 10523 | ||
10526 | again: | 10524 | again: |
10527 | r = shell_builtin_read(set_local_var_from_halves, | 10525 | r = shell_builtin_read(¶ms); |
10528 | argv, | ||
10529 | ifs, | ||
10530 | read_flags, | ||
10531 | opt_n, | ||
10532 | opt_p, | ||
10533 | opt_t, | ||
10534 | opt_u, | ||
10535 | opt_d | ||
10536 | ); | ||
10537 | 10526 | ||
10538 | if ((uintptr_t)r == 1 && errno == EINTR) { | 10527 | if ((uintptr_t)r == 1 && errno == EINTR) { |
10539 | unsigned sig = check_and_run_traps(); | 10528 | unsigned sig = check_and_run_traps(); |