📄 cccp.c
字号:
/* C Compatible Compiler Preprocessor (CCCP) Copyright (C) 1986, 87, 89, 92-96, 1997 Free Software Foundation, Inc. Written by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987This program is free software; you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation; either version 2, or (at your option) anylater version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA. In other words, you are welcome to use, share and improve this program. You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! */typedef unsigned char U_CHAR;#ifdef EMACS#define NO_SHORTNAMES#include "../src/config.h"#ifdef open#undef open#undef read#undef write#endif /* open */#endif /* EMACS *//* The macro EMACS is defined when cpp is distributed as part of Emacs, for the sake of machines with limited C compilers. */#ifndef EMACS#include "config.h"#endif /* not EMACS */#ifndef STANDARD_INCLUDE_DIR#define STANDARD_INCLUDE_DIR "/usr/include"#endif#include "pcp.h"/* By default, colon separates directories in a path. */#ifndef PATH_SEPARATOR#define PATH_SEPARATOR ':'#endif#include <sys/types.h>#include <sys/stat.h>#include <ctype.h>#include <stdio.h>#include <signal.h>/* The following symbols should be autoconfigured: HAVE_FCNTL_H HAVE_STDLIB_H HAVE_SYS_TIME_H HAVE_UNISTD_H STDC_HEADERS TIME_WITH_SYS_TIME In the mean time, we'll get by with approximations based on existing GCC configuration symbols. */#ifdef POSIX# ifndef HAVE_STDLIB_H# define HAVE_STDLIB_H 1# endif# ifndef HAVE_UNISTD_H# define HAVE_UNISTD_H 1# endif# ifndef STDC_HEADERS# define STDC_HEADERS 1# endif#endif /* defined (POSIX) */#if defined (POSIX) || (defined (USG) && !defined (VMS))# ifndef HAVE_FCNTL_H# define HAVE_FCNTL_H 1# endif#endif#ifndef RLIMIT_STACK# include <time.h>#else# if TIME_WITH_SYS_TIME# include <sys/time.h># include <time.h># else# if HAVE_SYS_TIME_H# include <sys/time.h># else# include <time.h># endif# endif# include <sys/resource.h>#endif#if HAVE_FCNTL_H# include <fcntl.h>#endif#include <errno.h>#if HAVE_STDLIB_H# include <stdlib.h>#elsechar *getenv ();#endif#if STDC_HEADERS# include <string.h># ifndef bcmp# define bcmp(a, b, n) memcmp (a, b, n)# endif# ifndef bcopy# define bcopy(s, d, n) memcpy (d, s, n)# endif# ifndef bzero# define bzero(d, n) memset (d, 0, n)# endif#else /* !STDC_HEADERS */char *index ();char *rindex ();# if !defined (BSTRING) && (defined (USG) || defined (VMS))# ifndef bcmp# define bcmp my_bcmpstatic intmy_bcmp (a, b, n) register char *a; register char *b; register unsigned n;{ while (n-- > 0) if (*a++ != *b++) return 1; return 0;}# endif /* !defined (bcmp) */# ifndef bcopy# define bcopy my_bcopystatic voidmy_bcopy (s, d, n) register char *s; register char *d; register unsigned n;{ while (n-- > 0) *d++ = *s++;}# endif /* !defined (bcopy) */# ifndef bzero# define bzero my_bzerostatic voidmy_bzero (b, length) register char *b; register unsigned length;{ while (length-- > 0) *b++ = 0;}# endif /* !defined (bzero) */# endif /* !defined (BSTRING) && (defined (USG) || defined (VMS)) */#endif /* ! STDC_HEADERS */#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)# define __attribute__(x)#endif#ifndef PROTO# if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)# define PROTO(ARGS) ARGS# else# define PROTO(ARGS) ()# endif#endif#if defined (__STDC__) && defined (HAVE_VPRINTF)# include <stdarg.h># define VA_START(va_list, var) va_start (va_list, var)# define PRINTF_ALIST(msg) char *msg, ...# define PRINTF_DCL(msg)# define PRINTF_PROTO(ARGS, m, n) PROTO (ARGS) __attribute__ ((format (__printf__, m, n)))#else# include <varargs.h># define VA_START(va_list, var) va_start (va_list)# define PRINTF_ALIST(msg) msg, va_alist# define PRINTF_DCL(msg) char *msg; va_dcl# define PRINTF_PROTO(ARGS, m, n) () __attribute__ ((format (__printf__, m, n)))# define vfprintf(file, msg, args) \ { \ char *a0 = va_arg(args, char *); \ char *a1 = va_arg(args, char *); \ char *a2 = va_arg(args, char *); \ char *a3 = va_arg(args, char *); \ fprintf (file, msg, a0, a1, a2, a3); \ }#endif#define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2)#define PRINTF_PROTO_2(ARGS) PRINTF_PROTO(ARGS, 2, 3)#define PRINTF_PROTO_3(ARGS) PRINTF_PROTO(ARGS, 3, 4)#if HAVE_UNISTD_H# include <unistd.h>#endif/* VMS-specific definitions */#ifdef VMS#include <descrip.h>#define open(fname,mode,prot) VMS_open (fname,mode,prot)#define fopen(fname,mode) VMS_fopen (fname,mode)#define freopen(fname,mode,ofile) VMS_freopen (fname,mode,ofile)#define fstat(fd,stbuf) VMS_fstat (fd,stbuf)static int VMS_fstat (), VMS_stat ();static int VMS_open ();static FILE * VMS_fopen ();static FILE * VMS_freopen ();static void hack_vms_include_specification ();#define INO_T_EQ(a, b) (!bcmp((char *) &(a), (char *) &(b), sizeof (a)))#define INO_T_HASH(a) 0#define INCLUDE_LEN_FUDGE 12 /* leave room for VMS syntax conversion */#endif /* VMS *//* Windows does not natively support inodes, and neither does MSDOS. */#if (defined (_WIN32) && ! defined (CYGWIN32)) || defined (__MSDOS__)#define INO_T_EQ(a, b) 0#endif#ifndef O_RDONLY#define O_RDONLY 0#endif#undef MIN#undef MAX#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))/* Find the largest host integer type and set its size and type. Don't blindly use `long'; on some crazy hosts it is shorter than `int'. */#ifndef HOST_BITS_PER_WIDE_INT#if HOST_BITS_PER_LONG > HOST_BITS_PER_INT#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG#define HOST_WIDE_INT long#else#define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT#define HOST_WIDE_INT int#endif#endif#ifndef S_ISREG#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)#endif#ifndef S_ISDIR#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)#endif#ifndef INO_T_EQ#define INO_T_EQ(a, b) ((a) == (b))#endif#ifndef INO_T_HASH#define INO_T_HASH(a) (a)#endif/* Define a generic NULL if one hasn't already been defined. */#ifndef NULL#define NULL 0#endif#ifndef GENERIC_PTR#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)#define GENERIC_PTR void *#else#define GENERIC_PTR char *#endif#endif#ifndef NULL_PTR#define NULL_PTR ((GENERIC_PTR) 0)#endif#ifndef INCLUDE_LEN_FUDGE#define INCLUDE_LEN_FUDGE 0#endif/* External declarations. */extern char *version_string;#ifndef VMS#ifndef HAVE_STRERRORextern int sys_nerr;extern char *sys_errlist[];#else /* HAVE_STRERROR */#ifndef DONT_DECLARE_STRERRORchar *strerror ();#endif#endif#else /* VMS */char *strerror (int,...);#endifHOST_WIDE_INT parse_escape PROTO((char **, HOST_WIDE_INT));HOST_WIDE_INT parse_c_expression PROTO((char *));#ifndef errnoextern int errno;#endif/* Name under which this program was invoked. */static char *progname;/* Nonzero means use extra default include directories for C++. */static int cplusplus;/* Nonzero means handle cplusplus style comments */static int cplusplus_comments;/* Nonzero means handle #import, for objective C. */static int objc;/* Nonzero means this is an assembly file, and allow unknown directives, which could be comments. */static int lang_asm;/* Current maximum length of directory names in the search path for include files. (Altered as we get more of them.) */static int max_include_len;/* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */static int for_lint = 0;/* Nonzero means copy comments into the output file. */static int put_out_comments = 0;/* Nonzero means don't process the ANSI trigraph sequences. */static int no_trigraphs = 0;/* Nonzero means print the names of included files rather than the preprocessed output. 1 means just the #include "...", 2 means #include <...> as well. */static int print_deps = 0;/* Nonzero if missing .h files in -M output are assumed to be generated files and not errors. */static int print_deps_missing_files = 0;/* Nonzero means print names of header files (-H). */static int print_include_names = 0;/* Nonzero means don't output line number information. */static int no_line_directives;/* Nonzero means output the text in failing conditionals, inside #failed ... #endfailed. */static int output_conditionals;/* dump_only means inhibit output of the preprocessed text and instead output the definitions of all user-defined macros in a form suitable for use as input to cccp. dump_names means pass #define and the macro name through to output. dump_definitions means pass the whole definition (plus #define) through*/static enum {dump_none, dump_only, dump_names, dump_definitions} dump_macros = dump_none;/* Nonzero means pass all #define and #undef directives which we actually process through to the output stream. This feature is used primarily to allow cc1 to record the #defines and #undefs for the sake of debuggers which understand about preprocessor macros, but it may also be useful with -E to figure out how symbols are defined, and where they are defined. */static int debug_output = 0;/* Nonzero indicates special processing used by the pcp program. The special effects of this mode are: Inhibit all macro expansion, except those inside #if directives. Process #define directives normally, and output their contents to the output file. Output preconditions to pcp_outfile indicating all the relevant preconditions for use of this file in a later cpp run.*/static FILE *pcp_outfile;/* Nonzero means we are inside an IF during a -pcp run. In this mode macro expansion is done, and preconditions are output for all macro uses requiring them. */static int pcp_inside_if;/* Nonzero means never to include precompiled files. This is 1 since there's no way now to make precompiled files, so it's not worth testing for them. */static int no_precomp = 1;/* Nonzero means give all the error messages the ANSI standard requires. */int pedantic;/* Nonzero means try to make failure to fit ANSI C an error. */static int pedantic_errors;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -