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/ash.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/ash.c')
-rw-r--r-- | shell/ash.c | 38 |
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) | |||
13762 | static int FAST_FUNC | 13762 | static int FAST_FUNC |
13763 | readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 13763 | readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
13764 | { | 13764 | { |
13765 | char *opt_n = NULL; | 13765 | struct builtin_read_params params; |
13766 | char *opt_p = NULL; | ||
13767 | char *opt_t = NULL; | ||
13768 | char *opt_u = NULL; | ||
13769 | char *opt_d = NULL; /* optimized out if !BASH */ | ||
13770 | int read_flags = 0; | ||
13771 | const char *r; | 13766 | const char *r; |
13772 | int i; | 13767 | int i; |
13773 | 13768 | ||
13769 | memset(¶ms, 0, sizeof(params)); | ||
13770 | |||
13774 | while ((i = nextopt("p:u:rt:n:sd:")) != '\0') { | 13771 | while ((i = nextopt("p:u:rt:n:sd:")) != '\0') { |
13775 | switch (i) { | 13772 | switch (i) { |
13776 | case 'p': | 13773 | case 'p': |
13777 | opt_p = optionarg; | 13774 | params.opt_p = optionarg; |
13778 | break; | 13775 | break; |
13779 | case 'n': | 13776 | case 'n': |
13780 | opt_n = optionarg; | 13777 | params.opt_n = optionarg; |
13781 | break; | 13778 | break; |
13782 | case 's': | 13779 | case 's': |
13783 | read_flags |= BUILTIN_READ_SILENT; | 13780 | params.read_flags |= BUILTIN_READ_SILENT; |
13784 | break; | 13781 | break; |
13785 | case 't': | 13782 | case 't': |
13786 | opt_t = optionarg; | 13783 | params.opt_t = optionarg; |
13787 | break; | 13784 | break; |
13788 | case 'r': | 13785 | case 'r': |
13789 | read_flags |= BUILTIN_READ_RAW; | 13786 | params.read_flags |= BUILTIN_READ_RAW; |
13790 | break; | 13787 | break; |
13791 | case 'u': | 13788 | case 'u': |
13792 | opt_u = optionarg; | 13789 | params.opt_u = optionarg; |
13793 | break; | 13790 | break; |
13794 | #if BASH_READ_D | 13791 | #if BASH_READ_D |
13795 | case 'd': | 13792 | case 'd': |
13796 | opt_d = optionarg; | 13793 | params.opt_d = optionarg; |
13797 | break; | 13794 | break; |
13798 | #endif | 13795 | #endif |
13799 | default: | 13796 | default: |
@@ -13801,21 +13798,16 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
13801 | } | 13798 | } |
13802 | } | 13799 | } |
13803 | 13800 | ||
13801 | params.argv = argptr; | ||
13802 | params.setvar = setvar0; | ||
13803 | params.ifs = bltinlookup("IFS"); /* can be NULL */ | ||
13804 | |||
13804 | /* "read -s" needs to save/restore termios, can't allow ^C | 13805 | /* "read -s" needs to save/restore termios, can't allow ^C |
13805 | * to jump out of it. | 13806 | * to jump out of it. |
13806 | */ | 13807 | */ |
13807 | again: | 13808 | again: |
13808 | INT_OFF; | 13809 | INT_OFF; |
13809 | r = shell_builtin_read(setvar0, | 13810 | r = shell_builtin_read(¶ms); |
13810 | argptr, | ||
13811 | bltinlookup("IFS"), /* can be NULL */ | ||
13812 | read_flags, | ||
13813 | opt_n, | ||
13814 | opt_p, | ||
13815 | opt_t, | ||
13816 | opt_u, | ||
13817 | opt_d | ||
13818 | ); | ||
13819 | INT_ON; | 13811 | INT_ON; |
13820 | 13812 | ||
13821 | if ((uintptr_t)r == 1 && errno == EINTR) { | 13813 | if ((uintptr_t)r == 1 && errno == EINTR) { |