diff options
author | Ron Yorston <rmy@pobox.com> | 2021-05-14 08:17:12 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-05-14 08:17:12 +0100 |
commit | a3f5a1b7f4275f713acf22f534f95c0da8392e53 (patch) | |
tree | 49b65422a3e9c33f508da9ccf3ae79d324bd9e96 /libbb | |
parent | 375cda9a88024135d630ca8990d9aff4ea414e89 (diff) | |
parent | 7de0ab21d939a5a304157f75918d0318a95261a3 (diff) | |
download | busybox-w32-a3f5a1b7f4275f713acf22f534f95c0da8392e53.tar.gz busybox-w32-a3f5a1b7f4275f713acf22f534f95c0da8392e53.tar.bz2 busybox-w32-a3f5a1b7f4275f713acf22f534f95c0da8392e53.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/appletlib.c | 30 | ||||
-rw-r--r-- | libbb/duration.c | 14 | ||||
-rw-r--r-- | libbb/lineedit.c | 4 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 2 |
4 files changed, 37 insertions, 13 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 193a78e31..f53d74834 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -278,9 +278,14 @@ void lbb_prepare(const char *applet | |||
278 | && strcmp(argv[1], "--help") == 0 | 278 | && strcmp(argv[1], "--help") == 0 |
279 | && !is_prefixed_with(applet, "busybox") | 279 | && !is_prefixed_with(applet, "busybox") |
280 | ) { | 280 | ) { |
281 | /* Special case. POSIX says "test --help" | 281 | /* Special cases. POSIX says "test --help" |
282 | * should be no different from e.g. "test --foo". */ | 282 | * should be no different from e.g. "test --foo". |
283 | if (!ENABLE_TEST || strcmp(applet_name, "test") != 0) | 283 | */ |
284 | if (!(ENABLE_TEST && strcmp(applet_name, "test") == 0) | ||
285 | && !(ENABLE_TRUE && strcmp(applet_name, "true") == 0) | ||
286 | && !(ENABLE_FALSE && strcmp(applet_name, "false") == 0) | ||
287 | && !(ENABLE_ECHO && strcmp(applet_name, "echo") == 0) | ||
288 | ) | ||
284 | bb_show_usage(); | 289 | bb_show_usage(); |
285 | } | 290 | } |
286 | #endif | 291 | #endif |
@@ -1021,15 +1026,21 @@ int busybox_main(int argc UNUSED_PARAM, char **argv) | |||
1021 | if (!argv[2]) | 1026 | if (!argv[2]) |
1022 | goto help; | 1027 | goto help; |
1023 | /* convert to "<applet> --help" */ | 1028 | /* convert to "<applet> --help" */ |
1024 | argv[0] = argv[2]; | 1029 | applet_name = argv[0] = argv[2]; |
1025 | argv[2] = NULL; | 1030 | argv[2] = NULL; |
1031 | if (find_applet_by_name(applet_name) >= 0) { | ||
1032 | /* Make "--help foo" exit with 0: */ | ||
1033 | xfunc_error_retval = 0; | ||
1034 | bb_show_usage(); | ||
1035 | } /* else: unknown applet, fall through (causes "applet not found" later) */ | ||
1026 | } else { | 1036 | } else { |
1027 | /* "busybox <applet> arg1 arg2 ..." */ | 1037 | /* "busybox <applet> arg1 arg2 ..." */ |
1028 | argv++; | 1038 | argv++; |
1039 | /* We support "busybox /a/path/to/applet args..." too. Allows for | ||
1040 | * "#!/bin/busybox"-style wrappers | ||
1041 | */ | ||
1042 | applet_name = bb_get_last_path_component_nostrip(argv[0]); | ||
1029 | } | 1043 | } |
1030 | /* We support "busybox /a/path/to/applet args..." too. Allows for | ||
1031 | * "#!/bin/busybox"-style wrappers */ | ||
1032 | applet_name = bb_get_last_path_component_nostrip(argv[0]); | ||
1033 | run_applet_and_exit(applet_name, argv); | 1044 | run_applet_and_exit(applet_name, argv); |
1034 | } | 1045 | } |
1035 | # endif | 1046 | # endif |
@@ -1040,7 +1051,7 @@ void FAST_FUNC show_usage_if_dash_dash_help(int applet_no, char **argv) | |||
1040 | /* Special case. POSIX says "test --help" | 1051 | /* Special case. POSIX says "test --help" |
1041 | * should be no different from e.g. "test --foo". | 1052 | * should be no different from e.g. "test --foo". |
1042 | * Thus for "test", we skip --help check. | 1053 | * Thus for "test", we skip --help check. |
1043 | * "true" and "false" are also special. | 1054 | * "true", "false", "echo" are also special. |
1044 | */ | 1055 | */ |
1045 | if (1 | 1056 | if (1 |
1046 | # if defined APPLET_NO_test | 1057 | # if defined APPLET_NO_test |
@@ -1052,6 +1063,9 @@ void FAST_FUNC show_usage_if_dash_dash_help(int applet_no, char **argv) | |||
1052 | # if defined APPLET_NO_false | 1063 | # if defined APPLET_NO_false |
1053 | && applet_no != APPLET_NO_false | 1064 | && applet_no != APPLET_NO_false |
1054 | # endif | 1065 | # endif |
1066 | # if defined APPLET_NO_echo | ||
1067 | && applet_no != APPLET_NO_echo | ||
1068 | # endif | ||
1055 | # if ENABLE_PLATFORM_MINGW32 && defined APPLET_NO_busybox | 1069 | # if ENABLE_PLATFORM_MINGW32 && defined APPLET_NO_busybox |
1056 | && applet_no != APPLET_NO_busybox | 1070 | && applet_no != APPLET_NO_busybox |
1057 | # endif | 1071 | # endif |
diff --git a/libbb/duration.c b/libbb/duration.c index 086da15fb..a6a29ddae 100644 --- a/libbb/duration.c +++ b/libbb/duration.c | |||
@@ -37,8 +37,18 @@ duration_t FAST_FUNC parse_duration_str(char *str) | |||
37 | if (strchr(str, '.')) { | 37 | if (strchr(str, '.')) { |
38 | double d; | 38 | double d; |
39 | char *pp; | 39 | char *pp; |
40 | int len = strspn(str, "0123456789."); | 40 | int len; |
41 | char sv = str[len]; | 41 | char sv; |
42 | |||
43 | # if ENABLE_LOCALE_SUPPORT | ||
44 | /* Undo busybox.c: on input, we want to use dot | ||
45 | * as fractional separator in strtod(), | ||
46 | * regardless of current locale | ||
47 | */ | ||
48 | setlocale(LC_NUMERIC, "C"); | ||
49 | # endif | ||
50 | len = strspn(str, "0123456789."); | ||
51 | sv = str[len]; | ||
42 | str[len] = '\0'; | 52 | str[len] = '\0'; |
43 | errno = 0; | 53 | errno = 0; |
44 | d = strtod(str, &pp); | 54 | d = strtod(str, &pp); |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index c20436270..e7de32250 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -1157,7 +1157,7 @@ static NOINLINE int build_match_prefix(char *match_buf) | |||
1157 | continue; | 1157 | continue; |
1158 | for (--i; i >= 0; i--) { | 1158 | for (--i; i >= 0; i--) { |
1159 | int cur = int_buf[i]; | 1159 | int cur = int_buf[i]; |
1160 | if (cur == ' ' || cur == '<' || cur == '>' || cur == '|' || cur == '&') { | 1160 | if (cur == ' ' || cur == '<' || cur == '>' || cur == '|' || cur == '&' || cur == '=') { |
1161 | remove_chunk(int_buf, 0, i + 1); | 1161 | remove_chunk(int_buf, 0, i + 1); |
1162 | break; | 1162 | break; |
1163 | } | 1163 | } |
@@ -1426,7 +1426,7 @@ static NOINLINE void input_tab(smallint *lastWasTab) | |||
1426 | strcpy(&command[cursor_mb], chosen_match + match_pfx_len); | 1426 | strcpy(&command[cursor_mb], chosen_match + match_pfx_len); |
1427 | len = load_string(command); | 1427 | len = load_string(command); |
1428 | /* add match and tail */ | 1428 | /* add match and tail */ |
1429 | sprintf(&command[cursor_mb], "%s%s", chosen_match + match_pfx_len, match_buf); | 1429 | stpcpy(stpcpy(&command[cursor_mb], chosen_match + match_pfx_len), match_buf); |
1430 | command_len = load_string(command); | 1430 | command_len = load_string(command); |
1431 | /* write out the matched command */ | 1431 | /* write out the matched command */ |
1432 | /* paranoia: load_string can return 0 on conv error, | 1432 | /* paranoia: load_string can return 0 on conv error, |
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 47dbdd1b6..d7d8b1092 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -226,7 +226,7 @@ int FAST_FUNC rename_or_warn(const char *oldpath, const char *newpath) | |||
226 | return n; | 226 | return n; |
227 | } | 227 | } |
228 | 228 | ||
229 | void FAST_FUNC xpipe(int filedes[2]) | 229 | void FAST_FUNC xpipe(int *filedes) |
230 | { | 230 | { |
231 | if (pipe(filedes)) | 231 | if (pipe(filedes)) |
232 | bb_simple_perror_msg_and_die("can't create pipe"); | 232 | bb_simple_perror_msg_and_die("can't create pipe"); |