diff --git a/ulib/string/char.h b/ulib/string/char.h index 145f35f..dd76015 100644 --- a/ulib/string/char.h +++ b/ulib/string/char.h @@ -14,4 +14,17 @@ #define string_chr_isascii(c) (!((c) < 0 || (c) > 0x7f)) #define string_chr_isxdigit(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) +#define STRING_CHECK_ALL(str, macro, okp) \ + do { \ + (okp) = true; \ + char *__p = (str); \ + while (*__p) { \ + if (!macro(*__p)) { \ + (okp) = false; \ + break; \ + } \ + __p++; \ + } \ + } while(0) + #endif // ULIB_STRING_CHAR_H_ diff --git a/user/tb/interp.c b/user/tb/interp.c index 0cf85ca..d7d7423 100644 --- a/user/tb/interp.c +++ b/user/tb/interp.c @@ -167,6 +167,13 @@ bool interp_runstring(char *string, InterpResult **res, bool logcmds, bool inter uprintf("+%s\n", line); } + bool skip; + STRING_CHECK_ALL(line, string_chr_isspace, skip); + if (skip) { + line = string_tokenizealloc(NULL, "\n"); + continue; + } + Tokenizer tz; ZERO(&tz); tz_init(&tz, line);