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>
diff --git a/shell/ash.c b/shell/ash.c
index c7deffd..31dc592 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1884,7 +1884,7 @@
* 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 @@
/*
* 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 @@
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 @@
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 @@
}
}
- r = builtin_read(setvar,
+ r = shell_builtin_read(setvar2,
argptr,
bltinlookup("IFS"), /* can be NULL */
read_flags,