[PATCH 3/6] tokenize_stream(): don't bother with isspace()
Al Viro <[email protected]> Tue, 31 Mar 2026 09:07:26 +0100
| Newsgroups | org.kernel.vger.linux-sparse |
|---|---|
| Message-ID | <[email protected]> |
we have a spare bit in cclass[]... Signed-off-by: Al Viro <[email protected]> --- tokenize.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tokenize.c b/tokenize.c index 7c12cf6e..e6e071ae 100644 --- a/tokenize.c +++ b/tokenize.c @@ -496,9 +496,16 @@ enum { Dot = 16, ValidSecond = 32, Quote = 64, + Whitespace = 128, }; static const char cclass[257] = { + [' ' + 1] = Whitespace, + ['\t' + 1] = Whitespace, + ['\n' + 1] = Whitespace, + ['\v' + 1] = Whitespace, + ['\r' + 1] = Whitespace, + ['\f' + 1] = Whitespace, ['0' + 1 ... '9' + 1] = Digit | Hex, ['A' + 1 ... 'D' + 1] = Letter | Hex, ['E' + 1] = Letter | Hex | Exp, /* E<exp> */ @@ -986,16 +993,16 @@ static struct token *tokenize_stream(stream_t *stream) { int c = nextchar(stream); while (c != EOF) { - if (!isspace(c)) { + if (!(cclass[c + 1] & Whitespace)) { struct token *token = alloc_token(stream); stream->token = token; stream->newline = 0; stream->whitespace = 0; c = get_one_token(c, stream); - continue; + } else { + stream->whitespace = 1; + c = nextchar(stream); } - stream->whitespace = 1; - c = nextchar(stream); } return mark_eof(stream); } -- 2.47.3