aboutsummaryrefslogtreecommitdiff
path: root/tccpp.c
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2016-04-13 10:23:46 +0300
committerseyko <seyko2@gmail.com>2016-04-13 10:23:46 +0300
commit6a49afb3ed134240f64bc219e2fb73ffb72ed326 (patch)
treeb79cdcd9840802c8c8938c27c37ccb19f95c65e2 /tccpp.c
parent989b5ee8aee98b44377a3c82c5d65f54c0c6eb2f (diff)
downloadtinycc-6a49afb3ed134240f64bc219e2fb73ffb72ed326.tar.gz
tinycc-6a49afb3ed134240f64bc219e2fb73ffb72ed326.tar.bz2
correct version of "Identifiers can start and/or contain"
A problem was in TOK_ASMDIR_text: - sprintf(sname, ".%s", get_tok_str(tok1, NULL)); + sprintf(sname, "%s", get_tok_str(tok1, NULL)); When tok1 is '.text', then sname is '..text'
Diffstat (limited to 'tccpp.c')
-rw-r--r--tccpp.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tccpp.c b/tccpp.c
index 603a65e..c8687e3 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1328,6 +1328,9 @@ ST_FUNC void parse_define(void)
parse_flags |= PARSE_FLAG_SPACES;
next_nomacro_spc();
if (tok == '(') {
+ /* must be able to parse TOK_DOTS (in asm mode '.' can be part of identifier) */
+ parse_flags &= ~PARSE_FLAG_ASM_FILE;
+ isidnum_table['.' - CH_EOF] = 0;
next_nomacro();
ps = &first;
if (tok != ')') for (;;) {
@@ -1355,6 +1358,9 @@ ST_FUNC void parse_define(void)
}
next_nomacro_spc();
t = MACRO_FUNC;
+ parse_flags |= (saved_parse_flags & PARSE_FLAG_ASM_FILE);
+ isidnum_table['.' - CH_EOF] =
+ (parse_flags & PARSE_FLAG_ASM_FILE) ? IS_ID : 0;
}
tok_str_new(&str);
spc = 2;
@@ -2508,7 +2514,8 @@ maybe_newline:
p--;
PEEKC(c, p);
parse_ident_slow:
- while (isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM)) {
+ while (isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
+ {
cstr_ccat(&tokcstr, c);
PEEKC(c, p);
}
@@ -2567,7 +2574,7 @@ maybe_newline:
cstr_reset(&tokcstr);
cstr_ccat(&tokcstr, '.');
goto parse_num;
- } else if ((isidnum_table['.' - CH_EOF] & IS_ID) != 0) { /* asm mode */
+ } else if (parse_flags & PARSE_FLAG_ASM_FILE) {
*--p = c = '.';
goto parse_ident_fast;
} else if (c == '.') {
@@ -3364,6 +3371,9 @@ ST_FUNC void preprocess_init(TCCState *s1)
isidnum_table['$' - CH_EOF] =
tcc_state->dollars_in_identifiers ? IS_ID : 0;
+
+ isidnum_table['.' - CH_EOF] =
+ (parse_flags & PARSE_FLAG_ASM_FILE) ? IS_ID : 0;
}
ST_FUNC void preprocess_new(void)