⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cccp.c

📁 这是完整的gcc源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	#define test$	lose(test)	*/#ifndef DOLLARS_IN_IDENTIFIERS#define DOLLARS_IN_IDENTIFIERS 0#endifint dollars_in_ident = DOLLARS_IN_IDENTIFIERS;FILE_BUF expand_to_temp_buffer ();DEFINITION *collect_expansion ();/* Stack of conditionals currently in progress   (including both successful and failing conditionals).  */struct if_stack {  struct if_stack *next;	/* for chaining to the next stack frame */  char *fname;		/* copied from input when frame is made */  int lineno;			/* similarly */  int if_succeeded;		/* true if a leg of this if-group				    has been passed through rescan */  enum node_type type;		/* type of last directive seen in this group */};typedef struct if_stack IF_STACK_FRAME;IF_STACK_FRAME *if_stack = NULL;/* Buffer of -M output.  */char *deps_buffer;/* Number of bytes allocated in above.  */int deps_allocated_size;/* Number of bytes used.  */int deps_size;/* Number of bytes since the last newline.  */int deps_column;/* Nonzero means -I- has been seen,   so don't look for #include "foo" the source-file directory.  */int ignore_srcdir;/* Handler for SIGPIPE.  */static voidpipe_closed (){  fatal ("output pipe has been closed");}intmain (argc, argv)     int argc;     char **argv;{  int st_mode;  long st_size;  char *in_fname, *out_fname;  int f, i;  FILE_BUF *fp;  char **pend_files = (char **) xmalloc (argc * sizeof (char *));  char **pend_defs = (char **) xmalloc (argc * sizeof (char *));  char **pend_undefs = (char **) xmalloc (argc * sizeof (char *));  int inhibit_predefs = 0;  int no_standard_includes = 0;  /* Non-0 means don't output the preprocessed program.  */  int inhibit_output = 0;  /* Stream on which to print the dependency information.  */  FILE *deps_stream = 0;  /* Target-name to write with the dependency information.  */  char *deps_target = 0;#ifdef RLIMIT_STACK  /* Get rid of any avoidable limit on stack size.  */  {    struct rlimit rlim;    /* Set the stack limit huge so that alloca (particularly stringtab     * in dbxread.c) does not fail. */    getrlimit (RLIMIT_STACK, &rlim);    rlim.rlim_cur = rlim.rlim_max;    setrlimit (RLIMIT_STACK, &rlim);  }#endif /* RLIMIT_STACK defined */  progname = argv[0];#ifdef VMS  {    /* Remove directories from PROGNAME.  */    char *s;    extern char *rindex ();    progname = savestring (argv[0]);    if (!(s = rindex (progname, ']')))      s = rindex (progname, ':');    if (s)      strcpy (progname, s+1);    if (s = rindex (progname, '.'))      *s = '\0';  }#endif  in_fname = NULL;  out_fname = NULL;  /* Initialize is_idchar to allow $.  */  dollars_in_ident = 1;  initialize_char_syntax ();  dollars_in_ident = DOLLARS_IN_IDENTIFIERS;  no_line_commands = 0;  no_trigraphs = 1;  dump_macros = 0;  no_output = 0;  cplusplus = 0;#ifdef CPLUSPLUS  cplusplus = 1;#endif  signal (SIGPIPE, pipe_closed);#ifndef VMS  max_include_len    = max (max (sizeof (GCC_INCLUDE_DIR),		sizeof (GPLUSPLUS_INCLUDE_DIR)),	   sizeof ("/usr/include/CC"));#else /* VMS */  max_include_len    = sizeof("SYS$SYSROOT:[SYSLIB.]");#endif /* VMS */  bzero (pend_files, argc * sizeof (char *));  bzero (pend_defs, argc * sizeof (char *));  bzero (pend_undefs, argc * sizeof (char *));  /* Process switches and find input file name.  */  for (i = 1; i < argc; i++) {    if (argv[i][0] != '-') {      if (out_fname != NULL)	fatal ("Usage: %s [switches] input output", argv[0]);      else if (in_fname != NULL)	out_fname = argv[i];      else	in_fname = argv[i];    } else {      switch (argv[i][1]) {      case 'i':	if (argv[i][2] != 0)	  pend_files[i] = argv[i] + 2;	else if (i + 1 == argc)	  fatal ("Filename missing after -i option");	else	  pend_files[i] = argv[i+1], i++;	break;      case 'o':	if (out_fname != NULL)	  fatal ("Output filename specified twice");	if (i + 1 == argc)	  fatal ("Filename missing after -o option");	out_fname = argv[++i];	if (!strcmp (out_fname, "-"))	  out_fname = "";	break;      case 'p':	pedantic = 1;	break;      case 't':	if (!strcmp (argv[i], "-traditional")) {	  traditional = 1;	  dollars_in_ident = 1;	} else if (!strcmp (argv[i], "-trigraphs")) {	  no_trigraphs = 0;	}	break;      case '+':	cplusplus = 1;	break;      case 'w':	inhibit_warnings = 1;	break;      case 'W':	if (!strcmp (argv[i], "-Wtrigraphs")) {	  warn_trigraphs = 1;	}	if (!strcmp (argv[i], "-Wcomments"))	  warn_comments = 1;	if (!strcmp (argv[i], "-Wcomment"))	  warn_comments = 1;	if (!strcmp (argv[i], "-Wall")) {	  warn_trigraphs = 1;	  warn_comments = 1;	}	break;      case 'M':	if (!strcmp (argv[i], "-M"))	  print_deps = 2;	else if (!strcmp (argv[i], "-MM"))	  print_deps = 1;	inhibit_output = 1;	break;      case 'd':	dump_macros = 1;	no_output = 1;	break;      case 'v':	fprintf (stderr, "GNU CPP version %s\n", version_string);	break;      case 'D':	{	  char *p, *p1;	  if (argv[i][2] != 0)	    p = argv[i] + 2;	  else if (i + 1 == argc)	    fatal ("Macro name missing after -D option");	  else	    p = argv[++i];	  if ((p1 = (char *) index (p, '=')) != NULL)	    *p1 = ' ';	  pend_defs[i] = p;	}	break;      case 'U':		/* JF #undef something */	if (argv[i][2] != 0)	  pend_undefs[i] = argv[i] + 2;	else if (i + 1 == argc)	  fatal ("Macro name missing after -U option");	else	  pend_undefs[i] = argv[i+1], i++;	break;      case 'C':	put_out_comments = 1;	break;      case 'E':			/* -E comes from cc -E; ignore it.  */	break;      case 'P':	no_line_commands = 1;	break;      case '$':			/* Don't include $ in identifiers.  */	dollars_in_ident = 0;	break;      case 'I':			/* Add directory to path for includes.  */	{	  struct file_name_list *dirtmp;	  if (! ignore_srcdir && !strcmp (argv[i] + 2, "-"))	    ignore_srcdir = 1;	  else {	    dirtmp = (struct file_name_list *)	      xmalloc (sizeof (struct file_name_list));	    dirtmp->next = 0;		/* New one goes on the end */	    if (include == 0)	      include = dirtmp;	    else	      last_include->next = dirtmp;	    last_include = dirtmp;	/* Tail follows the last one */	    if (argv[i][2] != 0)	      dirtmp->fname = argv[i] + 2;	    else if (i + 1 == argc)	      fatal ("Directory name missing after -I option");	    else	      dirtmp->fname = argv[++i];	    if (strlen (dirtmp->fname) > max_include_len)	      max_include_len = strlen (dirtmp->fname);	    if (ignore_srcdir && first_bracket_include == 0)	      first_bracket_include = dirtmp;	    }	}	break;      case 'n':	/* -nostdinc causes no default include directories.	   You must specify all include-file directories with -I.  */	no_standard_includes = 1;	break;      case 'u':	/* Sun compiler passes undocumented switch "-undef".	   Let's assume it means to inhibit the predefined symbols.  */	inhibit_predefs = 1;	break;      case '\0': /* JF handle '-' as file name meaning stdin or stdout */	if (in_fname == NULL) {	  in_fname = "";	  break;	} else if (out_fname == NULL) {	  out_fname = "";	  break;	}	/* else fall through into error */      default:	fatal ("Invalid option `%s'", argv[i]);      }    }  }  /* Now that dollars_in_ident is known, initialize is_idchar.  */  initialize_char_syntax ();  /* Install __LINE__, etc.  Must follow initialize_char_syntax     and option processing.  */  initialize_builtins ();  /* Do standard #defines that identify processor type.  */  if (!inhibit_predefs) {    char *p = (char *) alloca (strlen (predefs) + 1);    strcpy (p, predefs);    while (*p) {      char *q;      if (p[0] != '-' || p[1] != 'D')	abort ();      q = &p[2];      while (*p && *p != ' ')	{	  /* If we have -DFOO=BAR, make it `FOO BAR' for make_definition.  */	  if (*p == '=')	    *p = ' ';	  p++;	}      if (*p != 0)	*p++= 0;      make_definition (q);    }  }  /* Do defines specified with -D.  */  for (i = 1; i < argc; i++)    if (pend_defs[i])      make_definition (pend_defs[i]);  /* Do undefines specified with -U.  */  for (i = 1; i < argc; i++)    if (pend_undefs[i])      make_undef (pend_undefs[i]);  /* Unless -fnostdinc,     tack on the standard include file dirs to the specified list */  if (!no_standard_includes) {    if (include == 0)      include = (cplusplus ? cplusplus_include_defaults : include_defaults);    else      last_include->next	= (cplusplus ? cplusplus_include_defaults : include_defaults);    /* Make sure the list for #include <...> also has the standard dirs.  */    if (ignore_srcdir && first_bracket_include == 0)      first_bracket_include	= (cplusplus ? cplusplus_include_defaults : include_defaults);  }  /* Initialize output buffer */  outbuf.buf = (U_CHAR *) xmalloc (OUTBUF_SIZE);  outbuf.bufp = outbuf.buf;  outbuf.length = OUTBUF_SIZE;  /* Scan the -i files before the main input.     Much like #including them, but with no_output set     so that only their macro definitions matter.  */  no_output++;  for (i = 1; i < argc; i++)    if (pend_files[i]) {      int fd = open (pend_files[i], O_RDONLY, 0666);      if (fd < 0) {	perror_with_name (pend_files[i]);	return FATAL_EXIT_CODE;      }      finclude (fd, pend_files[i], &outbuf);    }  no_output--;  /* Create an input stack level for the main input file     and copy the entire contents of the file into it.  */  fp = &instack[++indepth];  /* JF check for stdin */  if (in_fname == NULL || *in_fname == 0) {    in_fname = "";    f = 0;  } else if ((f = open (in_fname, O_RDONLY, 0666)) < 0)    goto perror;  /* Either of two environment variables can specify output of deps.     Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",     where OUTPUT_FILE is the file to write deps info to     and DEPS_TARGET is the target to mention in the deps.  */  if (print_deps == 0      && (getenv ("SUNPRO_DEPENDENCIES") != 0	  || getenv ("DEPENDENCIES_OUTPUT") != 0))    {      char *spec = getenv ("DEPENDENCIES_OUTPUT");      char *s;      char *output_file;      if (spec == 0)	{	  spec = getenv ("SUNPRO_DEPENDENCIES");	  print_deps = 2;	}      else	print_deps = 1;      s = spec;      /* Find the space before the DEPS_TARGET, if there is one.  */      /* Don't use `index'; that causes trouble on USG.  */      while (*s != 0 && *s != ' ') s++;      if (*s != 0)	{	  deps_target = s + 1;	  output_file = (char *) xmalloc (s - spec + 1);	  bcopy (spec, output_file, s - spec);	  output_file[s - spec] = 0;	}      else	{	  deps_target = 0;	  output_file = spec;	}            deps_stream = fopen (output_file, "a");      if (deps_stream == 0)	pfatal_with_name (output_file);    }  /* If the -M option was used, output the deps to standard output.  */  else if (print_deps)    deps_stream = stdout;  /* For -M, print the expected object file name     as the target of this Make-rule.  */  if (print_deps) {    deps_allocated_size = 200;    deps_buffer = (char *) xmalloc (deps_allocated_size);    deps_buffer[0] = 0;    deps_size = 0;    deps_column = 0;    if (deps_target) {      deps_output (deps_target, 0);      deps_output (":", 0);    } else if (*in_fname == 0)      deps_output ("-: ", 0);    else {      int len;      char *p = in_fname;      char *p1 = p;      /* Discard all directory prefixes from P.  */      while (*p1) {	if (*p1 == '/')	  p = p1 + 1;	p1++;      }      /* Output P, but remove known suffixes.  */      len = strlen (p);      if (p[len - 2] == '.'	  && (p[len - 1] == 'c' || p[len - 1] == 'C' || p[len - 1] == 'S'))	deps_output (p, len - 2);      else if (p[len - 3] == '.'	       && p[len - 2] == 'c'	       && p[len - 1] == 'c')	deps_output (p, len - 3);      else	deps_output (p, 0);      /* Supply our own suffix.  */      deps_output (".o : ", 0);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -