diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2013-01-28 19:02:21 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-01-28 19:02:21 +0000 |
commit | f627f77f23d1497c9e1f4269b5c8812d12b42f18 (patch) | |
tree | 708772d83a8355e25155cf233d5a9e38f8ad4d96 /src/preproc | |
parent | 6ab0c0f5bf14ed9c15370407b9ee7e0b4b089ae1 (diff) | |
download | icon-upstream.tar.gz |
Imported Upstream version 9.5.0upstream/9.5.0upstream
Diffstat (limited to 'src/preproc')
-rw-r--r-- | src/preproc/Makefile | 34 | ||||
-rw-r--r-- | src/preproc/README | 7 | ||||
-rw-r--r-- | src/preproc/files.c | 84 | ||||
-rw-r--r-- | src/preproc/pinit.c | 16 | ||||
-rw-r--r-- | src/preproc/pmain.c | 109 |
5 files changed, 3 insertions, 247 deletions
diff --git a/src/preproc/Makefile b/src/preproc/Makefile deleted file mode 100644 index c3d17ed..0000000 --- a/src/preproc/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -include ../../Makedefs - -POBJS = pout.o pchars.o perr.o pmem.o bldtok.o macro.o preproc.o evaluate.o\ - files.o gettok.o pinit.o - -COBJS= ../common/getopt.o ../common/time.o ../common/strtbl.o ../common/alloc.o - -ICOBJS= getopt.o time.o strtbl.o alloc.o - -OBJS= $(POBJS) $(COBJS) - -DOT_H = preproc.h pproto.h ptoken.h ../h/define.h ../h/config.h\ - ../h/typedefs.h ../h/mproto.h - -common: - cd ../common; $(MAKE) $(ICOBJS) - $(MAKE) pp - -pp: pmain.o $(OBJS) - $(CC) -o pp pmain.o $(OBJS) - -pmain.o: $(DOT_H) -p_out.o: $(DOT_H) -pchars.o: $(DOT_H) -p_err.o: $(DOT_H) -pmem.o: $(DOT_H) -pstring.o: $(DOT_H) -bldtok.o: $(DOT_H) -macro.o: $(DOT_H) -preproc.o: $(DOT_H) -evaluate.o: $(DOT_H) -files.o: $(DOT_H) -gettok.o: $(DOT_H) -p_init.o: $(DOT_H) diff --git a/src/preproc/README b/src/preproc/README deleted file mode 100644 index 35d6a23..0000000 --- a/src/preproc/README +++ /dev/null @@ -1,7 +0,0 @@ -This directory contains files for building pp, a ANSI-C preprocessor for -C (with some extensions). pp itself is not needed to build the Icon -compiler system -- the files here are automatically incorporated in -rtt. - -However, if you want to build a stand-alone version of pp for -some other use, the Makefile here will do it. diff --git a/src/preproc/files.c b/src/preproc/files.c index 07abf60..016d04d 100644 --- a/src/preproc/files.c +++ b/src/preproc/files.c @@ -5,12 +5,6 @@ #include "../preproc/preproc.h" #include "../preproc/pproto.h" -#if CYGWIN - #include <limits.h> - #include <string.h> - #include <sys/cygwin.h> -#endif /* CYGWIN */ - #define IsRelPath(fname) (fname[0] != '/') static void file_src (char *fname, FILE *f); @@ -27,12 +21,6 @@ FILE *f; { union src_ref ref; - #if CYGWIN - char posix_path[ _POSIX_PATH_MAX + 1 ]; - cygwin_conv_to_posix_path( fname, posix_path ); - fname = strdup( posix_path ); - #endif /* CYGWIN */ - ref.cs = new_cs(fname, f, CBufSize); push_src(CharSrc, &ref); next_char = NULL; @@ -154,31 +142,8 @@ char **opt_args; * that establishes these search locations. */ - #if CYGWIN - char *incl_var; - static char *sysdir = "/usr/include"; - static char *windir = "/usr/include/w32api"; - n_paths = 2; - - incl_var = getenv("C_INCLUDE_PATH"); - if (incl_var != NULL) { - /* - * Add one entry for evry non-empty, colon-separated string in incl_var. - */ - char *dir_start, *dir_end; - - dir_start = incl_var; - while( ( dir_end = strchr( dir_start, ':' ) ) != NULL ) { - if (dir_end > dir_start) ++n_paths; - dir_start = dir_end + 1; - } - if ( *dir_start != '\0' ) - ++n_paths; /* One path after the final ':' */ - } - #else /* CYGWIN */ - static char *sysdir = "/usr/include/"; - n_paths = 1; - #endif /* CYGWIN */ + static char *sysdir = "/usr/include/"; + n_paths = 1; /* * Count the number of -I options to the preprocessor. @@ -201,22 +166,6 @@ char **opt_args; s = opt_args[i]; s1 = alloc(strlen(s) + 1); strcpy(s1, s); - - #if CYGWIN - /* - * Run s1 through cygwin_conv_to_posix_path; if the posix path - * differs from s1, reset s1 to a copy of the posix path. - */ - { - char posix_path[ _POSIX_PATH_MAX ]; - cygwin_conv_to_posix_path( s1, posix_path ); - if (strcmp( s1, posix_path ) != 0) { - free( s1 ); - s1 = salloc( posix_path ); - } - } - #endif /* CYGWIN */ - incl_search[j++] = s1; } @@ -224,34 +173,7 @@ char **opt_args; * Establish the standard locations to search after the -I options * on the preprocessor. */ - #if CYGWIN - if (incl_var != NULL) { - /* - * The C_INCLUDE_PATH components are carved out of a copy of incl_var. - * The colons after non-empty directory names are replaced by null - * chars, and the pointers to the start of these names are stored - * in inc_search. - */ - char *dir_start, *dir_end; - - dir_start = salloc( incl_var ); - while( ( dir_end = strchr( dir_start, ':' ) ) != NULL ) { - if (dir_end > dir_start) { - incl_search[j++] = dir_start; - *dir_end = '\0'; - } - dir_start = dir_end + 1; - } - if ( *dir_start != '\0' ) - incl_search[j++] = dir_start; - } - - /* Finally, add the system dir(s) */ - incl_search[j++] = sysdir; - incl_search[j++] = windir; - #else - incl_search[n_paths - 1] = sysdir; - #endif /* CYGWIN */ + incl_search[n_paths - 1] = sysdir; incl_search[n_paths] = NULL; } diff --git a/src/preproc/pinit.c b/src/preproc/pinit.c index 9f64cb0..219735e 100644 --- a/src/preproc/pinit.c +++ b/src/preproc/pinit.c @@ -47,22 +47,6 @@ char **opt_args; int i; /* - * Establish predefined macros. - */ - #if CYGWIN - do_directive("#define __CYGWIN32__\n"); - do_directive("#define __CYGWIN__\n"); - do_directive("#define __unix__\n"); - do_directive("#define __unix\n"); - do_directive("#define _WIN32\n"); - do_directive("#define __WIN32\n"); - do_directive("#define __WIN32__\n"); - #else /* CYGWIN */ - do_directive("#define unix 1\n"); - do_directive(PPInit); /* defines that vary between Unix systems */ - #endif /* CYGWIN*/ - - /* * look for options that affect macro definitions (-U, -D, etc). */ for (i = 0; opt_lst[i] != '\0'; ++i) diff --git a/src/preproc/pmain.c b/src/preproc/pmain.c deleted file mode 100644 index 9cc721a..0000000 --- a/src/preproc/pmain.c +++ /dev/null @@ -1,109 +0,0 @@ -#include "../preproc/preproc.h" -#include "../preproc/pproto.h" - -char *progname = "pp"; - -/* - * Establish command-line options. - */ -static char *ostr = "+CPD:I:U:o:"; -static char *options = - "[-C] [-P] [-Dname[=[text]]] [-Uname] [-Ipath] [-ofile] [files]"; - -extern line_cntrl; - -/* - * getopt() variables - */ -extern int optind; /* index into parent argv vector */ -extern int optopt; /* character checked for validity */ -extern char *optarg; /* argument associated with option */ - -int main(argc, argv) -int argc; -char **argv; - { - int c; - char *opt_lst; - char **opt_args; - int nopts; - FILE *out_file; - - /* - * By default, keep the image of white space, but replace each comment - * by a space. By default, output #line directives. - */ - whsp_image = NoComment; - line_cntrl = 1; - - /* - * The number of options that must be passed on to other phases - * of the preprocessor are at most as large as the entire option - * list. - */ - opt_lst = alloc(argc); - opt_args = alloc(argc * sizeof (char *)); - nopts = 0; - out_file = stdout; - - /* - * Process options. - */ - while ((c = getopt(argc, argv, ostr)) != EOF) - switch (c) { - - case 'C': /* -C - retan comments */ - whsp_image = FullImage; - break; - - case 'P': /* -P - do not output #line directives */ - line_cntrl = 0; - break; - - case 'D': /* -D<id><definition> - predefine an identifier */ - case 'I': /* -I<path> - location to search for standard header files */ - case 'U': /* -U<id> - undefine predefined identifier */ - opt_lst[nopts] = c; - opt_args[nopts] = optarg; - ++nopts; - break; - - case 'o': /* -o<file> - write output to this file */ - out_file = fopen(optarg, "w"); - if (out_file == NULL) - err2("cannot open output file ", optarg); - break; - - default: - show_usage(); - } - - opt_lst[nopts] = '\0'; - - /* - * Scan file name arguments. If there are none, process standard input, - * indicated by the name "-". - */ - if (optind == argc) { - init_preproc("-", opt_lst, opt_args); - output(out_file); - } - else { - while (optind < argc) { - init_preproc(argv[optind], opt_lst, opt_args); - output(out_file); - optind++; - } - } - - return EXIT_SUCCESS; - } - -/* - * Print an error message if called incorrectly. - */ -void show_usage() - { - fprintf(stderr, "usage: %s %s\n", progname, options); - exit(EXIT_FAILURE); - } |