aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-14 13:19:57 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-09-14 13:19:57 +1000
commitec71cb6575290eb6ad716e4f620db445d8e1bcd3 (patch)
tree219a5dba000e0ad98ff563bc6f7d45d274d3a178 /libbb
parentb5139d7cd8982d9b683cb1babf0bd759076aaab0 (diff)
parent6814cbc9288601840aedb372e2bd84dab76ffa43 (diff)
downloadbusybox-w32-ec71cb6575290eb6ad716e4f620db445d8e1bcd3.tar.gz
busybox-w32-ec71cb6575290eb6ad716e4f620db445d8e1bcd3.tar.bz2
busybox-w32-ec71cb6575290eb6ad716e4f620db445d8e1bcd3.zip
Merge branch 'origin/master' (early part)
Diffstat (limited to 'libbb')
-rw-r--r--libbb/Config.src3
-rw-r--r--libbb/README1
-rw-r--r--libbb/lineedit.c52
-rw-r--r--libbb/make_directory.c2
-rw-r--r--libbb/selinux_common.c1
-rw-r--r--libbb/xfuncs_printf.c4
6 files changed, 33 insertions, 30 deletions
diff --git a/libbb/Config.src b/libbb/Config.src
index 80b1e0d21..9b01757c6 100644
--- a/libbb/Config.src
+++ b/libbb/Config.src
@@ -98,7 +98,7 @@ config FEATURE_USERNAME_COMPLETION
98 98
99config FEATURE_EDITING_FANCY_PROMPT 99config FEATURE_EDITING_FANCY_PROMPT
100 bool "Fancy shell prompts" 100 bool "Fancy shell prompts"
101 default n 101 default y
102 depends on FEATURE_EDITING 102 depends on FEATURE_EDITING
103 help 103 help
104 Setting this option allows for prompts to use things like \w and 104 Setting this option allows for prompts to use things like \w and
@@ -153,6 +153,7 @@ config FEATURE_COPYBUF_KB
153config MONOTONIC_SYSCALL 153config MONOTONIC_SYSCALL
154 bool "Use clock_gettime(CLOCK_MONOTONIC) syscall" 154 bool "Use clock_gettime(CLOCK_MONOTONIC) syscall"
155 default n 155 default n
156 depends on PLATFORM_LINUX
156 help 157 help
157 Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring 158 Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring
158 time intervals (time, ping, traceroute etc need this). 159 time intervals (time, ping, traceroute etc need this).
diff --git a/libbb/README b/libbb/README
index 4f28f7e34..6e63dc5f2 100644
--- a/libbb/README
+++ b/libbb/README
@@ -8,4 +8,3 @@ that you wrote that is mis-attributed, do let me know so we can fix that up.
8 8
9 Erik Andersen 9 Erik Andersen
10 <andersen@codepoet.org> 10 <andersen@codepoet.org>
11
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index ab418c0ab..866f9230d 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -53,19 +53,15 @@
53#if ENABLE_FEATURE_EDITING 53#if ENABLE_FEATURE_EDITING
54 54
55 55
56#define ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR \ 56#define ENABLE_USERNAME_OR_HOMEDIR \
57 (ENABLE_FEATURE_USERNAME_COMPLETION || ENABLE_FEATURE_EDITING_FANCY_PROMPT) 57 (ENABLE_FEATURE_USERNAME_COMPLETION || ENABLE_FEATURE_EDITING_FANCY_PROMPT)
58#define IF_FEATURE_GETUSERNAME_AND_HOMEDIR(...) 58#define IF_USERNAME_OR_HOMEDIR(...)
59#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR 59#if ENABLE_USERNAME_OR_HOMEDIR
60#undef IF_FEATURE_GETUSERNAME_AND_HOMEDIR 60# undef IF_USERNAME_OR_HOMEDIR
61#define IF_FEATURE_GETUSERNAME_AND_HOMEDIR(...) __VA_ARGS__ 61# define IF_USERNAME_OR_HOMEDIR(...) __VA_ARGS__
62#endif 62#endif
63 63
64 64
65#define SEQ_CLEAR_TILL_END_OF_SCREEN "\033[J"
66//#define SEQ_CLEAR_TILL_END_OF_LINE "\033[K"
67
68
69#undef CHAR_T 65#undef CHAR_T
70#if ENABLE_UNICODE_SUPPORT 66#if ENABLE_UNICODE_SUPPORT
71# define BB_NUL ((wchar_t)0) 67# define BB_NUL ((wchar_t)0)
@@ -90,14 +86,16 @@ static bool BB_ispunct(CHAR_T c) { return ((unsigned)c < 256 && ispunct(c)); }
90# define BB_isalnum(c) isalnum(c) 86# define BB_isalnum(c) isalnum(c)
91# define BB_ispunct(c) ispunct(c) 87# define BB_ispunct(c) ispunct(c)
92#endif 88#endif
89#if ENABLE_UNICODE_PRESERVE_BROKEN
90# define unicode_mark_raw_byte(wc) ((wc) | 0x20000000)
91# define unicode_is_raw_byte(wc) ((wc) & 0x20000000)
92#else
93# define unicode_is_raw_byte(wc) 0
94#endif
93 95
94 96
95# if ENABLE_UNICODE_PRESERVE_BROKEN 97#define SEQ_CLEAR_TILL_END_OF_SCREEN "\033[J"
96# define unicode_mark_raw_byte(wc) ((wc) | 0x20000000) 98//#define SEQ_CLEAR_TILL_END_OF_LINE "\033[K"
97# define unicode_is_raw_byte(wc) ((wc) & 0x20000000)
98# else
99# define unicode_is_raw_byte(wc) 0
100# endif
101 99
102 100
103enum { 101enum {
@@ -107,7 +105,7 @@ enum {
107 : 0x7ff0 105 : 0x7ff0
108}; 106};
109 107
110#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR 108#if ENABLE_USERNAME_OR_HOMEDIR
111static const char null_str[] ALIGN1 = ""; 109static const char null_str[] ALIGN1 = "";
112#endif 110#endif
113 111
@@ -134,7 +132,7 @@ struct lineedit_statics {
134 int num_ok_lines; /* = 1; */ 132 int num_ok_lines; /* = 1; */
135#endif 133#endif
136 134
137#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR 135#if ENABLE_USERNAME_OR_HOMEDIR
138 char *user_buf; 136 char *user_buf;
139 char *home_pwd_buf; /* = (char*)null_str; */ 137 char *home_pwd_buf; /* = (char*)null_str; */
140#endif 138#endif
@@ -145,7 +143,7 @@ struct lineedit_statics {
145#endif 143#endif
146 144
147#if ENABLE_FEATURE_EDITING_VI 145#if ENABLE_FEATURE_EDITING_VI
148#define DELBUFSIZ 128 146# define DELBUFSIZ 128
149 CHAR_T *delptr; 147 CHAR_T *delptr;
150 smallint newdelflag; /* whether delbuf should be reused yet */ 148 smallint newdelflag; /* whether delbuf should be reused yet */
151 CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */ 149 CHAR_T delbuf[DELBUFSIZ]; /* a place to store deleted characters */
@@ -191,7 +189,7 @@ extern struct lineedit_statics *const lineedit_ptr_to_statics;
191 barrier(); \ 189 barrier(); \
192 cmdedit_termw = 80; \ 190 cmdedit_termw = 80; \
193 IF_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines = 1;) \ 191 IF_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines = 1;) \
194 IF_FEATURE_GETUSERNAME_AND_HOMEDIR(home_pwd_buf = (char*)null_str;) \ 192 IF_USERNAME_OR_HOMEDIR(home_pwd_buf = (char*)null_str;) \
195} while (0) 193} while (0)
196static void deinit_S(void) 194static void deinit_S(void)
197{ 195{
@@ -200,7 +198,7 @@ static void deinit_S(void)
200 * (otherwise it points to verbatim prompt (NOT malloced) */ 198 * (otherwise it points to verbatim prompt (NOT malloced) */
201 free((char*)cmdedit_prompt); 199 free((char*)cmdedit_prompt);
202#endif 200#endif
203#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR 201#if ENABLE_USERNAME_OR_HOMEDIR
204 free(user_buf); 202 free(user_buf);
205 if (home_pwd_buf != null_str) 203 if (home_pwd_buf != null_str)
206 free(home_pwd_buf); 204 free(home_pwd_buf);
@@ -1677,7 +1675,7 @@ static void parse_and_put_prompt(const char *prmt_ptr)
1677 c = *prmt_ptr++; 1675 c = *prmt_ptr++;
1678 1676
1679 switch (c) { 1677 switch (c) {
1680# if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR 1678# if ENABLE_USERNAME_OR_HOMEDIR
1681 case 'u': 1679 case 'u':
1682 pbuf = user_buf ? user_buf : (char*)""; 1680 pbuf = user_buf ? user_buf : (char*)"";
1683 break; 1681 break;
@@ -1689,7 +1687,7 @@ static void parse_and_put_prompt(const char *prmt_ptr)
1689 case '$': 1687 case '$':
1690 c = (geteuid() == 0 ? '#' : '$'); 1688 c = (geteuid() == 0 ? '#' : '$');
1691 break; 1689 break;
1692# if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR 1690# if ENABLE_USERNAME_OR_HOMEDIR
1693 case 'w': 1691 case 'w':
1694 /* /home/user[/something] -> ~[/something] */ 1692 /* /home/user[/something] -> ~[/something] */
1695 pbuf = cwd_buf; 1693 pbuf = cwd_buf;
@@ -1773,11 +1771,13 @@ static void cmdedit_setwidth(unsigned w, int redraw_flg)
1773 1771
1774static void win_changed(int nsig) 1772static void win_changed(int nsig)
1775{ 1773{
1774 int sv_errno = errno;
1776 unsigned width; 1775 unsigned width;
1777 get_terminal_width_height(0, &width, NULL); 1776 get_terminal_width_height(0, &width, NULL);
1778 cmdedit_setwidth(width, nsig /* - just a yes/no flag */); 1777 cmdedit_setwidth(width, nsig /* - just a yes/no flag */);
1779 if (nsig == SIGWINCH) 1778 if (nsig == SIGWINCH)
1780 signal(SIGWINCH, win_changed); /* rearm ourself */ 1779 signal(SIGWINCH, win_changed); /* rearm ourself */
1780 errno = sv_errno;
1781} 1781}
1782 1782
1783static int lineedit_read_key(char *read_key_buffer) 1783static int lineedit_read_key(char *read_key_buffer)
@@ -1967,7 +1967,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
1967 /* Now initialize things */ 1967 /* Now initialize things */
1968 previous_SIGWINCH_handler = signal(SIGWINCH, win_changed); 1968 previous_SIGWINCH_handler = signal(SIGWINCH, win_changed);
1969 win_changed(0); /* do initial resizing */ 1969 win_changed(0); /* do initial resizing */
1970#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR 1970#if ENABLE_USERNAME_OR_HOMEDIR
1971 { 1971 {
1972 struct passwd *entry; 1972 struct passwd *entry;
1973 1973
@@ -2389,7 +2389,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
2389 } 2389 }
2390#endif 2390#endif
2391 2391
2392/* Stop bug catching using "command_must_not_be_used" trick */ 2392/* End of bug-catching "command_must_not_be_used" trick */
2393#undef command 2393#undef command
2394 2394
2395#if ENABLE_UNICODE_SUPPORT 2395#if ENABLE_UNICODE_SUPPORT
@@ -2423,7 +2423,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
2423 return len; /* can't return command_len, DEINIT_S() destroys it */ 2423 return len; /* can't return command_len, DEINIT_S() destroys it */
2424} 2424}
2425 2425
2426#else 2426#else /* !FEATURE_EDITING */
2427 2427
2428#undef read_line_input 2428#undef read_line_input
2429int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize) 2429int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize)
@@ -2434,7 +2434,7 @@ int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize)
2434 return strlen(command); 2434 return strlen(command);
2435} 2435}
2436 2436
2437#endif /* FEATURE_EDITING */ 2437#endif /* !FEATURE_EDITING */
2438 2438
2439 2439
2440/* 2440/*
diff --git a/libbb/make_directory.c b/libbb/make_directory.c
index 1eb8a8a49..4bb79bdf6 100644
--- a/libbb/make_directory.c
+++ b/libbb/make_directory.c
@@ -93,7 +93,7 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags)
93 if (mkdir(path, 0777) < 0) { 93 if (mkdir(path, 0777) < 0) {
94 /* If we failed for any other reason than the directory 94 /* If we failed for any other reason than the directory
95 * already exists, output a diagnostic and return -1 */ 95 * already exists, output a diagnostic and return -1 */
96 if (errno != EEXIST 96 if ((errno != EEXIST && errno != EISDIR)
97 || !(flags & FILEUTILS_RECUR) 97 || !(flags & FILEUTILS_RECUR)
98 || ((stat(path, &st) < 0) || !S_ISDIR(st.st_mode)) 98 || ((stat(path, &st) < 0) || !S_ISDIR(st.st_mode))
99 ) { 99 ) {
diff --git a/libbb/selinux_common.c b/libbb/selinux_common.c
index 7b5696754..2acb50e96 100644
--- a/libbb/selinux_common.c
+++ b/libbb/selinux_common.c
@@ -53,4 +53,3 @@ void FAST_FUNC selinux_preserve_fcontext(int fdesc)
53 setfscreatecon_or_die(context); 53 setfscreatecon_or_die(context);
54 freecon(context); 54 freecon(context);
55} 55}
56
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index 3e189c2d1..31a6d8e3c 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -401,8 +401,12 @@ int FAST_FUNC xsocket(int domain, int type, int protocol)
401 /* Hijack vaguely related config option */ 401 /* Hijack vaguely related config option */
402#if ENABLE_VERBOSE_RESOLUTION_ERRORS 402#if ENABLE_VERBOSE_RESOLUTION_ERRORS
403 const char *s = "INET"; 403 const char *s = "INET";
404# ifdef AF_PACKET
404 if (domain == AF_PACKET) s = "PACKET"; 405 if (domain == AF_PACKET) s = "PACKET";
406# endif
407# ifdef AF_NETLINK
405 if (domain == AF_NETLINK) s = "NETLINK"; 408 if (domain == AF_NETLINK) s = "NETLINK";
409# endif
406IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";) 410IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";)
407 bb_perror_msg_and_die("socket(AF_%s,%d,%d)", s, type, protocol); 411 bb_perror_msg_and_die("socket(AF_%s,%d,%d)", s, type, protocol);
408#else 412#else