hush: use ash's read builtin

function                                             old     new   delta
shell_builtin_read                                     -    1000   +1000
set_local_var_from_halves                              -      24     +24
setvar2                                                -       7      +7
...
popstring                                            140     134      -6
ash_main                                            1375    1368      -7
setvar                                               184     174     -10
arith_set_local_var                                   36       -     -36
builtin_read                                        1096     185    -911
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 5/23 up/down: 1038/-1007)        Total: 31 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2010-01-12 23:29:57 +01:00
parent 045f4ad92c
commit 03dad22f8a
18 changed files with 124 additions and 49 deletions

View File

@ -1884,7 +1884,7 @@ getoptsreset(const char *value)
* Return of a legal variable name (a letter or underscore followed by zero or
* more letters, underscores, and digits).
*/
static char *
static char* FAST_FUNC
endofname(const char *name)
{
char *p;
@ -1991,7 +1991,7 @@ findvar(struct var **vpp, const char *name)
/*
* Find the value of a variable. Returns NULL if not set.
*/
static const char *
static const char* FAST_FUNC
lookupvar(const char *name)
{
struct var *v;
@ -2114,6 +2114,12 @@ setvar(const char *name, const char *val, int flags)
INT_ON;
}
static void FAST_FUNC
setvar2(const char *name, const char *val)
{
setvar(name, val, 0);
}
#if ENABLE_ASH_GETOPTS
/*
* Safe version of setvar, returns 1 on success 0 on failure.
@ -5304,7 +5310,7 @@ ash_arith(const char *s)
int errcode = 0;
math_hooks.lookupvar = lookupvar;
math_hooks.setvar = setvar;
math_hooks.setvar = setvar2;
math_hooks.endofname = endofname;
INT_OFF;
@ -12526,7 +12532,7 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
}
}
r = builtin_read(setvar,
r = shell_builtin_read(setvar2,
argptr,
bltinlookup("IFS"), /* can be NULL */
read_flags,