diff options
| -rw-r--r-- | gcc/ChangeLog | 16 | ||||
| -rw-r--r-- | gcc/cpphash.h | 4 | ||||
| -rw-r--r-- | gcc/cppinit.c | 31 | ||||
| -rw-r--r-- | gcc/toplev.c | 12 | 
4 files changed, 47 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 637efd3e5a1..c55e13a13d7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,21 @@  2001-03-01  Zack Weinberg  <zackw@stanford.edu> +	* cpphash.h (struct cpp_reader): Add print_version field. +	* cppinit.c (cpp_handle_option): For -v, -version, and --version, +	just set print_version and other flags as appropriate. +	(cpp_post_options): Print version here if print_version is set. + +	* toplev.c (exit_after_options): New flag. +	(independent_decode_option): Don't exit here; just set +	exit_after_options. +	(main): Exit after calling lang_hooks.post_options if +	exit_after_options is true. + +	* cppinit.c (append_include_chain): Drop never-used case QUOTE. +	(merge_include_chains): Adjust comment to match code. + +2001-03-01  Zack Weinberg  <zackw@stanford.edu> +  	* stringpool.c (set_identifier): New function.  	* tree.h: Prototype it. diff --git a/gcc/cpphash.h b/gcc/cpphash.h index ddeacac5f7f..14df2da9b20 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -343,6 +343,10 @@ struct cpp_reader    /* True if we are skipping a failed conditional group.  */    unsigned char skipping; + +  /* Whether to print our version number.  Done this way so +     we don't get it twice for -v -version.  */ +  unsigned char print_version;  };  /* Character classes.  Based on the more primitive macros in safe-ctype.h. diff --git a/gcc/cppinit.c b/gcc/cppinit.c index d8efb4b559c..e6ae245f823 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -117,8 +117,9 @@ static void new_pending_directive	PARAMS ((struct cpp_pending *,  static void output_deps			PARAMS ((cpp_reader *));  static int parse_option			PARAMS ((const char *)); -/* Fourth argument to append_include_chain: chain to use.  */ -enum { QUOTE = 0, BRACKET, SYSTEM, AFTER }; +/* Fourth argument to append_include_chain: chain to use. +   Note it's never asked to append to the quote chain.  */ +enum { BRACKET = 0, SYSTEM, AFTER };  /* If we have designated initializers (GCC >2.7) these tables can be     initialized, constant data.  Otherwise, they have to be filled in at @@ -250,7 +251,6 @@ append_include_chain (pfile, dir, path, cxx_aware)    switch (path)      { -    case QUOTE:		APPEND (pend, quote, new); break;      case BRACKET:	APPEND (pend, brack, new); break;      case SYSTEM:	APPEND (pend, systm, new); break;      case AFTER:		APPEND (pend, after, new); break; @@ -338,7 +338,7 @@ merge_include_chains (pfile)    /* This is a bit tricky.  First we drop dupes from the quote-include       list.  Then we drop dupes from the bracket-include list.       Finally, if qtail and brack are the same directory, we cut out -     brack. +     brack and move brack up to point to qtail.       We can't just merge the lists and then uniquify them because       then we may lose directories from the <> search path that should @@ -1316,18 +1316,14 @@ cpp_handle_option (pfile, argc, argv)  	     verbose and -version.  Historical reasons, don't ask.  */  	case OPT__version:  	  CPP_OPTION (pfile, help_only) = 1; -	  goto version; +	  pfile->print_version = 1; +	  break;  	case OPT_v:  	  CPP_OPTION (pfile, verbose) = 1; -	  goto version; - +	  pfile->print_version = 1; +	  break;  	case OPT_version: -	version: -	  fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string); -#ifdef TARGET_VERSION -	  TARGET_VERSION; -#endif -	  fputc ('\n', stderr); +	  pfile->print_version = 1;  	  break;  	case OPT_C: @@ -1684,6 +1680,15 @@ void  cpp_post_options (pfile)       cpp_reader *pfile;  { +  if (pfile->print_version) +    { +      fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string); +#ifdef TARGET_VERSION +      TARGET_VERSION; +#endif +      fputc ('\n', stderr); +    } +    /* Canonicalize in_fname and out_fname.  We guarantee they are not       NULL, and that the empty string represents stdin / stdout.  */    if (CPP_OPTION (pfile, in_fname) == NULL diff --git a/gcc/toplev.c b/gcc/toplev.c index 68ba3efaa8a..fdd839021bc 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -391,6 +391,9 @@ int errorcount = 0;  int warningcount = 0;  int sorrycount = 0; +/* Nonzero if we should exit after parsing options.  */ +static int exit_after_options = 0; +  /* The FUNCTION_DECL for the function currently being compiled,     or 0 if between functions.  */  tree current_function_decl; @@ -4368,19 +4371,19 @@ independent_decode_option (argc, argv)    if (!strcmp (arg, "-help"))      {        display_help (); -      exit (0); +      exit_after_options = 1;      }    if (!strcmp (arg, "-target-help"))      {        display_target_options (); -      exit (0); +      exit_after_options = 1;      }    if (!strcmp (arg, "-version"))      {        print_version (stderr, ""); -      exit (0); +      exit_after_options = 1;      }    /* Handle '--param <name>=<value>'.  */ @@ -4830,6 +4833,9 @@ main (argc, argv)    if (lang_hooks.post_options)      (*lang_hooks.post_options) (); +  if (exit_after_options) +    exit (0); +    /* Reflect any language-specific diagnostic option setting.  */    reshape_diagnostic_buffer ();  | 

