History

tccpp.c: Define and use tok_last for checking if last token is space.

Edmund Grimley Evans committed 11 years ago

Commit 20f0c171 parent b0515491 file · +16 −1Browse files

Unified · Split

tccpp.c+16−1
@@ -1032,6 +1032,19 @@ static inline void TOK_GET(int *t, const int **pp, CValue *cv) · 1031 unmodified lines
10321032 *pp = p;
10331033 }
10341034
1035+/* Calling this function is expensive, but it is not possible
1036+ to read a token string backwards. */
1037+static int tok_last(const int *str0, const int *str1)
1038+{
1039+ const int *str = str0;
1040+ int tok = 0;
1041+ CValue cval;
1042+
1043+ while (str < str1)
1044+ TOK_GET(&tok, &str, &cval);
1045+ return tok;
1046+}
1047+
10351048 static int macro_is_equal(const int *a, const int *b)
10361049 {
10371050 char buf[STRING_MAX_SIZE + 1];
@@ -3266,7 +3279,9 @@ static void macro_subst( · 2228 unmodified lines
32663279 end_macro ();
32673280 }
32683281
3269− spc = tok_str->len && is_space(tok_str->str[tok_str->len-1]);
3282+ spc = (tok_str->len &&
3283+ is_space(tok_last(tok_str->str,
3284+ tok_str->str + tok_str->len)));
32703285
32713286 } else {
32723287

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t