introduced #pragma preproc_asm [ + | - ]
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 31 Oct 2003 22:32:00 +0000 (22:32 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 31 Oct 2003 22:32:00 +0000 (22:32 +0000)
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
support/cpp2/cpplex.c
support/cpp2/cpplib.c
support/cpp2/cpplib.h

index 18a1b0053042c8a7ea15562cd3ba2cdbac402f42..5cf8d60e14d3234ad75ea510f06bfc715e1a8821 100644 (file)
@@ -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));
index 489559fb64164d55efac17f4278eab74a5b42f06..9600f3af491fbfcae5740265dae1f209cccea0e0 100644 (file)
@@ -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;
 
index c93d670e92db704a2829ddb7a28553be51c50f1b..2b3512b8cc87b6abf84afc7d96fe53aff6452c93 100644 (file)
@@ -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
index 97c2e925925b775f4fddbe3a3ff0fe6b4e59612a..e5f9823893a90fc496858c4358cace27a3ca1aba 100644 (file)
@@ -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.  */