diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-07-18 22:21:24 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-07-18 22:21:24 +0200 |
commit | b9e35dc15dbf8aa22dbc260d121ad8f7a34017de (patch) | |
tree | a3b8e2677b36fc76ffbbec3d983fbd14c51f655f /libbb/lineedit.c | |
parent | 4cab7f3e63ff850bc478f96d0589a01dec878a00 (diff) | |
download | busybox-w32-b9e35dc15dbf8aa22dbc260d121ad8f7a34017de.tar.gz busybox-w32-b9e35dc15dbf8aa22dbc260d121ad8f7a34017de.tar.bz2 busybox-w32-b9e35dc15dbf8aa22dbc260d121ad8f7a34017de.zip |
lineedit: cosmetics, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r-- | libbb/lineedit.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 8a2ea7974..3905b8cc4 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 | ||
103 | enum { | 101 | enum { |
@@ -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 |
111 | static const char null_str[] ALIGN1 = ""; | 109 | static 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) |
196 | static void deinit_S(void) | 194 | static 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); |
@@ -1669,7 +1667,7 @@ static void parse_and_put_prompt(const char *prmt_ptr) | |||
1669 | c = *prmt_ptr++; | 1667 | c = *prmt_ptr++; |
1670 | 1668 | ||
1671 | switch (c) { | 1669 | switch (c) { |
1672 | # if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR | 1670 | # if ENABLE_USERNAME_OR_HOMEDIR |
1673 | case 'u': | 1671 | case 'u': |
1674 | pbuf = user_buf ? user_buf : (char*)""; | 1672 | pbuf = user_buf ? user_buf : (char*)""; |
1675 | break; | 1673 | break; |
@@ -1681,7 +1679,7 @@ static void parse_and_put_prompt(const char *prmt_ptr) | |||
1681 | case '$': | 1679 | case '$': |
1682 | c = (geteuid() == 0 ? '#' : '$'); | 1680 | c = (geteuid() == 0 ? '#' : '$'); |
1683 | break; | 1681 | break; |
1684 | # if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR | 1682 | # if ENABLE_USERNAME_OR_HOMEDIR |
1685 | case 'w': | 1683 | case 'w': |
1686 | /* /home/user[/something] -> ~[/something] */ | 1684 | /* /home/user[/something] -> ~[/something] */ |
1687 | pbuf = cwd_buf; | 1685 | pbuf = cwd_buf; |
@@ -1957,7 +1955,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
1957 | /* Now initialize things */ | 1955 | /* Now initialize things */ |
1958 | previous_SIGWINCH_handler = signal(SIGWINCH, win_changed); | 1956 | previous_SIGWINCH_handler = signal(SIGWINCH, win_changed); |
1959 | win_changed(0); /* do initial resizing */ | 1957 | win_changed(0); /* do initial resizing */ |
1960 | #if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR | 1958 | #if ENABLE_USERNAME_OR_HOMEDIR |
1961 | { | 1959 | { |
1962 | struct passwd *entry; | 1960 | struct passwd *entry; |
1963 | 1961 | ||
@@ -2379,7 +2377,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
2379 | } | 2377 | } |
2380 | #endif | 2378 | #endif |
2381 | 2379 | ||
2382 | /* Stop bug catching using "command_must_not_be_used" trick */ | 2380 | /* End of bug-catching "command_must_not_be_used" trick */ |
2383 | #undef command | 2381 | #undef command |
2384 | 2382 | ||
2385 | #if ENABLE_UNICODE_SUPPORT | 2383 | #if ENABLE_UNICODE_SUPPORT |
@@ -2413,7 +2411,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
2413 | return len; /* can't return command_len, DEINIT_S() destroys it */ | 2411 | return len; /* can't return command_len, DEINIT_S() destroys it */ |
2414 | } | 2412 | } |
2415 | 2413 | ||
2416 | #else | 2414 | #else /* !FEATURE_EDITING */ |
2417 | 2415 | ||
2418 | #undef read_line_input | 2416 | #undef read_line_input |
2419 | int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize) | 2417 | int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize) |
@@ -2424,7 +2422,7 @@ int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize) | |||
2424 | return strlen(command); | 2422 | return strlen(command); |
2425 | } | 2423 | } |
2426 | 2424 | ||
2427 | #endif /* FEATURE_EDITING */ | 2425 | #endif /* !FEATURE_EDITING */ |
2428 | 2426 | ||
2429 | 2427 | ||
2430 | /* | 2428 | /* |