diff options
author | Ron Yorston <rmy@pobox.com> | 2013-03-19 11:18:39 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2013-03-19 11:18:39 +0000 |
commit | 63d2c5fead323df5f4250ed544d0bc03527c8936 (patch) | |
tree | 660979b139a4bc4b143c08843cb7efbc69bdcb4d /libbb | |
parent | 27fc2d535588728ac3ca69337271471fb6fe3ee9 (diff) | |
parent | a42f530e034b673726a91ea5d8202254e677f066 (diff) | |
download | busybox-w32-63d2c5fead323df5f4250ed544d0bc03527c8936.tar.gz busybox-w32-63d2c5fead323df5f4250ed544d0bc03527c8936.tar.bz2 busybox-w32-63d2c5fead323df5f4250ed544d0bc03527c8936.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/appletlib.c | 2 | ||||
-rw-r--r-- | libbb/endofname.c | 26 | ||||
-rw-r--r-- | libbb/lineedit.c | 1 | ||||
-rw-r--r-- | libbb/platform.c | 10 | ||||
-rw-r--r-- | libbb/xreadlink.c | 3 |
5 files changed, 36 insertions, 6 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index fb06ab9a5..f0df4e080 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -752,7 +752,7 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) | |||
752 | //TODO: just compare applet_no with APPLET_NO_test | 752 | //TODO: just compare applet_no with APPLET_NO_test |
753 | if (!ENABLE_TEST || strcmp(applet_name, "test") != 0) { | 753 | if (!ENABLE_TEST || strcmp(applet_name, "test") != 0) { |
754 | /* If you want "foo --help" to return 0: */ | 754 | /* If you want "foo --help" to return 0: */ |
755 | /*xfunc_error_retval = 0;*/ | 755 | xfunc_error_retval = 0; |
756 | bb_show_usage(); | 756 | bb_show_usage(); |
757 | } | 757 | } |
758 | } | 758 | } |
diff --git a/libbb/endofname.c b/libbb/endofname.c new file mode 100644 index 000000000..305f0932b --- /dev/null +++ b/libbb/endofname.c | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * Utility routines. | ||
3 | * | ||
4 | * Copyright (C) 2013 Denys Vlasenko | ||
5 | * | ||
6 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
7 | */ | ||
8 | |||
9 | //kbuild:lib-y += endofname.o | ||
10 | |||
11 | #include "libbb.h" | ||
12 | |||
13 | #define is_name(c) ((c) == '_' || isalpha((unsigned char)(c))) | ||
14 | #define is_in_name(c) ((c) == '_' || isalnum((unsigned char)(c))) | ||
15 | |||
16 | const char* FAST_FUNC | ||
17 | endofname(const char *name) | ||
18 | { | ||
19 | if (!is_name(*name)) | ||
20 | return name; | ||
21 | while (*++name) { | ||
22 | if (!is_in_name(*name)) | ||
23 | break; | ||
24 | } | ||
25 | return name; | ||
26 | } | ||
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 8a276d941..09e203159 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -187,6 +187,7 @@ extern struct lineedit_statics *const lineedit_ptr_to_statics; | |||
187 | cmdedit_termw = 80; \ | 187 | cmdedit_termw = 80; \ |
188 | IF_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines = 1;) \ | 188 | IF_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines = 1;) \ |
189 | IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \ | 189 | IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \ |
190 | IF_FEATURE_EDITING_VI(delptr = delbuf;) \ | ||
190 | } while (0) | 191 | } while (0) |
191 | 192 | ||
192 | static void deinit_S(void) | 193 | static void deinit_S(void) |
diff --git a/libbb/platform.c b/libbb/platform.c index 2bf34f5bc..19734517b 100644 --- a/libbb/platform.c +++ b/libbb/platform.c | |||
@@ -28,14 +28,16 @@ int FAST_FUNC vasprintf(char **string_ptr, const char *format, va_list p) | |||
28 | r = vsnprintf(buf, 128, format, p); | 28 | r = vsnprintf(buf, 128, format, p); |
29 | va_end(p); | 29 | va_end(p); |
30 | 30 | ||
31 | /* Note: can't use xstrdup/xmalloc, they call vasprintf (us) on failure! */ | ||
32 | |||
31 | if (r < 128) { | 33 | if (r < 128) { |
32 | va_end(p2); | 34 | va_end(p2); |
33 | *string_ptr = xstrdup(buf); | 35 | *string_ptr = strdup(buf); |
34 | return r; | 36 | return (*string_ptr ? r : -1); |
35 | } | 37 | } |
36 | 38 | ||
37 | *string_ptr = xmalloc(r+1); | 39 | *string_ptr = malloc(r+1); |
38 | r = vsnprintf(*string_ptr, r+1, format, p2); | 40 | r = (*string_ptr ? vsnprintf(*string_ptr, r+1, format, p2) : -1); |
39 | va_end(p2); | 41 | va_end(p2); |
40 | 42 | ||
41 | return r; | 43 | return r; |
diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index f2faa6d7a..bc1d0e665 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c | |||
@@ -102,7 +102,8 @@ char* FAST_FUNC xmalloc_readlink_or_warn(const char *path) | |||
102 | 102 | ||
103 | char* FAST_FUNC xmalloc_realpath(const char *path) | 103 | char* FAST_FUNC xmalloc_realpath(const char *path) |
104 | { | 104 | { |
105 | #if defined(__GLIBC__) && !defined(__UCLIBC__) | 105 | #if defined(__GLIBC__) || \ |
106 | (defined(__UCLIBC__) && UCLIBC_VERSION >= KERNEL_VERSION(0, 9, 31)) | ||
106 | /* glibc provides a non-standard extension */ | 107 | /* glibc provides a non-standard extension */ |
107 | /* new: POSIX.1-2008 specifies this behavior as well */ | 108 | /* new: POSIX.1-2008 specifies this behavior as well */ |
108 | return realpath(path, NULL); | 109 | return realpath(path, NULL); |