This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

a small patch to the gcc preprocessor


I've attached a small patch to src/gcc/cccp.c that gives the
preprocessor a new directive `#cinclude'.  #cinclude -- "conditional
include" -- includes the specified file if it exists but doesn't cause
an error if the file doesn't exist.  Syntax is the same as the #include
directive.

I've also included a patch to the Changelog.

Patches are against egcs-2.91.57 from cygwin b20.1

Chris Moller
Senior Programmer
BOPS, Inc
--- /tmp/src/gcc/cccp.c	Tue Aug 24 15:42:39 1999
+++ cccp.c	Tue Aug 24 14:57:11 1999
@@ -624,6 +624,7 @@ static char rest_extension[] = "...";
 /* different flavors of hash nodes --- also used in keyword table */
 enum node_type {
  T_DEFINE = 1,	/* the `#define' keyword */
+ T_CINCLUDE,	/* the `#cinclude' keyword */			/* chlm */
  T_INCLUDE,	/* the `#include' keyword */
  T_INCLUDE_NEXT, /* the `#include_next' keyword */
  T_IMPORT,      /* the `#import' keyword */
@@ -791,8 +792,13 @@ struct directive {
   enum node_type type;		/* Code which describes which directive.  */
 };
 
+#if 1								/* chlm */
+#define IS_INCLUDE_DIRECTIVE_TYPE(t) \
+((int) T_CINCLUDE <= (int) (t) && (int) (t) <= (int) T_IMPORT)
+#else								/* chlm */
 #define IS_INCLUDE_DIRECTIVE_TYPE(t) \
 ((int) T_INCLUDE <= (int) (t) && (int) (t) <= (int) T_IMPORT)
+#endif								/* chlm */
 
 /* These functions are declared to return int instead of void since they
    are going to be placed in the table and some old compilers have trouble with
@@ -828,6 +834,7 @@ static struct directive directive_table[
   {  4, do_else, "else", T_ELSE},
   {  4, do_elif, "elif", T_ELIF},
   {  4, do_line, "line", T_LINE},
+  {  8, do_include, "cinclude", T_CINCLUDE},			/* chlm */
   {  7, do_include, "include", T_INCLUDE},
   { 12, do_include, "include_next", T_INCLUDE_NEXT},
   {  6, do_include, "import", T_IMPORT},
@@ -4662,7 +4669,18 @@ get_filename:
     else if (0 < print_deps  &&  print_deps <= (system_include_depth != 0))
       warning ("No include path in which to find %s", fbeg);
     else if (f != -3)
+#if 1							/* chlm */
+	{
+	  if ( traditional && keyword->type == T_CINCLUDE)
+		warning("#include directive not supported under ANSI.");
+	  if (!traditional && keyword->type == T_CINCLUDE)
+		warning("Include file %s not found.  Skipped.\n",fbeg);
+	  else
+#endif							/* chlm */
       error_from_errno (fbeg);
+#if 1							/* chlm */
+	}
+#endif							/* chlm */
     else
       error ("No include path in which to find %s", fbeg);
 
@@ -7576,6 +7594,7 @@ skip_if_group (ip, any, op)
 	    free (temp);
 	    break;
 
+	  case T_CINCLUDE:				/* chlm */
 	  case T_INCLUDE:
 	  case T_INCLUDE_NEXT:
 	  case T_IMPORT:
@@ -9785,6 +9804,7 @@ initialize_builtins (inp, outp)
 	   NULL_PTR, -1);
   install ((U_CHAR *) "__TIME__", -1, T_TIME, NULL_PTR, -1);
   if (!traditional) {
+    install ((U_CHAR *) "__CINCLUDE__", -1, T_CONST, "1", -1);	/* chlm */
     install ((U_CHAR *) "__STDC__", -1, T_CONST, "1", -1);
     install ((U_CHAR *) "__STDC_VERSION__", -1, T_CONST, "199409L", -1);
   }
--- ChangeLog.orig	Tue Aug 24 15:53:25 1999
+++ ChangeLog	Tue Aug 24 15:52:34 1999
@@ -1,3 +1,9 @@
+Tue Aug 24 15:46:43 1999  Chris Moller <moller@bops.com>
+
+	* cccp.c: Added a '#cinclude' directive that includes the
+	specified file if it exists but doesn't cause an error if
+	the file doesn't exist.  Syntax is the same as #include.
+
 Wed Nov 18 08:52:26 1998  Christopher Faylor <cgf@cygnus.com>
 
         * pexecute.c: Reorganize WIN32 case to accomodate Cygwin

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]