aboutsummaryrefslogtreecommitdiff
path: root/tccpp.c
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2015-04-10 16:53:29 +0300
committerseyko <seyko2@gmail.com>2015-04-10 16:53:29 +0300
commitd81611b6416a397f69272bffdb90506869e3fce8 (patch)
treea3afcc150fd3c3d684a704d97b1abf4406f2a13e /tccpp.c
parent8037a1ce39730f729b75907d0fa5691412c82e46 (diff)
downloadtinycc-d81611b6416a397f69272bffdb90506869e3fce8.tar.gz
tinycc-d81611b6416a397f69272bffdb90506869e3fce8.tar.bz2
fix a preprocessor for .S
Lets assume that in *.S files a preprocessor directive follow '#' char w/o spaces between. Otherwise there is too many problems with the content of the comments.
Diffstat (limited to 'tccpp.c')
-rw-r--r--tccpp.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/tccpp.c b/tccpp.c
index 1d41d6b..f38e41a 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -782,6 +782,8 @@ redo_start:
else if (parse_flags & PARSE_FLAG_ASM_COMMENTS)
p = parse_line_comment(p);
}
+ else if (parse_flags & PARSE_FLAG_ASM_FILE)
+ p = parse_line_comment(p);
break;
_default:
default:
@@ -1432,7 +1434,7 @@ ST_FUNC void preprocess(int is_bof)
saved_parse_flags = parse_flags;
parse_flags = PARSE_FLAG_PREPROCESS | PARSE_FLAG_TOK_NUM |
PARSE_FLAG_LINEFEED;
- parse_flags |= (saved_parse_flags & PARSE_FLAG_ASM_COMMENTS);
+ parse_flags |= (saved_parse_flags & (PARSE_FLAG_ASM_FILE | PARSE_FLAG_ASM_COMMENTS));
next_nomacro();
redo:
switch(tok) {
@@ -2259,6 +2261,11 @@ maybe_newline:
case '#':
/* XXX: simplify */
PEEKC(c, p);
+ if (is_space(c) && (parse_flags & PARSE_FLAG_ASM_FILE)) {
+ p = parse_line_comment(p);
+ goto redo_no_start;
+ }
+ else
if ((tok_flags & TOK_FLAG_BOL) &&
(parse_flags & PARSE_FLAG_PREPROCESS)) {
file->buf_ptr = p;
@@ -2588,7 +2595,12 @@ maybe_newline:
p++;
break;
default:
- tcc_error("unrecognized character \\x%02x", c);
+ if ((parse_flags & PARSE_FLAG_ASM_FILE) == 0)
+ tcc_error("unrecognized character \\x%02x", c);
+ else {
+ tok = ' ';
+ p++;
+ }
break;
}
tok_flags = 0;
@@ -3215,7 +3227,8 @@ ST_FUNC int tcc_preprocess(TCCState *s1)
preprocess_init(s1);
ch = file->buf_ptr[0];
tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
- parse_flags = PARSE_FLAG_ASM_COMMENTS | PARSE_FLAG_PREPROCESS |
+ parse_flags = (parse_flags & PARSE_FLAG_ASM_FILE);
+ parse_flags |= PARSE_FLAG_ASM_COMMENTS | PARSE_FLAG_PREPROCESS |
PARSE_FLAG_LINEFEED | PARSE_FLAG_SPACES;
token_seen = 0;
file->line_ref = 0;