diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-17 21:02:37 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-06-17 21:13:13 +0200 |
commit | 96769486e20fd5f1142cae0db2cbacef31dc75e9 (patch) | |
tree | f40b504f812eda9787084aaaf377fe1a144466d0 /shell/shell_common.c | |
parent | d0441222db80c6fc0c47fa014106d38e25bfada7 (diff) | |
download | busybox-w32-96769486e20fd5f1142cae0db2cbacef31dc75e9.tar.gz busybox-w32-96769486e20fd5f1142cae0db2cbacef31dc75e9.tar.bz2 busybox-w32-96769486e20fd5f1142cae0db2cbacef31dc75e9.zip |
shell: move varcmp() to shell_common.h and use it in hush
function old new delta
unset_local_var - 112 +112
findvar 31 35 +4
set_vars_and_save_old 144 141 -3
helper_export_local 235 230 -5
set_local_var 425 416 -9
handle_changed_special_names 38 27 -11
builtin_unset 154 141 -13
builtin_getopts 404 391 -13
get_local_var_value 281 260 -21
get_ptr_to_local_var 71 45 -26
unset_local_var_len 139 - -139
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/8 up/down: 116/-240) Total: -124 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/shell_common.c')
-rw-r--r-- | shell/shell_common.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/shell/shell_common.c b/shell/shell_common.c index 1eca101b9..e5c2cefb3 100644 --- a/shell/shell_common.c +++ b/shell/shell_common.c | |||
@@ -22,6 +22,25 @@ | |||
22 | const char defifsvar[] ALIGN1 = "IFS= \t\n"; | 22 | const char defifsvar[] ALIGN1 = "IFS= \t\n"; |
23 | const char defoptindvar[] ALIGN1 = "OPTIND=1"; | 23 | const char defoptindvar[] ALIGN1 = "OPTIND=1"; |
24 | 24 | ||
25 | /* Compare two strings up to the first '=' or '\0'. */ | ||
26 | int FAST_FUNC varcmp(const char *p, const char *q) | ||
27 | { | ||
28 | int c, d; | ||
29 | |||
30 | while ((c = *p) == (d = *q)) { | ||
31 | if (c == '\0' || c == '=') | ||
32 | goto out; | ||
33 | p++; | ||
34 | q++; | ||
35 | } | ||
36 | if (c == '=') | ||
37 | c = '\0'; | ||
38 | if (d == '=') | ||
39 | d = '\0'; | ||
40 | out: | ||
41 | return c - d; | ||
42 | } | ||
43 | |||
25 | /* read builtin */ | 44 | /* read builtin */ |
26 | 45 | ||
27 | /* Needs to be interruptible: shell must handle traps and shell-special signals | 46 | /* Needs to be interruptible: shell must handle traps and shell-special signals |