From 10ad364006038b2154eba9402fc70aabd90ce708 Mon Sep 17 00:00:00 2001 From: borutr Date: Fri, 31 Oct 2003 22:32:00 +0000 Subject: [PATCH] introduced #pragma preproc_asm [ + | - ] to switch _asm block preprocessing on / off. Default is #pragma preproc_asm + git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2979 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- support/cpp2/cppinit.c | 2 ++ support/cpp2/cpplex.c | 6 +++++- support/cpp2/cpplib.c | 36 +++++++++++++++++++++++++++++++----- support/cpp2/cpplib.h | 4 ++++ 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/support/cpp2/cppinit.c b/support/cpp2/cppinit.c index 18a1b005..5cf8d60e 100644 --- a/support/cpp2/cppinit.c +++ b/support/cpp2/cppinit.c @@ -509,6 +509,8 @@ cpp_create_reader (table, lang) CPP_OPTION (pfile, show_column) = 1; CPP_OPTION (pfile, tabstop) = 8; CPP_OPTION (pfile, operator_names) = 1; + /* SDCC _asm specific */ + CPP_OPTION (pfile, preproc_asm) = 1; CPP_OPTION (pfile, pending) = (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending)); diff --git a/support/cpp2/cpplex.c b/support/cpp2/cpplex.c index 489559fb..9600f3af 100644 --- a/support/cpp2/cpplex.c +++ b/support/cpp2/cpplex.c @@ -794,6 +794,10 @@ parse_string (pfile, token, terminator) POOL_COMMIT (pool, token->val.str.len + 1); } +/* Fixed _WIN32 problem with CR-CR-LF sequences when outputting + comment blocks (when executed with -C option) and + _asm (SDCPP specific) blocks */ + /* Count and copy characters from src to dest, excluding CRs: CRs are automatically generated, because the output is opened in TEXT mode. If dest == NULL, only count chars */ @@ -1113,7 +1117,7 @@ _cpp_lex_token (pfile, result) } /* SDCC _asm specific */ /* handle _asm ... _endasm ; */ - else if (result->val.node == pfile->spec_nodes.n__asm) + else if (CPP_OPTION(pfile, preproc_asm) == 0 && result->val.node == pfile->spec_nodes.n__asm) { int read_ahead = buffer->read_ahead; diff --git a/support/cpp2/cpplib.c b/support/cpp2/cpplib.c index c93d670e..2b3512b8 100644 --- a/support/cpp2/cpplib.c +++ b/support/cpp2/cpplib.c @@ -93,16 +93,17 @@ static unsigned int read_flag PARAMS ((cpp_reader *, unsigned int)); static int strtoul_for_line PARAMS ((const U_CHAR *, unsigned int, unsigned long *)); static void do_diagnostic PARAMS ((cpp_reader *, enum error_type, int)); -static cpp_hashnode *lex_macro_node PARAMS ((cpp_reader *)); +static cpp_hashnode *lex_macro_node PARAMS ((cpp_reader *)); static void do_include_common PARAMS ((cpp_reader *, enum include_type)); static void do_pragma_once PARAMS ((cpp_reader *)); static void do_pragma_poison PARAMS ((cpp_reader *)); static void do_pragma_sdcc_hash PARAMS ((cpp_reader *)); -static void do_pragma_system_header PARAMS ((cpp_reader *)); -static void do_pragma_dependency PARAMS ((cpp_reader *)); +static void do_pragma_preproc_asm PARAMS ((cpp_reader *)); +static void do_pragma_system_header PARAMS ((cpp_reader *)); +static void do_pragma_dependency PARAMS ((cpp_reader *)); static int get__Pragma_string PARAMS ((cpp_reader *, cpp_token *)); -static unsigned char *destringize PARAMS ((const cpp_string *, - unsigned int *)); +static unsigned char *destringize PARAMS ((const cpp_string *, + unsigned int *)); static int parse_answer PARAMS ((cpp_reader *, struct answer **, int)); static cpp_hashnode *parse_assertion PARAMS ((cpp_reader *, struct answer **, int)); @@ -1029,6 +1030,8 @@ _cpp_init_internal_pragmas (pfile) /* Kevin abuse for SDCC. */ cpp_register_pragma(pfile, 0, "sdcc_hash", do_pragma_sdcc_hash); + /* SDCC _asm specific */ + cpp_register_pragma(pfile, 0, "preproc_asm", do_pragma_preproc_asm); } static void @@ -1152,6 +1155,29 @@ do_pragma_sdcc_hash (pfile) } } +/* SDCC _asm specific + switch _asm block preprocessing on / off */ +static void +do_pragma_preproc_asm (pfile) + cpp_reader *pfile; +{ + cpp_token tok; + + _cpp_lex_token (pfile, &tok); + if (tok.type == CPP_PLUS) + { + CPP_OPTION(pfile, preproc_asm) = 1; + } + else if (tok.type == CPP_MINUS) + { + CPP_OPTION(pfile, preproc_asm)= 0; + } + else + { + cpp_error (pfile, "invalid #pragma preproc_asm directive, need '+' or '-'"); + } +} + /* Mark the current header as a system header. This will suppress some categories of warnings (notably those from -pedantic). It is intended for use in system libraries that cannot be implemented in diff --git a/support/cpp2/cpplib.h b/support/cpp2/cpplib.h index 97c2e925..e5f98238 100644 --- a/support/cpp2/cpplib.h +++ b/support/cpp2/cpplib.h @@ -392,6 +392,10 @@ struct cpp_options * (see _cpp_create_definition in cppmacro.c) */ unsigned char allow_naked_hash; + + /* SDCC _asm specific + switch _asm block preprocessing on / off */ + unsigned char preproc_asm; }; /* This structure is passed to the call back when changing file. */ -- 2.30.2