aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-10-22 22:28:08 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-22 22:28:08 +0200
commitc0dab37d0a2e079d0e0c85aa979439373e9096ca (patch)
treea9604c6673dfef0726eebba516c5674bcf40ef3e
parent6935ec9c0b2ac58b1ddc206c21bea36582e1f233 (diff)
downloadbusybox-w32-c0dab37d0a2e079d0e0c85aa979439373e9096ca.tar.gz
busybox-w32-c0dab37d0a2e079d0e0c85aa979439373e9096ca.tar.bz2
busybox-w32-c0dab37d0a2e079d0e0c85aa979439373e9096ca.zip
*: remove last function calls to isspace
function old new delta xstrtoul_range_sfx 232 231 -1 xstrtoull_range_sfx 295 293 -2 trim 82 80 -2 trim_trailing_spaces_and_print 57 52 -5 isspace 18 - -18 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/cal.c2
-rw-r--r--coreutils/wc.c25
-rw-r--r--editors/sed.c6
-rw-r--r--editors/vi.c10
-rw-r--r--libbb/ask_confirmation.c4
-rw-r--r--libbb/trim.c9
-rw-r--r--libbb/xatonum_template.c5
-rw-r--r--shell/lash_unused.c2
8 files changed, 28 insertions, 35 deletions
diff --git a/coreutils/cal.c b/coreutils/cal.c
index ef70b0e35..7973b82a1 100644
--- a/coreutils/cal.c
+++ b/coreutils/cal.c
@@ -262,7 +262,7 @@ static void trim_trailing_spaces_and_print(char *s)
262 } 262 }
263 while (p != s) { 263 while (p != s) {
264 --p; 264 --p;
265 if (!(isspace)(*p)) { /* We want the function... not the inline. */ 265 if (!isspace(*p)) {
266 p[1] = '\0'; 266 p[1] = '\0';
267 break; 267 break;
268 } 268 }
diff --git a/coreutils/wc.c b/coreutils/wc.c
index d0e5482ca..3e32e3d6d 100644
--- a/coreutils/wc.c
+++ b/coreutils/wc.c
@@ -43,22 +43,19 @@
43 43
44#include "libbb.h" 44#include "libbb.h"
45 45
46#if ENABLE_LOCALE_SUPPORT 46#if !ENABLE_LOCALE_SUPPORT
47#define isspace_given_isprint(c) isspace(c) 47# undef isprint
48#else 48# undef isspace
49#undef isspace 49# define isprint(c) ((unsigned)((c) - 0x20) <= (0x7e - 0x20))
50#undef isprint 50# define isspace(c) ((c) == ' ')
51#define isspace(c) ((((c) == ' ') || (((unsigned int)((c) - 9)) <= (13 - 9))))
52#define isprint(c) (((unsigned int)((c) - 0x20)) <= (0x7e - 0x20))
53#define isspace_given_isprint(c) ((c) == ' ')
54#endif 51#endif
55 52
56#if ENABLE_FEATURE_WC_LARGE 53#if ENABLE_FEATURE_WC_LARGE
57#define COUNT_T unsigned long long 54# define COUNT_T unsigned long long
58#define COUNT_FMT "llu" 55# define COUNT_FMT "llu"
59#else 56#else
60#define COUNT_T unsigned 57# define COUNT_T unsigned
61#define COUNT_FMT "u" 58# define COUNT_FMT "u"
62#endif 59#endif
63 60
64enum { 61enum {
@@ -123,11 +120,11 @@ int wc_main(int argc UNUSED_PARAM, char **argv)
123 c = getc(fp); 120 c = getc(fp);
124 if (isprint(c)) { 121 if (isprint(c)) {
125 ++linepos; 122 ++linepos;
126 if (!isspace_given_isprint(c)) { 123 if (!isspace(c)) {
127 in_word = 1; 124 in_word = 1;
128 continue; 125 continue;
129 } 126 }
130 } else if (((unsigned int)(c - 9)) <= 4) { 127 } else if ((unsigned)(c - 9) <= 4) {
131 /* \t 9 128 /* \t 9
132 * \n 10 129 * \n 10
133 * \v 11 130 * \v 11
diff --git a/editors/sed.c b/editors/sed.c
index 9b360b669..27c345921 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -423,10 +423,10 @@ static const char *parse_cmd_args(sed_cmd_t *sed_cmd, const char *cmdstr)
423 if (*cmdstr == '\n' || *cmdstr == '\\') { 423 if (*cmdstr == '\n' || *cmdstr == '\\') {
424 cmdstr++; 424 cmdstr++;
425 break; 425 break;
426 } else if (isspace(*cmdstr)) 426 }
427 cmdstr++; 427 if (!isspace(*cmdstr))
428 else
429 break; 428 break;
429 cmdstr++;
430 } 430 }
431 sed_cmd->string = xstrdup(cmdstr); 431 sed_cmd->string = xstrdup(cmdstr);
432 /* "\anychar" -> "anychar" */ 432 /* "\anychar" -> "anychar" */
diff --git a/editors/vi.c b/editors/vi.c
index a24b72303..82f302dca 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -1783,23 +1783,23 @@ static int st_test(char *p, int type, int dir, char *tested)
1783 1783
1784 if (type == S_BEFORE_WS) { 1784 if (type == S_BEFORE_WS) {
1785 c = ci; 1785 c = ci;
1786 test = ((!isspace(c)) || c == '\n'); 1786 test = (!isspace(c) || c == '\n');
1787 } 1787 }
1788 if (type == S_TO_WS) { 1788 if (type == S_TO_WS) {
1789 c = c0; 1789 c = c0;
1790 test = ((!isspace(c)) || c == '\n'); 1790 test = (!isspace(c) || c == '\n');
1791 } 1791 }
1792 if (type == S_OVER_WS) { 1792 if (type == S_OVER_WS) {
1793 c = c0; 1793 c = c0;
1794 test = ((isspace(c))); 1794 test = isspace(c);
1795 } 1795 }
1796 if (type == S_END_PUNCT) { 1796 if (type == S_END_PUNCT) {
1797 c = ci; 1797 c = ci;
1798 test = ((ispunct(c))); 1798 test = ispunct(c);
1799 } 1799 }
1800 if (type == S_END_ALNUM) { 1800 if (type == S_END_ALNUM) {
1801 c = ci; 1801 c = ci;
1802 test = ((isalnum(c)) || c == '_'); 1802 test = (isalnum(c) || c == '_');
1803 } 1803 }
1804 *tested = c; 1804 *tested = c;
1805 return test; 1805 return test;
diff --git a/libbb/ask_confirmation.c b/libbb/ask_confirmation.c
index d08bc515e..9dfbd15cf 100644
--- a/libbb/ask_confirmation.c
+++ b/libbb/ask_confirmation.c
@@ -20,9 +20,7 @@ int FAST_FUNC bb_ask_confirmation(void)
20 int c; 20 int c;
21 21
22 while (((c = getchar()) != EOF) && (c != '\n')) { 22 while (((c = getchar()) != EOF) && (c != '\n')) {
23 /* Make sure we get the actual function call for isspace, 23 if (first && !isspace(c)) {
24 * as speed is not critical here. */
25 if (first && !(isspace)(c)) {
26 --first; 24 --first;
27 if ((c == 'y') || (c == 'Y')) { 25 if ((c == 'y') || (c == 'Y')) {
28 ++retval; 26 ++retval;
diff --git a/libbb/trim.c b/libbb/trim.c
index ea20ff370..df00b846e 100644
--- a/libbb/trim.c
+++ b/libbb/trim.c
@@ -13,7 +13,6 @@
13void FAST_FUNC trim(char *s) 13void FAST_FUNC trim(char *s)
14{ 14{
15 size_t len = strlen(s); 15 size_t len = strlen(s);
16 size_t lws;
17 16
18 /* trim trailing whitespace */ 17 /* trim trailing whitespace */
19 while (len && isspace(s[len-1])) 18 while (len && isspace(s[len-1]))
@@ -21,10 +20,10 @@ void FAST_FUNC trim(char *s)
21 20
22 /* trim leading whitespace */ 21 /* trim leading whitespace */
23 if (len) { 22 if (len) {
24 lws = strspn(s, " \n\r\t\v"); 23 char *nws = skip_whitespace(s);
25 if (lws) { 24 if ((nws - s) != 0) {
26 len -= lws; 25 len -= (nws - s);
27 memmove(s, s + lws, len); 26 memmove(s, nws, len);
28 } 27 }
29 } 28 }
30 s[len] = '\0'; 29 s[len] = '\0';
diff --git a/libbb/xatonum_template.c b/libbb/xatonum_template.c
index 339a7d35f..c97a4b795 100644
--- a/libbb/xatonum_template.c
+++ b/libbb/xatonum_template.c
@@ -25,9 +25,8 @@ unsigned type FAST_FUNC xstrtou(_range_sfx)(const char *numstr, int base,
25 int old_errno; 25 int old_errno;
26 char *e; 26 char *e;
27 27
28 /* Disallow '-' and any leading whitespace. Make sure we get the 28 /* Disallow '-' and any leading whitespace. */
29 * actual isspace function rather than a macro implementaion. */ 29 if (*numstr == '-' || *numstr == '+' || isspace(*numstr))
30 if (*numstr == '-' || *numstr == '+' || (isspace)(*numstr))
31 goto inval; 30 goto inval;
32 31
33 /* Since this is a lib function, we're not allowed to reset errno to 0. 32 /* Since this is a lib function, we're not allowed to reset errno to 0.
diff --git a/shell/lash_unused.c b/shell/lash_unused.c
index 2574987c5..f71daf236 100644
--- a/shell/lash_unused.c
+++ b/shell/lash_unused.c
@@ -697,7 +697,7 @@ static char * strsep_space(char *string, int * ix)
697 697
698 /* Find the end of any whitespace trailing behind 698 /* Find the end of any whitespace trailing behind
699 * the token and let that be part of the token */ 699 * the token and let that be part of the token */
700 while (string[*ix] && (isspace)(string[*ix]) ) { 700 while (string[*ix] && isspace(string[*ix])) {
701 (*ix)++; 701 (*ix)++;
702 } 702 }
703 703