From bbcb54a1f40fe283a3503268dd141657598c2623 Mon Sep 17 00:00:00 2001 From: seyko Date: Mon, 27 Apr 2015 16:36:58 +0300 Subject: [PATCH] replace PARSE_FLAG_ASM_COMMENTS with PARSE_FLAG_ASM_FILE after "assign PARSE_FLAG_ASM_COMMENTS only for asm files" functions of this flags are identical --- libtcc.c | 2 +- tcc.h | 3 +-- tccasm.c | 2 +- tccpp.c | 14 +++++++------- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/libtcc.c b/libtcc.c index abef9c8..90dd185 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1166,7 +1166,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags, /* if .S file, define __ASSEMBLER__ like gcc does */ if ((filetype == TCC_FILETYPE_ASM) || (filetype == TCC_FILETYPE_ASM_PP)) { tcc_define_symbol(s1, "__ASSEMBLER__", NULL); - parse_flags = PARSE_FLAG_ASM_FILE | PARSE_FLAG_ASM_COMMENTS; + parse_flags = PARSE_FLAG_ASM_FILE; } #endif diff --git a/tcc.h b/tcc.h index a0b4894..384e8de 100644 --- a/tcc.h +++ b/tcc.h @@ -1150,9 +1150,8 @@ ST_DATA TokenSym **table_ident; #define PARSE_FLAG_LINEFEED 0x0004 /* line feed is returned as a token. line feed is also returned at eof */ -#define PARSE_FLAG_ASM_COMMENTS 0x0008 /* '#' can be used for line comment */ +#define PARSE_FLAG_ASM_FILE 0x0008 /* we processing an asm file: '#' can be used for line comment, etc. */ #define PARSE_FLAG_SPACES 0x0010 /* next() returns space tokens (for -E) */ -#define PARSE_FLAG_ASM_FILE 0x0020 /* we processing an asm file */ ST_FUNC TokenSym *tok_alloc(const char *str, int len); ST_FUNC char *get_tok_str(int v, CValue *cv); diff --git a/tccasm.c b/tccasm.c index 87ec175..b46ce3d 100644 --- a/tccasm.c +++ b/tccasm.c @@ -747,7 +747,7 @@ static int tcc_assemble_internal(TCCState *s1, int do_preprocess) ch = file->buf_ptr[0]; tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF; - parse_flags = PARSE_FLAG_ASM_COMMENTS | PARSE_FLAG_ASM_FILE; + parse_flags = PARSE_FLAG_ASM_FILE; if (do_preprocess) parse_flags |= PARSE_FLAG_PREPROCESS; next(); diff --git a/tccpp.c b/tccpp.c index 921d589..62bfa9a 100644 --- a/tccpp.c +++ b/tccpp.c @@ -779,7 +779,7 @@ redo_start: in_warn_or_error = 1; else if (tok == TOK_LINEFEED) goto redo_start; - else if (parse_flags & PARSE_FLAG_ASM_COMMENTS) + else if (parse_flags & PARSE_FLAG_ASM_FILE) p = parse_line_comment(p); } else if (parse_flags & PARSE_FLAG_ASM_FILE) @@ -1503,7 +1503,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_FILE | PARSE_FLAG_ASM_COMMENTS)); + parse_flags |= (saved_parse_flags & PARSE_FLAG_ASM_FILE); next_nomacro(); redo: switch(tok) { @@ -1745,7 +1745,7 @@ include_done: next(); if (tok != TOK_LINEFEED) { if (tok != TOK_STR) { - if ((parse_flags & PARSE_FLAG_ASM_COMMENTS) == 0) { + if ((parse_flags & PARSE_FLAG_ASM_FILE) == 0) { file->line_num = i; tcc_error("#line format is wrong"); } @@ -1786,7 +1786,7 @@ include_done: /* '!' is ignored to allow C scripts. numbers are ignored to emulate cpp behaviour */ } else { - if (!(parse_flags & PARSE_FLAG_ASM_COMMENTS)) + if (!(parse_flags & PARSE_FLAG_ASM_FILE)) tcc_warning("Ignoring unknown preprocessing directive #%s", get_tok_str(tok, &tokc)); else { /* this is a gas line comment in an 'S' file. */ @@ -2346,7 +2346,7 @@ maybe_newline: p++; tok = TOK_TWOSHARPS; } else { - if (parse_flags & PARSE_FLAG_ASM_COMMENTS) { + if (parse_flags & PARSE_FLAG_ASM_FILE) { p = parse_line_comment(p - 1); goto redo_no_start; } else { @@ -2477,7 +2477,7 @@ maybe_newline: } else if (c == '.') { PEEKC(c, p); if (c != '.') { - if ((parse_flags & PARSE_FLAG_ASM_COMMENTS) == 0) + if ((parse_flags & PARSE_FLAG_ASM_FILE) == 0) expect("'.'"); tok = '.'; break; @@ -3304,7 +3304,7 @@ 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_FILE | PARSE_FLAG_ASM_COMMENTS); + parse_flags &= PARSE_FLAG_ASM_FILE; parse_flags |= PARSE_FLAG_PREPROCESS | PARSE_FLAG_LINEFEED | PARSE_FLAG_SPACES; token_seen = 0; file->line_ref = 0;