}
while (p != s) {
--p;
- if (!(isspace)(*p)) { /* We want the function... not the inline. */
+ if (!isspace(*p)) {
p[1] = '\0';
break;
}
#include "libbb.h"
-#if ENABLE_LOCALE_SUPPORT
-#define isspace_given_isprint(c) isspace(c)
-#else
-#undef isspace
-#undef isprint
-#define isspace(c) ((((c) == ' ') || (((unsigned int)((c) - 9)) <= (13 - 9))))
-#define isprint(c) (((unsigned int)((c) - 0x20)) <= (0x7e - 0x20))
-#define isspace_given_isprint(c) ((c) == ' ')
+#if !ENABLE_LOCALE_SUPPORT
+# undef isprint
+# undef isspace
+# define isprint(c) ((unsigned)((c) - 0x20) <= (0x7e - 0x20))
+# define isspace(c) ((c) == ' ')
#endif
#if ENABLE_FEATURE_WC_LARGE
-#define COUNT_T unsigned long long
-#define COUNT_FMT "llu"
+# define COUNT_T unsigned long long
+# define COUNT_FMT "llu"
#else
-#define COUNT_T unsigned
-#define COUNT_FMT "u"
+# define COUNT_T unsigned
+# define COUNT_FMT "u"
#endif
enum {
c = getc(fp);
if (isprint(c)) {
++linepos;
- if (!isspace_given_isprint(c)) {
+ if (!isspace(c)) {
in_word = 1;
continue;
}
- } else if (((unsigned int)(c - 9)) <= 4) {
+ } else if ((unsigned)(c - 9) <= 4) {
/* \t 9
* \n 10
* \v 11
if (*cmdstr == '\n' || *cmdstr == '\\') {
cmdstr++;
break;
- } else if (isspace(*cmdstr))
- cmdstr++;
- else
+ }
+ if (!isspace(*cmdstr))
break;
+ cmdstr++;
}
sed_cmd->string = xstrdup(cmdstr);
/* "\anychar" -> "anychar" */
if (type == S_BEFORE_WS) {
c = ci;
- test = ((!isspace(c)) || c == '\n');
+ test = (!isspace(c) || c == '\n');
}
if (type == S_TO_WS) {
c = c0;
- test = ((!isspace(c)) || c == '\n');
+ test = (!isspace(c) || c == '\n');
}
if (type == S_OVER_WS) {
c = c0;
- test = ((isspace(c)));
+ test = isspace(c);
}
if (type == S_END_PUNCT) {
c = ci;
- test = ((ispunct(c)));
+ test = ispunct(c);
}
if (type == S_END_ALNUM) {
c = ci;
- test = ((isalnum(c)) || c == '_');
+ test = (isalnum(c) || c == '_');
}
*tested = c;
return test;
int c;
while (((c = getchar()) != EOF) && (c != '\n')) {
- /* Make sure we get the actual function call for isspace,
- * as speed is not critical here. */
- if (first && !(isspace)(c)) {
+ if (first && !isspace(c)) {
--first;
if ((c == 'y') || (c == 'Y')) {
++retval;
void FAST_FUNC trim(char *s)
{
size_t len = strlen(s);
- size_t lws;
/* trim trailing whitespace */
while (len && isspace(s[len-1]))
/* trim leading whitespace */
if (len) {
- lws = strspn(s, " \n\r\t\v");
- if (lws) {
- len -= lws;
- memmove(s, s + lws, len);
+ char *nws = skip_whitespace(s);
+ if ((nws - s) != 0) {
+ len -= (nws - s);
+ memmove(s, nws, len);
}
}
s[len] = '\0';
int old_errno;
char *e;
- /* Disallow '-' and any leading whitespace. Make sure we get the
- * actual isspace function rather than a macro implementaion. */
- if (*numstr == '-' || *numstr == '+' || (isspace)(*numstr))
+ /* Disallow '-' and any leading whitespace. */
+ if (*numstr == '-' || *numstr == '+' || isspace(*numstr))
goto inval;
/* Since this is a lib function, we're not allowed to reset errno to 0.
/* Find the end of any whitespace trailing behind
* the token and let that be part of the token */
- while (string[*ix] && (isspace)(string[*ix]) ) {
+ while (string[*ix] && isspace(string[*ix])) {
(*ix)++;
}