aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-08-05 15:42:29 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-08-05 18:11:15 +0200
commit19358cc31317dca4642417066c1445ce00438e18 (patch)
tree08b922ba5bbfe026432dc814341bc855892f90dd /shell/ash.c
parentfd6f295a98956b7f495ba09a56528ef9e0d51398 (diff)
downloadbusybox-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/ash.c')
-rw-r--r--shell/ash.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 4641dfd19..f74bef6b1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13762,38 +13762,35 @@ letcmd(int argc UNUSED_PARAM, char **argv)
static int FAST_FUNC
readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
- char *opt_n = NULL;
- char *opt_p = NULL;
- char *opt_t = NULL;
- char *opt_u = NULL;
- char *opt_d = NULL; /* optimized out if !BASH */
- int read_flags = 0;
+ struct builtin_read_params params;
const char *r;
int i;
+ memset(&params, 0, sizeof(params));
+
while ((i = nextopt("p:u:rt:n:sd:")) != '\0') {
switch (i) {
case 'p':
- opt_p = optionarg;
+ params.opt_p = optionarg;
break;
case 'n':
- opt_n = optionarg;
+ params.opt_n = optionarg;
break;
case 's':
- read_flags |= BUILTIN_READ_SILENT;
+ params.read_flags |= BUILTIN_READ_SILENT;
break;
case 't':
- opt_t = optionarg;
+ params.opt_t = optionarg;
break;
case 'r':
- read_flags |= BUILTIN_READ_RAW;
+ params.read_flags |= BUILTIN_READ_RAW;
break;
case 'u':
- opt_u = optionarg;
+ params.opt_u = optionarg;
break;
#if BASH_READ_D
case 'd':
- opt_d = optionarg;
+ params.opt_d = optionarg;
break;
#endif
default:
@@ -13801,21 +13798,16 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
}
}
+ params.argv = argptr;
+ params.setvar = setvar0;
+ params.ifs = bltinlookup("IFS"); /* can be NULL */
+
/* "read -s" needs to save/restore termios, can't allow ^C
* to jump out of it.
*/
again:
INT_OFF;
- r = shell_builtin_read(setvar0,
- argptr,
- bltinlookup("IFS"), /* can be NULL */
- read_flags,
- opt_n,
- opt_p,
- opt_t,
- opt_u,
- opt_d
- );
+ r = shell_builtin_read(&params);
INT_ON;
if ((uintptr_t)r == 1 && errno == EINTR) {