summaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko2018-08-05 15:42:29 +0200
committerDenys Vlasenko2018-08-05 18:11:15 +0200
commit19358cc31317dca4642417066c1445ce00438e18 (patch)
tree08b922ba5bbfe026432dc814341bc855892f90dd /shell/hush.c
parentfd6f295a98956b7f495ba09a56528ef9e0d51398 (diff)
downloadbusybox-19358cc31317dca4642417066c1445ce00438e18.zip
busybox-19358cc31317dca4642417066c1445ce00438e18.tar.gz
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.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 4c8814a..3c19bce 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -10500,40 +10500,29 @@ static int FAST_FUNC builtin_type(char **argv)
static int FAST_FUNC builtin_read(char **argv)
{
const char *r;
- char *opt_n = NULL;
- char *opt_p = NULL;
- char *opt_t = NULL;
- char *opt_u = NULL;
- char *opt_d = NULL; /* optimized out if !BASH */
- const char *ifs;
- int read_flags;
+ struct builtin_read_params params;
+
+ memset(&params, 0, sizeof(params));
/* "!": do not abort on errors.
* Option string must start with "sr" to match BUILTIN_READ_xxx
*/
- read_flags = getopt32(argv,
+ params.read_flags = getopt32(argv,
#if BASH_READ_D
- "!srn:p:t:u:d:", &opt_n, &opt_p, &opt_t, &opt_u, &opt_d
+ "!srn:p:t:u:d:", &params.opt_n, &params.opt_p, &params.opt_t, &params.opt_u, &params.opt_d
#else
- "!srn:p:t:u:", &opt_n, &opt_p, &opt_t, &opt_u
+ "!srn:p:t:u:", &params.opt_n, &params.opt_p, &params.opt_t, &params.opt_u
#endif
);
- if (read_flags == (uint32_t)-1)
+ if ((uint32_t)params.read_flags == (uint32_t)-1)
return EXIT_FAILURE;
argv += optind;
- ifs = get_local_var_value("IFS"); /* can be NULL */
+ params.argv = argv;
+ params.setvar = set_local_var_from_halves;
+ params.ifs = get_local_var_value("IFS"); /* can be NULL */
again:
- r = shell_builtin_read(set_local_var_from_halves,
- argv,
- ifs,
- read_flags,
- opt_n,
- opt_p,
- opt_t,
- opt_u,
- opt_d
- );
+ r = shell_builtin_read(&params);
if ((uintptr_t)r == 1 && errno == EINTR) {
unsigned sig = check_and_run_traps();