diff options
| author | Edmund Grimley Evans <Edmund.Grimley.Evans@gmail.com> | 2015-11-04 20:25:26 +0000 |
|---|---|---|
| committer | Edmund Grimley Evans <Edmund.Grimley.Evans@gmail.com> | 2015-11-04 20:25:26 +0000 |
| commit | 20f0c179daeaa191c1ec39ac8a9a93f1942c1673 (patch) | |
| tree | 13529d48903e9abc1f8cc58aae1e2ae83e3df068 | |
| parent | b051549f2eb9466c81538f3d3d07b59e4e624bb7 (diff) | |
| download | tinycc-20f0c179daeaa191c1ec39ac8a9a93f1942c1673.tar.gz tinycc-20f0c179daeaa191c1ec39ac8a9a93f1942c1673.tar.bz2 | |
tccpp.c: Define and use tok_last for checking if last token is space.
| -rw-r--r-- | tccpp.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -1032,6 +1032,19 @@ static inline void TOK_GET(int *t, const int **pp, CValue *cv) *pp = p; } +/* Calling this function is expensive, but it is not possible + to read a token string backwards. */ +static int tok_last(const int *str0, const int *str1) +{ + const int *str = str0; + int tok = 0; + CValue cval; + + while (str < str1) + TOK_GET(&tok, &str, &cval); + return tok; +} + static int macro_is_equal(const int *a, const int *b) { char buf[STRING_MAX_SIZE + 1]; @@ -3266,7 +3279,9 @@ static void macro_subst( end_macro (); } - spc = tok_str->len && is_space(tok_str->str[tok_str->len-1]); + spc = (tok_str->len && + is_space(tok_last(tok_str->str, + tok_str->str + tok_str->len))); } else { |
