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

📄 cccp.c

📁 编译工具
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif/* We let tm.h override the types used here, to handle trivial differences   such as the choice of unsigned int or long unsigned int for size_t.   When machines start needing nontrivial differences in the size type,   it would be best to do something here to figure out automatically   from other information what type to use.  *//* The string value for __SIZE_TYPE__.  */#ifndef SIZE_TYPE#define SIZE_TYPE "long unsigned int"#endif/* The string value for __PTRDIFF_TYPE__.  */#ifndef PTRDIFF_TYPE#define PTRDIFF_TYPE "long int"#endif/* The string value for __WCHAR_TYPE__.  */#ifndef WCHAR_TYPE#define WCHAR_TYPE "int"#endifchar * wchar_type = WCHAR_TYPE;#undef WCHAR_TYPE/* The string value for __USER_LABEL_PREFIX__ */#ifndef USER_LABEL_PREFIX#define USER_LABEL_PREFIX ""#endif/* The string value for __REGISTER_PREFIX__ */#ifndef REGISTER_PREFIX#define REGISTER_PREFIX ""#endif/* The string value for __IMMEDIATE_PREFIX__ */#ifndef IMMEDIATE_PREFIX#define IMMEDIATE_PREFIX ""#endif/* In the definition of a #assert name, this structure forms   a list of the individual values asserted.   Each value is itself a list of "tokens".   These are strings that are compared by name.  */struct tokenlist_list {  struct tokenlist_list *next;  struct arglist *tokens;};struct assertion_hashnode {  struct assertion_hashnode *next;	/* double links for easy deletion */  struct assertion_hashnode *prev;  /* also, a back pointer to this node's hash     chain is kept, in case the node is the head     of the chain and gets deleted.  */  struct assertion_hashnode **bucket_hdr;  int length;			/* length of token, for quick comparison */  U_CHAR *name;			/* the actual name */  /* List of token-sequences.  */  struct tokenlist_list *value;};typedef struct assertion_hashnode ASSERTION_HASHNODE;/* Some definitions for the hash table.  The hash function MUST be   computed as shown in hashf below.  That is because the rescan   loop computes the hash value `on the fly' for most tokens,   in order to avoid the overhead of a lot of procedure calls to   the hashf function.  hashf only exists for the sake of   politeness, for use when speed isn't so important.  */#define ASSERTION_HASHSIZE 37static ASSERTION_HASHNODE *assertion_hashtab[ASSERTION_HASHSIZE];/* Nonzero means inhibit macroexpansion of what seem to be   assertion tests, in rescan.  For #if.  */static int assertions_flag;/* `struct directive' defines one #-directive, including how to handle it.  */#define DO_PROTO PROTO((U_CHAR *, U_CHAR *, FILE_BUF *, struct directive *))struct directive {  int length;			/* Length of name */  int (*func) DO_PROTO;	/* Function to handle directive */  char *name;			/* Name of directive */  enum node_type type;		/* Code which describes which directive.  */  char angle_brackets;		/* Nonzero => <...> is special.  */  char traditional_comments;	/* Nonzero: keep comments if -traditional.  */  char pass_thru;		/* Copy directive to output:				   if 1, copy if dumping definitions;				   if 2, always copy, after preprocessing.  */};/* 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   pointers to functions returning void.  */static int do_assert DO_PROTO;static int do_define DO_PROTO;static int do_elif DO_PROTO;static int do_else DO_PROTO;static int do_endif DO_PROTO;static int do_error DO_PROTO;static int do_ident DO_PROTO;static int do_if DO_PROTO;static int do_include DO_PROTO;static int do_line DO_PROTO;static int do_pragma DO_PROTO;#ifdef SCCS_DIRECTIVEstatic int do_sccs DO_PROTO;#endifstatic int do_unassert DO_PROTO;static int do_undef DO_PROTO;static int do_warning DO_PROTO;static int do_xifdef DO_PROTO;/* Here is the actual list of #-directives, most-often-used first.  */static struct directive directive_table[] = {  {  6, do_define, "define", T_DEFINE, 0, 1, 1},  {  2, do_if, "if", T_IF},  {  5, do_xifdef, "ifdef", T_IFDEF},  {  6, do_xifdef, "ifndef", T_IFNDEF},  {  5, do_endif, "endif", T_ENDIF},  {  4, do_else, "else", T_ELSE},  {  4, do_elif, "elif", T_ELIF},  {  4, do_line, "line", T_LINE},  {  7, do_include, "include", T_INCLUDE, 1},  { 12, do_include, "include_next", T_INCLUDE_NEXT, 1},  {  6, do_include, "import", T_IMPORT, 1},  {  5, do_undef, "undef", T_UNDEF},  {  5, do_error, "error", T_ERROR},  {  7, do_warning, "warning", T_WARNING},#ifdef SCCS_DIRECTIVE  {  4, do_sccs, "sccs", T_SCCS},#endif  {  6, do_pragma, "pragma", T_PRAGMA, 0, 0, 2},  {  5, do_ident, "ident", T_IDENT},  {  6, do_assert, "assert", T_ASSERT},  {  8, do_unassert, "unassert", T_UNASSERT},  {  -1, 0, "", T_UNUSED},};/* When a directive handler is called,   this points to the # (or the : of the %:) that started the directive.  */U_CHAR *directive_start;/* table to tell if char can be part of a C identifier.  */U_CHAR is_idchar[256];/* table to tell if char can be first char of a c identifier.  */U_CHAR is_idstart[256];/* table to tell if c is horizontal space.  */static U_CHAR is_hor_space[256];/* table to tell if c is horizontal or vertical space.  */U_CHAR is_space[256];/* names of some characters */static char *char_name[256];#define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0)#define SKIP_ALL_WHITE_SPACE(p) do { while (is_space[*p]) p++; } while (0)  static int errors = 0;			/* Error counter for exit code *//* Name of output file, for error messages.  */static char *out_fname;/* 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 */  U_CHAR *control_macro;	/* For #ifndef at start of file,				   this is the macro name tested.  */  enum node_type type;		/* type of last directive seen in this group */};typedef struct if_stack IF_STACK_FRAME;static IF_STACK_FRAME *if_stack = NULL;/* Buffer of -M output.  */static char *deps_buffer;/* Number of bytes allocated in above.  */static int deps_allocated_size;/* Number of bytes used.  */static int deps_size;/* Number of bytes since the last newline.  */static int deps_column;/* Nonzero means -I- has been seen,   so don't look for #include "foo" the source-file directory.  */static int ignore_srcdir;static int safe_read PROTO((int, char *, int));static void safe_write PROTO((int, char *, int));int main PROTO((int, char **));static void path_include PROTO((char *));static U_CHAR *index0 PROTO((U_CHAR *, int, size_t));static void trigraph_pcp PROTO((FILE_BUF *));static void newline_fix PROTO((U_CHAR *));static void name_newline_fix PROTO((U_CHAR *));static char *get_lintcmd PROTO((U_CHAR *, U_CHAR *, U_CHAR **, int *, int *));static void rescan PROTO((FILE_BUF *, int));static FILE_BUF expand_to_temp_buffer PROTO((U_CHAR *, U_CHAR *, int, int));static int handle_directive PROTO((FILE_BUF *, FILE_BUF *));static struct tm *timestamp PROTO((void));static void special_symbol PROTO((HASHNODE *, FILE_BUF *));static int is_system_include PROTO((char *));static char *base_name PROTO((char *));static int absolute_filename PROTO((char *));static size_t simplify_filename PROTO((char *));static char *read_filename_string PROTO((int, FILE *));static struct file_name_map *read_name_map PROTO((char *));static int open_include_file PROTO((char *, char *, struct file_name_list *, U_CHAR *, struct include_file **));static char *remap_include_file PROTO((char *, struct file_name_list *));static int lookup_ino_include PROTO((struct include_file *));static void finclude PROTO((int, struct include_file *, FILE_BUF *, int, struct file_name_list *));static void record_control_macro PROTO((struct include_file *, U_CHAR *));static char *check_precompiled PROTO((int, struct stat *, char *, char **));static int check_preconditions PROTO((char *));static void pcfinclude PROTO((U_CHAR *, U_CHAR *, U_CHAR *, FILE_BUF *));static void pcstring_used PROTO((HASHNODE *));static void write_output PROTO((void));static void pass_thru_directive PROTO((U_CHAR *, U_CHAR *, FILE_BUF *, struct directive *));static MACRODEF create_definition PROTO((U_CHAR *, U_CHAR *, FILE_BUF *));static int check_macro_name PROTO((U_CHAR *, char *));static int compare_defs PROTO((DEFINITION *, DEFINITION *));static int comp_def_part PROTO((int, U_CHAR *, int, U_CHAR *, int, int));static DEFINITION *collect_expansion  PROTO((U_CHAR *, U_CHAR *, int, struct arglist *));int check_assertion PROTO((U_CHAR *, int, int, struct arglist *));static int compare_token_lists PROTO((struct arglist *, struct arglist *));static struct arglist *read_token_list PROTO((U_CHAR **, U_CHAR *, int *));static void free_token_list PROTO((struct arglist *));static ASSERTION_HASHNODE *assertion_install PROTO((U_CHAR *, int, int));static ASSERTION_HASHNODE *assertion_lookup PROTO((U_CHAR *, int, int));static void delete_assertion PROTO((ASSERTION_HASHNODE *));static void do_once PROTO((void));static HOST_WIDE_INT eval_if_expression PROTO((U_CHAR *, int));static void conditional_skip PROTO((FILE_BUF *, int, enum node_type, U_CHAR *, FILE_BUF *));static void skip_if_group PROTO((FILE_BUF *, int, FILE_BUF *));static void validate_else PROTO((U_CHAR *, U_CHAR *));static U_CHAR *skip_to_end_of_comment PROTO((FILE_BUF *, int *, int));static U_CHAR *skip_quoted_string PROTO((U_CHAR *, U_CHAR *, int, int *, int *, int *));static char *quote_string PROTO((char *, char *));static U_CHAR *skip_paren_group PROTO((FILE_BUF *));/* Last arg to output_line_directive.  */enum file_change_code {same_file, enter_file, leave_file};static void output_line_directive PROTO((FILE_BUF *, FILE_BUF *, int, enum file_change_code));static void macroexpand PROTO((HASHNODE *, FILE_BUF *));struct argdata;static char *macarg PROTO((struct argdata *, int));static U_CHAR *macarg1 PROTO((U_CHAR *, U_CHAR *, int *, int *, int *, int));static int discard_comments PROTO((U_CHAR *, int, int));static int change_newlines PROTO((U_CHAR *, int));char *my_strerror PROTO((int));void error PRINTF_PROTO_1((char *, ...));static void verror PROTO((char *, va_list));static void error_from_errno PROTO((char *));void warning PRINTF_PROTO_1((char *, ...));static void vwarning PROTO((char *, va_list));static void error_with_line PRINTF_PROTO_2((int, char *, ...));static void verror_with_line PROTO((int, char *, va_list));static void vwarning_with_line PROTO((int, char *, va_list));static void warning_with_line PRINTF_PROTO_2((int, char *, ...));void pedwarn PRINTF_PROTO_1((char *, ...));void pedwarn_with_line PRINTF_PROTO_2((int, char *, ...));static void pedwarn_with_file_and_line PRINTF_PROTO_3((char *, int, char *, ...));static void print_containing_files PROTO((void));static int line_for_error PROTO((int));static int grow_outbuf PROTO((FILE_BUF *, int));static HASHNODE *install PROTO((U_CHAR *, int, enum node_type, char *, int));HASHNODE *lookup PROTO((U_CHAR *, int, int));static void delete_macro PROTO((HASHNODE *));static int hashf PROTO((U_CHAR *, int, int));static void dump_single_macro PROTO((HASHNODE *, FILE *));static void dump_all_macros PROTO((void));static void dump_defn_1 PROTO((U_CHAR *, int, int, FILE *));static void dump_arg_n PROTO((DEFINITION *, int, FILE *));static void initialize_char_syntax PROTO((void));static void initialize_builtins PROTO((FILE_BUF *, FILE_BUF *));static void make_definition PROTO((char *, FILE_BUF *));static void make_undef PROTO((char *, FILE_BUF *));static void make_assertion PROTO((char *, char *));static struct file_name_list *new_include_prefix PROTO((struct file_name_list *, char *, char *));static void append_include_chain PROTO((struct file_name_list *, struct file_name_list *));static void deps_output PROTO((char *, int));static void fatal PRINTF_PROTO_1((char *, ...)) __attribute__ ((noreturn));void fancy_abort PROTO((void)) __attribute__ ((noreturn));static void perror_with_name PROTO((char *));static void pfatal_with_name PROTO((char *)) __attribute__ ((noreturn));static void pipe_closed PROTO((int)) __attribute__ ((noreturn));static void memory_full PROTO((void)) __attribute__ ((noreturn));GENERIC_PTR xmalloc PROTO((size_t));static GENERIC_PTR xrealloc PROTO((GENERIC_PTR, size_t));static GENERIC_PTR xcalloc PROTO((size_t, size_t));static char *savestring PROTO((char *));/* Read LEN bytes at PTR from descriptor DESC, for file FILENAME,   retrying if necessary.  If MAX_READ_LEN is defined, read at most   that bytes at a time.  Return a negative value if an error occurs,   otherwise return the actual number of bytes read,   which must be LEN unless end-of-file was reached.  */static intsafe_read (desc, ptr, len)     int desc;     char *ptr;     int len;{  int left, rcount, nchars;  left = len;  while (left > 0) {    rcount = left;#ifdef MAX_READ_LEN    if (rcount > MAX_READ_LEN)      rcount = MAX_READ_LEN;#endif    nchars = read (desc, ptr, rcount);    if (nchars < 0)      {#ifdef EINTR	if (errno == EINTR)	  continue;#endif	return nchars;      }    if (nchars == 0)      break;    ptr += nchars;    left -= nchars;  }  return len - left;}/* Write LEN bytes at PTR to descriptor DESC,   retrying if necessary, and treating any real error as fatal.   If MAX_WRITE_LEN is defined, write at most that many bytes at a time.  */static voidsafe_write (desc, ptr, len)     int desc;     char *ptr;     int len;{  int wcount, written;  while (len > 0) {    wcount = len;#ifdef MAX_WRITE_LEN    if (wcount > MAX_WRITE_LEN)      wcount = MAX_WRITE_LEN;#endif    written = write (desc, ptr, wcount);    if (written < 0)      {#ifdef EINTR	if (errno == EINTR)	  continue;#endif	pfatal_with_name (out_fname);      }    ptr += written;    len -= written;  }}intmain (argc, argv)     int argc;     char **argv;{  struct stat st;  char *in_fname;  char *cp;  int f, i;  FILE_BUF *fp;  char **pend_files = (char **) xmalloc (argc * sizeof (char *));  char **pend_defs = (char **) xmalloc (argc * sizeof (char *));

⌨️ 快捷键说明

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