From 86702e3134874b23eb9b10dd5725957c29294513 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Tue, 18 Apr 2000 22:34:13 +0000 Subject: [PATCH] cccp.c, [...]: Removed. * cccp.c, cexp.y, cexp.c, cccp.1: Removed. * configure.in: Delete --disable-cpplib option and all references to cpp_main. * configure: Regenerate. * Makefile.in: Remove all references to CCCP, CCCP_OBJS, @cpp_main@, cccp.c, cexp.c, cexp.y, cexp.output, cexp.o, cccp.o, cccp, or cppmain. Link cppmain.o straight to cpp$(exeext). Add --no-headers to makeinfo command line when generating INSTALL. Install and uninstall cpp.1 manpage, not cccp.1. * install.texi: Delete all references to cexp.y/cexp.c. Delete ancient instructions for compiling GCC on 3b1. * INSTALL: Regenerate. * cppfiles.c, cpplib.h, jump.c, protoize.c, c-lex.c, ch/decl.c, ch/lex.c, cp/lex.c, f/lex.c, mips/t-ecoff, mips/t-elf, mips/t-r3900: Remove references to cccp.c. * convex.h, fx80.h, m68k.h, pdp11.h, contrib/gcc_update, f/g77install.texi: Remove references to cexp.c/cexp.y. * xm-linux.h, xm-os2.h, romp.h: Remove definition of BSTRING, which is no longer tested anywhere. * po/POTFILES.in: Remove cccp.c and cexp.c. Comment out alpha/vms-tramp.asm. From-SVN: r33238 --- contrib/ChangeLog | 4 + contrib/gcc_update | 1 - gcc/ChangeLog | 22 + gcc/INSTALL | 449 +- gcc/Makefile.in | 59 +- gcc/c-lex.c | 2 +- gcc/cccp.1 | 674 --- gcc/cccp.c | 11313 ----------------------------------- gcc/cexp.c | 2209 ------- gcc/cexp.y | 1226 ---- gcc/ch/ChangeLog | 4 + gcc/ch/decl.c | 4 +- gcc/ch/lex.c | 2 +- gcc/config/convex/convex.h | 1 - gcc/config/fx80/fx80.h | 4 +- gcc/config/i386/xm-os2.h | 1 - gcc/config/m68k/m68k.h | 6 +- gcc/config/mips/t-ecoff | 2 - gcc/config/mips/t-elf | 2 - gcc/config/mips/t-r3900 | 2 - gcc/config/pdp11/pdp11.h | 5 - gcc/config/romp/xm-romp.h | 5 - gcc/config/xm-linux.h | 3 - gcc/configure | 477 +- gcc/configure.in | 10 - gcc/cp/ChangeLog | 4 + gcc/cp/lex.c | 2 +- gcc/cppfiles.c | 2 +- gcc/cpplib.h | 2 +- gcc/f/ChangeLog | 7 +- gcc/f/g77install.texi | 2 +- gcc/f/lex.c | 2 +- gcc/install.texi | 58 +- gcc/jump.c | 2 +- gcc/po/ChangeLog | 5 + gcc/po/POTFILES.in | 4 +- gcc/protoize.c | 2 +- 37 files changed, 528 insertions(+), 16051 deletions(-) delete mode 100644 gcc/cccp.1 delete mode 100644 gcc/cccp.c delete mode 100644 gcc/cexp.c delete mode 100644 gcc/cexp.y diff --git a/contrib/ChangeLog b/contrib/ChangeLog index e4423324e7c..4321ff25c31 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,7 @@ +2000-04-18 Zack Weinberg + + * gcc_update: Remove references to cexp.c/cexp.y. + 1999-12-18 Gerald Pfeifer * newcvsroot: Add check on the number of command-line arguments. diff --git a/contrib/gcc_update b/contrib/gcc_update index a25e275025b..67b00207f7e 100755 --- a/contrib/gcc_update +++ b/contrib/gcc_update @@ -67,7 +67,6 @@ gcc/c-parse.y: gcc/c-parse.in gcc/c-parse.c: gcc/c-parse.y gcc/c-parse.h: gcc/c-parse.c gcc/c-gperf.h: gcc/c-parse.gperf -gcc/cexp.c: gcc/cexp.y gcc/fixinc/fixincl.x: gcc/fixinc/fixincl.tpl gcc/fixinc/inclhack.def gcc/fixinc/inclhack.sh: gcc/fixinc/inclhack.def gcc/fixinc/inclhack.tpl gcc/fixinc/hackshell.tpl gcc/fixinc/fixincl.sh: gcc/fixinc/inclhack.def gcc/fixinc/inclhack.tpl diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8a6b3a090e4..b6be8a9fa16 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,27 @@ 2000-04-18 Zack Weinberg + * cccp.c, cexp.y, cexp.c, cccp.1: Removed. + + * configure.in: Delete --disable-cpplib option and all + references to cpp_main. + * configure: Regenerate. + * Makefile.in: Remove all references to CCCP, CCCP_OBJS, + @cpp_main@, cccp.c, cexp.c, cexp.y, cexp.output, cexp.o, + cccp.o, cccp, or cppmain. Link cppmain.o straight to + cpp$(exeext). Add --no-headers to makeinfo command line when + generating INSTALL. Install and uninstall cpp.1 manpage, not + cccp.1. + * install.texi: Delete all references to cexp.y/cexp.c. + Delete ancient instructions for compiling GCC on 3b1. + * INSTALL: Regenerate. + + * cppfiles.c, cpplib.h, jump.c, protoize.c, c-lex.c, mips/t-ecoff, + mips/t-elf, mips/t-r3900: Remove references to cccp.c. + * convex.h, fx80.h, m68k.h, pdp11.h: Remove references to + cexp.c/cexp.y. + * xm-linux.h, xm-os2.h, romp.h: Remove definition of BSTRING, + which is no longer tested anywhere. + * cppinit.c (handle_option): Don't run error message through gettext twice. diff --git a/gcc/INSTALL b/gcc/INSTALL index a7c63d57de8..37fca13c68e 100644 --- a/gcc/INSTALL +++ b/gcc/INSTALL @@ -1,32 +1,16 @@ -This is Info file INSTALL, produced by Makeinfo version 1.68 from the -input file install1.texi. - - This file documents the installation of the GNU compiler. Copyright +This file documents the installation of the GNU compiler. Copyright (C) 1988, 1989, 1992, 1994, 1995 Free Software Foundation, Inc. You may copy, distribute, and modify it freely as long as you preserve this copyright notice and permission notice. - -File: INSTALL, Node: Installation, Up: (dir) - Installing GNU CC ***************** - Note most of this information is out of date and superceded by the + Note most of this information is out of date and superseded by the EGCS install procedures. It is provided for historical reference only. -* Menu: - -* Configurations:: Configurations Supported by GNU CC. -* Other Dir:: Compiling in a separate directory (not where the source is). -* Cross-Compiler:: Building and installing a cross-compiler. -* Sun Install:: See below for installation on the Sun. -* VMS Install:: See below for installation on VMS. -* Collect2:: How `collect2' works; how it finds `ld'. -* Header Dirs:: Understanding the standard header file directories. - - Here is the procedure for installing GNU CC on a Unix system. See -*Note VMS Install::, for VMS systems. In this section we assume you + Here is the procedure for installing GNU CC on a GNU or Unix system. +See *Note VMS Install::, for VMS systems. In this section we assume you compile in the same directory that contains the source files; see *Note Other Dir::, to find out how to compile in a separate directory on Unix systems. @@ -47,8 +31,26 @@ and includes all the necessary compilation tools and libraries. `/usr/ucb' in `PATH'. The `cc' command in `/usr/ucb' uses libraries which have bugs. - 3. Specify the host, build and target machine configurations. You do - this by running the file `configure'. + 3. Make sure the Bison parser generator is installed. (This is + unnecessary if the Bison output file `c-parse.c' is more recent + than `c-parse.y',and you do not plan to change the `.y' file.) + + Bison versions older than Sept 8, 1988 will produce incorrect + output for `c-parse.c'. + + 4. If you have chosen a configuration for GNU CC which requires other + GNU tools (such as GAS or the GNU linker) instead of the standard + system tools, install the required tools in the build directory + under the names `as', `ld' or whatever is appropriate. This will + enable the compiler to find the proper tools for compilation of + the program `enquire'. + + Alternatively, you can do subsequent compilation using a value of + the `PATH' environment variable such that the necessary GNU tools + come before the standard system tools. + + 5. Specify the host, build and target machine configurations. You do + this when you run the `configure' script. The "build" machine is the system which you are using, the "host" machine is the system where you want to run the resulting compiler @@ -97,9 +99,10 @@ and includes all the necessary compilation tools and libraries. the notes in that section before proceeding any further with the installation of GNU CC. - There are four additional options you can specify independently to - describe variant hardware and software configurations. These are - `--with-gnu-as', `--with-gnu-ld', `--with-stabs' and `--nfp'. + 6. When running `configure', you may also need to specify certain + additional options that describe variant hardware and software + configurations. These are `--with-gnu-as', `--with-gnu-ld', + `--with-stabs' and `--nfp'. `--with-gnu-as' If you will use GNU CC with the GNU assembler (GAS), you @@ -205,104 +208,130 @@ and includes all the necessary compilation tools and libraries. the compiler and may only work properly if you are building the compiler with GNU C. - The `configure' script searches subdirectories of the source - directory for other compilers that are to be integrated into GNU - CC. The GNU compiler for C++, called G++ is in a subdirectory - named `cp'. `configure' inserts rules into `Makefile' to build - all of those compilers. + The `configure' script searches subdirectories of the source + directory for other compilers that are to be integrated into + GNU CC. The GNU compiler for C++, called G++ is in a + subdirectory named `cp'. `configure' inserts rules into + `Makefile' to build all of those compilers. - Here we spell out what files will be set up by `configure'. - Normally you need not be concerned with these files. + Here we spell out what files will be set up by `configure'. + Normally you need not be concerned with these files. - * A file named `config.h' is created that contains a `#include' - of the top-level config file for the machine you will run the - compiler on (*note The Configuration File: - (gcc.info)Config.). This file is responsible for defining - information about the host machine. It includes `tm.h'. + * A file named `config.h' is created that contains a + `#include' of the top-level config file for the machine + you will run the compiler on (*note The Configuration + File: (gcc.info)Config.). This file is responsible for + defining information about the host machine. It + includes `tm.h'. - The top-level config file is located in the subdirectory - `config'. Its name is always `xm-SOMETHING.h'; usually - `xm-MACHINE.h', but there are some exceptions. + The top-level config file is located in the subdirectory + `config'. Its name is always `xm-SOMETHING.h'; usually + `xm-MACHINE.h', but there are some exceptions. - If your system does not support symbolic links, you might - want to set up `config.h' to contain a `#include' command - which refers to the appropriate file. + If your system does not support symbolic links, you + might want to set up `config.h' to contain a `#include' + command which refers to the appropriate file. - * A file named `tconfig.h' is created which includes the - top-level config file for your target machine. This is used - for compiling certain programs to run on that machine. + * A file named `tconfig.h' is created which includes the + top-level config file for your target machine. This is + used for compiling certain programs to run on that + machine. - * A file named `tm.h' is created which includes the - machine-description macro file for your target machine. It - should be in the subdirectory `config' and its name is often - `MACHINE.h'. + * A file named `tm.h' is created which includes the + machine-description macro file for your target machine. + It should be in the subdirectory `config' and its name + is often `MACHINE.h'. - * The command file `configure' also constructs the file - `Makefile' by adding some text to the template file - `Makefile.in'. The additional text comes from files in the - `config' directory, named `t-TARGET' and `x-HOST'. If these - files do not exist, it means nothing needs to be added for a - given target or host. + `--enable-nls' + `--disable-nls' + The `--enable-nls' option enables Native Language Support + (NLS), which lets GCC output diagnostics in languages other + than American English. No translations are available yet, so + the main users of this option now are those translating GCC's + diagnostics who want to test their work. Once translations + become available, Native Language Support will become enabled + by default. The `--disable-nls' option disables NLS. - 4. The standard directory for installing GNU CC is `/usr/local/lib'. - If you want to install its files somewhere else, specify - `--prefix=DIR' when you run `configure'. Here DIR is a directory - name to use instead of `/usr/local' for all purposes with one - exception: the directory `/usr/local/include' is searched for - header files no matter where you install the compiler. To override - this name, use the `--with-local-prefix' option below. The - directory you specify need not exist, but its parent directory - must exist. + `--with-included-gettext' + If NLS is enabled, the GCC build procedure normally attempts + to use the host's `gettext' libraries, and falls back on + GCC's copy of the GNU `gettext' library only if the host + libraries do not suffice. The `--with-included-gettext' + option causes the build procedure to prefer its copy of GNU + `gettext'. - 5. Specify `--with-local-prefix=DIR' if you want the compiler to - search directory `DIR/include' for locally installed header files - *instead* of `/usr/local/include'. + `--with-catgets' + If NLS is enabled, and if the host lacks `gettext' but has the + inferior `catgets' interface, the GCC build procedure normally + ignores `catgets' and instead uses GCC's copy of the GNU + `gettext' library. The `--with-catgets' option causes the + build procedure to use the host's `catgets' in this situation. - You should specify `--with-local-prefix' *only* if your site has a - different convention (not `/usr/local') for where to put - site-specific files. + `--enable-win32-registry' + `--enable-win32-registry=KEY' + `--disable-win32-registry' + The `--enable-win32-registry' option enables Windows-hosted + GCC to look up installations paths in the registry using the + following key: - The default value for `--with-local-prefix' is `/usr/local' - regardless of the value of `--prefix'. Specifying `--prefix' has - no effect on which directory GNU CC searches for local header - files. This may seem counterintuitive, but actually it is logical. + `HKEY_LOCAL_MACHINE\SOFTWARE\Free Software Foundation\' - The purpose of `--prefix' is to specify where to *install GNU CC*. - The local header files in `/usr/local/include'--if you put any in - that directory--are not part of GNU CC. They are part of other - programs--perhaps many others. (GNU CC installs its own header - files in another directory which is based on the `--prefix' value.) + defaults to GCC version number, and can be overridden + by the `--enable-win32-registry=KEY' option. Vendors and + distributors who use custom installers are encouraged to + provide a different key, perhaps one comprised of vendor name + and GCC version number, to avoid conflict with existing + installations. This feature is enabled by default, and can be + disabled by `--disable-win32-registry' option. This option + has no effect on the other hosts. - *Do not* specify `/usr' as the `--with-local-prefix'! The - directory you use for `--with-local-prefix' *must not* contain any - of the system's standard header files. If it did contain them, - certain programs would be miscompiled (including GNU Emacs, on - certain targets), because this would override and nullify the - header file corrections made by the `fixincludes' script. + 7. In certain cases, you should specify certain other options when + you run `configure'. - Indications are that people who use this option use it based on - mistaken ideas of what it is for. People use it as if it specified - where to install part of GNU CC. Perhaps they make this assumption - because installing GNU CC creates the directory. + * The standard directory for installing GNU CC is + `/usr/local/lib'. If you want to install its files somewhere + else, specify `--prefix=DIR' when you run `configure'. Here + DIR is a directory name to use instead of `/usr/local' for + all purposes with one exception: the directory + `/usr/local/include' is searched for header files no matter + where you install the compiler. To override this name, use + the `--with-local-prefix' option below. The directory you + specify need not exist, but its parent directory must exist. - 6. Make sure the Bison parser generator is installed. (This is - unnecessary if the Bison output files `c-parse.c' and `cexp.c' are - more recent than `c-parse.y' and `cexp.y' and you do not plan to - change the `.y' files.) + * Specify `--with-local-prefix=DIR' if you want the compiler to + search directory `DIR/include' for locally installed header + files *instead* of `/usr/local/include'. - Bison versions older than Sept 8, 1988 will produce incorrect - output for `c-parse.c'. + You should specify `--with-local-prefix' *only* if your site + has a different convention (not `/usr/local') for where to put + site-specific files. - 7. If you have chosen a configuration for GNU CC which requires other - GNU tools (such as GAS or the GNU linker) instead of the standard - system tools, install the required tools in the build directory - under the names `as', `ld' or whatever is appropriate. This will - enable the compiler to find the proper tools for compilation of - the program `enquire'. + The default value for `--with-local-prefix' is `/usr/local' + regardless of the value of `--prefix'. Specifying `--prefix' + has no effect on which directory GNU CC searches for local + header files. This may seem counterintuitive, but actually + it is logical. - Alternatively, you can do subsequent compilation using a value of - the `PATH' environment variable such that the necessary GNU tools - come before the standard system tools. + The purpose of `--prefix' is to specify where to *install GNU + CC*. The local header files in `/usr/local/include'--if you + put any in that directory--are not part of GNU CC. They are + part of other programs--perhaps many others. (GNU CC + installs its own header files in another directory which is + based on the `--prefix' value.) + + *Do not* specify `/usr' as the `--with-local-prefix'! The + directory you use for `--with-local-prefix' *must not* contain + any of the system's standard header files. If it did contain + them, certain programs would be miscompiled (including GNU + Emacs, on certain targets), because this would override and + nullify the header file corrections made by the `fixincludes' + script. + + Indications are that people who use this option use it based + on mistaken ideas of what it is for. People use it as if it + specified where to install part of GNU CC. Perhaps they make + this assumption because installing GNU CC creates the + directory. 8. Build the compiler. Just type `make LANGUAGES=c' in the compiler directory. @@ -325,17 +354,16 @@ and includes all the necessary compilation tools and libraries. escape sequence" are normal in `genopinit.c' and perhaps some other files. Likewise, you should ignore warnings about "constant is so large that it is unsigned" in `insn-emit.c' and - `insn-recog.c', a warning about a comparison always being zero in - `enquire.o', and warnings about shift counts exceeding type widths - in `cexp.y'. Any other compilation errors may represent bugs in + `insn-recog.c', and a warning about a comparison always being zero + in `enquire.o'. Any other compilation errors may represent bugs in the port to your machine or operating system, and should be investigated and reported. - Some commercial compilers fail to compile GNU CC because they have - bugs or limitations. For example, the Microsoft compiler is said - to run out of macro space. Some Ultrix compilers run out of - expression space; then you need to break up the statement where - the problem happens. + Some compilers fail to compile GNU CC because they have bugs or + limitations. For example, the Microsoft compiler is said to run + out of macro space. Some Ultrix compilers run out of expression + space; then you need to break up the statement where the problem + happens. 9. If you are building a cross-compiler, stop here. *Note Cross-Compiler::. @@ -411,8 +439,8 @@ and includes all the necessary compilation tools and libraries. instead of making `stage1', `stage2', and performing the two compiler builds. - 14. Then compare the latest object files with the stage 2 object - files--they ought to be identical, aside from time stamps (if any). + 14. Compare the latest object files with the stage 2 object files--they + ought to be identical, aside from time stamps (if any). On some systems, meaningful comparison of object files is impossible; they always appear "different." This is currently @@ -485,11 +513,9 @@ and includes all the necessary compilation tools and libraries. or 3, since they usually run faster than the ones compiled with some other compiler.) - 16. If you're going to use C++, it's likely that you need to also - install a C++ runtime library. Just as GNU C does not distribute - a C runtime library, it also does not include a C++ runtime - library. All I/O functionality, special class libraries, etc., are - provided by the C++ runtime library. + 16. If you're going to use C++, you need to install the C++ runtime + library. This includes all I/O functionality, special class + libraries, etc. The standard C++ runtime library for GNU CC is called `libstdc++'. An obsolescent library `libg++' may also be available, but it's @@ -566,19 +592,50 @@ and includes all the necessary compilation tools and libraries. * thr-win32 Microsoft Win32 API thread support. - -File: INSTALL, Node: Configurations, Next: Other Dir, Up: Installation +Files Created by `configure' +============================ + + Here we spell out what files will be set up by `configure'. Normally +you need not be concerned with these files. + + * A file named `config.h' is created that contains a `#include' of + the top-level config file for the machine you will run the compiler + on (*note The Configuration File: (gcc.info)Config.). This file + is responsible for defining information about the host machine. + It includes `tm.h'. + + The top-level config file is located in the subdirectory `config'. + Its name is always `xm-SOMETHING.h'; usually `xm-MACHINE.h', but + there are some exceptions. + + If your system does not support symbolic links, you might want to + set up `config.h' to contain a `#include' command which refers to + the appropriate file. + + * A file named `tconfig.h' is created which includes the top-level + config file for your target machine. This is used for compiling + certain programs to run on that machine. + + * A file named `tm.h' is created which includes the + machine-description macro file for your target machine. It should + be in the subdirectory `config' and its name is often `MACHINE.h'. + + * The command file `configure' also constructs the file `Makefile' + by adding some text to the template file `Makefile.in'. The + additional text comes from files in the `config' directory, named + `t-TARGET' and `x-HOST'. If these files do not exist, it means + nothing needs to be added for a given target or host. Configurations Supported by GNU CC ================================== Here are the possible CPU types: - 1750a, a29k, alpha, arm, cN, clipper, dsp16xx, elxsi, h8300, - hppa1.0, hppa1.1, i370, i386, i486, i586, i860, i960, m32r, - m68000, m68k, m88k, mips, mipsel, mips64, mips64el, ns32k, - powerpc, powerpcle, pyramid, romp, rs6000, sh, sparc, sparclite, - sparc64, vax, we32k. + 1750a, a29k, alpha, arm, avr, cN, clipper, dsp16xx, elxsi, fr30, + h8300, hppa1.0, hppa1.1, i370, i386, i486, i586, i686, i786, i860, + i960, m32r, m68000, m68k, m88k, mcore, mips, mipsel, mips64, + mips64el, mn10200, mn10300, ns32k, pdp11, powerpc, powerpcle, + romp, rs6000, sh, sparc, sparclite, sparc64, v850, vax, we32k. Here are the recognized company names. As you can see, customary abbreviations are used rather than the longer official names. @@ -744,12 +801,24 @@ special things you must know: You may need to make a variant of the file `arm.h' for your particular configuration. -`arm-*-linuxaout' - Any of the ARM family processors running the Linux-based GNU - system with the `a.out' binary format (ELF is not yet supported). - You must use version 2.8.1.0.7 or later of the GNU/Linux binutils, - which you can download from `sunsite.unc.edu:/pub/Linux/GCC' and - other mirror sites for Linux-based GNU systems. +`arm-*-elf' + This configuration is intended for embedded systems. + +`arm-*-linux-gnuaout' + Any of the ARM-family processors running the Linux-based GNU + system with the `a.out' binary format. This is an obsolete + configuration. + +`arm-*-linux-gnu' +`arm-*-linux-gnuoldld' + Any of the ARM-family processors running the Linux-based GNU + system with the `ELF' binary format. You must use version + 2.9.1.0.22 or later of the GNU/Linux binutils, which you can + download from `ftp.varesearch.com:/pub/support/hjl/binutils'. + + These two configurations differ only in the required version of GNU + binutils. For binutils 2.9.1.0.x, use `arm-*-linux-gnuoldld'. For + newer versions of binutils, use `arm-*-linux-gnu'. `arm-*-riscix' The ARM2 or ARM3 processor running RISC iX, Acorn's port of BSD @@ -775,6 +844,12 @@ special things you must know: `a29k-*-bsd' AMD Am29050 used in a system running a variant of BSD Unix. +`avr' + ATMEL AVR-family micro controllers. These are used in embedded + applications. There are no standard Unix configurations. + Supports following MCU's: - AT90S23xx - ATtiny22 - AT90S44xx - + AT90S85xx - ATmega603/603L - ATmega103/103L + `decstation-*' MIPS-based DECstations can support three different personalities: Ultrix, DEC OSF/1, and OSF/rose. (Alpha-based DECstation products @@ -1019,37 +1094,11 @@ special things you must know: the original. `m68k-att-sysv' - AT&T 3b1, a.k.a. 7300 PC. Special procedures are needed to - compile GNU CC with this machine's standard C compiler, due to - bugs in that compiler. You can bootstrap it more easily with - previous versions of GNU CC if you have them. - - Installing GNU CC on the 3b1 is difficult if you do not already - have GNU CC running, due to bugs in the installed C compiler. - However, the following procedure might work. We are unable to - test it. - - 1. Comment out the `#include "config.h"' line near the start of - `cccp.c' and do `make cpp'. This makes a preliminary version - of GNU cpp. - - 2. Save the old `/lib/cpp' and copy the preliminary GNU cpp to - that file name. - - 3. Undo your change in `cccp.c', or reinstall the original - version, and do `make cpp' again. - - 4. Copy this final version of GNU cpp into `/lib/cpp'. - - 5. Replace every occurrence of `obstack_free' in the file - `tree.c' with `_obstack_free'. - - 6. Run `make' to get the first-stage GNU CC. - - 7. Reinstall the original version of `/lib/cpp'. - - 8. Now you can compile GNU CC with itself and install it in the - normal fashion. + AT&T 3b1, a.k.a. 7300 PC. This version of GNU CC cannot be + compiled with the system C compiler, which is too buggy. You will + need to get a previous version of GCC and use it to bootstrap. + Binaries are available from the OSU-CIS archive, at + `ftp://archive.cis.ohio-state.edu/pub/att7300/'. `m68k-bull-sysv' Bull DPX/2 series 200 and 300 with BOS-2.00.45 up to BOS-2.01. GNU @@ -1446,9 +1495,6 @@ special things you must know: You may need to raise the ULIMIT setting to build a C++ compiler, as the file `cc1plus' is larger than one megabyte. - -File: INSTALL, Node: Other Dir, Next: Cross-Compiler, Prev: Configurations, Up: Installation - Compilation in a Separate Directory =================================== @@ -1493,9 +1539,6 @@ configuration steps shown above, when ordinary source files change. You must, however, run `configure' again when the configuration files change, if your system does not support symbolic links. - -File: INSTALL, Node: Cross-Compiler, Next: Sun Install, Prev: Other Dir, Up: Installation - Building and Installing a Cross-Compiler ======================================== @@ -1522,20 +1565,6 @@ If you want to link on other than the target machine, you need a cross-linker as well. You also need header files and libraries suitable for the target machine that you can install on the host machine. -* Menu: - -* Steps of Cross:: Using a cross-compiler involves several steps - that may be carried out on different machines. -* Configure Cross:: Configuring a cross-compiler. -* Tools and Libraries:: Where to put the linker and assembler, and the C library. -* Cross Headers:: Finding and installing header files - for a cross-compiler. -* Cross Runtime:: Supplying arithmetic runtime routines (`libgcc1.a'). -* Build Cross:: Actually compiling the cross-compiler. - - -File: INSTALL, Node: Steps of Cross, Next: Configure Cross, Up: Cross-Compiler - Steps of Cross-Compilation -------------------------- @@ -1561,9 +1590,6 @@ machine, since then you can do it all with a single invocation of GNU CC. This requires a suitable cross-assembler and cross-linker. For some targets, the GNU assembler and linker are available. - -File: INSTALL, Node: Configure Cross, Next: Tools and Libraries, Prev: Steps of Cross, Up: Cross-Compiler - Configuring a Cross-Compiler ---------------------------- @@ -1576,9 +1602,6 @@ system running BSD on a system that `configure' can correctly identify: ./configure --target=m68k-hp-bsd4.3 - -File: INSTALL, Node: Tools and Libraries, Next: Cross Headers, Prev: Configure Cross, Up: Cross-Compiler - Tools and Libraries for a Cross-Compiler ---------------------------------------- @@ -1647,9 +1670,6 @@ machine: mget *crt*.o quit - -File: INSTALL, Node: Cross Runtime, Next: Build Cross, Prev: Cross Headers, Up: Cross-Compiler - `libgcc.a' and Cross-Compilers ------------------------------ @@ -1735,9 +1755,6 @@ Otherwise, you should place your replacement library under the name `libgcc1.a' in the directory in which you will build the cross-compiler, before you run `make'. - -File: INSTALL, Node: Cross Headers, Next: Cross Runtime, Prev: Tools and Libraries, Up: Cross-Compiler - Cross-Compilers and Header Files -------------------------------- @@ -1786,9 +1803,6 @@ machine. On the target machine, do this: quit tar xf tarfile - -File: INSTALL, Node: Build Cross, Prev: Cross Runtime, Up: Cross-Compiler - Actually Building the Cross-Compiler ------------------------------------ @@ -1822,9 +1836,6 @@ must specify a 68030 as the host when you configure it. To install the cross-compiler, use `make install', as usual. - -File: INSTALL, Node: Sun Install, Next: VMS Install, Prev: Cross-Compiler, Up: Installation - Installing GNU CC on the Sun ============================ @@ -1860,9 +1871,6 @@ error which does not recur if you run it again. To fix the problem, install Sun recommended patch 100726 (for SunOS 4.1.3) or 101508 (for SunOS 4.1.3_U1), or upgrade to a later SunOS release. - -File: INSTALL, Node: VMS Install, Next: Collect2, Prev: Sun Install, Up: Installation - Installing GNU CC on VMS ======================== @@ -2068,9 +2076,6 @@ edit the file `tm.h' (created by `vmsconfig.com') to define the macro `QSORT_WORKAROUND' is always defined when GNU CC is compiled with VAX C, to avoid a problem in case `gcclib.olb' is not yet available. - -File: INSTALL, Node: Collect2, Next: Header Dirs, Prev: VMS Install, Up: Installation - `collect2' ========== @@ -2136,9 +2141,6 @@ search path. `collect2' searches for the utilities `nm' and `strip' using the same algorithm as above for `ld'. - -File: INSTALL, Node: Header Dirs, Prev: Collect2, Up: Installation - Standard Header File Directories ================================ @@ -2150,9 +2152,9 @@ cross compilation header files need to be fixed, they must be installed before GNU CC is built. If the cross compilation header files are already suitable for ANSI C and GNU CC, nothing special need be done). - `GPLUS_INCLUDE_DIR' means the same thing for native and cross. It -is where `g++' looks first for header files. The C++ library installs -only target independent header files in that directory. + `GPLUSPLUS_INCLUDE_DIR' means the same thing for native and cross. +It is where `g++' looks first for header files. The C++ library +installs only target independent header files in that directory. `LOCAL_INCLUDE_DIR' is used only for a native compiler. It is normally `/usr/local/include'. GNU CC searches this directory so that @@ -2167,22 +2169,3 @@ use. For a cross-compiler, this is the equivalent of `/usr/include'. When you build a cross-compiler, `fixincludes' processes any header files in this directory. - - -Tag Table: -Node: Installation351 -Node: Configurations26618 -Node: Other Dir65739 -Node: Cross-Compiler67454 -Node: Steps of Cross69284 -Node: Configure Cross70401 -Node: Tools and Libraries71037 -Node: Cross Runtime73475 -Node: Cross Headers77555 -Node: Build Cross79553 -Node: Sun Install81428 -Node: VMS Install83099 -Node: Collect293028 -Node: Header Dirs95592 - -End Tag Table diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 76d93ff3e54..e4e0c2589a6 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -692,8 +692,6 @@ OBJS = diagnostic.o \ GEN= genemit genoutput genrecog genextract genflags gencodes genconfig \ genpeep gengenrtl gencheck -CCCP=@cpp_main@ - # Files to be copied away after each stage in building. STAGESTUFF = *$(objext) insn-flags.h insn-config.h insn-codes.h \ insn-output.c insn-recog.c insn-emit.c insn-extract.c insn-peep.c \ @@ -707,9 +705,8 @@ STAGESTUFF = *$(objext) insn-flags.h insn-config.h insn-codes.h \ genattr$(build_exeext) genopinit$(build_exeext) gengenrtl$(build_exeext) \ gencheck$(build_exeext) \ xgcc$(exeext) xcpp$(exeext) cc1$(exeext) cpp$(exeext) $(EXTRA_PASSES) \ - $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) \ - $(CCCP)$(exeext) cc1obj$(exeext) enquire$(exeext) \ - protoize$(exeext) unprotoize$(exeext) \ + $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) cc1obj$(exeext) \ + enquire$(exeext) protoize$(exeext) unprotoize$(exeext) \ specs collect2$(exeext) $(USE_COLLECT2) underscore.c \ gcov$(exeext) *.[0-9][0-9].* *.[si] libcpp.a \ $(LANG_STAGESTUFF) @@ -2013,7 +2010,7 @@ $(top_builddir)/intl/libintl.a: # Make sure all the headers are there for xgettext to scan. $(INTL_TARGETS): $(srcdir)/c-gperf.h \ - $(srcdir)/c-parse.c $(srcdir)/c-parse.h $(srcdir)/cexp.c + $(srcdir)/c-parse.c $(srcdir)/c-parse.h intl.all intl.install intl.uninstall intl.distdir \ intl.mostlyclean intl.clean intl.distclean intl.maintainer-clean: @@ -2032,37 +2029,18 @@ intl.distdir-fixup: # # Remake cpp and protoize. -# Making the preprocessor -cpp$(exeext): $(CCCP)$(exeext) - -rm -f cpp$(exeext) - $(LN) $(CCCP)$(exeext) cpp$(exeext) -CCCP_OBJS = cccp.o cexp.o intl.o prefix.o version.o @extra_cpp_objs@ mbchar.o -cccp$(exeext): $(CCCP_OBJS) $(LIBDEPS) - $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(CCCP_OBJS) $(LIBS) -cexp.o: $(srcdir)/cexp.c $(CONFIG_H) system.h mbchar.h - $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $(srcdir)/cexp.c -$(srcdir)/cexp.c: $(srcdir)/cexp.y - cd $(srcdir); $(BISON) -o cexp.c cexp.y - PREPROCESSOR_DEFINES = \ -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \ -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \ -DLOCAL_INCLUDE_DIR=\"$(includedir)\" \ -DCROSS_INCLUDE_DIR=\"$(gcc_tooldir)/sys-include\" \ -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" -# We use $(libsubdir)/$(unlibsubdir) to match the -# -iprefix argument which gcc will pass if GCC_EXEC_PREFIX is used. -cccp.o: cccp.c $(CONFIG_H) intl.h pcp.h version.c config.status system.h \ - mbchar.h prefix.h Makefile.in version.h - $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ - $(PREPROCESSOR_DEFINES) \ - -c `echo $(srcdir)/cccp.c | sed 's,^\./,,'` LIBCPP_OBJS = cpplib.o cpphash.o cpperror.o cppexp.o cppfiles.o \ cppinit.o cppulp.o cpplex.o mkdeps.o \ prefix.o version.o mbchar.o @extra_cpp_objs@ -LIBCPP_DEPS = cpplib.h cpphash.h intl.h system.h +LIBCPP_DEPS = cpplib.h cpphash.h intl.h system.h # All the other archives built/used by this makefile are for targets. This # one is strictly for the host. @@ -2072,8 +2050,8 @@ libcpp.a: $(LIBCPP_OBJS) $(AR) $(AR_FLAGS) libcpp.a $(LIBCPP_OBJS) if $(RANLIB_TEST) ; then $(RANLIB) libcpp.a ; else true ; fi -cppmain$(exeext): cppmain.o intl.o libcpp.a $(LIBDEPS) - $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cppmain$(exeext) cppmain.o \ +cpp$(exeext): cppmain.o intl.o libcpp.a $(LIBDEPS) + $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cpp$(exeext) cppmain.o \ intl.o libcpp.a $(LIBS) cppmain.o: cppmain.c $(CONFIG_H) cpplib.h intl.h system.h @@ -2361,7 +2339,7 @@ cpp.dvi: $(srcdir)/cpp.texi INSTALL: $(srcdir)/install1.texi $(srcdir)/install.texi cd $(srcdir); $(MAKEINFO) -D INSTALLONLY \ - --no-split -o INSTALL install1.texi + --no-split --no-headers -o INSTALL install1.texi # # Deletion of files made during compilation. # There are four levels of this: @@ -2476,8 +2454,7 @@ maintainer-clean: $(MAKE) INTL_DISTCLEAN= INTL_CLEAN= INTL_MOSTLYCLEAN= \ intl.maintainer-clean lang.maintainer-clean distclean -rm -f c-parse.y c-gperf.h - -rm -f c-parse.c c-parse.h c-parse.output - -rm -f cexp.c cexp.output TAGS + -rm -f c-parse.c c-parse.h c-parse.output TAGS -rm -f cpp.info* cpp.??s cpp.*aux -rm -f gcc.info* gcc.??s gcc.*aux # @@ -2661,7 +2638,7 @@ install-info: doc installdirs lang.install-info -chmod a-x $(infodir)/cpp.info* $(infodir)/gcc.info* # Install the man pages. -install-man: installdirs $(srcdir)/gcc.1 $(srcdir)/cccp.1 lang.install-man +install-man: installdirs $(srcdir)/gcc.1 $(srcdir)/cpp.1 lang.install-man -if [ -f gcc-cross$(exeext) ] ; then \ rm -f $(man1dir)/$(GCC_CROSS_NAME)$(manext); \ $(INSTALL_DATA) $(srcdir)/gcc.1 $(man1dir)/$(GCC_CROSS_NAME)$(manext); \ @@ -2671,9 +2648,9 @@ install-man: installdirs $(srcdir)/gcc.1 $(srcdir)/cccp.1 lang.install-man $(INSTALL_DATA) $(srcdir)/gcc.1 $(man1dir)/$(GCC_INSTALL_NAME)$(manext); \ chmod a-x $(man1dir)/$(GCC_INSTALL_NAME)$(manext); \ fi - -rm -f $(man1dir)/cccp$(manext) - -$(INSTALL_DATA) $(srcdir)/cccp.1 $(man1dir)/cccp$(manext) - -chmod a-x $(man1dir)/cccp$(manext) + -rm -f $(man1dir)/cpp$(manext) + -$(INSTALL_DATA) $(srcdir)/cpp.1 $(man1dir)/cpp$(manext) + -chmod a-x $(man1dir)/cpp$(manext) # Install the library. install-libgcc: libgcc.a installdirs @@ -2782,7 +2759,7 @@ uninstall: intl.uninstall lang.uninstall $(UNINSTALL_CPP) -rm -rf $(bindir)/$(GCOV_INSTALL_NAME)$(exeext) -rm -rf $(man1dir)/$(GCC_INSTALL_NAME)$(manext) -rm -rf $(man1dir)/$(GCC_CROSS_NAME)$(manext) - -rm -rf $(man1dir)/cccp$(manext) + -rm -rf $(man1dir)/cpp$(manext) -rm -rf $(man1dir)/protoize$(manext) -rm -rf $(man1dir)/unprotoize$(manext) -rm -f $(infodir)/cpp.info* $(infodir)/gcc.info* @@ -2898,7 +2875,7 @@ check-objc: testsuite/site.exp TAGS: force cd $(srcdir); \ mkdir tmp-tags; \ - mv -f c-parse.[ch] cexp.c =*.[chy] tmp-tags; \ + mv -f c-parse.[ch] =*.[chy] tmp-tags; \ etags *.y *.h *.c; \ mv tmp-tags/* .; \ rmdir tmp-tags @@ -2918,8 +2895,7 @@ distdir-cvs: force # This target exists to do the initial work before the language specific # stuff gets done. distdir-start: doc $(srcdir)/INSTALL $(srcdir)/c-parse.y $(srcdir)/c-gperf.h \ - $(srcdir)/c-parse.c $(srcdir)/cexp.c $(srcdir)/config.in \ - $(srcdir)/version.c TAGS + $(srcdir)/c-parse.c $(srcdir)/config.in $(srcdir)/version.c TAGS @case '$(USE_NLS)' in \ yes) ;; \ *) echo "configure with --enable-nls before making a distribution"; \ @@ -2948,7 +2924,7 @@ distdir-start: doc $(srcdir)/INSTALL $(srcdir)/c-parse.y $(srcdir)/c-gperf.h \ test -f $(srcdir)/$$file && $(LN_S) $(srcdir)/$$file tmp; \ done if test "$(srcdir)" != "." ; then \ - for file in c-parse.c cexp.c ; do \ + for file in c-parse.c ; do \ test -f ./$$file && $(LN_S) ../$$file tmp; \ done; \ fi @@ -2998,8 +2974,7 @@ distdir: distdir-cvs distdir-start intl.distdir intl.distdir-fixup \ # The -P option assumes this is GNU diff. diff: diff -rc2P -x c-parse.y -x c-parse.c -x c-parse.h -x c-gperf.h \ - -x cexp.c -x -x TAGS -x INSTALL \ - -x configure -x config.in \ + -x TAGS -x INSTALL -x configure -x config.in \ -x "gcc.??" -x "gcc.??s" -x gcc.aux -x "gcc.info*" \ -x "cpp.??" -x "cpp.??s" -x cpp.aux -x "cpp.info*" \ $(LANG_DIFF_EXCLUDES) \ diff --git a/gcc/c-lex.c b/gcc/c-lex.c index d7697067ac7..8498e5f9607 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -680,7 +680,7 @@ check_newline () } else if (!strcmp (name, "ident")) { - /* #ident. The pedantic warning is now in cccp.c. */ + /* #ident. The pedantic warning is now in cpp. */ /* Here we have just seen `#ident '. A string constant should follow. */ diff --git a/gcc/cccp.1 b/gcc/cccp.1 deleted file mode 100644 index 84eb19ede54..00000000000 --- a/gcc/cccp.1 +++ /dev/null @@ -1,674 +0,0 @@ -.\" Copyright (c) 1991, 1992, 1993 Free Software Foundation \-*-Text-*- -.\" See section COPYING for conditions for redistribution -.TH cpp 1 "30apr1993" "GNU Tools" "GNU Tools" -.SH NAME -cccp, cpp \- The GNU C-Compatible Compiler Preprocessor. -.SH SYNOPSIS -.hy 0 -.na -.TP -.B cccp -.RB "[\|" \-$ "\|]" -.RB "[\|" \-A \c -.I predicate\c -.RB [ (\c -.I value\c -.BR ) ]\|] -.RB "[\|" \-C "\|]" -.RB "[\|" \-D \c -.I name\c -.RB [ =\c -.I definition\c -\&]\|] -.RB "[\|" \-dD "\|]" -.RB "[\|" \-dM "\|]" -.RB "[\|" "\-I\ "\c -.I directory\c -\&\|] -.RB "[\|" \-H "\|]" -.RB "[\|" \-I\- "\|]" -.RB "[\|" "\-imacros\ "\c -.I file\c -\&\|] -.RB "[\|" "\-include\ "\c -.I file\c -\&\|] -.RB "[\|" "\-idirafter\ "\c -.I dir\c -\&\|] -.RB "[\|" "\-iprefix\ "\c -.I prefix\c -\&\|] -.RB "[\|" "\-iwithprefix\ "\c -.I dir\c -\&\|] -.RB "[\|" \-lang\-c "\|]" -.RB "[\|" \-lang\-c++ "\|]" -.RB "[\|" \-lang\-objc "\|]" -.RB "[\|" \-lang\-objc++ "\|]" -.RB "[\|" \-lint "\|]" -.RB "[\|" \-M\ [ \-MG "\|]]" -.RB "[\|" \-MM\ [ \-MG "\|]]" -.RB "[\|" \-MD\ \c -.I file\ \c -\&\|] -.RB "[\|" \-MMD\ \c -.I file\ \c -\&\|] -.RB "[\|" \-nostdinc "\|]" -.RB "[\|" \-nostdinc++ "\|]" -.RB "[\|" \-P "\|]" -.RB "[\|" \-pedantic "\|]" -.RB "[\|" \-pedantic\-errors "\|]" -.RB "[\|" \-traditional "\|]" -.RB "[\|" \-trigraphs "\|]" -.RB "[\|" \-U \c -.I name\c -\&\|] -.RB "[\|" \-undef "\|]" -.RB "[\|" \-Wtrigraphs "\|]" -.RB "[\|" \-Wcomment "\|]" -.RB "[\|" \-Wall "\|]" -.RB "[\|" \-Wtraditional "\|]" -.br -.RB "[\|" \c -.I infile\c -.RB | \- "\|]" -.RB "[\|" \c -.I outfile\c -.RB | \- "\|]" -.ad b -.hy 1 -.SH DESCRIPTION -The C preprocessor is a \c -.I macro processor\c -\& that is used automatically by -the C compiler to transform your program before actual compilation. It is -called a macro processor because it allows you to define \c -.I macros\c -\&, -which are brief abbreviations for longer constructs. - -The C preprocessor provides four separate facilities that you can use as -you see fit: -.TP -\(bu -Inclusion of header files. These are files of declarations that can be -substituted into your program. -.TP -\(bu -Macro expansion. You can define \c -.I macros\c -\&, which are abbreviations -for arbitrary fragments of C code, and then the C preprocessor will -replace the macros with their definitions throughout the program. -.TP -\(bu -Conditional compilation. Using special preprocessing directives, you -can include or exclude parts of the program according to various -conditions. -.TP -\(bu -Line control. If you use a program to combine or rearrange source files into -an intermediate file which is then compiled, you can use line control -to inform the compiler of where each source line originally came from. -.PP -C preprocessors vary in some details. For a full explanation of the -GNU C preprocessor, see the -.B info -file `\|\c -.B cpp.info\c -\&\|', or the manual -.I The C Preprocessor\c -\&. Both of these are built from the same documentation source file, `\|\c -.B cpp.texinfo\c -\&\|'. The GNU C -preprocessor provides a superset of the features of ANSI Standard C. - -ANSI Standard C requires the rejection of many harmless constructs commonly -used by today's C programs. Such incompatibility would be inconvenient for -users, so the GNU C preprocessor is configured to accept these constructs -by default. Strictly speaking, to get ANSI Standard C, you must use the -options `\|\c -.B \-trigraphs\c -\&\|', `\|\c -.B \-undef\c -\&\|' and `\|\c -.B \-pedantic\c -\&\|', but in -practice the consequences of having strict ANSI Standard C make it -undesirable to do this. - -Most often when you use the C preprocessor you will not have to invoke it -explicitly: the C compiler will do so automatically. However, the -preprocessor is sometimes useful individually. - -When you call the preprocessor individually, either name -(\c -.B cpp\c -\& or \c -.B cccp\c -\&) will do\(em\&they are completely synonymous. - -The C preprocessor expects two file names as arguments, \c -.I infile\c -\& and -\c -.I outfile\c -\&. The preprocessor reads \c -.I infile\c -\& together with any other -files it specifies with `\|\c -.B #include\c -\&\|'. All the output generated by the -combined input files is written in \c -.I outfile\c -\&. - -Either \c -.I infile\c -\& or \c -.I outfile\c -\& may be `\|\c -.B \-\c -\&\|', which as \c -.I infile\c -\& -means to read from standard input and as \c -.I outfile\c -\& means to write to -standard output. Also, if \c -.I outfile\c -\& or both file names are omitted, -the standard output and standard input are used for the omitted file names. -.SH OPTIONS -Here is a table of command options accepted by the C preprocessor. -These options can also be given when compiling a C program; they are -passed along automatically to the preprocessor when it is invoked by -the compiler. -.TP -.B \-P -Inhibit generation of `\|\c -.B #\c -\&\|'-lines with line-number information in -the output from the preprocessor. This might be -useful when running the preprocessor on something that is not C code -and will be sent to a program which might be confused by the -`\|\c -.B #\c -\&\|'-lines. -.TP -.B \-C -Do not discard comments: pass them through to the output file. -Comments appearing in arguments of a macro call will be copied to the -output before the expansion of the macro call. -.TP -.B \-traditional -Try to imitate the behavior of old-fashioned C, as opposed to ANSI C. -.TP -.B \-trigraphs -Process ANSI standard trigraph sequences. These are three-character -sequences, all starting with `\|\c -.B ??\c -\&\|', that are defined by ANSI C to -stand for single characters. For example, `\|\c -.B ??/\c -\&\|' stands for -`\|\c -.BR "\e" "\|'," -so `\|\c -.B '??/n'\c -\&\|' is a character constant for a newline. -Strictly speaking, the GNU C preprocessor does not support all -programs in ANSI Standard C unless `\|\c -.B \-trigraphs\c -\&\|' is used, but if -you ever notice the difference it will be with relief. - -You don't want to know any more about trigraphs. -.TP -.B \-pedantic -Issue warnings required by the ANSI C standard in certain cases such -as when text other than a comment follows `\|\c -.B #else\c -\&\|' or `\|\c -.B #endif\c -\&\|'. -.TP -.B \-pedantic\-errors -Like `\|\c -.B \-pedantic\c -\&\|', except that errors are produced rather than -warnings. -.TP -.B \-Wtrigraphs -Warn if any trigraphs are encountered (assuming they are enabled). -.TP -.B \-Wcomment -.TP -.B \-Wcomments -Warn whenever a comment-start sequence `\|\c -.B /*\c -\&\|' appears in a comment. -(Both forms have the same effect). -.TP -.B \-Wall -Requests both `\|\c -.B \-Wtrigraphs\c -\&\|' and `\|\c -.B \-Wcomment\c -\&\|' (but not -`\|\c -.B \-Wtraditional\c -\&\|'). -.TP -.B \-Wtraditional -Warn about certain constructs that behave differently in traditional and -ANSI C. -.TP -.BI "\-I " directory\c -\& -Add the directory \c -.I directory\c -\& to the end of the list of -directories to be searched for header files. -This can be used to override a system header file, substituting your -own version, since these directories are searched before the system -header file directories. If you use more than one `\|\c -.B \-I\c -\&\|' option, -the directories are scanned in left-to-right order; the standard -system directories come after. -.TP -.B \-I\- -Any directories specified with `\|\c -.B \-I\c -\&\|' options before the `\|\c -.B \-I\-\c -\&\|' -option are searched only for the case of `\|\c -.B #include "\c -.I file\c -\&"\c -\&\|'; -they are not searched for `\|\c -.B #include <\c -.I file\c -\&>\c -\&\|'. - -If additional directories are specified with `\|\c -.B \-I\c -\&\|' options after -the `\|\c -.B \-I\-\c -\&\|', these directories are searched for all `\|\c -.B #include\c -\&\|' -directives. - -In addition, the `\|\c -.B \-I\-\c -\&\|' option inhibits the use of the current -directory as the first search directory for `\|\c -.B #include "\c -.I file\c -\&"\c -\&\|'. -Therefore, the current directory is searched only if it is requested -explicitly with `\|\c -.B \-I.\c -\&\|'. Specifying both `\|\c -.B \-I\-\c -\&\|' and `\|\c -.B \-I.\c -\&\|' -allows you to control precisely which directories are searched before -the current one and which are searched after. -.TP -.B \-nostdinc -Do not search the standard system directories for header files. -Only the directories you have specified with `\|\c -.B \-I\c -\&\|' options -(and the current directory, if appropriate) are searched. -.TP -.B \-nostdinc++ -Do not search for header files in the C++ specific standard -directories, but do still search the other standard directories. -(This option is used when building libg++.) -.TP -.BI "\-D " "name"\c -\& -Predefine \c -.I name\c -\& as a macro, with definition `\|\c -.B 1\c -\&\|'. -.TP -.BI "\-D " "name" = definition -\& -Predefine \c -.I name\c -\& as a macro, with definition \c -.I definition\c -\&. -There are no restrictions on the contents of \c -.I definition\c -\&, but if -you are invoking the preprocessor from a shell or shell-like program -you may need to use the shell's quoting syntax to protect characters -such as spaces that have a meaning in the shell syntax. If you use more than -one `\|\c -.B \-D\c -\&\|' for the same -.I name\c -\&, the rightmost definition takes effect. -.TP -.BI "\-U " "name"\c -\& -Do not predefine \c -.I name\c -\&. If both `\|\c -.B \-U\c -\&\|' and `\|\c -.B \-D\c -\&\|' are -specified for one name, the `\|\c -.B \-U\c -\&\|' beats the `\|\c -.B \-D\c -\&\|' and the name -is not predefined. -.TP -.B \-undef -Do not predefine any nonstandard macros. -.TP -.BI "\-A " "name(" value ) -Assert (in the same way as the \c -.B #assert\c -\& directive) -the predicate \c -.I name\c -\& with tokenlist \c -.I value\c -\&. Remember to escape or quote the parentheses on -shell command lines. - -You can use `\|\c -.B \-A-\c -\&\|' to disable all predefined assertions; it also -undefines all predefined macros. -.TP -.B \-dM -Instead of outputting the result of preprocessing, output a list of -`\|\c -.B #define\c -\&\|' directives for all the macros defined during the -execution of the preprocessor, including predefined macros. This gives -you a way of finding out what is predefined in your version of the -preprocessor; assuming you have no file `\|\c -.B foo.h\c -\&\|', the command -.sp -.br -touch\ foo.h;\ cpp\ \-dM\ foo.h -.br -.sp -will show the values of any predefined macros. -.TP -.B \-dD -Like `\|\c -.B \-dM\c -\&\|' except in two respects: it does \c -.I not\c -\& include the -predefined macros, and it outputs \c -.I both\c -\& the `\|\c -.B #define\c -\&\|' -directives and the result of preprocessing. Both kinds of output go to -the standard output file. -.PP -.TP -.BR \-M\ [ \-MG ] -Instead of outputting the result of preprocessing, output a rule -suitable for \c -.B make\c -\& describing the dependencies of the main -source file. The preprocessor outputs one \c -.B make\c -\& rule containing -the object file name for that source file, a colon, and the names of -all the included files. If there are many included files then the -rule is split into several lines using `\|\c -.B \\\\\c -\&\|'-newline. - -`\|\c -.B \-MG\c -\&\|' says to treat missing header files as generated files and assume \c -they live in the same directory as the source file. It must be specified \c -in addition to `\|\c -.B \-M\c -\&\|'. - -This feature is used in automatic updating of makefiles. -.TP -.BR \-MM\ [ \-MG ] -Like `\|\c -.B \-M\c -\&\|' but mention only the files included with `\|\c -.B #include -"\c -.I file\c -\&"\c -\&\|'. System header files included with `\|\c -.B #include -<\c -.I file\c -\&>\c -\&\|' are omitted. -.TP -.BI \-MD\ file -Like `\|\c -.B \-M\c -\&\|' but the dependency information is written to `\|\c -.I file\c -\&\|'. This is in addition to compiling the file as -specified\(em\&`\|\c -.B \-MD\c -\&\|' does not inhibit ordinary compilation the way -`\|\c -.B \-M\c -\&\|' does. - -When invoking gcc, do not specify the `\|\c -.I file\c -\&\|' argument. Gcc will create file names made by replacing `\|\c -.B .c\c -\&\|' with `\|\c -.B .d\c -\&\|' at the end of the input file names. - -In Mach, you can use the utility \c -.B md\c -\& to merge multiple files -into a single dependency file suitable for using with the `\|\c -.B make\c -\&\|' -command. -.TP -.BI \-MMD\ file -Like `\|\c -.B \-MD\c -\&\|' except mention only user header files, not system -header files. -.TP -.B \-H -Print the name of each header file used, in addition to other normal -activities. -.TP -.BI "\-imacros " "file"\c -\& -Process \c -.I file\c -\& as input, discarding the resulting output, before -processing the regular input file. Because the output generated from -\c -.I file\c -\& is discarded, the only effect of `\|\c -.B \-imacros \c -.I file\c -\&\c -\&\|' is to -make the macros defined in \c -.I file\c -\& available for use in the main -input. The preprocessor evaluates any `\|\c -.B \-D\c -\&\|' and `\|\c -.B \-U\c -\&\|' options -on the command line before processing `\|\c -.B \-imacros \c -.I file\c -\&\|' \c -\&. -.TP -.BI "\-include " "file" -Process -.I file -as input, and include all the resulting output, -before processing the regular input file. -.TP -.BI "-idirafter " "dir"\c -\& -Add the directory \c -.I dir\c -\& to the second include path. The directories -on the second include path are searched when a header file is not found -in any of the directories in the main include path (the one that -`\|\c -.B \-I\c -\&\|' adds to). -.TP -.BI "-iprefix " "prefix"\c -\& -Specify \c -.I prefix\c -\& as the prefix for subsequent `\|\c -.B \-iwithprefix\c -\&\|' -options. -.TP -.BI "-iwithprefix " "dir"\c -\& -Add a directory to the second include path. The directory's name is -made by concatenating \c -.I prefix\c -\& and \c -.I dir\c -\&, where \c -.I prefix\c -\& -was specified previously with `\|\c -.B \-iprefix\c -\&\|'. -.TP -.B \-lang-c -.TP -.B \-lang-c++ -.TP -.B \-lang-objc -.TP -.B \-lang-objc++ -Specify the source language. `\|\c -.B \-lang-c++\c -\&\|' makes the preprocessor -handle C++ comment syntax, and includes extra default include -directories for C++, and `\|\c -.B \-lang-objc\c -\&\|' enables the Objective C -`\|\c -.B #import\c -\&\|' directive. `\|\c -.B \-lang-c\c -\&\|' explicitly turns off both of -these extensions, and `\|\c -.B \-lang-objc++\c -\&\|' enables both. - -These options are generated by the compiler driver \c -.B gcc\c -\&, but not -passed from the `\|\c -.B gcc\c -\&\|' command line. -.TP -.B \-lint -Look for commands to the program checker \c -.B lint\c -\& embedded in -comments, and emit them preceded by `\|\c -.B #pragma lint\c -\&\|'. For example, -the comment `\|\c -.B /* NOTREACHED */\c -\&\|' becomes `\|\c -.B #pragma lint -NOTREACHED\c -\&\|'. - -This option is available only when you call \c -.B cpp\c -\& directly; -\c -.B gcc\c -\& will not pass it from its command line. -.TP -.B \-$ -Forbid the use of `\|\c -.B $\c -\&\|' in identifiers. This was formerly required for strict conformance -to the C Standard before the standard was corrected. \c - -This option is available only when you call \c -.B cpp\c -\& directly; -.B gcc\c -\& will not pass it from its command line. -.SH "SEE ALSO" -.RB "`\|" Cpp "\|'" -entry in -.B info\c -\&; -.I The C Preprocessor\c -, Richard M. Stallman. -.br -.BR gcc "(" 1 ");" -.RB "`\|" Gcc "\|'" -entry in -.B info\c -\&; -.I -Using and Porting GNU CC (for version 2.0)\c -, Richard M. Stallman. -.SH COPYING -Copyright (c) 1991, 1992, 1993 Free Software Foundation, Inc. -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be included in -translations approved by the Free Software Foundation instead of in -the original English. diff --git a/gcc/cccp.c b/gcc/cccp.c deleted file mode 100644 index 9a023334409..00000000000 --- a/gcc/cccp.c +++ /dev/null @@ -1,11313 +0,0 @@ -/* C Compatible Compiler Preprocessor (CCCP) - Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, - 1998, 1999, 2000 Free Software Foundation, Inc. - Written by Paul Rubin, June 1986 - Adapted to ANSI C, Richard Stallman, Jan 1987 - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include "config.h" - -#include "system.h" -#include - -#ifdef HAVE_SYS_RESOURCE_H -# include -#endif - -typedef unsigned char U_CHAR; - -#include "pcp.h" -#include "intl.h" -#include "prefix.h" -#include "version.h" - -#ifdef MULTIBYTE_CHARS -#include "mbchar.h" -#include -#endif /* MULTIBYTE_CHARS */ - -#ifndef GET_ENV_PATH_LIST -#define GET_ENV_PATH_LIST(VAR,NAME) do { (VAR) = getenv (NAME); } while (0) -#endif - -#ifndef STANDARD_INCLUDE_DIR -# define STANDARD_INCLUDE_DIR "/usr/include" -#endif - -/* By default, the suffix for object files is ".o". */ -#ifdef OBJECT_SUFFIX -# define HAVE_OBJECT_SUFFIX -#else -# define OBJECT_SUFFIX ".o" -#endif - -/* VMS-specific definitions */ -#ifdef VMS -#include -#include -#include -#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) -#define fwrite(ptr,size,nitems,stream) VMS_fwrite (ptr,size,nitems,stream) -static int VMS_fstat (), VMS_stat (); -static int VMS_open (); -static FILE *VMS_fopen (); -static FILE *VMS_freopen (); -static size_t VMS_fwrite (); -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. - Cygwin's emulation can generate non-unique inodes, so don't use it. */ -#if (defined (_WIN32) && ! defined (_UWIN)) \ - || defined (__MSDOS__) -#define INO_T_EQ(a, b) 0 -#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 - -#ifndef INCLUDE_LEN_FUDGE -#define INCLUDE_LEN_FUDGE 0 -#endif - -/* External declarations. */ - -HOST_WIDEST_INT parse_escape PARAMS ((char **, HOST_WIDEST_INT)); -HOST_WIDEST_INT parse_c_expression PARAMS ((char *, int)); - -/* Name under which this program was invoked. */ - -static const 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 means pass #include lines through to the output, - even if they are ifdefed out. */ -static int dump_includes; - -/* 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; - -/* Nonzero means don't print warning messages. -w. */ - -static int inhibit_warnings = 0; - -/* Nonzero means warn if slash-star appears in a slash-star comment, - or if newline-backslash appears in a slash-slash comment. */ - -static int warn_comments; - -/* Nonzero means warn if a macro argument is (or would be) - stringified with -traditional. */ - -static int warn_stringify; - -/* Nonzero means warn if there are any trigraphs. */ - -static int warn_trigraphs; - -/* Nonzero means warn if undefined identifiers are evaluated in an #if. */ - -static int warn_undef; - -/* Nonzero means warn if we find white space where it doesn't belong. */ - -static int warn_white_space; - -/* Nonzero means warn if #import is used. */ - -static int warn_import = 1; - -/* Nonzero means turn warnings into errors. */ - -static int warnings_are_errors; - -/* Nonzero means try to imitate old fashioned non-ANSI preprocessor. */ - -int traditional; - -/* Nonzero for the 1989 C Standard, including corrigenda and amendments. */ - -int c89; - -/* Nonzero for the 1999 C Standard. */ - -int c99; - -/* Nonzero causes output not to be done, - but directives such as #define that have side effects - are still obeyed. */ - -static int no_output; - -/* Nonzero means we should look for header.gcc files that remap file names. */ -static int remap; - -/* Nonzero means this file was included with a -imacros or -include - command line and should not be recorded as an include file. */ - -static int no_record_file; - -/* Nonzero means that we have finished processing the command line options. - This flag is used to decide whether or not to issue certain errors - and/or warnings. */ - -static int done_initializing = 0; - -/* Line where a newline was first seen in a string constant. */ - -static int multiline_string_line = 0; - -/* I/O buffer structure. - The `fname' field is nonzero for source files and #include files - and for the dummy text used for -D and -U. - It is zero for rescanning results of macro expansion - and for expanding macro arguments. */ -#define INPUT_STACK_MAX 400 -static struct file_buf { - const char *fname; - /* Filename specified with #line directive. */ - const char *nominal_fname; - /* The length of nominal_fname, which may contain embedded NULs. */ - size_t nominal_fname_len; - /* Include file description. */ - struct include_file *inc; - /* Record where in the search path this file was found. - For #include_next. */ - struct file_name_list *dir; - int lineno; - int length; - U_CHAR *buf; - U_CHAR *bufp; - /* Macro that this level is the expansion of. - Included so that we can reenable the macro - at the end of this level. */ - struct hashnode *macro; - /* Value of if_stack at start of this file. - Used to prohibit unmatched #endif (etc) in an include file. */ - struct if_stack *if_stack; - /* Object to be freed at end of input at this level. */ - U_CHAR *free_ptr; - /* True if this is a system header file; see is_system_include. */ - char system_header_p; -} instack[INPUT_STACK_MAX]; - -static int last_error_tick; /* Incremented each time we print it. */ -static int input_file_stack_tick; /* Incremented when the status changes. */ - -/* Current nesting level of input sources. - `instack[indepth]' is the level currently being read. */ -static int indepth = -1; -#define CHECK_DEPTH(code) \ - if (indepth >= (INPUT_STACK_MAX - 1)) \ - { \ - error_with_line (line_for_error (instack[indepth].lineno), \ - "macro or `#include' recursion too deep"); \ - code; \ - } - -/* Current depth in #include directives that use <...>. */ -static int system_include_depth = 0; - -typedef struct file_buf FILE_BUF; - -/* The output buffer. Its LENGTH field is the amount of room allocated - for the buffer, not the number of chars actually present. To get - that, subtract outbuf.buf from outbuf.bufp. */ - -#define OUTBUF_SIZE 10 /* initial size of output buffer */ -static FILE_BUF outbuf; - -/* Grow output buffer OBUF points at - so it can hold at least NEEDED more chars. */ - -#define check_expand(OBUF, NEEDED) \ - (((OBUF)->length - ((OBUF)->bufp - (OBUF)->buf) <= (NEEDED)) \ - ? grow_outbuf ((OBUF), (NEEDED)) : 0) - -struct file_name_list - { - struct file_name_list *next; - /* If the following is 1, it is a C-language system include - directory. */ - int c_system_include_path; - /* Mapping of file names for this directory. */ - struct file_name_map *name_map; - /* Non-zero if name_map is valid. */ - int got_name_map; - /* The include directory status. */ - struct stat st; - /* The include prefix: "" denotes the working directory, - otherwise fname must end in '/'. - The actual size is dynamically allocated. */ - char fname[1]; - }; - -/* #include "file" looks in source file dir, then stack. */ -/* #include just looks in the stack. */ -/* -I directories are added to the end, then the defaults are added. */ -/* The */ -static struct default_include { - const char *fname; /* The name of the directory. */ - const char *component; /* The component containing the directory */ - int cplusplus; /* Only look here if we're compiling C++. */ - int cxx_aware; /* Includes in this directory don't need to - be wrapped in extern "C" when compiling - C++. */ - int included; /* Set if the directory is acceptable. */ -} include_defaults_array[] -#ifdef INCLUDE_DEFAULTS - = INCLUDE_DEFAULTS; -#else - = { - /* Pick up GNU C++ specific include files. */ - { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0 }, -#ifdef CROSS_COMPILE - /* This is the dir for fixincludes. Put it just before - the files that we fix. */ - { GCC_INCLUDE_DIR, "GCC", 0, 0, 0 }, - /* For cross-compilation, this dir name is generated - automatically in Makefile.in. */ - { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0 }, -#ifdef TOOL_INCLUDE_DIR - /* This is another place that the target system's headers might be. */ - { TOOL_INCLUDE_DIR, "BINUTILS", 0, 0, 0 }, -#endif -#else /* not CROSS_COMPILE */ -#ifdef LOCAL_INCLUDE_DIR - /* This should be /usr/local/include and should come before - the fixincludes-fixed header files. */ - { LOCAL_INCLUDE_DIR, 0, 0, 1, 0 }, -#endif -#ifdef TOOL_INCLUDE_DIR - /* This is here ahead of GCC_INCLUDE_DIR because assert.h goes here. - Likewise, behind LOCAL_INCLUDE_DIR, where glibc puts its assert.h. */ - { TOOL_INCLUDE_DIR, "BINUTILS", 0, 0, 0 }, -#endif - /* This is the dir for fixincludes. Put it just before - the files that we fix. */ - { GCC_INCLUDE_DIR, "GCC", 0, 0, 0 }, - /* Some systems have an extra dir of include files. */ -#ifdef SYSTEM_INCLUDE_DIR - { SYSTEM_INCLUDE_DIR, 0, 0, 0, 0 }, -#endif -#ifndef STANDARD_INCLUDE_COMPONENT -#define STANDARD_INCLUDE_COMPONENT 0 -#endif - { STANDARD_INCLUDE_DIR, STANDARD_INCLUDE_COMPONENT, 0, 0, 0 }, -#endif /* not CROSS_COMPILE */ - { 0, 0, 0, 0, 0 } - }; -#endif /* no INCLUDE_DEFAULTS */ - -/* The code looks at the defaults through this pointer, rather than through - the constant structure above. This pointer gets changed if an environment - variable specifies other defaults. */ -static struct default_include *include_defaults = include_defaults_array; - -static struct file_name_list *include = 0; /* First dir to search */ - /* First dir to search for */ -/* This is the first element to use for #include <...>. - If it is 0, use the entire chain for such includes. */ -static struct file_name_list *first_bracket_include = 0; -/* This is the first element in the chain that corresponds to - a directory of system header files. */ -static struct file_name_list *first_system_include = 0; -static struct file_name_list *last_include = 0; /* Last in chain */ - -/* Chain of include directories to put at the end of the other chain. */ -static struct file_name_list *after_include = 0; -static struct file_name_list *last_after_include = 0; /* Last in chain */ - -/* Chain to put at the start of the system include files. */ -static struct file_name_list *before_system = 0; -static struct file_name_list *last_before_system = 0; /* Last in chain */ - -/* Directory prefix that should replace `/usr' in the standard - include file directories. */ -static char *include_prefix; - -/* Maintain and search list of included files. */ - -struct include_file { - struct include_file *next; /* for include_hashtab */ - struct include_file *next_ino; /* for include_ino_hashtab */ - char *fname; - /* If the following is the empty string, it means #pragma once - was seen in this include file, or #import was applied to the file. - Otherwise, if it is nonzero, it is a macro name. - Don't include the file again if that macro is defined. */ - const U_CHAR *control_macro; - /* Nonzero if the dependency on this include file has been output. */ - int deps_output; - struct stat st; -}; - -/* Hash tables of files already included with #include or #import. - include_hashtab is by full name; include_ino_hashtab is by inode number. */ - -#define INCLUDE_HASHSIZE 61 -static struct include_file *include_hashtab[INCLUDE_HASHSIZE]; -static struct include_file *include_ino_hashtab[INCLUDE_HASHSIZE]; - -/* Global list of strings read in from precompiled files. This list - is kept in the order the strings are read in, with new strings being - added at the end through stringlist_tailp. We use this list to output - the strings at the end of the run. -*/ -static STRINGDEF *stringlist; -static STRINGDEF **stringlist_tailp = &stringlist; - - -/* Structure returned by create_definition */ -typedef struct macrodef MACRODEF; -struct macrodef -{ - struct definition *defn; - const U_CHAR *symnam; - int symlen; -}; - -enum sharp_token_type { - NO_SHARP_TOKEN = 0, /* token not present */ - - SHARP_TOKEN = '#', /* token spelled with # only */ - WHITE_SHARP_TOKEN, /* token spelled with # and white space */ - - PERCENT_COLON_TOKEN = '%', /* token spelled with %: only */ - WHITE_PERCENT_COLON_TOKEN /* token spelled with %: and white space */ -}; - -/* Structure allocated for every #define. For a simple replacement - such as - #define foo bar , - nargs = -1, the `pattern' list is null, and the expansion is just - the replacement text. Nargs = 0 means a functionlike macro with no args, - e.g., - #define getchar() getc (stdin) . - When there are args, the expansion is the replacement text with the - args squashed out, and the reflist is a list describing how to - build the output from the input: e.g., "3 chars, then the 1st arg, - then 9 chars, then the 3rd arg, then 0 chars, then the 2nd arg". - The chars here come from the expansion. Whatever is left of the - expansion after the last arg-occurrence is copied after that arg. - Note that the reflist can be arbitrarily long--- - its length depends on the number of times the arguments appear in - the replacement text, not how many args there are. Example: - #define f(x) x+x+x+x+x+x+x would have replacement text "++++++" and - pattern list - { (0, 1), (1, 1), (1, 1), ..., (1, 1), NULL } - where (x, y) means (nchars, argno). */ - -typedef struct definition DEFINITION; -struct definition { - int nargs; - int length; /* length of expansion string */ - int predefined; /* True if the macro was builtin or */ - /* came from the command line */ - U_CHAR *expansion; - int line; /* Line number of definition */ - const char *file; /* File of definition */ - size_t file_len; /* Length of file (which can contain NULs) */ - char rest_args; /* Nonzero if last arg. absorbs the rest */ - struct reflist { - struct reflist *next; - - enum sharp_token_type stringify; /* set if a # operator before arg */ - enum sharp_token_type raw_before; /* set if a ## operator before arg */ - enum sharp_token_type raw_after; /* set if a ## operator after arg */ - - char rest_args; /* Nonzero if this arg. absorbs the rest */ - int nchars; /* Number of literal chars to copy before - this arg occurrence. */ - int argno; /* Number of arg to substitute (origin-0) */ - } *pattern; - union { - /* Names of macro args, concatenated in reverse order - with comma-space between them. - The only use of this is that we warn on redefinition - if this differs between the old and new definitions. */ - U_CHAR *argnames; - } args; -}; - -/* different kinds of things that can appear in the value field - of a hash node. Actually, this may be useless now. */ -union hashval { - const char *cpval; - DEFINITION *defn; - KEYDEF *keydef; -}; - -/* - * special extension string that can be added to the last macro argument to - * allow it to absorb the "rest" of the arguments when expanded. Ex: - * #define wow(a, b...) process (b, a, b) - * { wow (1, 2, 3); } -> { process (2, 3, 1, 2, 3); } - * { wow (one, two); } -> { process (two, one, two); } - * if this "rest_arg" is used with the concat token '##' and if it is not - * supplied then the token attached to with ## will not be outputted. Ex: - * #define wow (a, b...) process (b ## , a, ## b) - * { wow (1, 2); } -> { process (2, 1, 2); } - * { wow (one); } -> { process (one); { - */ -static char rest_extension[] = "..."; -#define REST_EXTENSION_LENGTH (sizeof (rest_extension) - 1) - -/* This is the implicit parameter name when using variable number of - parameters for macros using the ISO C 99 extension. */ -static char va_args_name[] = "__VA_ARGS__"; -#define VA_ARGS_NAME_LENGTH (sizeof (va_args_name) - 1) - -/* The structure of a node in the hash table. The hash table - has entries for all tokens defined by #define directives (type T_MACRO), - plus some special tokens like __LINE__ (these each have their own - type, and the appropriate code is run when that type of node is seen. - It does not contain control words like "#define", which are recognized - by a separate piece of code. */ - -/* different flavors of hash nodes --- also used in keyword table */ -enum node_type { - T_DEFINE = 1, /* the `#define' keyword */ - T_INCLUDE, /* the `#include' keyword */ - T_INCLUDE_NEXT, /* the `#include_next' keyword */ - T_IMPORT, /* the `#import' keyword */ - T_IFDEF, /* the `#ifdef' keyword */ - T_IFNDEF, /* the `#ifndef' keyword */ - T_IF, /* the `#if' keyword */ - T_ELSE, /* `#else' */ - T_PRAGMA, /* `#pragma' */ - T_ELIF, /* `#elif' */ - T_UNDEF, /* `#undef' */ - T_LINE, /* `#line' */ - T_ERROR, /* `#error' */ - T_WARNING, /* `#warning' */ - T_ENDIF, /* `#endif' */ - T_SCCS, /* `#sccs', used on system V. */ - T_IDENT, /* `#ident', used on system V. */ - T_ASSERT, /* `#assert', taken from system V. */ - T_UNASSERT, /* `#unassert', taken from system V. */ - T_SPECLINE, /* special symbol `__LINE__' */ - T_DATE, /* `__DATE__' */ - T_FILE, /* `__FILE__' */ - T_BASE_FILE, /* `__BASE_FILE__' */ - T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */ - T_VERSION, /* `__VERSION__' */ - T_SIZE_TYPE, /* `__SIZE_TYPE__' */ - T_PTRDIFF_TYPE, /* `__PTRDIFF_TYPE__' */ - T_WCHAR_TYPE, /* `__WCHAR_TYPE__' */ - T_USER_LABEL_PREFIX_TYPE, /* `__USER_LABEL_PREFIX__' */ - T_REGISTER_PREFIX_TYPE, /* `__REGISTER_PREFIX__' */ - T_IMMEDIATE_PREFIX_TYPE, /* `__IMMEDIATE_PREFIX__' */ - T_TIME, /* `__TIME__' */ - T_CONST, /* Constant value, used by `__STDC__' */ - T_MACRO, /* macro defined by `#define' */ - T_DISABLED, /* macro temporarily turned off for rescan */ - T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */ - T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */ - T_POISON, /* defined with `#pragma poison' */ - T_UNUSED /* Used for something not defined. */ - }; - -struct hashnode { - struct hashnode *next; /* double links for easy deletion */ - struct hashnode *prev; - struct hashnode **bucket_hdr; /* 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. */ - enum node_type type; /* type of special token */ - int length; /* length of token, for quick comparison */ - U_CHAR *name; /* the actual name */ - union hashval value; /* pointer to expansion, or whatever */ -}; - -typedef struct hashnode 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 HASHSIZE 1403 -static HASHNODE *hashtab[HASHSIZE]; -#define HASHSTEP(old, c) ((old << 2) + c) -#define MAKE_POS(v) (v & 0x7fffffff) /* make number positive */ - - -/* 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" -#endif -static const char * wchar_type = WCHAR_TYPE; -#undef WCHAR_TYPE - -/* The string value for __USER_LABEL_PREFIX__ */ - -#ifndef USER_LABEL_PREFIX -#define USER_LABEL_PREFIX "" -#endif -static const char * user_label_prefix = USER_LABEL_PREFIX; -#undef USER_LABEL_PREFIX - -/* 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 37 -static 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 PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *, struct directive *)) - -struct directive { - int length; /* Length of name */ - int (*func) DO_PROTO; /* Function to handle directive */ - const char *name; /* Name of directive */ - enum node_type type; /* Code which describes which directive. */ -}; - -#define IS_INCLUDE_DIRECTIVE_TYPE(t) \ -((int) T_INCLUDE <= (int) (t) && (int) (t) <= (int) T_IMPORT) - -/* 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_DIRECTIVE -static int do_sccs DO_PROTO; -#endif -static int do_unassert DO_PROTO; -static int do_undef 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}, - { 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}, - { 12, do_include, "include_next", T_INCLUDE_NEXT}, - { 6, do_include, "import", T_IMPORT}, - { 5, do_undef, "undef", T_UNDEF}, - { 5, do_error, "error", T_ERROR}, - { 7, do_error, "warning", T_WARNING}, -#ifdef SCCS_DIRECTIVE - { 4, do_sccs, "sccs", T_SCCS}, -#endif - { 6, do_pragma, "pragma", T_PRAGMA}, - { 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]; - -#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 const char *out_fname; - -/* Nonzero to ignore \ in string constants. Use to treat #line 1 "A:\file.h - as a non-form feed. If you want it to be a form feed, you must use - # 1 "\f". */ -static int ignore_escape_flag = 1; - -/* 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 */ - const char *fname; /* copied from input when frame is made */ - size_t fname_len; /* similarly */ - int lineno; /* similarly */ - int if_succeeded; /* true if a leg of this if-group - has been passed through rescan */ - const 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 PARAMS ((int, char *, int)); -static void safe_write PARAMS ((int, const char *, int)); - -int main PARAMS ((int, char **)); - -static void path_include PARAMS ((char *)); - -static const U_CHAR *index0 PARAMS ((const U_CHAR *, int, size_t)); - -static void trigraph_pcp PARAMS ((FILE_BUF *)); -static void check_white_space PARAMS ((FILE_BUF *)); - -static void newline_fix PARAMS ((U_CHAR *)); -static void name_newline_fix PARAMS ((U_CHAR *)); - -static const char *get_lintcmd PARAMS ((const U_CHAR *, const U_CHAR *, - const U_CHAR **, int *, int *)); - -static void rescan PARAMS ((FILE_BUF *, int)); - -static FILE_BUF expand_to_temp_buffer PARAMS ((const U_CHAR *, const U_CHAR *, - int, int)); - -static int handle_directive PARAMS ((FILE_BUF *, FILE_BUF *)); - -static struct tm *timestamp PARAMS ((void)); -static void special_symbol PARAMS ((HASHNODE *, FILE_BUF *)); - -static int is_system_include PARAMS ((const char *)); -static char *base_name PARAMS ((const char *)); -static int absolute_filename PARAMS ((const char *)); -static size_t simplify_filename PARAMS ((char *)); - -static char *read_filename_string PARAMS ((int, FILE *)); -static struct file_name_map *read_name_map PARAMS ((const char *)); -static int open_include_file PARAMS ((char *, struct file_name_list *, - const U_CHAR *, struct include_file **)); -static char *remap_include_file PARAMS ((char *, struct file_name_list *)); -static int lookup_ino_include PARAMS ((struct include_file *)); - -static void finclude PARAMS ((int, struct include_file *, FILE_BUF *, int, - struct file_name_list *)); -static void record_control_macro PARAMS ((struct include_file *, - const U_CHAR *)); - -static char *check_precompiled PARAMS ((int, struct stat *, const char *, - const char **)); -static int check_preconditions PARAMS ((const char *)); -static void pcfinclude PARAMS ((U_CHAR *, const U_CHAR *, FILE_BUF *)); -static void pcstring_used PARAMS ((HASHNODE *)); -static void write_output PARAMS ((void)); -static void pass_thru_directive PARAMS ((const U_CHAR *, const U_CHAR *, - FILE_BUF *, struct directive *)); - -static MACRODEF create_definition PARAMS ((const U_CHAR *, const U_CHAR *, - FILE_BUF *)); - -static int check_macro_name PARAMS ((const U_CHAR *, int)); -static int compare_defs PARAMS ((DEFINITION *, DEFINITION *)); -static int comp_def_part PARAMS ((int, const U_CHAR *, int, const U_CHAR *, - int, int)); - -static DEFINITION *collect_expansion PARAMS ((const U_CHAR *, const U_CHAR *, - int, struct arglist *)); - -int check_assertion PARAMS ((const U_CHAR *, int, int, struct arglist *)); -static int compare_token_lists PARAMS ((struct arglist *, struct arglist *)); - -static struct arglist *read_token_list PARAMS ((const U_CHAR **, - const U_CHAR *, int *)); -static void free_token_list PARAMS ((struct arglist *)); - -static ASSERTION_HASHNODE *assertion_install PARAMS ((const U_CHAR *, int, int)); -static ASSERTION_HASHNODE *assertion_lookup PARAMS ((const U_CHAR *, int, int)); -static void delete_assertion PARAMS ((ASSERTION_HASHNODE *)); - -static void do_once PARAMS ((void)); - -static HOST_WIDEST_INT eval_if_expression PARAMS ((const U_CHAR *, int)); -static void conditional_skip PARAMS ((FILE_BUF *, int, enum node_type, - const U_CHAR *, FILE_BUF *)); -static void skip_if_group PARAMS ((FILE_BUF *, int, FILE_BUF *)); -static void validate_else PARAMS ((const U_CHAR *, const U_CHAR *)); - -static U_CHAR *skip_to_end_of_comment PARAMS ((FILE_BUF *, int *, int)); -static U_CHAR *skip_quoted_string PARAMS ((const U_CHAR *, const U_CHAR *, - int, int *, int *, int *)); -static char *quote_string PARAMS ((char *, const char *, size_t)); -static U_CHAR *skip_paren_group PARAMS ((FILE_BUF *)); - -/* Last arg to output_line_directive. */ -enum file_change_code {same_file, enter_file, leave_file}; -static void output_line_directive PARAMS ((FILE_BUF *, FILE_BUF *, int, enum file_change_code)); - -static void macroexpand PARAMS ((HASHNODE *, FILE_BUF *)); - -struct argdata; -static int macarg PARAMS ((struct argdata *, int)); - -static U_CHAR *macarg1 PARAMS ((U_CHAR *, const U_CHAR *, struct hashnode *, int *, int *, int *, int)); - -static int discard_comments PARAMS ((U_CHAR *, int, int)); - -static void change_newlines PARAMS ((struct argdata *)); - -static void notice PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; -static void vnotice PARAMS ((const char *, va_list)); -void error PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; -void verror PARAMS ((const char *, va_list)); -static void error_from_errno PARAMS ((const char *)); -void warning PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; -static void vwarning PARAMS ((const char *, va_list)); -static void error_with_line PARAMS ((int, const char *, ...)) ATTRIBUTE_PRINTF_2; -static void verror_with_line PARAMS ((int, const char *, va_list)); -static void vwarning_with_line PARAMS ((int, const char *, va_list)); -static void warning_with_line PARAMS ((int, const char *, ...)) ATTRIBUTE_PRINTF_2; -void pedwarn PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; -void pedwarn_with_line PARAMS ((int, const char *, ...)) ATTRIBUTE_PRINTF_2; -static void pedwarn_with_file_and_line PARAMS ((const char *, size_t, int, const char *, ...)) ATTRIBUTE_PRINTF_4; -static void pedwarn_strange_white_space PARAMS ((int)); - -static void print_containing_files PARAMS ((void)); - -static int line_for_error PARAMS ((int)); -static int grow_outbuf PARAMS ((FILE_BUF *, int)); - -static HASHNODE *install PARAMS ((const U_CHAR *, int, enum node_type, - const char *, int)); -HASHNODE *lookup PARAMS ((const U_CHAR *, int, int)); -static void delete_macro PARAMS ((HASHNODE *)); -static int hashf PARAMS ((const U_CHAR *, int, int)); - -static void dump_single_macro PARAMS ((HASHNODE *, FILE *)); -static void dump_all_macros PARAMS ((void)); -static void dump_defn_1 PARAMS ((const U_CHAR *, int, int, FILE *)); -static void dump_arg_n PARAMS ((DEFINITION *, int, FILE *)); - -static void initialize_char_syntax PARAMS ((void)); -static void initialize_builtins PARAMS ((FILE_BUF *, FILE_BUF *)); - -static void make_definition PARAMS ((char *)); -static void make_undef PARAMS ((char *, FILE_BUF *)); - -static void make_assertion PARAMS ((const char *, const char *)); - -static struct file_name_list *new_include_prefix PARAMS ((struct file_name_list *, const char *, const char *, const char *)); -static void append_include_chain PARAMS ((struct file_name_list *, struct file_name_list *)); - -static int quote_string_for_make PARAMS ((char *, const char *)); -static void deps_output PARAMS ((const char *, int)); - -void fatal PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; -void fancy_abort PARAMS ((void)) ATTRIBUTE_NORETURN; -static void perror_with_name PARAMS ((const char *)); -static void pfatal_with_name PARAMS ((const char *)) ATTRIBUTE_NORETURN; -static void pipe_closed PARAMS ((int)) ATTRIBUTE_NORETURN; - -static void memory_full PARAMS ((void)) ATTRIBUTE_NORETURN; -static void print_help PARAMS ((void)); - -/* 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 int -safe_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 void -safe_write (desc, ptr, len) - int desc; - const 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; - } -} - - -static void -print_help () -{ - printf ("Usage: %s [switches] input output\n", progname); - printf ("Switches:\n"); - printf (" -include Include the contents of before other files\n"); - printf (" -imacros Accept definition of macros in \n"); - printf (" -iprefix Specify as a prefix for next two options\n"); - printf (" -iwithprefix Add to the end of the system include paths\n"); - printf (" -iwithprefixbefore Add to the end of the main include paths\n"); - printf (" -isystem Add to the start of the system include paths\n"); - printf (" -idirafter Add to the end of the system include paths\n"); - printf (" -I Add to the end of the main include paths\n"); - printf (" -nostdinc Do not search the system include directories\n"); - printf (" -nostdinc++ Do not search the system include directories for C++\n"); - printf (" -o Put output into \n"); - printf (" -pedantic Issue all warnings demanded by strict ANSI C\n"); - printf (" -traditional Follow K&R pre-processor behaviour\n"); - printf (" -trigraphs Support ANSI C trigraphs\n"); - printf (" -lang-c Assume that the input sources are in C\n"); - printf (" -lang-c89 Assume that the input is C89; depricated\n"); - printf (" -lang-c++ Assume that the input sources are in C++\n"); - printf (" -lang-objc Assume that the input sources are in ObjectiveC\n"); - printf (" -lang-objc++ Assume that the input sources are in ObjectiveC++\n"); - printf (" -lang-asm Assume that the input sources are in assembler\n"); - printf (" -lang-fortran Assume that the input sources are in Fortran\n"); - printf (" -lang-chill Assume that the input sources are in Chill\n"); - printf (" -std= Specify the conformance standard; one of:\n"); - printf (" gnu89, gnu99, c89, c99, iso9899:1990,\n"); - printf (" iso9899:199409, iso9899:1999\n"); - printf (" -+ Allow parsing of C++ style features\n"); - printf (" -w Inhibit warning messages\n"); - printf (" -Wtrigraphs Warn if trigraphs are encountered\n"); - printf (" -Wno-trigraphs Do not warn about trigraphs\n"); - printf (" -Wcomment{s} Warn if one comment starts inside another\n"); - printf (" -Wno-comment{s} Do not warn about comments\n"); - printf (" -Wtraditional Warn if a macro argument is/would be turned into\n"); - printf (" a string if -traditional is specified\n"); - printf (" -Wno-traditional Do not warn about stringification\n"); - printf (" -Wundef Warn if an undefined macro is used by #if\n"); - printf (" -Wno-undef Do not warn about testing undefined macros\n"); - printf (" -Wimport Warn about the use of the #import directive\n"); - printf (" -Wno-import Do not warn about the use of #import\n"); - printf (" -Werror Treat all warnings as errors\n"); - printf (" -Wno-error Do not treat warnings as errors\n"); - printf (" -Wall Enable all preprocessor warnings\n"); - printf (" -M Generate make dependencies\n"); - printf (" -MM As -M, but ignore system header files\n"); - printf (" -MD As -M, but put output in a .d file\n"); - printf (" -MMD As -MD, but ignore system header files\n"); - printf (" -MG Treat missing header file as generated files\n"); - printf (" -g Include #define and #undef directives in the output\n"); - printf (" -D Define a with string '1' as its value\n"); - printf (" -D= Define a with as its value\n"); - printf (" -A () Assert the to \n"); - printf (" -U Undefine \n"); - printf (" -u or -undef Do not predefine any macros\n"); - printf (" -v Display the version number\n"); - printf (" -H Print the name of header files as they are used\n"); - printf (" -C Do not discard comments\n"); - printf (" -dM Display a list of macro definitions active at end\n"); - printf (" -dD Preserve macro definitions in output\n"); - printf (" -dN As -dD except that only the names are preserved\n"); - printf (" -dI Include #include directives in the output\n"); - printf (" -ifoutput Describe skipped code blocks in output \n"); - printf (" -P Do not generate #line directives\n"); - printf (" -$ Do not include '$' in identifiers\n"); - printf (" -remap Remap file names when including files.\n"); - printf (" -h or --help Display this information\n"); -} - -int -main (argc, argv) - int argc; - char **argv; -{ - struct stat st; - const char *in_fname; - char *cp; - int f, i; - FILE_BUF *fp; - - char **pend_files; - char **pend_defs; - char **pend_undefs; - char **pend_assertions; - char **pend_includes; - - /* Record the option used with each element of pend_assertions. - This is preparation for supporting more than one option for making - an assertion. */ - const char **pend_assertion_options; - int no_standard_includes = 0; - int no_standard_cplusplus_includes = 0; - int missing_newline = 0; - - /* Non-0 means don't output the preprocessed program. */ - int inhibit_output = 0; - /* Non-0 means -v, so print the full set of include dirs. */ - int verbose = 0; - - /* File name which deps are being written to. - This is 0 if deps are being written to stdout. */ - char *deps_file = 0; - /* Fopen file mode to open deps_file with. */ - const char *deps_mode = "a"; - /* Stream on which to print the dependency information. */ - FILE *deps_stream = 0; - /* Target-name to write with the dependency information. */ - char *deps_target = 0; - -#if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT) - /* 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 - -#ifdef SIGPIPE - signal (SIGPIPE, pipe_closed); -#endif - -#ifdef HAVE_LC_MESSAGES - setlocale (LC_MESSAGES, ""); -#endif - (void) bindtextdomain (PACKAGE, localedir); - (void) textdomain (PACKAGE); - - progname = base_name (argv[0]); - -#ifdef VMS - { - /* Remove extension from PROGNAME. */ - char *p; - char *s = xstrdup (progname); - progname = s; - - if ((p = rindex (s, ';')) != 0) *p = '\0'; /* strip version number */ - if ((p = rindex (s, '.')) != 0 /* strip type iff ".exe" */ - && (p[1] == 'e' || p[1] == 'E') - && (p[2] == 'x' || p[2] == 'X') - && (p[3] == 'e' || p[3] == 'E') - && !p[4]) - *p = '\0'; - } -#endif - - /* Do not invoke xmalloc before this point, since locale and - progname need to be set first, in case a diagnostic is issued. */ - - pend_files = (char **) xmalloc (argc * sizeof (char *)); - pend_defs = (char **) xmalloc ((2 * argc) * sizeof (char *)); - pend_undefs = (char **) xmalloc (argc * sizeof (char *)); - pend_assertions = (char **) xmalloc (argc * sizeof (char *)); - pend_includes = (char **) xmalloc (argc * sizeof (char *)); - pend_assertion_options = (const char **) xmalloc (argc * sizeof (char *)); - - in_fname = NULL; - out_fname = NULL; - - /* Initialize is_idchar. */ - initialize_char_syntax (); - - no_line_directives = 0; - no_trigraphs = 1; - dump_macros = dump_none; - no_output = 0; - cplusplus = 0; - cplusplus_comments = 1; - - bzero ((char *) pend_files, argc * sizeof (char *)); - bzero ((char *) pend_defs, (2 * argc) * sizeof (char *)); - bzero ((char *) pend_undefs, argc * sizeof (char *)); - bzero ((char *) pend_assertions, argc * sizeof (char *)); - bzero ((char *) pend_includes, argc * sizeof (char *)); - -#ifdef MULTIBYTE_CHARS - /* Change to the native locale for multibyte conversions. */ - setlocale (LC_CTYPE, ""); - literal_codeset = getenv ("LANG"); -#endif - - /* Process switches and find input file name. */ - - for (i = 1; i < argc; i++) { - if (argv[i][0] != '-') { - if (out_fname != NULL) - { - print_help (); - fatal ("Too many arguments"); - } - else if (in_fname != NULL) - out_fname = argv[i]; - else - in_fname = argv[i]; - } else { - switch (argv[i][1]) { - - case 'i': - if (!strcmp (argv[i], "-include")) { - if (i + 1 == argc) - fatal ("Filename missing after `-include' option"); - else { - i++; - simplify_filename (pend_includes[i] = argv[i]); - } - } - if (!strcmp (argv[i], "-imacros")) { - if (i + 1 == argc) - fatal ("Filename missing after `-imacros' option"); - else { - i++; - simplify_filename (pend_files[i] = argv[i]); - } - } - if (!strcmp (argv[i], "-iprefix")) { - if (i + 1 == argc) - fatal ("Filename missing after `-iprefix' option"); - else - include_prefix = argv[++i]; - } - if (!strcmp (argv[i], "-ifoutput")) { - output_conditionals = 1; - } - if (!strcmp (argv[i], "-isystem")) { - struct file_name_list *dirtmp; - - if (! (dirtmp = new_include_prefix (NULL_PTR, NULL_PTR, - "", argv[++i]))) - break; - dirtmp->c_system_include_path = 1; - - if (before_system == 0) - before_system = dirtmp; - else - last_before_system->next = dirtmp; - last_before_system = dirtmp; /* Tail follows the last one */ - } - /* Add directory to end of path for includes, - with the default prefix at the front of its name. */ - if (!strcmp (argv[i], "-iwithprefix")) { - struct file_name_list *dirtmp; - char *prefix; - - if (include_prefix != 0) - prefix = include_prefix; - else { - prefix = xstrdup (GCC_INCLUDE_DIR); - /* Remove the `include' from /usr/local/lib/gcc.../include. */ - if (!strcmp (prefix + strlen (prefix) - 8, "/include")) - prefix[strlen (prefix) - 7] = 0; - } - - if (! (dirtmp = new_include_prefix (NULL_PTR, NULL_PTR, - prefix, argv[++i]))) - break; - - if (after_include == 0) - after_include = dirtmp; - else - last_after_include->next = dirtmp; - last_after_include = dirtmp; /* Tail follows the last one */ - } - /* Add directory to main path for includes, - with the default prefix at the front of its name. */ - if (!strcmp (argv[i], "-iwithprefixbefore")) { - struct file_name_list *dirtmp; - char *prefix; - - if (include_prefix != 0) - prefix = include_prefix; - else { - prefix = xstrdup (GCC_INCLUDE_DIR); - /* Remove the `include' from /usr/local/lib/gcc.../include. */ - if (!strcmp (prefix + strlen (prefix) - 8, "/include")) - prefix[strlen (prefix) - 7] = 0; - } - - dirtmp = new_include_prefix (NULL_PTR, NULL_PTR, prefix, argv[++i]); - append_include_chain (dirtmp, dirtmp); - } - /* Add directory to end of path for includes. */ - if (!strcmp (argv[i], "-idirafter")) { - struct file_name_list *dirtmp; - - if (! (dirtmp = new_include_prefix (NULL_PTR, NULL_PTR, - "", argv[++i]))) - break; - - if (after_include == 0) - after_include = dirtmp; - else - last_after_include->next = dirtmp; - last_after_include = dirtmp; /* Tail follows the last one */ - } - 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': - if (!strcmp (argv[i], "-pedantic")) - pedantic = 1; - else if (!strcmp (argv[i], "-pedantic-errors")) { - pedantic = 1; - pedantic_errors = 1; - } else if (!strcmp (argv[i], "-pcp")) { - char *pcp_fname; - if (i + 1 == argc) - fatal ("Filename missing after -pcp option"); - pcp_fname = argv[++i]; - pcp_outfile - = ((pcp_fname[0] != '-' || pcp_fname[1] != '\0') - ? fopen (pcp_fname, "w") - : stdout); - if (pcp_outfile == 0) - pfatal_with_name (pcp_fname); - no_precomp = 1; - } - break; - - case 't': - if (!strcmp (argv[i], "-traditional")) { - traditional = 1; - cplusplus_comments = 0; - } else if (!strcmp (argv[i], "-trigraphs")) { - no_trigraphs = 0; - } - break; - - case 'l': - if (! strcmp (argv[i], "-lang-c")) - cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 1, objc = 0; - else if (! strcmp (argv[i], "-lang-c89")) - { - cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0; - no_trigraphs = 0; - pend_defs[2*i] = "__STRICT_ANSI__"; - } - else if (! strcmp (argv[i], "-lang-c++")) - cplusplus = 1, cplusplus_comments = 1, c89 = 0, c99 = 0, objc = 0; - else if (! strcmp (argv[i], "-lang-objc")) - cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 0, objc = 1; - else if (! strcmp (argv[i], "-lang-objc++")) - cplusplus = 1, cplusplus_comments = 1, c89 = 0, c99 = 0, objc = 1; - else if (! strcmp (argv[i], "-lang-asm")) - lang_asm = 1; - else if (! strcmp (argv[i], "-lang-fortran")) - /* Doesn't actually do anything. */ ; - else if (! strcmp (argv[i], "-lint")) - for_lint = 1; - break; - - case '+': - cplusplus = 1, cplusplus_comments = 1; - break; - - case 's': - if (!strcmp (argv[i], "-std=gnu89")) - { - cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0; - } - else if (!strcmp (argv[i], "-std=gnu9x") - || !strcmp (argv[i], "-std=gnu99")) - { - cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 1, objc = 0; - pend_defs[2*i+1] = "__STDC_VERSION__=199901L"; - } - else if (!strcmp (argv[i], "-std=iso9899:1990") - || !strcmp (argv[i], "-std=c89")) - { - cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0; - no_trigraphs = 0; - pend_defs[2*i] = "__STRICT_ANSI__"; - } - else if (!strcmp (argv[i], "-std=iso9899:199409")) - { - cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0; - no_trigraphs = 0; - pend_defs[2*i] = "__STRICT_ANSI__"; - pend_defs[2*i+1] = "__STDC_VERSION__=199409L"; - } - else if (!strcmp (argv[i], "-std=iso9899:199x") - || !strcmp (argv[i], "-std=iso9899:1999") - || !strcmp (argv[i], "-std=c9x") - || !strcmp (argv[i], "-std=c99")) - { - cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 1, objc = 0; - no_trigraphs = 0; - pend_defs[2*i] = "__STRICT_ANSI__"; - pend_defs[2*i+1] = "__STDC_VERSION__=199901L"; - } - break; - - case 'w': - inhibit_warnings = 1; - break; - - case 'W': - if (!strcmp (argv[i], "-Wtrigraphs")) - warn_trigraphs = 1; - else if (!strcmp (argv[i], "-Wno-trigraphs")) - warn_trigraphs = 0; - else if (!strcmp (argv[i], "-Wcomment")) - warn_comments = 1; - else if (!strcmp (argv[i], "-Wno-comment")) - warn_comments = 0; - else if (!strcmp (argv[i], "-Wcomments")) - warn_comments = 1; - else if (!strcmp (argv[i], "-Wno-comments")) - warn_comments = 0; - else if (!strcmp (argv[i], "-Wtraditional")) - warn_stringify = 1; - else if (!strcmp (argv[i], "-Wno-traditional")) - warn_stringify = 0; - else if (!strcmp (argv[i], "-Wwhite-space")) - warn_white_space = 1; - else if (!strcmp (argv[i], "-Wno-white-space")) - warn_white_space = 0; - else if (!strcmp (argv[i], "-Wundef")) - warn_undef = 1; - else if (!strcmp (argv[i], "-Wno-undef")) - warn_undef = 0; - else if (!strcmp (argv[i], "-Wimport")) - warn_import = 1; - else if (!strcmp (argv[i], "-Wno-import")) - warn_import = 0; - else if (!strcmp (argv[i], "-Werror")) - warnings_are_errors = 1; - else if (!strcmp (argv[i], "-Wno-error")) - warnings_are_errors = 0; - else if (!strcmp (argv[i], "-Wall")) - { - warn_trigraphs = 1; - warn_comments = 1; - warn_white_space = 1; - } - break; - - case 'f': - if (!strcmp (argv[i], "-fleading-underscore")) - user_label_prefix = "_"; - else if (!strcmp (argv[i], "-fno-leading-underscore")) - user_label_prefix = ""; - break; - - case 'M': - /* The style of the choices here is a bit mixed. - The chosen scheme is a hybrid of keeping all options in one string - and specifying each option in a separate argument: - -M|-MM|-MD file|-MMD file [-MG]. An alternative is: - -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely: - -M[M][G][D file]. This is awkward to handle in specs, and is not - as extensible. */ - /* ??? -MG must be specified in addition to one of -M or -MM. - This can be relaxed in the future without breaking anything. - The converse isn't true. */ - - /* -MG isn't valid with -MD or -MMD. This is checked for later. */ - if (!strcmp (argv[i], "-MG")) - { - print_deps_missing_files = 1; - break; - } - if (!strcmp (argv[i], "-M")) - print_deps = 2; - else if (!strcmp (argv[i], "-MM")) - print_deps = 1; - else if (!strcmp (argv[i], "-MD")) - print_deps = 2; - else if (!strcmp (argv[i], "-MMD")) - print_deps = 1; - /* For -MD and -MMD options, write deps on file named by next arg. */ - if (!strcmp (argv[i], "-MD") - || !strcmp (argv[i], "-MMD")) { - if (i + 1 == argc) - fatal ("Filename missing after %s option", argv[i]); - i++; - deps_file = argv[i]; - deps_mode = "w"; - } else { - /* For -M and -MM, write deps on standard output - and suppress the usual output. */ - deps_stream = stdout; - inhibit_output = 1; - } - break; - - case 'd': - { - char *p = argv[i] + 2; - char c; - while ((c = *p++)) { - /* Arg to -d specifies what parts of macros to dump */ - switch (c) { - case 'M': - dump_macros = dump_only; - no_output = 1; - break; - case 'N': - dump_macros = dump_names; - break; - case 'D': - dump_macros = dump_definitions; - break; - case 'I': - dump_includes = 1; - break; - } - } - } - break; - - case 'g': - if (argv[i][2] == '3') - debug_output = 1; - break; - - case '-': - if (strcmp (argv[i], "--help") != 0) - return i; - print_help (); - exit (0); - break; - - case 'v': - notice ("GNU CPP version %s", version_string); -#ifdef TARGET_VERSION - TARGET_VERSION; -#endif - fprintf (stderr, "\n"); - verbose = 1; - break; - - case 'H': - print_include_names = 1; - break; - - case 'D': - if (argv[i][2] != 0) - pend_defs[2*i] = argv[i] + 2; - else if (i + 1 == argc) - fatal ("Macro name missing after -D option"); - else - i++, pend_defs[2*i] = argv[i]; - break; - - case 'A': - { - char *p; - - if (argv[i][2] != 0) - p = argv[i] + 2; - else if (i + 1 == argc) - fatal ("Assertion missing after -A option"); - else - p = argv[++i]; - - if (!strcmp (p, "-")) { - /* -A- eliminates all predefined macros and assertions. - Let's include also any that were specified earlier - on the command line. That way we can get rid of any - that were passed automatically in from GCC. */ - int j; - for (j = 0; j < i; j++) - pend_defs[2*j] = pend_assertions[j] = 0; - } else { - pend_assertions[i] = p; - pend_assertion_options[i] = "-A"; - } - } - 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_directives = 1; - break; - - case '$': /* Don't include $ in identifiers. */ - is_idchar['$'] = is_idstart['$'] = 0; - break; - - case 'I': /* Add directory to path for includes. */ - { - struct file_name_list *dirtmp; - char *dir = argv[i][2] ? argv[i] + 2 : argv[++i]; - - if (! ignore_srcdir && dir && !strcmp (dir, "-")) { - ignore_srcdir = 1; - /* Don't use any preceding -I directories for #include <...>. */ - first_bracket_include = 0; - } - else { - dirtmp = new_include_prefix (last_include, NULL_PTR, "", dir); - append_include_chain (dirtmp, dirtmp); - } - } - break; - - case 'n': - if (!strcmp (argv[i], "-nostdinc")) - /* -nostdinc causes no default include directories. - You must specify all include-file directories with -I. */ - no_standard_includes = 1; - else if (!strcmp (argv[i], "-nostdinc++")) - /* -nostdinc++ causes no default C++-specific include directories. */ - no_standard_cplusplus_includes = 1; - else if (!strcmp (argv[i], "-noprecomp")) - no_precomp = 1; - break; - - case 'r': - if (!strcmp (argv[i], "-remap")) - remap = 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]); - } - } - } - - /* Add dirs from CPATH after dirs from -I. */ - /* There seems to be confusion about what CPATH should do, - so for the moment it is not documented. */ - /* Some people say that CPATH should replace the standard include dirs, - but that seems pointless: it comes before them, so it overrides them - anyway. */ - GET_ENV_PATH_LIST (cp, "CPATH"); - if (cp && ! no_standard_includes) - path_include (cp); - - /* Initialize output buffer */ - - outbuf.buf = (U_CHAR *) xmalloc (OUTBUF_SIZE); - outbuf.bufp = outbuf.buf; - outbuf.length = OUTBUF_SIZE; - - /* Do partial setup of input buffer for the sake of generating - early #line directives (when -g is in effect). */ - - fp = &instack[++indepth]; - if (in_fname == NULL) - in_fname = ""; - fp->nominal_fname = fp->fname = in_fname; - fp->nominal_fname_len = strlen (in_fname); - fp->lineno = 0; - - /* Install __LINE__, etc. Must follow initialize_char_syntax - and option processing. */ - initialize_builtins (fp, &outbuf); - - /* Now handle the command line options. */ - - /* Do -U's, -D's and -A's in the order they were seen. */ - for (i = 1; i < argc; i++) { - if (pend_undefs[i]) { - if (debug_output) - output_line_directive (fp, &outbuf, 0, same_file); - make_undef (pend_undefs[i], &outbuf); - } - if (pend_defs[2*i]) { - if (debug_output) - output_line_directive (fp, &outbuf, 0, same_file); - make_definition (pend_defs[2*i]); - } - if (pend_defs[2*i+1]) { - if (debug_output) - output_line_directive (fp, &outbuf, 0, same_file); - make_definition (pend_defs[2*i+1]); - } - if (pend_assertions[i]) - make_assertion (pend_assertion_options[i], pend_assertions[i]); - } - - done_initializing = 1; - - { /* Read the appropriate environment variable and if it exists - replace include_defaults with the listed path. */ - char *epath = 0; - switch ((objc << 1) + cplusplus) - { - case 0: - GET_ENV_PATH_LIST (epath, "C_INCLUDE_PATH"); - break; - case 1: - GET_ENV_PATH_LIST (epath, "CPLUS_INCLUDE_PATH"); - break; - case 2: - GET_ENV_PATH_LIST (epath, "OBJC_INCLUDE_PATH"); - break; - case 3: - GET_ENV_PATH_LIST (epath, "OBJCPLUS_INCLUDE_PATH"); - break; - } - /* If the environment var for this language is set, - add to the default list of include directories. */ - if (epath) { - int num_dirs; - char *startp, *endp; - - for (num_dirs = 1, startp = epath; *startp; startp++) - if (*startp == PATH_SEPARATOR) - num_dirs++; - include_defaults - = (struct default_include *) xmalloc ((num_dirs - * sizeof (struct default_include)) - + sizeof (include_defaults_array)); - startp = endp = epath; - num_dirs = 0; - while (1) { - char c = *endp++; - if (c == PATH_SEPARATOR || !c) { - endp[-1] = 0; - include_defaults[num_dirs].fname - = startp == endp ? "." : xstrdup (startp); - endp[-1] = c; - include_defaults[num_dirs].component = 0; - include_defaults[num_dirs].cplusplus = cplusplus; - include_defaults[num_dirs].cxx_aware = 1; - num_dirs++; - if (!c) - break; - startp = endp; - } - } - /* Put the usual defaults back in at the end. */ - bcopy ((const PTR) include_defaults_array, - (PTR) &include_defaults[num_dirs], - sizeof (include_defaults_array)); - } - } - - append_include_chain (before_system, last_before_system); - first_system_include = before_system; - - /* Unless -fnostdinc, - tack on the standard include file dirs to the specified list */ - if (!no_standard_includes) { - struct default_include *p = include_defaults; - char *specd_prefix = include_prefix; - char *default_prefix = xstrdup (GCC_INCLUDE_DIR); - int default_len = 0; - /* Remove the `include' from /usr/local/lib/gcc.../include. */ - if (!strcmp (default_prefix + strlen (default_prefix) - 8, "/include")) { - default_len = strlen (default_prefix) - 7; - default_prefix[default_len] = 0; - } - /* Search "translated" versions of GNU directories. - These have /usr/local/lib/gcc... replaced by specd_prefix. */ - if (specd_prefix != 0 && default_len != 0) - for (p = include_defaults; p->fname; p++) { - /* Some standard dirs are only for C++. */ - if (!p->cplusplus || (cplusplus && !no_standard_cplusplus_includes)) { - /* Does this dir start with the prefix? */ - if (!strncmp (p->fname, default_prefix, default_len)) { - /* Yes; change prefix and add to search list. */ - struct file_name_list *new - = new_include_prefix (NULL_PTR, NULL_PTR, specd_prefix, - p->fname + default_len); - if (new) { - new->c_system_include_path = !p->cxx_aware; - append_include_chain (new, new); - if (first_system_include == 0) - first_system_include = new; - p->included = 1; - } - } - } - } - /* Search ordinary names for GNU include directories. */ - for (p = include_defaults; p->fname; p++) { - /* Some standard dirs are only for C++. */ - if (!p->cplusplus || (cplusplus && !no_standard_cplusplus_includes)) { - struct file_name_list *new - = new_include_prefix (NULL_PTR, p->component, "", p->fname); - if (new) { - new->c_system_include_path = !p->cxx_aware; - append_include_chain (new, new); - if (first_system_include == 0) - first_system_include = new; - p->included = 1; - } - } - } - } - - /* Tack the after_include chain at the end of the include chain. */ - append_include_chain (after_include, last_after_include); - if (first_system_include == 0) - first_system_include = after_include; - - /* With -v, print the list of dirs to search. */ - if (verbose) { - struct file_name_list *p; - notice ("#include \"...\" search starts here:\n"); - for (p = include; p; p = p->next) { - if (p == first_bracket_include) - notice ("#include <...> search starts here:\n"); - if (!p->fname[0]) - fprintf (stderr, " .\n"); - else if (!strcmp (p->fname, "/") || !strcmp (p->fname, "//")) - fprintf (stderr, " %s\n", p->fname); - else - /* Omit trailing '/'. */ - fprintf (stderr, " %.*s\n", (int) strlen (p->fname) - 1, p->fname); - } - notice ("End of search list.\n"); - { - struct default_include * d; - notice ("The following default directories have been omitted from the search path:\n"); - for (d = include_defaults; d->fname; d++) - if (! d->included) - fprintf (stderr, " %s\n", d->fname); - notice ("End of omitted list.\n"); - } - } - - /* -MG doesn't select the form of output and must be specified with one of - -M or -MM. -MG doesn't make sense with -MD or -MMD since they don't - inhibit compilation. */ - if (print_deps_missing_files && (print_deps == 0 || !inhibit_output)) - fatal ("-MG must be specified with one of -M or -MM"); - - /* 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; - - /* Find the space before the DEPS_TARGET, if there is one. */ - s = index (spec, ' '); - if (s) { - deps_target = s + 1; - output_file = xmalloc (s - spec + 1); - bcopy (spec, output_file, s - spec); - output_file[s - spec] = 0; - } else { - deps_target = 0; - output_file = spec; - } - - deps_file = output_file; - deps_mode = "a"; - } - - /* For -M, print the expected object file name - as the target of this Make-rule. */ - if (print_deps) { - deps_allocated_size = 200; - deps_buffer = xmalloc (deps_allocated_size); - deps_buffer[0] = 0; - deps_size = 0; - deps_column = 0; - - if (deps_target) { - deps_output (deps_target, ':'); - } else if (*in_fname == 0) { - deps_output ("-", ':'); - } else { - char *p, *q; - int len; - - q = base_name (in_fname); - - /* Copy remainder to mungable area. */ - p = (char *) alloca (strlen(q) + 8); - strcpy (p, q); - - /* Output P, but remove known suffixes. */ - len = strlen (p); - q = p + len; - if (len >= 2 - && p[len - 2] == '.' - && index("cCsSm", p[len - 1])) - q = p + (len - 2); - else if (len >= 3 - && p[len - 3] == '.' - && p[len - 2] == 'c' - && p[len - 1] == 'c') - q = p + (len - 3); - else if (len >= 4 - && p[len - 4] == '.' - && p[len - 3] == 'c' - && p[len - 2] == 'x' - && p[len - 1] == 'x') - q = p + (len - 4); - else if (len >= 4 - && p[len - 4] == '.' - && p[len - 3] == 'c' - && p[len - 2] == 'p' - && p[len - 1] == 'p') - q = p + (len - 4); - - /* Supply our own suffix. */ - strcpy (q, OBJECT_SUFFIX); - - deps_output (p, ':'); - } - - deps_output (in_fname, ' '); - } - - /* Scan the -imacros files before the main input. - Much like #including them, but with no_output set - so that only their macro definitions matter. */ - - no_output++; no_record_file++; - for (i = 1; i < argc; i++) - if (pend_files[i]) { - struct include_file *inc; - int fd = open_include_file (pend_files[i], NULL_PTR, NULL_PTR, &inc); - if (fd < 0) { - perror_with_name (pend_files[i]); - return FATAL_EXIT_CODE; - } - finclude (fd, inc, &outbuf, 0, NULL_PTR); - } - no_output--; no_record_file--; - - /* Copy the entire contents of the main input file into - the stacked input buffer previously allocated for it. */ - - /* 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; - - if (fstat (f, &st) != 0) - pfatal_with_name (in_fname); - fp->nominal_fname = fp->fname = in_fname; - fp->nominal_fname_len = strlen (in_fname); - fp->lineno = 1; - fp->system_header_p = 0; - /* JF all this is mine about reading pipes and ttys */ - if (! S_ISREG (st.st_mode)) { - /* Read input from a file that is not a normal disk file. - We cannot preallocate a buffer with the correct size, - so we must read in the file a piece at the time and make it bigger. */ - int size; - int bsize; - int cnt; - - if (S_ISDIR (st.st_mode)) - fatal ("Input file `%s' is a directory", in_fname); - - bsize = 2000; - size = 0; - fp->buf = (U_CHAR *) xmalloc (bsize + 2); - for (;;) { - cnt = safe_read (f, (char *) fp->buf + size, bsize - size); - if (cnt < 0) goto perror; /* error! */ - size += cnt; - if (size != bsize) break; /* End of file */ - bsize *= 2; - fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2); - } - fp->length = size; - } else { - /* Read a file whose size we can determine in advance. - For the sake of VMS, st.st_size is just an upper bound. */ - size_t s = (size_t) st.st_size; - if (s != st.st_size || s + 2 < s) - memory_full (); - fp->buf = (U_CHAR *) xmalloc (s + 2); - fp->length = safe_read (f, (char *) fp->buf, s); - if (fp->length < 0) goto perror; - } - fp->bufp = fp->buf; - fp->if_stack = if_stack; - - /* Make sure data ends with a newline. And put a null after it. */ - - if ((fp->length > 0 && fp->buf[fp->length - 1] != '\n') - /* Backslash-newline at end is not good enough. */ - || (fp->length > 1 && fp->buf[fp->length - 2] == '\\')) { - fp->buf[fp->length++] = '\n'; - missing_newline = 1; - } - fp->buf[fp->length] = '\0'; - - /* Unless inhibited, convert trigraphs in the input. */ - - if (!no_trigraphs) - trigraph_pcp (fp); - - if (warn_white_space) - check_white_space (fp); - - /* Now that we know the input file is valid, open the output. */ - - if (!out_fname || !strcmp (out_fname, "")) - out_fname = "stdout"; - else if (! freopen (out_fname, "w", stdout)) - pfatal_with_name (out_fname); - - output_line_directive (fp, &outbuf, 0, same_file); - - /* Scan the -include files before the main input. */ - - no_record_file++; - for (i = 1; i < argc; i++) - if (pend_includes[i]) { - struct include_file *inc; - int fd = open_include_file (pend_includes[i], NULL_PTR, NULL_PTR, &inc); - if (fd < 0) { - perror_with_name (pend_includes[i]); - return FATAL_EXIT_CODE; - } - finclude (fd, inc, &outbuf, 0, NULL_PTR); - } - no_record_file--; - - /* Scan the input, processing macros and directives. */ - - rescan (&outbuf, 0); - - if (missing_newline) - fp->lineno--; - - if (pedantic && missing_newline) - pedwarn ("file does not end in newline"); - - /* Now we have processed the entire input - Write whichever kind of output has been requested. */ - - if (dump_macros == dump_only) - dump_all_macros (); - else if (! inhibit_output) { - write_output (); - } - - if (print_deps) { - /* Don't actually write the deps file if compilation has failed. */ - if (errors == 0) { - if (deps_file && ! (deps_stream = fopen (deps_file, deps_mode))) - pfatal_with_name (deps_file); - fputs (deps_buffer, deps_stream); - putc ('\n', deps_stream); - if (deps_file) { - if (ferror (deps_stream) || fclose (deps_stream) != 0) - fatal ("I/O error on output"); - } - } - } - - if (pcp_outfile && pcp_outfile != stdout - && (ferror (pcp_outfile) || fclose (pcp_outfile) != 0)) - fatal ("I/O error on `-pcp' output"); - - if (ferror (stdout) || fclose (stdout) != 0) - fatal ("I/O error on output"); - - if (errors) - exit (FATAL_EXIT_CODE); - exit (SUCCESS_EXIT_CODE); - - perror: - pfatal_with_name (in_fname); - return 0; -} - -/* Given a colon-separated list of file names PATH, - add all the names to the search path for include files. */ - -static void -path_include (path) - char *path; -{ - char *p; - - p = path; - - if (*p) - while (1) { - char *q = p; - char c; - struct file_name_list *dirtmp; - - /* Find the end of this name. */ - while ((c = *q++) != PATH_SEPARATOR && c) - continue; - - q[-1] = 0; - dirtmp = new_include_prefix (last_include, NULL_PTR, - "", p == q ? "." : p); - q[-1] = c; - append_include_chain (dirtmp, dirtmp); - - /* Advance past this name. */ - p = q; - if (! c) - break; - } -} - -/* Return the address of the first character in S that equals C. - S is an array of length N, possibly containing '\0's, and followed by '\0'. - Return 0 if there is no such character. Assume that C itself is not '\0'. - If we knew we could use memchr, we could just invoke memchr (S, C, N), - but unfortunately memchr isn't autoconfigured yet. */ - -static const U_CHAR * -index0 (s, c, n) - const U_CHAR *s; - int c; - size_t n; -{ - const char *p = (const char *) s; - for (;;) { - const char *q = index (p, c); - if (q) - return (const U_CHAR *) q; - else { - size_t l = strlen (p); - if (l == n) - return 0; - l++; - p += l; - n -= l; - } - } -} - -/* Pre-C-Preprocessor to translate ANSI trigraph idiocy in BUF - before main CCCP processing. Name `pcp' is also in honor of the - drugs the trigraph designers must have been on. - - Using an extra pass through the buffer takes a little extra time, - but is infinitely less hairy than trying to handle trigraphs inside - strings, etc. everywhere, and also makes sure that trigraphs are - only translated in the top level of processing. */ - -static void -trigraph_pcp (buf) - FILE_BUF *buf; -{ - register U_CHAR c, *bptr; - register const U_CHAR *fptr, *sptr, *lptr; - int len; - - fptr = sptr = bptr = buf->buf; - lptr = fptr + buf->length; - while ((sptr = index0 (sptr, '?', (size_t) (lptr - sptr))) != NULL) { - if (*++sptr != '?') - continue; - switch (*++sptr) { - case '=': - c = '#'; - break; - case '(': - c = '['; - break; - case '/': - c = '\\'; - break; - case ')': - c = ']'; - break; - case '\'': - c = '^'; - break; - case '<': - c = '{'; - break; - case '!': - c = '|'; - break; - case '>': - c = '}'; - break; - case '-': - c = '~'; - break; - case '?': - sptr--; - continue; - default: - continue; - } - len = sptr - fptr - 2; - - /* BSD doc says bcopy () works right for overlapping strings. In ANSI - C, this will be memmove (). */ - if (bptr != fptr && len > 0) - bcopy ((const PTR) fptr, (PTR) bptr, len); - - bptr += len; - *bptr++ = c; - fptr = ++sptr; - } - len = buf->length - (fptr - buf->buf); - if (bptr != fptr && len > 0) - bcopy ((const PTR) fptr, (PTR) bptr, len); - buf->length -= fptr - bptr; - buf->buf[buf->length] = '\0'; - if (warn_trigraphs && fptr != bptr) - warning_with_line (0, "%lu trigraph(s) encountered", - (unsigned long) (fptr - bptr) / 2); -} - -/* Warn about white space between backslash and end of line. */ - -static void -check_white_space (buf) - FILE_BUF *buf; -{ - register const U_CHAR *sptr = buf->buf; - register const U_CHAR *lptr = sptr + buf->length; - register const U_CHAR *nptr; - int line = 0; - - nptr = sptr = buf->buf; - lptr = sptr + buf->length; - for (nptr = sptr; - (nptr = index0 (nptr, '\n', (size_t) (lptr - nptr))) != NULL; - nptr ++) { - register const U_CHAR *p = nptr; - line++; - for (p = nptr; sptr < p; p--) { - if (! is_hor_space[p[-1]]) { - if (p[-1] == '\\' && p != nptr) - warning_with_line (line, - "`\\' followed by white space at end of line"); - break; - } - } - } -} - -/* Move all backslash-newline pairs out of embarrassing places. - Exchange all such pairs following BP - with any potentially-embarrassing characters that follow them. - Potentially-embarrassing characters are / and * - (because a backslash-newline inside a comment delimiter - would cause it not to be recognized). - We assume that *BP == '\\'. */ - -static void -newline_fix (bp) - U_CHAR *bp; -{ - register U_CHAR *p = bp; - - /* First count the backslash-newline pairs here. */ - do { - if (p[1] != '\n') - break; - p += 2; - } while (*p == '\\'); - - /* What follows the backslash-newlines is not embarrassing. */ - - if (*p != '/' && *p != '*') - /* What follows the backslash-newlines is not embarrassing. */ - return; - - /* Copy all potentially embarrassing characters - that follow the backslash-newline pairs - down to where the pairs originally started. */ - do - *bp++ = *p++; - while (*p == '*' || *p == '/'); - - /* Now write the same number of pairs after the embarrassing chars. */ - while (bp < p) { - *bp++ = '\\'; - *bp++ = '\n'; - } -} - -/* Like newline_fix but for use within a directive-name. - Move any backslash-newlines up past any following symbol constituents. */ - -static void -name_newline_fix (bp) - U_CHAR *bp; -{ - register U_CHAR *p = bp; - - /* First count the backslash-newline pairs here. */ - do { - if (p[1] != '\n') - break; - p += 2; - } while (*p == '\\'); - - /* What follows the backslash-newlines is not embarrassing. */ - - if (!is_idchar[*p]) - /* What follows the backslash-newlines is not embarrassing. */ - return; - - /* Copy all potentially embarrassing characters - that follow the backslash-newline pairs - down to where the pairs originally started. */ - do - *bp++ = *p++; - while (is_idchar[*p]); - - /* Now write the same number of pairs after the embarrassing chars. */ - while (bp < p) { - *bp++ = '\\'; - *bp++ = '\n'; - } -} - -/* Look for lint commands in comments. - - When we come in here, ibp points into a comment. Limit is as one expects. - scan within the comment -- it should start, after lwsp, with a lint command. - If so that command is returned as a (constant) string. - - Upon return, any arg will be pointed to with argstart and will be - arglen long. Note that we don't parse that arg since it will just - be printed out again. */ - -static const char * -get_lintcmd (ibp, limit, argstart, arglen, cmdlen) - register const U_CHAR *ibp; - register const U_CHAR *limit; - const U_CHAR **argstart; /* point to command arg */ - int *arglen, *cmdlen; /* how long they are */ -{ - HOST_WIDEST_INT linsize; - register const U_CHAR *numptr; /* temp for arg parsing */ - - *arglen = 0; - - SKIP_WHITE_SPACE (ibp); - - if (ibp >= limit) return NULL; - - linsize = limit - ibp; - - /* Oh, I wish C had lexical functions... hell, I'll just open-code the set */ - if ((linsize >= 10) && !bcmp (ibp, "NOTREACHED", 10)) { - *cmdlen = 10; - return "NOTREACHED"; - } - if ((linsize >= 8) && !bcmp (ibp, "ARGSUSED", 8)) { - *cmdlen = 8; - return "ARGSUSED"; - } - if ((linsize >= 11) && !bcmp (ibp, "LINTLIBRARY", 11)) { - *cmdlen = 11; - return "LINTLIBRARY"; - } - if ((linsize >= 7) && !bcmp (ibp, "VARARGS", 7)) { - *cmdlen = 7; - ibp += 7; linsize -= 7; - if ((linsize == 0) || ! ISDIGIT (*ibp)) return "VARARGS"; - - /* OK, read a number */ - for (numptr = *argstart = ibp; (numptr < limit) && ISDIGIT (*numptr); - numptr++); - *arglen = numptr - *argstart; - return "VARARGS"; - } - return NULL; -} - -/* - * The main loop of the program. - * - * Read characters from the input stack, transferring them to the - * output buffer OP. - * - * Macros are expanded and push levels on the input stack. - * At the end of such a level it is popped off and we keep reading. - * At the end of any other kind of level, we return. - * #-directives are handled, except within macros. - * - * If OUTPUT_MARKS is nonzero, keep Newline markers found in the input - * and insert them when appropriate. This is set while scanning macro - * arguments before substitution. It is zero when scanning for final output. - * There are two types of Newline markers: - * * Newline - follows a macro name that was not expanded - * because it appeared inside an expansion of the same macro. - * This marker prevents future expansion of that identifier. - * When the input is rescanned into the final output, these are deleted. - * These are also deleted by ## concatenation. - * * Newline Space (or Newline and any other whitespace character) - * stands for a place that tokens must be separated or whitespace - * is otherwise desirable, but where the ANSI standard specifies there - * is no whitespace. This marker turns into a Space (or whichever other - * whitespace char appears in the marker) in the final output, - * but it turns into nothing in an argument that is stringified with #. - * Such stringified arguments are the only place where the ANSI standard - * specifies with precision that whitespace may not appear. - * - * During this function, IP->bufp is kept cached in IBP for speed of access. - * Likewise, OP->bufp is kept in OBP. Before calling a subroutine - * IBP, IP and OBP must be copied back to memory. IP and IBP are - * copied back with the RECACHE macro. OBP must be copied back from OP->bufp - * explicitly, and before RECACHE, since RECACHE uses OBP. - */ - -static void -rescan (op, output_marks) - FILE_BUF *op; - int output_marks; -{ - /* Character being scanned in main loop. */ - register U_CHAR c; - - /* Length of pending accumulated identifier. */ - register int ident_length = 0; - - /* Hash code of pending accumulated identifier. */ - register int hash = 0; - - /* Current input level (&instack[indepth]). */ - FILE_BUF *ip; - - /* Pointer for scanning input. */ - register U_CHAR *ibp; - - /* Pointer to end of input. End of scan is controlled by LIMIT. */ - register U_CHAR *limit; - - /* Pointer for storing output. */ - register U_CHAR *obp; - - /* REDO_CHAR is nonzero if we are processing an identifier - after backing up over the terminating character. - Sometimes we process an identifier without backing up over - the terminating character, if the terminating character - is not special. Backing up is done so that the terminating character - will be dispatched on again once the identifier is dealt with. */ - int redo_char = 0; - - /* 1 if within an identifier inside of which a concatenation - marker (Newline -) has been seen. */ - int concatenated = 0; - - /* While scanning a comment or a string constant, - this records the line it started on, for error messages. */ - int start_line; - - /* Record position of last `real' newline. */ - U_CHAR *beg_of_line; - -/* Pop the innermost input stack level, assuming it is a macro expansion. */ - -#define POPMACRO \ -do { ip->macro->type = T_MACRO; \ - if (ip->free_ptr) free (ip->free_ptr); \ - --indepth; } while (0) - -/* Reload `rescan's local variables that describe the current - level of the input stack. */ - -#define RECACHE \ -do { ip = &instack[indepth]; \ - ibp = ip->bufp; \ - limit = ip->buf + ip->length; \ - op->bufp = obp; \ - check_expand (op, limit - ibp); \ - beg_of_line = 0; \ - obp = op->bufp; } while (0) - - if (no_output && instack[indepth].fname != 0) - skip_if_group (&instack[indepth], 1, NULL); - - obp = op->bufp; - RECACHE; - - beg_of_line = ibp; - - /* Our caller must always put a null after the end of - the input at each input stack level. */ - if (*limit != 0) - abort (); - - while (1) { - c = *ibp++; - *obp++ = c; - - switch (c) { - case '\\': - if (*ibp == '\n' && !ip->macro) { - /* At the top level, always merge lines ending with backslash-newline, - even in middle of identifier. But do not merge lines in a macro, - since backslash might be followed by a newline-space marker. */ - ++ibp; - ++ip->lineno; - --obp; /* remove backslash from obuf */ - break; - } - /* If ANSI, backslash is just another character outside a string. */ - if (!traditional) - goto randomchar; - /* Otherwise, backslash suppresses specialness of following char, - so copy it here to prevent the switch from seeing it. - But first get any pending identifier processed. */ - if (ident_length > 0) - goto specialchar; - if (ibp < limit) - *obp++ = *ibp++; - break; - - case '%': - if (ident_length || ip->macro || traditional) - goto randomchar; - while (*ibp == '\\' && ibp[1] == '\n') { - ibp += 2; - ++ip->lineno; - } - if (*ibp != ':') - break; - /* Treat this %: digraph as if it were #. */ - /* Fall through. */ - - case '#': - if (assertions_flag) { - if (ident_length) - goto specialchar; - /* Copy #foo (bar lose) without macro expansion. */ - obp[-1] = '#'; /* In case it was '%'. */ - SKIP_WHITE_SPACE (ibp); - while (is_idchar[*ibp]) - *obp++ = *ibp++; - SKIP_WHITE_SPACE (ibp); - if (*ibp == '(') { - ip->bufp = ibp; - skip_paren_group (ip); - bcopy ((const PTR) ibp, (PTR) obp, ip->bufp - ibp); - obp += ip->bufp - ibp; - ibp = ip->bufp; - } - break; - } - - /* If this is expanding a macro definition, don't recognize - preprocessing directives. */ - if (ip->macro != 0) - goto randomchar; - /* If this is expand_into_temp_buffer, - don't recognize them either. Warn about them - only after an actual newline at this level, - not at the beginning of the input level. */ - if (! ip->fname) { - if (ip->buf != beg_of_line) - warning ("preprocessing directive not recognized within macro arg"); - goto randomchar; - } - if (ident_length) - goto specialchar; - - - /* # keyword: a # must be first nonblank char on the line */ - if (beg_of_line == 0) - goto randomchar; - { - U_CHAR *bp; - - /* Scan from start of line, skipping whitespace, comments - and backslash-newlines, and see if we reach this #. - If not, this # is not special. */ - bp = beg_of_line; - /* If -traditional, require # to be at beginning of line. */ - if (!traditional) { - while (1) { - if (is_hor_space[*bp]) - bp++; - else if (*bp == '\\' && bp[1] == '\n') - bp += 2; - else if (*bp == '/' && bp[1] == '*') { - bp += 2; - while (1) - { - if (*bp == '*') - { - if (bp[1] == '/') - { - bp += 2; - break; - } - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (bp, limit - bp); - if (length > 1) - bp += (length - 1); -#endif - } - bp++; - } - } - /* There is no point in trying to deal with C++ // comments here, - because if there is one, then this # must be part of the - comment and we would never reach here. */ - else break; - } - if (c == '%') { - if (bp[0] != '%') - break; - while (bp[1] == '\\' && bp[2] == '\n') - bp += 2; - if (bp + 1 != ibp) - break; - /* %: appears at start of line; skip past the ':' too. */ - bp++; - ibp++; - } - } - if (bp + 1 != ibp) - goto randomchar; - } - - /* This # can start a directive. */ - - --obp; /* Don't copy the '#' */ - - ip->bufp = ibp; - op->bufp = obp; - if (! handle_directive (ip, op)) { -#ifdef USE_C_ALLOCA - alloca (0); -#endif - /* Not a known directive: treat it as ordinary text. - IP, OP, IBP, etc. have not been changed. */ - if (no_output && instack[indepth].fname) { - /* If not generating expanded output, - what we do with ordinary text is skip it. - Discard everything until next # directive. */ - skip_if_group (&instack[indepth], 1, 0); - RECACHE; - beg_of_line = ibp; - break; - } - *obp++ = '#'; /* Copy # (even if it was originally %:). */ - /* Don't expand an identifier that could be a macro directive. - (Section 3.8.3 of the ANSI C standard) */ - SKIP_WHITE_SPACE (ibp); - if (is_idstart[*ibp]) - { - *obp++ = *ibp++; - while (is_idchar[*ibp]) - *obp++ = *ibp++; - } - goto randomchar; - } -#ifdef USE_C_ALLOCA - alloca (0); -#endif - /* A # directive has been successfully processed. */ - /* If not generating expanded output, ignore everything until - next # directive. */ - if (no_output && instack[indepth].fname) - skip_if_group (&instack[indepth], 1, 0); - obp = op->bufp; - RECACHE; - beg_of_line = ibp; - break; - - case '\"': /* skip quoted string */ - case '\'': - /* A single quoted string is treated like a double -- some - programs (e.g., troff) are perverse this way */ - - /* Handle any pending identifier; - but the L in L'...' or L"..." is not an identifier. */ - if (ident_length) { - if (! (ident_length == 1 && hash == HASHSTEP (0, 'L'))) - goto specialchar; - ident_length = hash = 0; - } - - start_line = ip->lineno; - - /* Skip ahead to a matching quote. */ - - while (1) { - if (ibp >= limit) { - if (ip->macro != 0) { - /* try harder: this string crosses a macro expansion boundary. - This can happen naturally if -traditional. - Otherwise, only -D can make a macro with an unmatched quote. */ - POPMACRO; - RECACHE; - continue; - } - if (!traditional) { - error_with_line (line_for_error (start_line), - "unterminated string or character constant"); - if (multiline_string_line) { - error_with_line (multiline_string_line, - "possible real start of unterminated constant"); - multiline_string_line = 0; - } - } - break; - } - *obp++ = *ibp; - switch (*ibp++) { - case '\n': - if (warn_white_space && ip->fname && is_hor_space[ibp[-2]]) - warning ("white space at end of line in string"); - ++ip->lineno; - ++op->lineno; - /* Traditionally, end of line ends a string constant with no error. - So exit the loop and record the new line. */ - if (traditional) { - beg_of_line = ibp; - goto while2end; - } - if (c == '\'') { - error_with_line (line_for_error (start_line), - "unterminated character constant"); - goto while2end; - } - if (multiline_string_line == 0) { - if (pedantic) - pedwarn_with_line (line_for_error (start_line), - "string constant runs past end of line"); - multiline_string_line = ip->lineno - 1; - } - break; - - case '\\': - if (*ibp == '\n') { - /* Backslash newline is replaced by nothing at all, but - keep the line counts correct. But if we are reading - from a macro, keep the backslash newline, since backslash - newlines have already been processed. */ - if (ip->macro) { - *obp++ = '\n'; - ++op->lineno; - } else - --obp; - ++ibp; - ++ip->lineno; - } else { - /* ANSI stupidly requires that in \\ the second \ - is *not* prevented from combining with a newline. */ - if (!ip->macro) { - while (*ibp == '\\' && ibp[1] == '\n') { - *obp++ = *ibp++; - *obp++ = *ibp++; - ++ip->lineno; - ++op->lineno; - } - } - *obp++ = *ibp++; - } - break; - - case '\"': - case '\'': - if (ibp[-1] == c) - goto while2end; - break; -#ifdef MULTIBYTE_CHARS - default: - { - int length; - --ibp; - length = local_mblen (ibp, limit - ibp); - if (length > 0) - { - --obp; - bcopy (ibp, obp, length); - obp += length; - ibp += length; - } - else - ++ibp; - } - break; -#endif - } - } - while2end: - break; - - case '/': - if (ip->macro != 0) - goto randomchar; - if (*ibp == '\\') - newline_fix (ibp); - if (*ibp != '*' - && !(cplusplus_comments && *ibp == '/')) - goto randomchar; - if (ident_length) - goto specialchar; - - if (*ibp == '/') { - /* C++ style comment... */ - start_line = ip->lineno; - - /* Comments are equivalent to spaces. */ - if (! put_out_comments) - obp[-1] = ' '; - - { - U_CHAR *before_bp = ibp; - - while (++ibp < limit) { - if (*ibp == '\n') - { - if (put_out_comments) { - bcopy ((const PTR) before_bp, (PTR) obp, ibp - before_bp); - obp += ibp - before_bp; - } - break; - } - if (*ibp == '\\') - { - if (ibp + 1 < limit && ibp[1] == '\n') - { - if (warn_comments) - warning ("multiline `//' comment"); - ++ip->lineno; - /* Copy the newline into the output buffer, in order to - avoid the pain of a #line every time a multiline comment - is seen. */ - if (!put_out_comments) - *obp++ = '\n'; - ++op->lineno; - ++ibp; - } - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (ibp, limit - ibp); - if (length > 1) - ibp += (length - 1); -#endif - } - } - break; - } - } - - /* Ordinary C comment. Skip it, optionally copying it to output. */ - - start_line = ip->lineno; - - ++ibp; /* Skip the star. */ - - /* If this cpp is for lint, we peek inside the comments: */ - if (for_lint) { - const U_CHAR *argbp; - int cmdlen, arglen; - const char *lintcmd = - get_lintcmd (ibp, limit, &argbp, &arglen, &cmdlen); - - if (lintcmd != NULL) { - op->bufp = obp; - check_expand (op, cmdlen + arglen + 14); - obp = op->bufp; - /* I believe it is always safe to emit this newline: */ - obp[-1] = '\n'; - bcopy ("#pragma lint ", (char *) obp, 13); - obp += 13; - bcopy (lintcmd, (char *) obp, cmdlen); - obp += cmdlen; - - if (arglen != 0) { - *(obp++) = ' '; - bcopy (argbp, (char *) obp, arglen); - obp += arglen; - } - - /* OK, now bring us back to the state we were in before we entered - this branch. We need #line because the #pragma's newline always - messes up the line count. */ - op->bufp = obp; - output_line_directive (ip, op, 0, same_file); - check_expand (op, limit - ibp + 2); - obp = op->bufp; - *(obp++) = '/'; - } - } - - /* Comments are equivalent to spaces. - Note that we already output the slash; we might not want it. - For -traditional, a comment is equivalent to nothing. */ - if (! put_out_comments) { - if (traditional) - obp--; - else - obp[-1] = ' '; - } - else - *obp++ = '*'; - - { - U_CHAR *before_bp = ibp; - - for (;;) { - switch (*ibp++) { - case '*': - if (ibp[-2] == '/' && warn_comments) - warning ("`/*' within comment"); - if (*ibp == '\\') - newline_fix (ibp); - if (*ibp == '/') - goto comment_end; - break; - - case '\n': - ++ip->lineno; - /* Copy the newline into the output buffer, in order to - avoid the pain of a #line every time a multiline comment - is seen. */ - if (!put_out_comments) - *obp++ = '\n'; - ++op->lineno; - break; - - case 0: - if (limit < ibp) { - error_with_line (line_for_error (start_line), - "unterminated comment"); - goto limit_reached; - } - break; -#ifdef MULTIBYTE_CHARS - default: - { - int length; - length = local_mblen (ibp, limit - ibp); - if (length > 1) - ibp += (length - 1); - } - break; -#endif - } - } - comment_end: - - ibp++; - if (put_out_comments) { - bcopy ((const PTR) before_bp, (PTR) obp, ibp - before_bp); - obp += ibp - before_bp; - } - } - break; - - case '$': - if (! is_idchar['$']) - goto randomchar; - if (pedantic) - pedwarn ("`$' in identifier"); - goto letter; - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - /* If digit is not part of identifier, it starts a number, - which means that following letters are not an identifier. - "0x5" does not refer to an identifier "x5". - So copy all alphanumerics that follow without accumulating - as an identifier. Periods also, for sake of "3.e7". */ - - if (ident_length == 0) { - for (;;) { - if (!ip->macro) { - while (ibp[0] == '\\' && ibp[1] == '\n') { - ++ip->lineno; - ibp += 2; - } - } - c = *ibp++; - if (!is_idchar[c] && c != '.') { - --ibp; - break; - } - *obp++ = c; - /* A sign can be part of a preprocessing number - if it follows an `e' or `p'. */ - if (c == 'e' || c == 'E' || c == 'p' || c == 'P') { - if (!ip->macro) { - while (ibp[0] == '\\' && ibp[1] == '\n') { - ++ip->lineno; - ibp += 2; - } - } - if (*ibp == '+' || *ibp == '-') { - *obp++ = *ibp++; - /* But traditional C does not let the token go past the sign, - and C89 does not allow `p'. */ - if (traditional || (c89 && (c == 'p' || c == 'P'))) - break; - } - } - } - break; - } - /* fall through */ - - case '_': - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': - case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': - case 's': case 't': case 'u': case 'v': case 'w': case 'x': - case 'y': case 'z': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': - case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': - case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': - case 'Y': case 'Z': - letter: - ident_length++; - /* Compute step of hash function, to avoid a proc call on every token */ - hash = HASHSTEP (hash, c); - break; - - case '\n': - if (ip->fname == 0 && *ibp == '-') { - /* Newline - inhibits expansion of preceding token. - If expanding a macro arg, we keep the newline -. - In final output, it is deleted. - We recognize Newline - in macro bodies and macro args. */ - if (! concatenated) { - ident_length = 0; - hash = 0; - } - ibp++; - if (!output_marks) { - obp--; - } else { - /* If expanding a macro arg, keep the newline -. */ - *obp++ = '-'; - } - break; - } - - /* If reprocessing a macro expansion, newline is a special marker. */ - else if (ip->macro != 0) { - /* Newline White is a "funny space" to separate tokens that are - supposed to be separate but without space between. - Here White means any whitespace character. - Newline - marks a recursive macro use that is not - supposed to be expandable. */ - - if (is_space[*ibp]) { - /* Newline Space does not prevent expansion of preceding token - so expand the preceding token and then come back. */ - if (ident_length > 0) - goto specialchar; - - /* If generating final output, newline space makes a space. */ - if (!output_marks) { - obp[-1] = *ibp++; - /* And Newline Newline makes a newline, so count it. */ - if (obp[-1] == '\n') - op->lineno++; - } else { - /* If expanding a macro arg, keep the newline space. - If the arg gets stringified, newline space makes nothing. */ - *obp++ = *ibp++; - } - } else abort (); /* Newline followed by something random? */ - break; - } - - /* If there is a pending identifier, handle it and come back here. */ - if (ident_length > 0) - goto specialchar; - - beg_of_line = ibp; - - /* Update the line counts and output a #line if necessary. */ - ++ip->lineno; - ++op->lineno; - if (ip->lineno != op->lineno) { - op->bufp = obp; - output_line_directive (ip, op, 1, same_file); - check_expand (op, limit - ibp); - obp = op->bufp; - } - break; - - /* Come here either after (1) a null character that is part of the input - or (2) at the end of the input, because there is a null there. */ - case 0: - if (ibp <= limit) - /* Our input really contains a null character. */ - goto randomchar; - - limit_reached: - /* At end of a macro-expansion level, pop it and read next level. */ - if (ip->macro != 0) { - obp--; - ibp--; - /* If traditional, and we have an identifier that ends here, - process it now, so we get the right error for recursion. */ - if (traditional && ident_length - && ! is_idchar[*instack[indepth - 1].bufp]) { - redo_char = 1; - goto randomchar; - } - POPMACRO; - RECACHE; - break; - } - - /* If we don't have a pending identifier, - return at end of input. */ - if (ident_length == 0) { - obp--; - ibp--; - op->bufp = obp; - ip->bufp = ibp; - goto ending; - } - - /* If we do have a pending identifier, just consider this null - a special character and arrange to dispatch on it again. - The second time, IDENT_LENGTH will be zero so we will return. */ - - /* Fall through */ - -specialchar: - - /* Handle the case of a character such as /, ', " or null - seen following an identifier. Back over it so that - after the identifier is processed the special char - will be dispatched on again. */ - - ibp--; - obp--; - redo_char = 1; - - default: - -randomchar: - - if (ident_length > 0) { - register HASHNODE *hp; - - /* We have just seen an identifier end. If it's a macro, expand it. - - IDENT_LENGTH is the length of the identifier - and HASH is its hash code. - - The identifier has already been copied to the output, - so if it is a macro we must remove it. - - If REDO_CHAR is 0, the char that terminated the identifier - has been skipped in the output and the input. - OBP-IDENT_LENGTH-1 points to the identifier. - If the identifier is a macro, we must back over the terminator. - - If REDO_CHAR is 1, the terminating char has already been - backed over. OBP-IDENT_LENGTH points to the identifier. */ - - if (!pcp_outfile || pcp_inside_if) { - for (hp = hashtab[MAKE_POS (hash) % HASHSIZE]; hp != NULL; - hp = hp->next) { - - if (hp->length == ident_length) { - int obufp_before_macroname; - int op_lineno_before_macroname; - register int i = ident_length; - register U_CHAR *p = hp->name; - register U_CHAR *q = obp - i; - int disabled; - - if (! redo_char) - q--; - - do { /* All this to avoid a strncmp () */ - if (*p++ != *q++) - goto hashcollision; - } while (--i); - - /* We found a use of a macro name. - see if the context shows it is a macro call. */ - - /* Back up over terminating character if not already done. */ - if (! redo_char) { - ibp--; - obp--; - } - - /* Save this as a displacement from the beginning of the output - buffer. We can not save this as a position in the output - buffer, because it may get realloc'ed by RECACHE. */ - obufp_before_macroname = (obp - op->buf) - ident_length; - op_lineno_before_macroname = op->lineno; - - if (hp->type == T_PCSTRING) { - pcstring_used (hp); /* Mark the definition of this key - as needed, ensuring that it - will be output. */ - break; /* Exit loop, since the key cannot have a - definition any longer. */ - } - - /* Record whether the macro is disabled. */ - disabled = hp->type == T_DISABLED; - - /* This looks like a macro ref, but if the macro was disabled, - just copy its name and put in a marker if requested. */ - - if (disabled) { -#if 0 - /* This error check caught useful cases such as - #define foo(x,y) bar (x (y,0), y) - foo (foo, baz) */ - if (traditional) - error ("recursive use of macro `%s'", hp->name); -#endif - - if (output_marks) { - op->bufp = obp; - check_expand (op, limit - ibp + 2); - obp = op->bufp; - *obp++ = '\n'; - *obp++ = '-'; - } - break; - } - - /* If macro wants an arglist, verify that a '(' follows. - first skip all whitespace, copying it to the output - after the macro name. Then, if there is no '(', - decide this is not a macro call and leave things that way. */ - if ((hp->type == T_MACRO || hp->type == T_DISABLED) - && hp->value.defn->nargs >= 0) - { - U_CHAR *old_ibp = ibp; - U_CHAR *old_obp = obp; - int old_iln = ip->lineno; - int old_oln = op->lineno; - - while (1) { - /* Scan forward over whitespace, copying it to the output. */ - if (ibp == limit && ip->macro != 0) { - POPMACRO; - RECACHE; - old_ibp = ibp; - old_obp = obp; - old_iln = ip->lineno; - old_oln = op->lineno; - } - else if (is_space[*ibp]) { - *obp++ = *ibp++; - if (ibp[-1] == '\n') { - if (ip->macro == 0) { - /* Newline in a file. Count it. */ - ++ip->lineno; - ++op->lineno; - } else if (!output_marks) { - /* A newline mark, and we don't want marks - in the output. If it is newline-hyphen, - discard it entirely. Otherwise, it is - newline-whitechar, so keep the whitechar. */ - obp--; - if (*ibp == '-') - ibp++; - else { - if (*ibp == '\n') - ++op->lineno; - *obp++ = *ibp++; - } - } else { - /* A newline mark; copy both chars to the output. */ - *obp++ = *ibp++; - } - } - } - else if (ip->macro) - break; - else if (*ibp == '/') { - /* If a comment, copy it unchanged or discard it. */ - if (ibp[1] == '\\') - newline_fix (ibp + 1); - if (ibp[1] == '*') { - if (put_out_comments) { - *obp++ = '/'; - *obp++ = '*'; - } else if (! traditional) { - *obp++ = ' '; - } - for (ibp += 2; ibp < limit; ibp++) { - /* We need not worry about newline-marks, - since they are never found in comments. */ - if (ibp[0] == '*') { - if (ibp[1] == '\\') - newline_fix (ibp + 1); - if (ibp[1] == '/') { - ibp += 2; - if (put_out_comments) { - *obp++ = '*'; - *obp++ = '/'; - } - break; - } - } - else if (*ibp == '\n') { - /* Newline in a file. Count it. */ - ++ip->lineno; - ++op->lineno; - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (ibp, limit - ibp); - if (length > 1) - { - if (put_out_comments) - { - bcopy (ibp, obp, length - 1); - obp += length - 1; - } - ibp += (length - 1); - } -#endif - } - if (put_out_comments) - *obp++ = *ibp; - } - } else if (ibp[1] == '/' && cplusplus_comments) { - if (put_out_comments) { - *obp++ = '/'; - *obp++ = '/'; - } else if (! traditional) { - *obp++ = ' '; - } - for (ibp += 2; ; ibp++) - { - if (*ibp == '\n') - break; - if (*ibp == '\\' && ibp[1] == '\n') - { - if (put_out_comments) - *obp++ = *ibp++; - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (ibp, limit - ibp); - if (length > 1) - { - if (put_out_comments) - { - bcopy (ibp, obp, length - 1); - obp += length - 1; - } - ibp += (length - 1); - } -#endif - } - if (put_out_comments) - *obp++ = *ibp; - } - } else - break; - } - else if (ibp[0] == '\\' && ibp[1] == '\n') { - ibp += 2; - ++ip->lineno; - } - else break; - } - if (*ibp != '(') { - /* It isn't a macro call. - Put back the space that we just skipped. */ - ibp = old_ibp; - obp = old_obp; - ip->lineno = old_iln; - op->lineno = old_oln; - /* Exit the for loop. */ - break; - } - } - - /* This is now known to be a macro call. - Discard the macro name from the output, - along with any following whitespace just copied, - but preserve newlines if not outputting marks since this - is more likely to do the right thing with line numbers. */ - obp = op->buf + obufp_before_macroname; - if (output_marks) - op->lineno = op_lineno_before_macroname; - else { - int newlines = op->lineno - op_lineno_before_macroname; - while (0 < newlines--) - *obp++ = '\n'; - } - - /* Prevent accidental token-pasting with a character - before the macro call. */ - if (!traditional && obp != op->buf) { - switch (obp[-1]) { - case '!': case '%': case '&': case '*': - case '+': case '-': case '.': case '/': - case ':': case '<': case '=': case '>': - case '^': case '|': - /* If we are expanding a macro arg, make a newline marker - to separate the tokens. If we are making real output, - a plain space will do. */ - if (output_marks) - *obp++ = '\n'; - *obp++ = ' '; - } - } - - /* Expand the macro, reading arguments as needed, - and push the expansion on the input stack. */ - ip->bufp = ibp; - op->bufp = obp; - macroexpand (hp, op); - - /* Reexamine input stack, since macroexpand has pushed - a new level on it. */ - obp = op->bufp; - RECACHE; - break; - } -hashcollision: - ; - } /* End hash-table-search loop */ - } - ident_length = hash = 0; /* Stop collecting identifier */ - redo_char = 0; - concatenated = 0; - } /* End if (ident_length > 0) */ - } /* End switch */ - } /* End per-char loop */ - - /* Come here to return -- but first give an error message - if there was an unterminated successful conditional. */ - ending: - if (if_stack != ip->if_stack) - { - const char *str; - - switch (if_stack->type) - { - case T_IF: - str = "if"; - break; - case T_IFDEF: - str = "ifdef"; - break; - case T_IFNDEF: - str = "ifndef"; - break; - case T_ELSE: - str = "else"; - break; - case T_ELIF: - str = "elif"; - break; - default: - abort (); - } - - error_with_line (line_for_error (if_stack->lineno), - "unterminated `#%s' conditional", str); - } - if_stack = ip->if_stack; -} - -/* - * Rescan a string into a temporary buffer and return the result - * as a FILE_BUF. Note this function returns a struct, not a pointer. - * - * OUTPUT_MARKS nonzero means keep Newline markers found in the input - * and insert such markers when appropriate. See `rescan' for details. - * OUTPUT_MARKS is 1 for macroexpanding a macro argument separately - * before substitution; it is 0 for other uses. - */ -static FILE_BUF -expand_to_temp_buffer (buf, limit, output_marks, assertions) - const U_CHAR *buf; - const U_CHAR *limit; - int output_marks, assertions; -{ - register FILE_BUF *ip; - FILE_BUF obuf; - int length = limit - buf; - U_CHAR *buf1; - int odepth = indepth; - int save_assertions_flag = assertions_flag; - - assertions_flag = assertions; - - if (length < 0) - abort (); - - /* Set up the input on the input stack. */ - - buf1 = (U_CHAR *) alloca (length + 1); - { - register const U_CHAR *p1 = buf; - register U_CHAR *p2 = buf1; - - while (p1 != limit) - *p2++ = *p1++; - } - buf1[length] = 0; - - /* Set up to receive the output. */ - - obuf.length = length * 2 + 100; /* Usually enough. Why be stingy? */ - obuf.bufp = obuf.buf = (U_CHAR *) xmalloc (obuf.length); - obuf.nominal_fname = 0; - obuf.inc = 0; - obuf.dir = 0; - obuf.fname = 0; - obuf.macro = 0; - obuf.if_stack = 0; - obuf.free_ptr = 0; - obuf.system_header_p = 0; - - CHECK_DEPTH ({return obuf;}); - - ++indepth; - - ip = &instack[indepth]; - ip->fname = 0; - ip->nominal_fname = 0; - ip->nominal_fname_len = 0; - ip->inc = 0; - ip->system_header_p = 0; - ip->macro = 0; - ip->free_ptr = 0; - ip->length = length; - ip->buf = ip->bufp = buf1; - ip->if_stack = if_stack; - - ip->lineno = obuf.lineno = 1; - - /* Scan the input, create the output. */ - rescan (&obuf, output_marks); - - /* Pop input stack to original state. */ - --indepth; - - if (indepth != odepth) - abort (); - - assertions_flag = save_assertions_flag; - return obuf; -} - -/* - * Process a # directive. Expects IP->bufp to point after the '#', as in - * `#define foo bar'. Passes to the directive handler - * (do_define, do_include, etc.): the addresses of the 1st and - * last chars of the directive (starting immediately after the # - * keyword), plus op and the keyword table pointer. If the directive - * contains comments it is copied into a temporary buffer sans comments - * and the temporary buffer is passed to the directive handler instead. - * Likewise for backslash-newlines. - * - * Returns nonzero if this was a known # directive. - * Otherwise, returns zero, without advancing the input pointer. - */ - -static int -handle_directive (ip, op) - FILE_BUF *ip, *op; -{ - register U_CHAR *bp, *cp; - register struct directive *kt; - register int ident_length; - U_CHAR *resume_p; - - /* Nonzero means we must copy the entire directive - to get rid of comments or backslash-newlines. */ - int copy_directive = 0; - - U_CHAR *ident, *after_ident; - - bp = ip->bufp; - - /* Record where the directive started. do_xifdef needs this. */ - directive_start = bp - 1; - - ignore_escape_flag = 1; - - /* Skip whitespace and \-newline. */ - while (1) { - if (is_hor_space[*bp]) { - if (*bp != ' ' && *bp != '\t' && pedantic) - pedwarn_strange_white_space (*bp); - bp++; - } else if (*bp == '/') { - if (bp[1] == '\\') - newline_fix (bp + 1); - if (! (bp[1] == '*' || (cplusplus_comments && bp[1] == '/'))) - break; - ip->bufp = bp + 2; - skip_to_end_of_comment (ip, &ip->lineno, 0); - bp = ip->bufp; - } else if (*bp == '\\' && bp[1] == '\n') { - bp += 2; ip->lineno++; - } else break; - } - - /* Now find end of directive name. - If we encounter a backslash-newline, exchange it with any following - symbol-constituents so that we end up with a contiguous name. */ - - cp = bp; - while (1) { - if (is_idchar[*cp]) - cp++; - else { - if (*cp == '\\') - name_newline_fix (cp); - if (is_idchar[*cp]) - cp++; - else break; - } - } - ident_length = cp - bp; - ident = bp; - after_ident = cp; - - /* A line of just `#' becomes blank. */ - - if (ident_length == 0 && *after_ident == '\n') { - ip->bufp = after_ident; - return 1; - } - - if (ident_length == 0 || !is_idstart[*ident]) { - U_CHAR *p = ident; - while (is_idchar[*p]) { - if (*p < '0' || *p > '9') - break; - p++; - } - /* Handle # followed by a line number. */ - if (p != ident && !is_idchar[*p]) { - static struct directive line_directive_table[] = { - { 4, do_line, "line", T_LINE}, - }; - if (pedantic) - pedwarn ("`#' followed by integer"); - after_ident = ident; - kt = line_directive_table; - ignore_escape_flag = 0; - goto old_linenum; - } - - /* Avoid error for `###' and similar cases unless -pedantic. */ - if (p == ident) { - while (*p == '#' || is_hor_space[*p]) p++; - if (*p == '\n') { - if (pedantic && !lang_asm) - warning ("invalid preprocessing directive"); - return 0; - } - } - - if (!lang_asm) - error ("invalid preprocessing directive name"); - - return 0; - } - - /* - * Decode the keyword and call the appropriate expansion - * routine, after moving the input pointer up to the next line. - */ - for (kt = directive_table; kt->length > 0; kt++) { - if (kt->length == ident_length && !bcmp (kt->name, ident, ident_length)) { - register U_CHAR *buf; - register U_CHAR *limit; - int unterminated; - int junk; - int *already_output; - - /* Nonzero means do not delete comments within the directive. - #define needs this when -traditional. */ - int keep_comments; - - old_linenum: - - limit = ip->buf + ip->length; - unterminated = 0; - already_output = 0; - keep_comments = traditional && kt->type == T_DEFINE; - /* #import is defined only in Objective C, or when on the NeXT. */ - if (kt->type == T_IMPORT - && !(objc || lookup ((const U_CHAR *) "__NeXT__", -1, -1))) - break; - - /* Find the end of this directive (first newline not backslashed - and not in a string or comment). - Set COPY_DIRECTIVE if the directive must be copied - (it contains a backslash-newline or a comment). */ - - buf = bp = after_ident; - while (bp < limit) { - register U_CHAR c = *bp++; - switch (c) { - case '\\': - if (*bp == '\n') { - ip->lineno++; - copy_directive = 1; - bp++; - } else if (traditional && bp < limit) - bp++; - break; - - case '"': - /* "..." is special for #include. */ - if (IS_INCLUDE_DIRECTIVE_TYPE (kt->type)) { - while (bp < limit && *bp != '\n') { - if (*bp == '"') { - bp++; - break; - } - if (*bp == '\\' && bp[1] == '\n') { - ip->lineno++; - copy_directive = 1; - bp++; - } - bp++; - } - break; - } - /* Fall through. */ - case '\'': - bp = skip_quoted_string (bp - 1, limit, ip->lineno, &ip->lineno, ©_directive, &unterminated); - /* Don't bother calling the directive if we already got an error - message due to unterminated string. Skip everything and pretend - we called the directive. */ - if (unterminated) { - if (traditional) { - /* Traditional preprocessing permits unterminated strings. */ - ip->bufp = bp; - goto endloop1; - } - ip->bufp = bp; - return 1; - } - break; - - /* <...> is special for #include. */ - case '<': - if (! IS_INCLUDE_DIRECTIVE_TYPE (kt->type)) - break; - while (bp < limit && *bp != '>' && *bp != '\n') { - if (*bp == '\\' && bp[1] == '\n') { - ip->lineno++; - copy_directive = 1; - bp++; - } - bp++; - } - break; - - case '/': - if (*bp == '\\') - newline_fix (bp); - if (*bp == '*' - || (cplusplus_comments && *bp == '/')) { - U_CHAR *obp = bp - 1; - ip->bufp = bp + 1; - skip_to_end_of_comment (ip, &ip->lineno, 0); - bp = ip->bufp; - /* No need to copy the directive because of a comment at the end; - just don't include the comment in the directive. */ - if (!put_out_comments) { - U_CHAR *p; - for (p = bp; *p == ' ' || *p == '\t'; p++) - continue; - if (*p == '\n') { - bp = obp; - goto endloop1; - } - } - /* Don't remove the comments if -traditional. */ - if (! keep_comments) - copy_directive++; - } - break; - - case '\f': - case '\r': - case '\v': - if (pedantic) - pedwarn_strange_white_space (c); - break; - - case '\n': - --bp; /* Point to the newline */ - ip->bufp = bp; - goto endloop1; - } - } - ip->bufp = bp; - - endloop1: - resume_p = ip->bufp; - /* BP is the end of the directive. - RESUME_P is the next interesting data after the directive. - A comment may come between. */ - - /* If a directive should be copied through, and -C was given, - pass it through before removing comments. */ - if (!no_output && put_out_comments - && ((kt->type == T_DEFINE || kt->type == T_UNDEF) - ? dump_macros == dump_definitions - : IS_INCLUDE_DIRECTIVE_TYPE (kt->type) ? dump_includes - : kt->type == T_PRAGMA)) { - int len; - - /* Output directive name. */ - check_expand (op, kt->length + 2); - /* Make sure # is at the start of a line */ - if (op->bufp > op->buf && op->bufp[-1] != '\n') { - op->lineno++; - *op->bufp++ = '\n'; - } - *op->bufp++ = '#'; - bcopy (kt->name, op->bufp, kt->length); - op->bufp += kt->length; - - /* Output arguments. */ - len = (bp - buf); - check_expand (op, len); - bcopy (buf, (char *) op->bufp, len); - op->bufp += len; - /* Take account of any (escaped) newlines just output. */ - while (--len >= 0) - if (buf[len] == '\n') - op->lineno++; - - already_output = &junk; - } /* Don't we need a newline or #line? */ - - if (copy_directive) { - register U_CHAR *xp = buf; - /* Need to copy entire directive into temp buffer before dispatching */ - - /* room for directive plus some slop */ - cp = (U_CHAR *) alloca (2 * (bp - buf) + 5); - buf = cp; - - /* Copy to the new buffer, deleting comments - and backslash-newlines (and whitespace surrounding the latter - if outside of char and string constants). */ - - while (xp < bp) { - register U_CHAR c = *xp++; - *cp++ = c; - - switch (c) { - case '\n': - abort (); /* A bare newline should never part of the line. */ - break; - - /* <...> is special for #include. */ - case '<': - if (! IS_INCLUDE_DIRECTIVE_TYPE (kt->type)) - break; - while (xp < bp && c != '>') { - c = *xp++; - if (c == '\\' && xp < bp && *xp == '\n') - xp++; - else - *cp++ = c; - } - break; - - case '\\': - if (*xp == '\n') { - xp++; - cp--; - if (cp != buf && is_hor_space[cp[-1]]) { - while (cp - 1 != buf && is_hor_space[cp[-2]]) - cp--; - SKIP_WHITE_SPACE (xp); - } else if (is_hor_space[*xp]) { - *cp++ = *xp++; - SKIP_WHITE_SPACE (xp); - } - } else if (traditional && xp < bp) { - *cp++ = *xp++; - } - break; - - case '\'': - case '\"': - { - int backslash_newlines_p = 0; - - register const U_CHAR *bp1 - = skip_quoted_string (xp - 1, bp, ip->lineno, - NULL_PTR, &backslash_newlines_p, - NULL_PTR); - if (backslash_newlines_p) - while (xp != bp1) - { - /* With something like: - - #define X "a\ - b" - - we should still remove the backslash-newline - pair as part of phase two. */ - if (xp[0] == '\\' && xp[1] == '\n') - xp += 2; - else - *cp++ = *xp++; - } - else - /* This is the same as the loop above, but taking - advantage of the fact that we know there are no - backslash-newline pairs. */ - while (xp != bp1) - *cp++ = *xp++; - } - break; - - case '/': - if (*xp == '*' - || (cplusplus_comments && *xp == '/')) { - ip->bufp = xp + 1; - /* If we already copied the directive through, - already_output != 0 prevents outputting comment now. */ - skip_to_end_of_comment (ip, already_output, 0); - if (keep_comments) - while (xp != ip->bufp) - *cp++ = *xp++; - /* Delete or replace the slash. */ - else if (traditional) - cp--; - else - cp[-1] = ' '; - xp = ip->bufp; - } - } - } - - /* Null-terminate the copy. */ - - *cp = 0; - } else - cp = bp; - - ip->bufp = resume_p; - - /* Some directives should be written out for cc1 to process, - just as if they were not defined. And sometimes we're copying - directives through. */ - - if (!no_output && already_output == 0 - && ((kt->type == T_DEFINE || kt->type == T_UNDEF) - ? (int) dump_names <= (int) dump_macros - : IS_INCLUDE_DIRECTIVE_TYPE (kt->type) ? dump_includes - : kt->type == T_PRAGMA)) { - int len; - - /* Output directive name. */ - check_expand (op, kt->length + 1); - *op->bufp++ = '#'; - bcopy (kt->name, (char *) op->bufp, kt->length); - op->bufp += kt->length; - - if (kt->type == T_DEFINE && dump_macros == dump_names) { - /* Output `#define name' only. */ - U_CHAR *xp = buf; - U_CHAR *yp; - SKIP_WHITE_SPACE (xp); - yp = xp; - while (is_idchar[*xp]) xp++; - len = (xp - yp); - check_expand (op, len + 1); - *op->bufp++ = ' '; - bcopy (yp, (char *) op->bufp, len); - } else { - /* Output entire directive. */ - len = (cp - buf); - check_expand (op, len); - bcopy (buf, (char *) op->bufp, len); - } - op->bufp += len; - } - - /* Call the appropriate directive handler. buf now points to - either the appropriate place in the input buffer, or to - the temp buffer if it was necessary to make one. cp - points to the first char after the contents of the (possibly - copied) directive, in either case. */ - (*kt->func) (buf, cp, op, kt); - check_expand (op, ip->length - (ip->bufp - ip->buf)); - - return 1; - } - } - - /* It is deliberate that we don't warn about undefined directives. - That is the responsibility of cc1. */ - return 0; -} - -static struct tm * -timestamp () -{ - static struct tm tmbuf; - if (! tmbuf.tm_mday) { - time_t t = time ((time_t *) 0); - struct tm *tm = localtime (&t); - if (tm) - tmbuf = *tm; - else { - /* Use 0000-01-01 00:00:00 if local time is not available. */ - tmbuf.tm_year = -1900; - tmbuf.tm_mday = 1; - } - } - return &tmbuf; -} - -static const char * const monthnames[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", -}; - -/* - * expand things like __FILE__. Place the expansion into the output - * buffer *without* rescanning. - */ - -static void -special_symbol (hp, op) - HASHNODE *hp; - FILE_BUF *op; -{ - const char *buf; - int i, len; - int true_indepth; - FILE_BUF *ip = NULL; - struct tm *timebuf; - - int paren = 0; /* For special `defined' keyword */ - - if (pcp_outfile && pcp_inside_if - && hp->type != T_SPEC_DEFINED && hp->type != T_CONST) - error ("Predefined macro `%s' used inside `#if' during precompilation", - hp->name); - - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) { - ip = &instack[i]; - break; - } - if (ip == NULL) { - error ("cccp error: not in any file?!"); - return; /* the show must go on */ - } - - switch (hp->type) { - case T_FILE: - case T_BASE_FILE: - { - FILE_BUF *p = hp->type == T_FILE ? ip : &instack[0]; - const char *string = p->nominal_fname; - - if (string) - { - size_t string_len = p->nominal_fname_len; - char *newbuf = (char *) alloca (3 + 4 * string_len); - quote_string (newbuf, string, string_len); - buf = newbuf; - } - else - buf = "\"\""; - - break; - } - - case T_INCLUDE_LEVEL: - { - /* Eight bytes ought to be more than enough */ - char *newbuf = (char *) alloca (8); - true_indepth = 0; - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) - true_indepth++; - sprintf (newbuf, "%d", true_indepth - 1); - buf = newbuf; - } - break; - - case T_VERSION: - { - char *newbuf = (char *) alloca (3 + strlen (version_string)); - sprintf (newbuf, "\"%s\"", version_string); - buf = newbuf; - } - break; - -#ifndef NO_BUILTIN_SIZE_TYPE - case T_SIZE_TYPE: - buf = SIZE_TYPE; - break; -#endif - -#ifndef NO_BUILTIN_PTRDIFF_TYPE - case T_PTRDIFF_TYPE: - buf = PTRDIFF_TYPE; - break; -#endif - -#ifndef NO_BUILTIN_WCHAR_TYPE - case T_WCHAR_TYPE: - buf = wchar_type; - break; -#endif - - case T_USER_LABEL_PREFIX_TYPE: - buf = user_label_prefix; - break; - - case T_REGISTER_PREFIX_TYPE: - buf = REGISTER_PREFIX; - break; - - case T_IMMEDIATE_PREFIX_TYPE: - buf = IMMEDIATE_PREFIX; - break; - - case T_CONST: - buf = hp->value.cpval; -#ifdef STDC_0_IN_SYSTEM_HEADERS - if (ip->system_header_p - && hp->length == 8 && bcmp (hp->name, "__STDC__", 8) == 0 - && !lookup ((const U_CHAR *) "__STRICT_ANSI__", -1, -1)) - buf = "0"; -#endif - if (pcp_inside_if && pcp_outfile) - /* Output a precondition for this macro use */ - fprintf (pcp_outfile, "#define %s %s\n", hp->name, buf); - break; - - case T_SPECLINE: - { - char *newbuf = (char *) alloca (10); - sprintf (newbuf, "%d", ip->lineno); - buf = newbuf; - } - break; - - case T_DATE: - case T_TIME: - { - char *newbuf = (char *) alloca (20); - timebuf = timestamp (); - if (hp->type == T_DATE) - sprintf (newbuf, "\"%s %2d %4d\"", monthnames[timebuf->tm_mon], - timebuf->tm_mday, timebuf->tm_year + 1900); - else - sprintf (newbuf, "\"%02d:%02d:%02d\"", timebuf->tm_hour, - timebuf->tm_min, timebuf->tm_sec); - buf = newbuf; - } - break; - - case T_SPEC_DEFINED: - buf = " 0 "; /* Assume symbol is not defined */ - ip = &instack[indepth]; - SKIP_WHITE_SPACE (ip->bufp); - if (*ip->bufp == '(') { - paren++; - ip->bufp++; /* Skip over the paren */ - SKIP_WHITE_SPACE (ip->bufp); - } - - if (!is_idstart[*ip->bufp]) - goto oops; - if (ip->bufp[0] == 'L' && (ip->bufp[1] == '\'' || ip->bufp[1] == '"')) - goto oops; - if ((hp = lookup (ip->bufp, -1, -1))) { - if (pcp_outfile && pcp_inside_if - && (hp->type == T_CONST - || (hp->type == T_MACRO && hp->value.defn->predefined))) - /* Output a precondition for this macro use. */ - fprintf (pcp_outfile, "#define %s\n", hp->name); - if (hp->type == T_POISON) { - error("attempt to use poisoned `%s'.", hp->name); - buf = " 0 "; - } else { - buf = " 1 "; - } - } - else - if (pcp_outfile && pcp_inside_if) { - /* Output a precondition for this macro use */ - U_CHAR *cp = ip->bufp; - fprintf (pcp_outfile, "#undef "); - while (is_idchar[*cp]) /* Ick! */ - fputc (*cp++, pcp_outfile); - putc ('\n', pcp_outfile); - } - while (is_idchar[*ip->bufp]) - ++ip->bufp; - SKIP_WHITE_SPACE (ip->bufp); - if (paren) { - if (*ip->bufp != ')') - goto oops; - ++ip->bufp; - } - break; - - case T_POISON: - error("attempt to use poisoned `%s'.", hp->name); - buf = " 0 "; /* Consider poisoned symbol to not be defined */ - break; - -oops: - - error ("`defined' without an identifier"); - break; - - default: - error ("cccp error: invalid special hash type"); /* time for gdb */ - abort (); - } - len = strlen (buf); - check_expand (op, len); - bcopy (buf, (char *) op->bufp, len); - op->bufp += len; - - return; -} - - -/* Routines to handle #directives */ - -/* Handle #include and #import. - This function expects to see "fname" or on the input. */ - -static int -do_include (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword; -{ - const U_CHAR *importing = - keyword->type == T_IMPORT ? (const U_CHAR *) "" : (const U_CHAR *) 0; - int skip_dirs = (keyword->type == T_INCLUDE_NEXT); - static int import_warning = 0; - char *fname; /* Dynamically allocated fname buffer */ - char *pcftry; - char *pcfname; - char *fbeg, *fend; /* Beginning and end of fname */ - U_CHAR *fin; - - struct file_name_list *search_start = include; /* Chain of dirs to search */ - struct file_name_list *dsp; /* First in chain, if #include "..." */ - struct file_name_list *searchptr = 0; - size_t flen; - - int f = -3; /* file number */ - struct include_file *inc = 0; - - int retried = 0; /* Have already tried macro - expanding the include line*/ - int angle_brackets = 0; /* 0 for "...", 1 for <...> */ -#ifdef VMS - int vaxc_include = 0; /* 1 for token without punctuation */ -#endif - int pcf = -1; - char *pcfbuf; - const char *pcfbuflimit; - int pcfnum; - - if (pedantic && !instack[indepth].system_header_p) - { - if (importing) - pedwarn ("ANSI C does not allow `#import'"); - if (skip_dirs) - pedwarn ("ANSI C does not allow `#include_next'"); - } - - if (importing && warn_import && !inhibit_warnings - && !instack[indepth].system_header_p && !import_warning) { - import_warning = 1; - warning ("using `#import' is not recommended"); - notice ("The fact that a certain header file need not be processed more than once\n\ -should be indicated in the header file, not where it is used.\n\ -The best way to do this is with a conditional of this form:\n\ -\n\ - #ifndef _FOO_H_INCLUDED\n\ - #define _FOO_H_INCLUDED\n\ - ... ...\n\ - #endif /* Not _FOO_H_INCLUDED */\n\ -\n\ -Then users can use `#include' any number of times.\n\ -GNU C automatically avoids processing the file more than once\n\ -when it is equipped with such a conditional.\n"); - } - -get_filename: - - fin = buf; - SKIP_WHITE_SPACE (fin); - /* Discard trailing whitespace so we can easily see - if we have parsed all the significant chars we were given. */ - while (limit != fin && is_hor_space[limit[-1]]) limit--; - fbeg = fend = (char *) alloca (limit - fin); - - switch (*fin++) { - case '\"': - { - FILE_BUF *fp; - /* Copy the operand text, concatenating the strings. */ - { - for (;;) { - for (;;) { - if (fin == limit) - goto invalid_include_file_name; - *fend = *fin++; - if (*fend == '"') - break; - fend++; - } - if (fin == limit) - break; - /* If not at the end, there had better be another string. */ - /* Skip just horiz space, and don't go past limit. */ - while (fin != limit && is_hor_space[*fin]) fin++; - if (fin != limit && *fin == '\"') - fin++; - else - goto fail; - } - } - - /* We have "filename". Figure out directory this source - file is coming from and put it on the front of the list. */ - - /* If -I- was specified, don't search current dir, only spec'd ones. */ - if (ignore_srcdir) break; - - for (fp = &instack[indepth]; fp >= instack; fp--) - { - int n; - - if ((fp->nominal_fname) != NULL) { - char *nam; - /* Found a named file. Figure out dir of the file, - and put it in front of the search list. */ - dsp = ((struct file_name_list *) - alloca (sizeof (struct file_name_list) - + fp->nominal_fname_len)); - strcpy (dsp->fname, fp->nominal_fname); - simplify_filename (dsp->fname); - nam = base_name (dsp->fname); - *nam = 0; -#ifdef VMS - /* for hack_vms_include_specification(), a local - dir specification must start with "./" on VMS. */ - if (nam == dsp->fname) - { - *nam++ = '.'; - *nam++ = '/'; - *nam = 0; - } -#endif - /* But for efficiency's sake, do not insert the dir - if it matches the search list's first dir. */ - dsp->next = search_start; - if (!search_start || strcmp (dsp->fname, search_start->fname)) { - search_start = dsp; - n = nam - dsp->fname; - if (n + INCLUDE_LEN_FUDGE > max_include_len) - max_include_len = n + INCLUDE_LEN_FUDGE; - } - dsp[0].got_name_map = 0; - break; - } - } - break; - } - - case '<': - while (fin != limit && *fin != '>') - *fend++ = *fin++; - if (*fin == '>' && fin + 1 == limit) { - angle_brackets = 1; - /* If -I-, start with the first -I dir after the -I-. */ - search_start = first_bracket_include; - break; - } - goto fail; - - default: -#ifdef VMS - /* - * Support '#include xyz' like VAX-C to allow for easy use of all the - * decwindow include files. It defaults to '#include ' (so the - * code from case '<' is repeated here) and generates a warning. - * (Note: macro expansion of `xyz' takes precedence.) - */ - /* Note: The argument of ISALPHA() can be evaluated twice, so do - the pre-decrement outside of the macro. */ - if (retried && (--fin, ISALPHA(*(U_CHAR *) (fin)))) { - while (fin != limit && (!ISSPACE(*fin))) - *fend++ = *fin++; - warning ("VAX-C-style include specification found, use '#include ' !"); - vaxc_include = 1; - if (fin == limit) { - angle_brackets = 1; - /* If -I-, start with the first -I dir after the -I-. */ - search_start = first_bracket_include; - break; - } - } -#endif - - fail: - if (! retried) { - /* Expand buffer and then remove any newline markers. - We can't just tell expand_to_temp_buffer to omit the markers, - since it would put extra spaces in include file names. */ - U_CHAR *src; - int errors_before_expansion = errors; - FILE_BUF trybuf; - - trybuf = expand_to_temp_buffer (buf, limit, 1, 0); - if (errors != errors_before_expansion) { - free (trybuf.buf); - goto invalid_include_file_name; - } - src = trybuf.buf; - buf = (U_CHAR *) alloca (trybuf.bufp - trybuf.buf + 1); - limit = buf; - while (src != trybuf.bufp) { - switch ((*limit++ = *src++)) { - case '\n': - limit--; - src++; - break; - - case '\'': - case '\"': - { - const U_CHAR *src1 = skip_quoted_string (src - 1, trybuf.bufp, 0, - NULL_PTR, NULL_PTR, NULL_PTR); - while (src != src1) - *limit++ = *src++; - } - break; - } - } - *limit = 0; - free (trybuf.buf); - retried = 1; - goto get_filename; - } - - invalid_include_file_name: - error ("`#%s' expects \"FILENAME\" or ", keyword->name); - return 0; - } - - /* For #include_next, skip in the search path - past the dir in which the containing file was found. */ - if (skip_dirs) { - FILE_BUF *fp; - for (fp = &instack[indepth]; fp >= instack; fp--) - if (fp->fname != NULL) { - /* fp->dir is null if the containing file was specified - with an absolute file name. In that case, don't skip anything. */ - if (fp->dir) - search_start = fp->dir->next; - break; - } - } - - *fend = 0; - flen = simplify_filename (fbeg); - - if (flen == 0) - { - error ("empty file name in `#%s'", keyword->name); - return 0; - } - - /* Allocate this permanently, because it gets stored in the definitions - of macros. */ - fname = xmalloc (max_include_len + flen + 1); - /* + 1 above for terminating null. */ - - system_include_depth += angle_brackets; - - /* If specified file name is absolute, just open it. */ - - if (absolute_filename (fbeg)) { - strcpy (fname, fbeg); - f = open_include_file (fname, NULL_PTR, importing, &inc); - } else { - - struct bypass_dir { - struct bypass_dir *next; - char *fname; - struct file_name_list *searchptr; - } **bypass_slot = 0; - - /* Search directory path, trying to open the file. - Copy each filename tried into FNAME. */ - - for (searchptr = search_start; searchptr; searchptr = searchptr->next) { - - if (searchptr == first_bracket_include) { - /* Go to bypass directory if we know we've seen this file before. */ - static struct bypass_dir *bypass_hashtab[INCLUDE_HASHSIZE]; - struct bypass_dir *p; - bypass_slot = &bypass_hashtab[hashf ((U_CHAR *) fbeg, flen, - INCLUDE_HASHSIZE)]; - for (p = *bypass_slot; p; p = p->next) - if (!strcmp (fbeg, p->fname)) { - searchptr = p->searchptr; - bypass_slot = 0; - break; - } - } - -#ifdef VMS - /* Change this 1/2 Unix 1/2 VMS file specification into a - full VMS file specification */ - if (searchptr->fname[0]) - { - strcpy (fname, searchptr->fname); - if (fname[strlen (fname) - 1] == ':') - { - char *slashp; - slashp = strchr (fbeg, '/'); - - /* start at root-dir of logical device if no path given. */ - if (slashp == 0) - strcat (fname, "[000000]"); - } - strcat (fname, fbeg); - - /* Fix up the filename */ - hack_vms_include_specification (fname, vaxc_include); - } - else - { - /* This is a normal VMS filespec, so use it unchanged. */ - strcpy (fname, fbeg); - /* if it's '#include filename', add the missing .h */ - if (vaxc_include && index(fname,'.')==NULL) - strcat (fname, ".h"); - } -#else - strcpy (fname, searchptr->fname); - strcat (fname, fbeg); -#endif /* VMS */ - f = open_include_file (fname, searchptr, importing, &inc); - if (f != -1) { - if (bypass_slot && searchptr != first_bracket_include) { - /* This is the first time we found this include file, - and we found it after first_bracket_include. - Record its location so that we can bypass to here next time. */ - struct bypass_dir *p - = (struct bypass_dir *) xmalloc (sizeof (struct bypass_dir)); - p->next = *bypass_slot; - p->fname = fname + strlen (searchptr->fname); - p->searchptr = searchptr; - *bypass_slot = p; - } - break; - } -#ifdef VMS - /* Our VMS hacks can produce invalid filespecs, so don't worry - about errors other than EACCES. */ - if (errno == EACCES) - break; -#else - if (errno != ENOENT && errno != ENOTDIR) - break; -#endif - } - } - - - if (f < 0) { - - if (f == -2) { - /* The file was already included. */ - - /* If generating dependencies and -MG was specified, we assume missing - files are leaf files, living in the same directory as the source file - or other similar place; these missing files may be generated from - other files and may not exist yet (eg: y.tab.h). */ - } else if (print_deps_missing_files - && (system_include_depth != 0) < print_deps) - { - /* If it was requested as a system header file, - then assume it belongs in the first place to look for such. */ - if (angle_brackets) - { - if (search_start) { - char *p = (char *) alloca (strlen (search_start->fname) - + strlen (fbeg) + 1); - strcpy (p, search_start->fname); - strcat (p, fbeg); - deps_output (p, ' '); - } - } - else - { - /* Otherwise, omit the directory, as if the file existed - in the directory with the source. */ - deps_output (fbeg, ' '); - } - } - /* If -M was specified, and this header file won't be added to the - dependency list, then don't count this as an error, because we can - still produce correct output. Otherwise, we can't produce correct - output, because there may be dependencies we need inside the missing - file, and we don't know what directory this missing file exists in. */ - else if (0 < print_deps && print_deps <= (system_include_depth != 0)) - warning ("No include path in which to find %s", fbeg); - else if (f != -3) - error_from_errno (fbeg); - else - error ("No include path in which to find %s", fbeg); - - } else { - - /* Actually process the file. */ - - pcftry = (char *) alloca (strlen (fname) + 30); - pcfbuf = 0; - pcfnum = 0; - - if (!no_precomp) - { - do { - sprintf (pcftry, "%s%d", fname, pcfnum++); - - pcf = open (pcftry, O_RDONLY, 0666); - if (pcf != -1) - { - struct stat s; - - if (fstat (pcf, &s) != 0) - pfatal_with_name (pcftry); - if (! INO_T_EQ (inc->st.st_ino, s.st_ino) - || inc->st.st_dev != s.st_dev) - { - pcfbuf = check_precompiled (pcf, &s, fname, &pcfbuflimit); - /* Don't need it any more. */ - close (pcf); - } - else - { - /* Don't need it at all. */ - close (pcf); - break; - } - } - } while (pcf != -1 && !pcfbuf); - } - - /* Actually process the file */ - if (pcfbuf) { - pcfname = xstrdup (pcftry); - pcfinclude ((U_CHAR *) pcfbuf, (U_CHAR *) fname, op); - } - else - finclude (f, inc, op, is_system_include (fname), searchptr); - } - - system_include_depth -= angle_brackets; - - return 0; -} - -/* Return nonzero if the given FILENAME is an absolute pathname which - designates a file within one of the known "system" include file - directories. We assume here that if the given FILENAME looks like - it is the name of a file which resides either directly in a "system" - include file directory, or within any subdirectory thereof, then the - given file must be a "system" include file. This function tells us - if we should suppress pedantic errors/warnings for the given FILENAME. - - The value is 2 if the file is a C-language system header file - for which C++ should (on most systems) assume `extern "C"'. */ - -static int -is_system_include (filename) - register const char *filename; -{ - struct file_name_list *searchptr; - - for (searchptr = first_system_include; searchptr; - searchptr = searchptr->next) - if (! strncmp (searchptr->fname, filename, strlen (searchptr->fname))) - return searchptr->c_system_include_path + 1; - return 0; -} - -/* Yield the non-directory suffix of a file name. */ - -static char * -base_name (fname) - const char *fname; -{ - const char *s = fname; - const char *p; -#if defined (__MSDOS__) || defined (_WIN32) - if (ISALPHA (s[0]) && s[1] == ':') s += 2; -#endif -#ifdef VMS - if ((p = rindex (s, ':'))) s = p + 1; /* Skip device. */ - if ((p = rindex (s, ']'))) s = p + 1; /* Skip directory. */ - if ((p = rindex (s, '>'))) s = p + 1; /* Skip alternate (int'n'l) dir. */ - if (s != fname) - return (char *) s; -#endif - if ((p = rindex (s, '/'))) s = p + 1; -#ifdef DIR_SEPARATOR - if ((p = rindex (s, DIR_SEPARATOR))) s = p + 1; -#endif - return (char *) s; -} - -/* Yield nonzero if FILENAME is absolute (i.e. not relative). */ - -static int -absolute_filename (filename) - const char *filename; -{ -#if defined (__MSDOS__) \ - || (defined (_WIN32) && !defined (__CYGWIN__) && !defined (_UWIN)) - if (ISALPHA (filename[0]) && filename[1] == ':') filename += 2; -#endif -#if defined (__CYGWIN__) - /* At present, any path that begins with a drive spec is absolute. */ - if (ISALPHA (filename[0]) && filename[1] == ':') return 1; -#endif -#ifdef VMS - if (index (filename, ':') != 0) return 1; -#endif - if (filename[0] == '/') return 1; -#ifdef DIR_SEPARATOR - if (filename[0] == DIR_SEPARATOR) return 1; -#endif - return 0; -} - -/* Returns whether or not a given character is a directory separator. - Used by simplify_filename. */ -static inline int is_dir_separator PARAMS ((int)); - -static inline -int -is_dir_separator(ch) - char ch; -{ - return (ch == DIR_SEPARATOR) -#if defined (DIR_SEPARATOR_2) - || (ch == DIR_SEPARATOR_2) -#endif - ; -} - -/* Remove unnecessary characters from FILENAME in place, - to avoid unnecessary filename aliasing. - Return the length of the resulting string. - - Do only the simplifications allowed by Posix. - It is OK to miss simplifications on non-Posix hosts, - since this merely leads to suboptimal results. */ - -static size_t -simplify_filename (filename) - char *filename; -{ - register char *from = filename; - register char *to = filename; - char *to0; - - /* Remove redundant initial /s. */ - if (is_dir_separator (*from)) - { - *to++ = DIR_SEPARATOR; - if (is_dir_separator (*++from)) - { - if (is_dir_separator (*++from)) - { - /* 3 or more initial /s are equivalent to 1 /. */ - while (is_dir_separator (*++from)) - continue; - } - else - { - /* On some hosts // differs from /; Posix allows this. */ - *to++ = DIR_SEPARATOR; - } - } - } - - to0 = to; - - for (;;) - { -#ifndef VMS - if (from[0] == '.' && from[1] == '/') - from += 2; - else -#endif - { - /* Copy this component and trailing DIR_SEPARATOR, if any. */ - while (!is_dir_separator (*to++ = *from++)) - { - if (!to[-1]) - { - /* Trim . component at end of nonempty name. */ - to -= filename <= to - 3 && to[-3] == DIR_SEPARATOR && to[-2] == '.'; - - /* Trim unnecessary trailing /s. */ - while (to0 < --to && to[-1] == DIR_SEPARATOR) - continue; - - *to = 0; - return to - filename; - } - } -#if defined(DIR_SEPARATOR_2) - /* Simplify to one directory separator. */ - to[-1] = DIR_SEPARATOR; -#endif - } - - /* Skip /s after a /. */ - while (is_dir_separator (*from)) - from++; - } -} - -/* The file_name_map structure holds a mapping of file names for a - particular directory. This mapping is read from the file named - FILE_NAME_MAP_FILE in that directory. Such a file can be used to - map filenames on a file system with severe filename restrictions, - such as DOS. The format of the file name map file is just a series - of lines with two tokens on each line. The first token is the name - to map, and the second token is the actual name to use. */ - -struct file_name_map -{ - struct file_name_map *map_next; - char *map_from; - char *map_to; -}; - -#define FILE_NAME_MAP_FILE "header.gcc" - -/* Read a space delimited string of unlimited length from a stdio - file. */ - -static char * -read_filename_string (ch, f) - int ch; - FILE *f; -{ - char *alloc, *set; - int len; - - len = 20; - set = alloc = xmalloc (len + 1); - if (! is_space[ch]) - { - *set++ = ch; - while ((ch = getc (f)) != EOF && ! is_space[ch]) - { - if (set - alloc == len) - { - len *= 2; - alloc = xrealloc (alloc, len + 1); - set = alloc + len / 2; - } - *set++ = ch; - } - } - *set = '\0'; - ungetc (ch, f); - return alloc; -} - -/* Read the file name map file for DIRNAME. - If DIRNAME is empty, read the map file for the working directory; - otherwise DIRNAME must end in '/'. */ - -static struct file_name_map * -read_name_map (dirname) - const char *dirname; -{ - /* This structure holds a linked list of file name maps, one per - directory. */ - struct file_name_map_list - { - struct file_name_map_list *map_list_next; - char *map_list_name; - struct file_name_map *map_list_map; - }; - static struct file_name_map_list *map_list; - register struct file_name_map_list *map_list_ptr; - char *name; - FILE *f; - size_t dirlen; - - for (map_list_ptr = map_list; map_list_ptr; - map_list_ptr = map_list_ptr->map_list_next) - if (! strcmp (map_list_ptr->map_list_name, dirname)) - return map_list_ptr->map_list_map; - - map_list_ptr = ((struct file_name_map_list *) - xmalloc (sizeof (struct file_name_map_list))); - map_list_ptr->map_list_name = xstrdup (dirname); - map_list_ptr->map_list_map = NULL; - - dirlen = strlen (dirname); - name = (char *) alloca (dirlen + strlen (FILE_NAME_MAP_FILE) + 1); - strcpy (name, dirname); - strcat (name, FILE_NAME_MAP_FILE); - f = fopen (name, "r"); - if (!f) - map_list_ptr->map_list_map = NULL; - else - { - int ch; - - while ((ch = getc (f)) != EOF) - { - char *from, *to; - struct file_name_map *ptr; - size_t tolen; - - if (is_space[ch]) - continue; - from = read_filename_string (ch, f); - while ((ch = getc (f)) != EOF && is_hor_space[ch]) - ; - to = read_filename_string (ch, f); - - simplify_filename (from); - tolen = simplify_filename (to); - - ptr = ((struct file_name_map *) - xmalloc (sizeof (struct file_name_map))); - ptr->map_from = from; - - /* Make the real filename absolute. */ - if (absolute_filename (to)) - ptr->map_to = to; - else - { - ptr->map_to = xmalloc (dirlen + tolen + 1); - strcpy (ptr->map_to, dirname); - strcat (ptr->map_to, to); - free (to); - } - - ptr->map_next = map_list_ptr->map_list_map; - map_list_ptr->map_list_map = ptr; - - while ((ch = getc (f)) != '\n') - if (ch == EOF) - break; - } - fclose (f); - } - - map_list_ptr->map_list_next = map_list; - map_list = map_list_ptr; - - return map_list_ptr->map_list_map; -} - -/* Try to open include file FILENAME. SEARCHPTR is the directory - being tried from the include file search path. - IMPORTING is "" if we are importing, null otherwise. - Return -2 if found, either a matching name or a matching inode. - Otherwise, open the file and return a file descriptor if successful - or -1 if unsuccessful. - Unless unsuccessful, put a descriptor of the included file into *PINC. - This function maps filenames on file systems based on information read by - read_name_map. */ - -static int -open_include_file (filename, searchptr, importing, pinc) - char *filename; - struct file_name_list *searchptr; - const U_CHAR *importing; - struct include_file **pinc; -{ - char *fname = remap ? remap_include_file (filename, searchptr) : filename; - int fd = -2; - - /* Look up FNAME in include_hashtab. */ - struct include_file **phead = &include_hashtab[hashf ((U_CHAR *) fname, - strlen (fname), - INCLUDE_HASHSIZE)]; - struct include_file *inc, *head = *phead; - for (inc = head; inc; inc = inc->next) - if (!strcmp (fname, inc->fname)) - break; - - if (!inc - || ! inc->control_macro - || (inc->control_macro[0] && ! lookup (inc->control_macro, -1, -1))) { - - fd = open (fname, O_RDONLY, 0); - - if (fd < 0) - { -#ifdef VMS - /* if #include fails, try again with hacked spec. */ - if (!hack_vms_include_specification (fname, 0)) - return fd; - fd = open (fname, O_RDONLY, 0); - if (fd < 0) -#endif - return fd; - } - - if (!inc) { - /* FNAME was not in include_hashtab; insert a new entry. */ - inc = (struct include_file *) xmalloc (sizeof (struct include_file)); - inc->next = head; - inc->fname = fname; - inc->control_macro = 0; - inc->deps_output = 0; - if (fstat (fd, &inc->st) != 0) - pfatal_with_name (fname); - *phead = inc; - - /* Look for another file with the same inode and device. */ - if (lookup_ino_include (inc) - && inc->control_macro - && (!inc->control_macro[0] || lookup (inc->control_macro, -1, -1))) { - close (fd); - fd = -2; - } - } - - /* For -M, add this file to the dependencies. */ - if (! inc->deps_output && (system_include_depth != 0) < print_deps) { - inc->deps_output = 1; - deps_output (fname, ' '); - } - - /* Handle -H option. */ - if (print_include_names) - fprintf (stderr, "%*s%s\n", indepth, "", fname); - } - - if (importing) - inc->control_macro = importing; - - *pinc = inc; - return fd; -} - -/* Return the remapped name of the include file FILENAME. - SEARCHPTR is the directory being tried from the include file path. */ - -static char * -remap_include_file (filename, searchptr) - char *filename; - struct file_name_list *searchptr; -{ - register struct file_name_map *map; - register const char *from; - - if (searchptr) - { - if (! searchptr->got_name_map) - { - searchptr->name_map = read_name_map (searchptr->fname); - searchptr->got_name_map = 1; - } - - /* Check the mapping for the directory we are using. */ - from = filename + strlen (searchptr->fname); - for (map = searchptr->name_map; map; map = map->map_next) - if (! strcmp (map->map_from, from)) - return map->map_to; - } - - from = base_name (filename); - - if (from != filename || !searchptr) - { - /* Try to find a mapping file for the particular directory we are - looking in. Thus #include will look up sys/types.h - in /usr/include/header.gcc and look up types.h in - /usr/include/sys/header.gcc. */ - - char *dir = (char *) alloca (from - filename + 1); - bcopy (filename, dir, from - filename); - dir[from - filename] = '\0'; - - for (map = read_name_map (dir); map; map = map->map_next) - if (! strcmp (map->map_from, from)) - return map->map_to; - } - - return filename; -} - -/* Insert INC into the include file table, hashed by device and inode number. - If a file with different name but same dev+ino was already in the table, - return 1 and set INC's control macro to the already-known macro. */ - -static int -lookup_ino_include (inc) - struct include_file *inc; -{ - int hash = ((unsigned) (inc->st.st_dev + INO_T_HASH (inc->st.st_ino)) - % INCLUDE_HASHSIZE); - struct include_file *i = include_ino_hashtab[hash]; - inc->next_ino = i; - include_ino_hashtab[hash] = inc; - - for (; i; i = i->next_ino) - if (INO_T_EQ (inc->st.st_ino, i->st.st_ino) - && inc->st.st_dev == i->st.st_dev) { - inc->control_macro = i->control_macro; - return 1; - } - - return 0; -} - -/* Process file descriptor F, which corresponds to include file INC, - with output to OP. - SYSTEM_HEADER_P is 1 if this file resides in any one of the known - "system" include directories (as decided by the `is_system_include' - function above). - DIRPTR is the link in the dir path through which this file was found, - or 0 if the file name was absolute. */ - -static void -finclude (f, inc, op, system_header_p, dirptr) - int f; - struct include_file *inc; - FILE_BUF *op; - int system_header_p; - struct file_name_list *dirptr; -{ - char *fname = inc->fname; - int i; - FILE_BUF *fp; /* For input stack frame */ - int missing_newline = 0; - - CHECK_DEPTH (return;); - - fp = &instack[indepth + 1]; - bzero ((char *) fp, sizeof (FILE_BUF)); - fp->nominal_fname = fp->fname = fname; - fp->nominal_fname_len = strlen (fname); - fp->inc = inc; - fp->length = 0; - fp->lineno = 1; - fp->if_stack = if_stack; - fp->system_header_p = system_header_p; - fp->dir = dirptr; - - if (S_ISREG (inc->st.st_mode)) { - size_t s = (size_t) inc->st.st_size; - if (s != inc->st.st_size || s + 2 < s) - memory_full (); - fp->buf = (U_CHAR *) xmalloc (s + 2); - fp->bufp = fp->buf; - - /* Read the file contents, knowing that s is an upper bound - on the number of bytes we can read. */ - fp->length = safe_read (f, (char *) fp->buf, s); - if (fp->length < 0) goto nope; - } - else if (S_ISDIR (inc->st.st_mode)) { - error ("directory `%s' specified in #include", fname); - close (f); - return; - } else { - /* Cannot count its file size before reading. - First read the entire file into heap and - copy them into buffer on stack. */ - - int bsize = 2000; - int st_size = 0; - - fp->buf = (U_CHAR *) xmalloc (bsize + 2); - - for (;;) { - i = safe_read (f, (char *) fp->buf + st_size, bsize - st_size); - if (i < 0) - goto nope; /* error! */ - st_size += i; - if (st_size != bsize) - break; /* End of file */ - bsize *= 2; - fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2); - } - fp->bufp = fp->buf; - fp->length = st_size; - } - - if ((fp->length > 0 && fp->buf[fp->length - 1] != '\n') - /* Backslash-newline at end is not good enough. */ - || (fp->length > 1 && fp->buf[fp->length - 2] == '\\')) { - fp->buf[fp->length++] = '\n'; - missing_newline = 1; - } - fp->buf[fp->length] = '\0'; - - /* Close descriptor now, so nesting does not use lots of descriptors. */ - close (f); - - /* Must do this before calling trigraph_pcp, so that the correct file name - will be printed in warning messages. */ - - indepth++; - input_file_stack_tick++; - - if (!no_trigraphs) - trigraph_pcp (fp); - - if (warn_white_space) - check_white_space (fp); - - output_line_directive (fp, op, 0, enter_file); - rescan (op, 0); - - if (missing_newline) - fp->lineno--; - - if (pedantic && missing_newline) - pedwarn ("file does not end in newline"); - - indepth--; - input_file_stack_tick++; - output_line_directive (&instack[indepth], op, 0, leave_file); - free (fp->buf); - return; - - nope: - - perror_with_name (fname); - close (f); - free (fp->buf); -} - -/* Record that inclusion of the include file INC - should be controlled by the macro named MACRO_NAME. - This means that trying to include the file again - will do something if that macro is defined. */ - -static void -record_control_macro (inc, macro_name) - struct include_file *inc; - const U_CHAR *macro_name; -{ - if (!inc->control_macro || inc->control_macro[0]) - inc->control_macro = macro_name; -} - -/* Load the specified precompiled header into core, and verify its - preconditions. PCF indicates the file descriptor to read, which must - be a regular file. *ST is its file status. - FNAME indicates the file name of the original header. - *LIMIT will be set to an address one past the end of the file. - If the preconditions of the file are not satisfied, the buffer is - freed and we return 0. If the preconditions are satisfied, return - the address of the buffer following the preconditions. The buffer, in - this case, should never be freed because various pieces of it will - be referred to until all precompiled strings are output at the end of - the run. */ - -static char * -check_precompiled (pcf, st, fname, limit) - int pcf; - struct stat *st; - const char *fname ATTRIBUTE_UNUSED; - const char **limit; -{ - int length = 0; - char *buf; - char *cp; - - if (pcp_outfile) - return 0; - - if (S_ISREG (st->st_mode)) - { - size_t s = (size_t) st->st_size; - if (s != st->st_size || s + 2 < s) - memory_full (); - buf = xmalloc (s + 2); - length = safe_read (pcf, buf, s); - if (length < 0) - goto nope; - } - else - abort (); - - if (length > 0 && buf[length-1] != '\n') - buf[length++] = '\n'; - buf[length] = '\0'; - - *limit = buf + length; - - /* File is in core. Check the preconditions. */ - if (!check_preconditions (buf)) - goto nope; - for (cp = buf; *cp; cp++) - ; -#ifdef DEBUG_PCP - fprintf (stderr, "Using preinclude %s\n", fname); -#endif - return cp + 1; - - nope: -#ifdef DEBUG_PCP - fprintf (stderr, "Cannot use preinclude %s\n", fname); -#endif - free (buf); - return 0; -} - -/* PREC (null terminated) points to the preconditions of a - precompiled header. These are a series of #define and #undef - lines which must match the current contents of the hash - table. */ - -static int -check_preconditions (prec) - const char *prec; -{ - MACRODEF mdef; - const char *lineend; - - while (*prec) { - lineend = index (prec, '\n'); - - if (*prec++ != '#') { - error ("Bad format encountered while reading precompiled file"); - return 0; - } - if (!strncmp (prec, "define", 6)) { - HASHNODE *hp; - - prec += 6; - mdef = create_definition ((const U_CHAR *) prec, - (const U_CHAR *) lineend, NULL_PTR); - - if (mdef.defn == 0) - abort (); - - if ((hp = lookup (mdef.symnam, mdef.symlen, -1)) == NULL - || (hp->type != T_MACRO && hp->type != T_CONST) - || (hp->type == T_MACRO - && !compare_defs (mdef.defn, hp->value.defn) - && (mdef.defn->length != 2 - || mdef.defn->expansion[0] != '\n' - || mdef.defn->expansion[1] != ' '))) - return 0; - } else if (!strncmp (prec, "undef", 5)) { - const char *name; - int len; - - prec += 5; - while (is_hor_space[(U_CHAR) *prec]) - prec++; - name = prec; - while (is_idchar[(U_CHAR) *prec]) - prec++; - len = prec - name; - - if (lookup ((const U_CHAR *) name, len, -1)) - return 0; - } else { - error ("Bad format encountered while reading precompiled file"); - return 0; - } - prec = lineend + 1; - } - /* They all passed successfully */ - return 1; -} - -/* Process the main body of a precompiled file. BUF points to the - string section of the file, following the preconditions. LIMIT is one - character past the end. NAME is the name of the file being read - in. OP is the main output buffer. */ - -static void -pcfinclude (buf, name, op) - U_CHAR *buf; - const U_CHAR *name; - FILE_BUF *op; -{ - FILE_BUF tmpbuf; - int nstrings; - U_CHAR *cp = buf; - - /* First in the file comes 4 bytes indicating the number of strings, */ - /* in network byte order. (MSB first). */ - nstrings = *cp++; - nstrings = (nstrings << 8) | *cp++; - nstrings = (nstrings << 8) | *cp++; - nstrings = (nstrings << 8) | *cp++; - - /* Looping over each string... */ - while (nstrings--) { - U_CHAR *string_start; - U_CHAR *endofthiskey; - STRINGDEF *str; - int nkeys; - - /* Each string starts with a STRINGDEF structure (str), followed */ - /* by the text of the string (string_start) */ - - /* First skip to a longword boundary */ - /* ??? Why a 4-byte boundary? On all machines? */ - /* NOTE: This works correctly even if size_t - is narrower than a pointer. - Do not try risky measures here to get another type to use! - Do not include stddef.h--it will fail! */ - if ((size_t) cp & 3) - cp += 4 - ((size_t) cp & 3); - - /* Now get the string. */ - str = (STRINGDEF *) (PTR) cp; - string_start = cp += sizeof (STRINGDEF); - - for (; *cp; cp++) /* skip the string */ - ; - - /* We need to macro expand the string here to ensure that the - proper definition environment is in place. If it were only - expanded when we find out it is needed, macros necessary for - its proper expansion might have had their definitions changed. */ - tmpbuf = expand_to_temp_buffer (string_start, cp++, 0, 0); - /* Lineno is already set in the precompiled file */ - str->contents = tmpbuf.buf; - str->len = tmpbuf.bufp - tmpbuf.buf; - str->writeflag = 0; - str->filename = name; - str->output_mark = outbuf.bufp - outbuf.buf; - - str->chain = 0; - *stringlist_tailp = str; - stringlist_tailp = &str->chain; - - /* Next comes a fourbyte number indicating the number of keys - for this string. */ - nkeys = *cp++; - nkeys = (nkeys << 8) | *cp++; - nkeys = (nkeys << 8) | *cp++; - nkeys = (nkeys << 8) | *cp++; - - /* If this number is -1, then the string is mandatory. */ - if (nkeys == -1) - str->writeflag = 1; - else - /* Otherwise, for each key, */ - for (; nkeys--; free (tmpbuf.buf), cp = endofthiskey + 1) { - KEYDEF *kp = (KEYDEF *) (PTR) cp; - HASHNODE *hp; - U_CHAR *bp; - - /* It starts with a KEYDEF structure */ - cp += sizeof (KEYDEF); - - /* Find the end of the key. At the end of this for loop we - advance CP to the start of the next key using this variable. */ - endofthiskey = cp + strlen ((char *) cp); - kp->str = str; - - /* Expand the key, and enter it into the hash table. */ - tmpbuf = expand_to_temp_buffer (cp, endofthiskey, 0, 0); - bp = tmpbuf.buf; - - while (is_hor_space[*bp]) - bp++; - if (!is_idstart[*bp] || bp == tmpbuf.bufp) { - str->writeflag = 1; - continue; - } - - hp = lookup (bp, -1, -1); - if (hp == NULL) { - kp->chain = 0; - install (bp, -1, T_PCSTRING, (char *) kp, -1); - } - else if (hp->type == T_PCSTRING) { - kp->chain = hp->value.keydef; - hp->value.keydef = kp; - } - else - str->writeflag = 1; - } - } - /* This output_line_directive serves to switch us back to the current - input file in case some of these strings get output (which will - result in line directives for the header file being output). */ - output_line_directive (&instack[indepth], op, 0, enter_file); -} - -/* Called from rescan when it hits a key for strings. Mark them all - used and clean up. */ - -static void -pcstring_used (hp) - HASHNODE *hp; -{ - KEYDEF *kp; - - for (kp = hp->value.keydef; kp; kp = kp->chain) - kp->str->writeflag = 1; - delete_macro (hp); -} - -/* Write the output, interspersing precompiled strings in their - appropriate places. */ - -static void -write_output () -{ - STRINGDEF *next_string; - U_CHAR *cur_buf_loc; - int line_directive_len = 80; - char *line_directive = xmalloc (line_directive_len); - int len; - - /* In each run through the loop, either cur_buf_loc == - next_string_loc, in which case we print a series of strings, or - it is less than next_string_loc, in which case we write some of - the buffer. */ - cur_buf_loc = outbuf.buf; - next_string = stringlist; - - while (cur_buf_loc < outbuf.bufp || next_string) { - if (next_string - && cur_buf_loc - outbuf.buf == next_string->output_mark) { - if (next_string->writeflag) { - len = 4 * strlen ((const char *) next_string->filename) + 32; - while (len > line_directive_len) - line_directive = xrealloc (line_directive, - line_directive_len *= 2); - sprintf (line_directive, "\n# %d ", next_string->lineno); - strcpy (quote_string (line_directive + strlen (line_directive), - (const char *) next_string->filename, - strlen ((const char *) next_string->filename)), - "\n"); - safe_write (fileno (stdout), line_directive, strlen (line_directive)); - safe_write (fileno (stdout), - (char *) next_string->contents, next_string->len); - } - next_string = next_string->chain; - } - else { - len = (next_string - ? (next_string->output_mark - - (cur_buf_loc - outbuf.buf)) - : outbuf.bufp - cur_buf_loc); - - safe_write (fileno (stdout), (char *) cur_buf_loc, len); - cur_buf_loc += len; - } - } - free (line_directive); -} - -/* Pass a directive through to the output file. - BUF points to the contents of the directive, as a contiguous string. - LIMIT points to the first character past the end of the directive. - KEYWORD is the keyword-table entry for the directive. */ - -static void -pass_thru_directive (buf, limit, op, keyword) - const U_CHAR *buf; - const U_CHAR *limit; - FILE_BUF *op; - struct directive *keyword; -{ - register int keyword_length = keyword->length; - - check_expand (op, 1 + keyword_length + (limit - buf)); - *op->bufp++ = '#'; - bcopy (keyword->name, (char *) op->bufp, keyword_length); - op->bufp += keyword_length; - if (limit != buf && buf[0] != ' ') - *op->bufp++ = ' '; - bcopy ((const PTR) buf, (PTR) op->bufp, limit - buf); - op->bufp += (limit - buf); -#if 0 - *op->bufp++ = '\n'; - /* Count the line we have just made in the output, - to get in sync properly. */ - op->lineno++; -#endif -} - -/* The arglist structure is built by do_define to tell - collect_definition where the argument names begin. That - is, for a define like "#define f(x,y,z) foo+x-bar*y", the arglist - would contain pointers to the strings x, y, and z. - Collect_definition would then build a DEFINITION node, - with reflist nodes pointing to the places x, y, and z had - appeared. So the arglist is just convenience data passed - between these two routines. It is not kept around after - the current #define has been processed and entered into the - hash table. */ - -struct arglist { - struct arglist *next; - const U_CHAR *name; - int length; - int argno; - char rest_args; -}; - -/* Create a DEFINITION node from a #define directive. Arguments are - as for do_define. */ - -static MACRODEF -create_definition (buf, limit, op) - const U_CHAR *buf, *limit; - FILE_BUF *op; -{ - const U_CHAR *bp; /* temp ptr into input buffer */ - const U_CHAR *symname; /* remember where symbol name starts */ - int sym_length; /* and how long it is */ - int line = instack[indepth].lineno; - const char *file = instack[indepth].nominal_fname; - size_t file_len = instack[indepth].nominal_fname_len; - int rest_args = 0; - - DEFINITION *defn; - int arglengths = 0; /* Accumulate lengths of arg names - plus number of args. */ - MACRODEF mdef; - - bp = buf; - - while (is_hor_space[*bp]) - bp++; - - symname = bp; /* remember where it starts */ - sym_length = check_macro_name (bp, 0); - bp += sym_length; - - /* Lossage will occur if identifiers or control keywords are broken - across lines using backslash. This is not the right place to take - care of that. */ - - if (*bp == '(') { - struct arglist *arg_ptrs = NULL; - int argno = 0; - - bp++; /* skip '(' */ - SKIP_WHITE_SPACE (bp); - - /* Loop over macro argument names. */ - while (*bp != ')') { - struct arglist *temp; - - temp = (struct arglist *) alloca (sizeof (struct arglist)); - temp->name = bp; - temp->next = arg_ptrs; - temp->argno = argno++; - temp->rest_args = 0; - arg_ptrs = temp; - - if (rest_args) - pedwarn ("another parameter follows `%s'", - rest_extension); - - if (!is_idstart[*bp]) - { - if (c99 && limit - bp > (long) REST_EXTENSION_LENGTH - && bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0) - { - /* This is the ISO C 99 way to write macros with variable - number of arguments. */ - rest_args = 1; - temp->rest_args = 1; - } - else - pedwarn ("invalid character in macro parameter name"); - } - - /* Find the end of the arg name. */ - while (is_idchar[*bp]) { - bp++; - /* do we have a "special" rest-args extension here? */ - if (limit - bp > (long) REST_EXTENSION_LENGTH - && bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0) { - if (pedantic && !instack[indepth].system_header_p) - pedwarn ("ANSI C does not allow macro with variable arguments"); - rest_args = 1; - temp->rest_args = 1; - break; - } - } - if (bp == temp->name && rest_args == 1) - { - /* This is the ISO C 99 style. */ - temp->name = (U_CHAR *) va_args_name; - temp->length = VA_ARGS_NAME_LENGTH; - } - else - temp->length = bp - temp->name; - if (rest_args == 1) - bp += REST_EXTENSION_LENGTH; - arglengths += temp->length + 2; - SKIP_WHITE_SPACE (bp); - if (temp->length == 0 || (*bp != ',' && *bp != ')')) { - error ("badly punctuated parameter list in `#define'"); - goto nope; - } - if (*bp == ',') { - bp++; - SKIP_WHITE_SPACE (bp); - /* A comma at this point can only be followed by an identifier. */ - if (!is_idstart[*bp] - && !(c99 && limit - bp > (long) REST_EXTENSION_LENGTH - && bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0)) { - error ("badly punctuated parameter list in `#define'"); - goto nope; - } - } - if (bp >= limit) { - error ("unterminated parameter list in `#define'"); - goto nope; - } - { - struct arglist *otemp; - - for (otemp = temp->next; otemp != NULL; otemp = otemp->next) - if (temp->length == otemp->length - && bcmp (temp->name, otemp->name, temp->length) == 0) - { - error ("duplicate argument name `%.*s' in `#define'", - temp->length, temp->name); - goto nope; - } - if (rest_args == 0 && temp->length == VA_ARGS_NAME_LENGTH - && bcmp (temp->name, va_args_name, VA_ARGS_NAME_LENGTH) == 0) - { - error ("\ -reserved name `%s' used as argument name in `#define'", va_args_name); - goto nope; - } - } - } - - ++bp; /* skip paren */ - SKIP_WHITE_SPACE (bp); - /* now everything from bp before limit is the definition. */ - defn = collect_expansion (bp, limit, argno, arg_ptrs); - defn->rest_args = rest_args; - - /* Now set defn->args.argnames to the result of concatenating - the argument names in reverse order - with comma-space between them. */ - defn->args.argnames = (U_CHAR *) xmalloc (arglengths + 1); - { - struct arglist *temp; - int i = 0; - for (temp = arg_ptrs; temp; temp = temp->next) { - bcopy (temp->name, &defn->args.argnames[i], temp->length); - i += temp->length; - if (temp->next != 0) { - defn->args.argnames[i++] = ','; - defn->args.argnames[i++] = ' '; - } - } - defn->args.argnames[i] = 0; - } - } else { - /* Simple expansion or empty definition. */ - - if (bp < limit) - { - if (is_hor_space[*bp]) { - bp++; - SKIP_WHITE_SPACE (bp); - } else if (sym_length) { - switch (*bp) { - case '!': case '"': case '#': case '%': case '&': case '\'': - case ')': case '*': case '+': case ',': case '-': case '.': - case '/': case ':': case ';': case '<': case '=': case '>': - case '?': case '[': case '\\': case ']': case '^': case '{': - case '|': case '}': case '~': - warning ("missing white space after `#define %.*s'", - sym_length, symname); - break; - - default: - pedwarn ("missing white space after `#define %.*s'", - sym_length, symname); - break; - } - } - } - /* Now everything from bp before limit is the definition. */ - defn = collect_expansion (bp, limit, -1, NULL_PTR); - defn->args.argnames = (U_CHAR *) ""; - } - - defn->line = line; - defn->file = file; - defn->file_len = file_len; - - /* OP is null if this is a predefinition */ - defn->predefined = !op; - mdef.defn = defn; - mdef.symnam = symname; - mdef.symlen = sym_length; - - return mdef; - - nope: - mdef.defn = 0; - return mdef; -} - -/* Process a #define directive. -BUF points to the contents of the #define directive, as a contiguous string. -LIMIT points to the first character past the end of the definition. -KEYWORD is the keyword-table entry for #define. */ - -static int -do_define (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword; -{ - int hashcode; - MACRODEF mdef; - enum node_type newtype = keyword->type == T_DEFINE ? T_MACRO : T_POISON; - - /* If this is a precompiler run (with -pcp) pass thru #define directives. */ - if (pcp_outfile && op) - pass_thru_directive (buf, limit, op, keyword); - - mdef = create_definition (buf, limit, op); - if (mdef.defn == 0) - goto nope; - - hashcode = hashf (mdef.symnam, mdef.symlen, HASHSIZE); - - { - HASHNODE *hp; - if ((hp = lookup (mdef.symnam, mdef.symlen, hashcode)) != NULL) { - int ok = 0; - /* Redefining a precompiled key is ok. */ - if (hp->type == T_PCSTRING) - ok = 1; - /* Redefining a poisoned identifier is even worse than `not ok'. */ - else if (hp->type == T_POISON) - ok = -1; - /* Poisoning anything else is not ok. - The poison should always come first. */ - else if (newtype == T_POISON) - ok = 0; - /* Redefining a macro is ok if the definitions are the same. */ - else if (hp->type == T_MACRO) - ok = ! compare_defs (mdef.defn, hp->value.defn); - /* Redefining a constant is ok with -D. */ - else if (hp->type == T_CONST) - ok = ! done_initializing; - - /* Print the warning or error if it's not ok. */ - if (ok <= 0) - { - /* If we are passing through #define and #undef directives, do - that for this re-definition now. */ - if (debug_output && op) - pass_thru_directive (buf, limit, op, keyword); - - if (hp->type == T_POISON) - error ("redefining poisoned `%.*s'", mdef.symlen, mdef.symnam); - else - pedwarn ("`%.*s' redefined", mdef.symlen, mdef.symnam); - if (hp->type == T_MACRO) - pedwarn_with_file_and_line (hp->value.defn->file, - hp->value.defn->file_len, - hp->value.defn->line, - "this is the location of the previous definition"); - } - if (hp->type != T_POISON) - { - /* Replace the old definition. */ - hp->type = newtype; - hp->value.defn = mdef.defn; - } - } else { - /* If we are passing through #define and #undef directives, do - that for this new definition now. */ - if (debug_output && op) - pass_thru_directive (buf, limit, op, keyword); - install (mdef.symnam, mdef.symlen, newtype, - (char *) mdef.defn, hashcode); - } - } - - return 0; - -nope: - - return 1; -} - -/* Check a purported macro name SYMNAME, and yield its length. - ASSERTION is nonzero if this is really for an assertion name. */ - -static int -check_macro_name (symname, assertion) - const U_CHAR *symname; - int assertion; -{ - const U_CHAR *p; - int sym_length; - - for (p = symname; is_idchar[*p]; p++) - ; - sym_length = p - symname; - if (sym_length == 0 - || (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"'))) - { - if (assertion) - error ("invalid assertion name"); - else - error ("invalid macro name"); - } - else if (!is_idstart[*symname] - || (sym_length == 7 && ! bcmp (symname, "defined", 7))) - { - if (assertion) - error ("invalid assertion name `%.*s'", sym_length, symname); - else - error ("invalid macro name `%.*s'", sym_length, symname); - } - return sym_length; -} - -/* Return zero if two DEFINITIONs are isomorphic. */ - -static int -compare_defs (d1, d2) - DEFINITION *d1, *d2; -{ - register struct reflist *a1, *a2; - register U_CHAR *p1 = d1->expansion; - register U_CHAR *p2 = d2->expansion; - int first = 1; - - if (d1->nargs != d2->nargs) - return 1; - if (pedantic - && strcmp ((char *)d1->args.argnames, (char *)d2->args.argnames)) - return 1; - for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2; - a1 = a1->next, a2 = a2->next) { - if (!((a1->nchars == a2->nchars && ! bcmp (p1, p2, a1->nchars)) - || ! comp_def_part (first, p1, a1->nchars, p2, a2->nchars, 0)) - || a1->argno != a2->argno - || a1->stringify != a2->stringify - || a1->raw_before != a2->raw_before - || a1->raw_after != a2->raw_after) - return 1; - first = 0; - p1 += a1->nchars; - p2 += a2->nchars; - } - if (a1 != a2) - return 1; - if (comp_def_part (first, p1, d1->length - (p1 - d1->expansion), - p2, d2->length - (p2 - d2->expansion), 1)) - return 1; - return 0; -} - -/* Return 1 if two parts of two macro definitions are effectively different. - One of the parts starts at BEG1 and has LEN1 chars; - the other has LEN2 chars at BEG2. - Any sequence of whitespace matches any other sequence of whitespace. - FIRST means these parts are the first of a macro definition; - so ignore leading whitespace entirely. - LAST means these parts are the last of a macro definition; - so ignore trailing whitespace entirely. */ - -static int -comp_def_part (first, beg1, len1, beg2, len2, last) - int first; - const U_CHAR *beg1, *beg2; - int len1, len2; - int last; -{ - register const U_CHAR *end1 = beg1 + len1; - register const U_CHAR *end2 = beg2 + len2; - if (first) { - while (beg1 != end1 && is_space[*beg1]) beg1++; - while (beg2 != end2 && is_space[*beg2]) beg2++; - } - if (last) { - while (beg1 != end1 && is_space[end1[-1]]) end1--; - while (beg2 != end2 && is_space[end2[-1]]) end2--; - } - while (beg1 != end1 && beg2 != end2) { - if (is_space[*beg1] && is_space[*beg2]) { - while (beg1 != end1 && is_space[*beg1]) beg1++; - while (beg2 != end2 && is_space[*beg2]) beg2++; - } else if (*beg1 == *beg2) { - beg1++; beg2++; - } else break; - } - return (beg1 != end1) || (beg2 != end2); -} - -/* Read a replacement list for a macro with parameters. - Build the DEFINITION structure. - Reads characters of text starting at BUF until END. - ARGLIST specifies the formal parameters to look for - in the text of the definition; NARGS is the number of args - in that list, or -1 for a macro name that wants no argument list. - MACRONAME is the macro name itself (so we can avoid recursive expansion) - and NAMELEN is its length in characters. - -Note that comments, backslash-newlines, and leading white space -have already been deleted from the argument. */ - -/* If there is no trailing whitespace, a Newline Space is added at the end - to prevent concatenation that would be contrary to the standard. */ - -static DEFINITION * -collect_expansion (buf, end, nargs, arglist) - const U_CHAR *buf; - const U_CHAR *end; - int nargs; - struct arglist *arglist; -{ - DEFINITION *defn; - register const U_CHAR *p; - register const U_CHAR *limit; - register U_CHAR *lastp, *exp_p; - struct reflist *endpat = NULL; - /* Pointer to first nonspace after last ## seen. */ - const U_CHAR *concat = 0; - /* Pointer to first nonspace after last single-# seen. */ - const U_CHAR *stringify = 0; - /* How those tokens were spelled. */ - enum sharp_token_type concat_sharp_token_type = NO_SHARP_TOKEN; - enum sharp_token_type stringify_sharp_token_type = NO_SHARP_TOKEN; - int maxsize; - int expected_delimiter = '\0'; - - /* Scan thru the replacement list, ignoring comments and quoted - strings, picking up on the macro calls. It does a linear search - thru the arg list on every potential symbol. Profiling might say - that something smarter should happen. */ - - if (end < buf) - abort (); - - /* Find the beginning of the trailing whitespace. */ - limit = end; - p = buf; - while (p < limit && is_space[limit[-1]]) limit--; - - /* Allocate space for the text in the macro definition. - Each input char may or may not need 1 byte, - so this is an upper bound. - The extra 3 are for invented trailing newline-marker and final null. */ - maxsize = (sizeof (DEFINITION) - + (limit - p) + 3); - defn = (DEFINITION *) xcalloc (1, maxsize); - - defn->nargs = nargs; - exp_p = defn->expansion = (U_CHAR *) defn + sizeof (DEFINITION); - lastp = exp_p; - - if (p[0] == '#' - ? p[1] == '#' - : p[0] == '%' && p[1] == ':' && p[2] == '%' && p[3] == ':') { - error ("`##' at start of macro definition"); - p += p[0] == '#' ? 2 : 4; - } - - /* Process the main body of the definition. */ - while (p < limit) { - int skipped_arg = 0; - register U_CHAR c = *p++; - - *exp_p++ = c; - - if (!traditional) { - switch (c) { - case '\'': - case '\"': - if (expected_delimiter != '\0') { - if (c == expected_delimiter) - expected_delimiter = '\0'; - } else - expected_delimiter = c; - break; - - case '\\': - if (expected_delimiter) { - /* In a string, backslash goes through - and makes next char ordinary. */ - *exp_p++ = *p++; - } - break; - - case '%': - if (!expected_delimiter && *p == ':') { - /* %: is not a digraph if preceded by an odd number of '<'s. */ - const U_CHAR *p0 = p - 1; - while (buf < p0 && p0[-1] == '<') - p0--; - if ((p - p0) & 1) { - /* Treat %:%: as ## and %: as #. */ - if (p[1] == '%' && p[2] == ':') { - p += 2; - goto sharp_sharp_token; - } - if (nargs >= 0) { - p++; - goto sharp_token; - } - } - } - break; - - case '#': - /* # is ordinary inside a string. */ - if (expected_delimiter) - break; - if (*p == '#') { - sharp_sharp_token: - /* ##: concatenate preceding and following tokens. */ - /* Take out the first #, discard preceding whitespace. */ - exp_p--; - while (exp_p > lastp && is_hor_space[exp_p[-1]]) - --exp_p; - /* Skip the second #. */ - p++; - concat_sharp_token_type = c; - if (is_hor_space[*p]) { - concat_sharp_token_type = c + 1; - p++; - SKIP_WHITE_SPACE (p); - } - concat = p; - if (p == limit) - error ("`##' at end of macro definition"); - } else if (nargs >= 0) { - /* Single #: stringify following argument ref. - Don't leave the # in the expansion. */ - sharp_token: - exp_p--; - stringify_sharp_token_type = c; - if (is_hor_space[*p]) { - stringify_sharp_token_type = c + 1; - p++; - SKIP_WHITE_SPACE (p); - } - if (! is_idstart[*p] || nargs == 0 - || (*p == 'L' && (p[1] == '\'' || p[1] == '"'))) - error ("`#' operator is not followed by a macro argument name"); - else - stringify = p; - } - break; - } - } else { - /* In -traditional mode, recognize arguments inside strings and - character constants, and ignore special properties of #. - Arguments inside strings are considered "stringified", but no - extra quote marks are supplied. */ - switch (c) { - case '\'': - case '\"': - if (expected_delimiter != '\0') { - if (c == expected_delimiter) - expected_delimiter = '\0'; - } else - expected_delimiter = c; - break; - - case '\\': - /* Backslash quotes delimiters and itself, but not macro args. */ - if (expected_delimiter != 0 && p < limit - && (*p == expected_delimiter || *p == '\\')) { - *exp_p++ = *p++; - continue; - } - break; - - case '/': - if (expected_delimiter != '\0') /* No comments inside strings. */ - break; - if (*p == '*') { - /* If we find a comment that wasn't removed by handle_directive, - this must be -traditional. So replace the comment with - nothing at all. */ - exp_p--; - while (++p < limit) { - if (p[0] == '*' && p[1] == '/') { - p += 2; - break; - } - } -#if 0 - /* Mark this as a concatenation-point, as if it had been ##. */ - concat = p; -#endif - } - break; - } - } - -#ifdef MULTIBYTE_CHARS - /* Handle multibyte characters inside string and character literals. */ - if (expected_delimiter != '\0') - { - int length; - --p; - length = local_mblen (p, limit - p); - if (length > 1) - { - --exp_p; - bcopy (p, exp_p, length); - p += length; - exp_p += length; - continue; - } - ++p; - } -#endif - - /* Handle the start of a symbol. */ - if (is_idchar[c] && nargs > 0) { - const U_CHAR *id_beg = p - 1; - int id_len; - - --exp_p; - while (p != limit && is_idchar[*p]) p++; - id_len = p - id_beg; - - if (is_idstart[c] - && ! (id_len == 1 && c == 'L' && (*p == '\'' || *p == '"'))) { - register struct arglist *arg; - - for (arg = arglist; arg != NULL; arg = arg->next) { - struct reflist *tpat; - - if (arg->name[0] == c - && arg->length == id_len - && bcmp (arg->name, id_beg, id_len) == 0) { - enum sharp_token_type tpat_stringify; - if (expected_delimiter) { - if (warn_stringify) { - if (traditional) { - warning ("macro argument `%.*s' is stringified.", - id_len, arg->name); - } else { - warning ("macro arg `%.*s' would be stringified with -traditional.", - id_len, arg->name); - } - } - /* If ANSI, don't actually substitute inside a string. */ - if (!traditional) - break; - tpat_stringify = SHARP_TOKEN; - } else { - tpat_stringify - = (stringify == id_beg - ? stringify_sharp_token_type : NO_SHARP_TOKEN); - } - /* make a pat node for this arg and append it to the end of - the pat list */ - tpat = (struct reflist *) xmalloc (sizeof (struct reflist)); - tpat->next = NULL; - tpat->raw_before - = concat == id_beg ? concat_sharp_token_type : NO_SHARP_TOKEN; - tpat->raw_after = NO_SHARP_TOKEN; - tpat->rest_args = arg->rest_args; - tpat->stringify = tpat_stringify; - - if (endpat == NULL) - defn->pattern = tpat; - else - endpat->next = tpat; - endpat = tpat; - - tpat->argno = arg->argno; - tpat->nchars = exp_p - lastp; - { - register const U_CHAR *p1 = p; - SKIP_WHITE_SPACE (p1); - if (p1[0]=='#' - ? p1[1]=='#' - : p1[0]=='%' && p1[1]==':' && p1[2]=='%' && p1[3]==':') - tpat->raw_after = p1[0] + (p != p1); - } - lastp = exp_p; /* place to start copying from next time */ - skipped_arg = 1; - break; - } - } - } - - /* If this was not a macro arg, copy it into the expansion. */ - if (! skipped_arg) { - register const U_CHAR *lim1 = p; - p = id_beg; - while (p != lim1) - *exp_p++ = *p++; - if (stringify == id_beg) - error ("`#' operator should be followed by a macro argument name"); - } - } - } - - if (!traditional && expected_delimiter == 0) { - /* If ANSI, put in a newline-space marker to prevent token pasting. - But not if "inside a string" (which in ANSI mode happens only for - -D option). */ - *exp_p++ = '\n'; - *exp_p++ = ' '; - } - - *exp_p = '\0'; - - defn->length = exp_p - defn->expansion; - - /* Crash now if we overrun the allocated size. */ - if (defn->length + 1 > maxsize) - abort (); - -#if 0 -/* This isn't worth the time it takes. */ - /* give back excess storage */ - defn->expansion = (U_CHAR *) xrealloc (defn->expansion, defn->length + 1); -#endif - - return defn; -} - -static int -do_assert (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; - struct directive *keyword ATTRIBUTE_UNUSED; -{ - const U_CHAR *bp; /* temp ptr into input buffer */ - const U_CHAR *symname; /* remember where symbol name starts */ - int sym_length; /* and how long it is */ - struct arglist *tokens = NULL; - - if (pedantic && done_initializing && !instack[indepth].system_header_p) - pedwarn ("ANSI C does not allow `#assert'"); - - bp = buf; - - while (is_hor_space[*bp]) - bp++; - - symname = bp; /* remember where it starts */ - sym_length = check_macro_name (bp, 1); - bp += sym_length; - /* #define doesn't do this, but we should. */ - SKIP_WHITE_SPACE (bp); - - /* Lossage will occur if identifiers or control tokens are broken - across lines using backslash. This is not the right place to take - care of that. */ - - if (*bp != '(') { - error ("missing token-sequence in `#assert'"); - return 1; - } - - { - int error_flag = 0; - - bp++; /* skip '(' */ - SKIP_WHITE_SPACE (bp); - - tokens = read_token_list (&bp, limit, &error_flag); - if (error_flag) - return 1; - if (tokens == 0) { - error ("empty token-sequence in `#assert'"); - return 1; - } - - ++bp; /* skip paren */ - SKIP_WHITE_SPACE (bp); - } - - /* If this name isn't already an assertion name, make it one. - Error if it was already in use in some other way. */ - - { - ASSERTION_HASHNODE *hp; - int hashcode = hashf (symname, sym_length, ASSERTION_HASHSIZE); - struct tokenlist_list *value - = (struct tokenlist_list *) xmalloc (sizeof (struct tokenlist_list)); - - hp = assertion_lookup (symname, sym_length, hashcode); - if (hp == NULL) { - if (sym_length == 7 && ! bcmp (symname, "defined", 7)) - error ("`defined' redefined as assertion"); - hp = assertion_install (symname, sym_length, hashcode); - } - - /* Add the spec'd token-sequence to the list of such. */ - value->tokens = tokens; - value->next = hp->value; - hp->value = value; - } - - return 0; -} - -static int -do_unassert (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; - struct directive *keyword ATTRIBUTE_UNUSED; -{ - const U_CHAR *bp; /* temp ptr into input buffer */ - const U_CHAR *symname; /* remember where symbol name starts */ - int sym_length; /* and how long it is */ - - struct arglist *tokens = NULL; - int tokens_specified = 0; - - if (pedantic && done_initializing && !instack[indepth].system_header_p) - pedwarn ("ANSI C does not allow `#unassert'"); - - bp = buf; - - while (is_hor_space[*bp]) - bp++; - - symname = bp; /* remember where it starts */ - sym_length = check_macro_name (bp, 1); - bp += sym_length; - /* #define doesn't do this, but we should. */ - SKIP_WHITE_SPACE (bp); - - /* Lossage will occur if identifiers or control tokens are broken - across lines using backslash. This is not the right place to take - care of that. */ - - if (*bp == '(') { - int error_flag = 0; - - bp++; /* skip '(' */ - SKIP_WHITE_SPACE (bp); - - tokens = read_token_list (&bp, limit, &error_flag); - if (error_flag) - return 1; - if (tokens == 0) { - error ("empty token list in `#unassert'"); - return 1; - } - - tokens_specified = 1; - - ++bp; /* skip paren */ - SKIP_WHITE_SPACE (bp); - } - - { - ASSERTION_HASHNODE *hp; - int hashcode = hashf (symname, sym_length, ASSERTION_HASHSIZE); - struct tokenlist_list *tail, *prev; - - hp = assertion_lookup (symname, sym_length, hashcode); - if (hp == NULL) - return 1; - - /* If no token list was specified, then eliminate this assertion - entirely. */ - if (! tokens_specified) { - struct tokenlist_list *next; - for (tail = hp->value; tail; tail = next) { - next = tail->next; - free_token_list (tail->tokens); - free (tail); - } - delete_assertion (hp); - } else { - /* If a list of tokens was given, then delete any matching list. */ - - tail = hp->value; - prev = 0; - while (tail) { - struct tokenlist_list *next = tail->next; - if (compare_token_lists (tail->tokens, tokens)) { - if (prev) - prev->next = next; - else - hp->value = tail->next; - free_token_list (tail->tokens); - free (tail); - } else { - prev = tail; - } - tail = next; - } - } - } - - return 0; -} - -/* Test whether there is an assertion named NAME - and optionally whether it has an asserted token list TOKENS. - NAME is not null terminated; its length is SYM_LENGTH. - If TOKENS_SPECIFIED is 0, then don't check for any token list. */ - -int -check_assertion (name, sym_length, tokens_specified, tokens) - const U_CHAR *name; - int sym_length; - int tokens_specified; - struct arglist *tokens; -{ - ASSERTION_HASHNODE *hp; - int hashcode = hashf (name, sym_length, ASSERTION_HASHSIZE); - - if (pedantic && !instack[indepth].system_header_p) - pedwarn ("ANSI C does not allow testing assertions"); - - hp = assertion_lookup (name, sym_length, hashcode); - if (hp == NULL) - /* It is not an assertion; just return false. */ - return 0; - - /* If no token list was specified, then value is 1. */ - if (! tokens_specified) - return 1; - - { - struct tokenlist_list *tail; - - tail = hp->value; - - /* If a list of tokens was given, - then succeed if the assertion records a matching list. */ - - while (tail) { - if (compare_token_lists (tail->tokens, tokens)) - return 1; - tail = tail->next; - } - - /* Fail if the assertion has no matching list. */ - return 0; - } -} - -/* Compare two lists of tokens for equality including order of tokens. */ - -static int -compare_token_lists (l1, l2) - struct arglist *l1, *l2; -{ - while (l1 && l2) { - if (l1->length != l2->length) - return 0; - if (bcmp (l1->name, l2->name, l1->length)) - return 0; - l1 = l1->next; - l2 = l2->next; - } - - /* Succeed if both lists end at the same time. */ - return l1 == l2; -} - -/* Read a space-separated list of tokens ending in a close parenthesis. - Return a list of strings, in the order they were written. - (In case of error, return 0 and store -1 in *ERROR_FLAG.) - Parse the text starting at *BPP, and update *BPP. - Don't parse beyond LIMIT. */ - -static struct arglist * -read_token_list (bpp, limit, error_flag) - const U_CHAR **bpp; - const U_CHAR *limit; - int *error_flag; -{ - struct arglist *token_ptrs = 0; - const U_CHAR *bp = *bpp; - int depth = 1; - - *error_flag = 0; - - /* Loop over the assertion value tokens. */ - while (depth > 0) { - struct arglist *temp; - U_CHAR *temp2; - int eofp = 0; - const U_CHAR *beg = bp; - - /* Find the end of the token. */ - if (*bp == '(') { - bp++; - depth++; - } else if (*bp == ')') { - depth--; - if (depth == 0) - break; - bp++; - } else if (*bp == '"' || *bp == '\'') - bp = skip_quoted_string (bp, limit, 0, NULL_PTR, NULL_PTR, &eofp); - else - while (! is_hor_space[*bp] && *bp != '(' && *bp != ')' - && *bp != '"' && *bp != '\'' && bp != limit) - bp++; - - temp = (struct arglist *) xmalloc (sizeof (struct arglist)); - temp2 = (U_CHAR *) xmalloc (bp - beg + 1); - bcopy ((const PTR) beg, (PTR) temp2, bp - beg); - temp2[bp - beg] = 0; - temp->name = temp2; - temp->next = token_ptrs; - token_ptrs = temp; - temp->length = bp - beg; - - SKIP_WHITE_SPACE (bp); - - if (bp >= limit) { - error ("unterminated token sequence in `#assert' or `#unassert'"); - *error_flag = -1; - return 0; - } - } - *bpp = bp; - - /* We accumulated the names in reverse order. - Now reverse them to get the proper order. */ - { - register struct arglist *prev = 0, *this, *next; - for (this = token_ptrs; this; this = next) { - next = this->next; - this->next = prev; - prev = this; - } - return prev; - } -} - -static void -free_token_list (tokens) - struct arglist *tokens; -{ - while (tokens) { - struct arglist *next = tokens->next; - free ((PTR) tokens->name); - free (tokens); - tokens = next; - } -} - -/* Install a name in the assertion hash table. - - If LEN is >= 0, it is the length of the name. - Otherwise, compute the length by scanning the entire name. - - If HASH is >= 0, it is the precomputed hash code. - Otherwise, compute the hash code. */ - -static ASSERTION_HASHNODE * -assertion_install (name, len, hash) - const U_CHAR *name; - int len; - int hash; -{ - register ASSERTION_HASHNODE *hp; - register int i, bucket; - register U_CHAR *p; - register const U_CHAR *q; - - i = sizeof (ASSERTION_HASHNODE) + len + 1; - hp = (ASSERTION_HASHNODE *) xmalloc (i); - bucket = hash; - hp->bucket_hdr = &assertion_hashtab[bucket]; - hp->next = assertion_hashtab[bucket]; - assertion_hashtab[bucket] = hp; - hp->prev = NULL; - if (hp->next != NULL) - hp->next->prev = hp; - hp->length = len; - hp->value = 0; - hp->name = ((U_CHAR *) hp) + sizeof (ASSERTION_HASHNODE); - p = hp->name; - q = name; - for (i = 0; i < len; i++) - *p++ = *q++; - hp->name[len] = 0; - return hp; -} - -/* Find the most recent hash node for name "name" (ending with first - non-identifier char) installed by install - - If LEN is >= 0, it is the length of the name. - Otherwise, compute the length by scanning the entire name. - - If HASH is >= 0, it is the precomputed hash code. - Otherwise, compute the hash code. */ - -static ASSERTION_HASHNODE * -assertion_lookup (name, len, hash) - const U_CHAR *name; - int len; - int hash; -{ - register ASSERTION_HASHNODE *bucket; - - bucket = assertion_hashtab[hash]; - while (bucket) { - if (bucket->length == len && bcmp (bucket->name, name, len) == 0) - return bucket; - bucket = bucket->next; - } - return NULL; -} - -static void -delete_assertion (hp) - ASSERTION_HASHNODE *hp; -{ - - if (hp->prev != NULL) - hp->prev->next = hp->next; - if (hp->next != NULL) - hp->next->prev = hp->prev; - - /* Make sure that the bucket chain header that the deleted guy was - on points to the right thing afterwards. */ - if (hp == *hp->bucket_hdr) - *hp->bucket_hdr = hp->next; - - free (hp); -} - -/* - * interpret #line directive. Remembers previously seen fnames - * in its very own hash table. - */ -#define FNAME_HASHSIZE 37 - -static int -do_line (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword ATTRIBUTE_UNUSED; -{ - register U_CHAR *bp; - FILE_BUF *ip = &instack[indepth]; - FILE_BUF tem; - int new_lineno; - enum file_change_code file_change = same_file; - - /* Expand any macros. */ - tem = expand_to_temp_buffer (buf, limit, 0, 0); - - /* Point to macroexpanded line, which is null-terminated now. */ - bp = tem.buf; - limit = tem.bufp; - SKIP_WHITE_SPACE (bp); - - if (!ISDIGIT (*bp)) { - error ("invalid format `#line' directive"); - return 0; - } - - /* The Newline at the end of this line remains to be processed. - To put the next line at the specified line number, - we must store a line number now that is one less. */ - new_lineno = atoi ((char *) bp) - 1; - - /* NEW_LINENO is one less than the actual line number here. */ - if (pedantic && new_lineno < 0) - pedwarn ("line number out of range in `#line' directive"); - - /* skip over the line number. */ - while (ISDIGIT (*bp)) - bp++; - -#if 0 /* #line 10"foo.c" is supposed to be allowed. */ - if (*bp && !is_space[*bp]) { - error ("invalid format `#line' directive"); - return; - } -#endif - - SKIP_WHITE_SPACE (bp); - - if (*bp == '\"') { - static HASHNODE *fname_table[FNAME_HASHSIZE]; - HASHNODE *hp, **hash_bucket; - U_CHAR *fname, *p; - int fname_length; - - fname = ++bp; - - /* Turn the file name, which is a character string literal, - into a null-terminated string. Do this in place. */ - p = bp; - for (;;) - switch ((*p++ = *bp++)) { - case '\\': - if (! ignore_escape_flag) - { - char *bpc = (char *) bp; - HOST_WIDEST_INT c = parse_escape (&bpc, (HOST_WIDEST_INT) (U_CHAR) (-1)); - bp = (U_CHAR *) bpc; - if (c < 0) - p--; - else - p[-1] = c; - } - break; - - case '\"': - *--p = 0; - goto fname_done; - } - fname_done: - fname_length = p - fname; - - SKIP_WHITE_SPACE (bp); - if (*bp) { - if (pedantic) - pedwarn ("garbage at end of `#line' directive"); - if (*bp == '1') - file_change = enter_file; - else if (*bp == '2') - file_change = leave_file; - else if (*bp == '3') - ip->system_header_p = 1; - else if (*bp == '4') - ip->system_header_p = 2; - else { - error ("invalid format `#line' directive"); - return 0; - } - - bp++; - SKIP_WHITE_SPACE (bp); - if (*bp == '3') { - ip->system_header_p = 1; - bp++; - SKIP_WHITE_SPACE (bp); - } - if (*bp == '4') { - ip->system_header_p = 2; - bp++; - SKIP_WHITE_SPACE (bp); - } - if (*bp) { - error ("invalid format `#line' directive"); - return 0; - } - } - - hash_bucket = &fname_table[hashf (fname, fname_length, FNAME_HASHSIZE)]; - for (hp = *hash_bucket; hp != NULL; hp = hp->next) - if (hp->length == fname_length && - bcmp (hp->value.cpval, fname, fname_length) == 0) { - ip->nominal_fname = hp->value.cpval; - ip->nominal_fname_len = fname_length; - break; - } - if (hp == 0) { - /* Didn't find it; cons up a new one. */ - hp = (HASHNODE *) xcalloc (1, sizeof (HASHNODE) + fname_length + 1); - hp->next = *hash_bucket; - *hash_bucket = hp; - - ip->nominal_fname = hp->value.cpval = ((char *) hp) + sizeof (HASHNODE); - ip->nominal_fname_len = hp->length = fname_length; - bcopy (fname, ((char *) hp) + sizeof (HASHNODE), fname_length + 1); - } - } else if (*bp) { - error ("invalid format `#line' directive"); - return 0; - } - - ip->lineno = new_lineno; - output_line_directive (ip, op, 0, file_change); - check_expand (op, ip->length - (ip->bufp - ip->buf)); - return 0; -} - -/* Remove the definition of a symbol from the symbol table. - according to un*x /lib/cpp, it is not an error to undef - something that has no definitions, so it isn't one here either. */ - -static int -do_undef (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword; -{ - int sym_length; - HASHNODE *hp; - U_CHAR *orig_buf = buf; - - /* If this is a precompiler run (with -pcp) pass thru #undef directives. */ - if (pcp_outfile && op) - pass_thru_directive (buf, limit, op, keyword); - - SKIP_WHITE_SPACE (buf); - sym_length = check_macro_name (buf, 0); - - while ((hp = lookup (buf, sym_length, -1)) != NULL) { - /* If we are generating additional info for debugging (with -g) we - need to pass through all effective #undef directives. */ - if (debug_output && op) - pass_thru_directive (orig_buf, limit, op, keyword); - if (hp->type == T_POISON) - error ("cannot undefine poisoned `%s'", hp->name); - else { - if (hp->type != T_MACRO) - warning ("undefining `%s'", hp->name); - delete_macro (hp); - } - } - - if (pedantic) { - buf += sym_length; - SKIP_WHITE_SPACE (buf); - if (buf != limit) - pedwarn ("garbage after `#undef' directive"); - } - return 0; -} - - -/* Report an error detected by the program we are processing. - Use the text of the line in the error message. */ - -static int -do_error (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op ATTRIBUTE_UNUSED; - struct directive *keyword; -{ - int length = limit - buf; - U_CHAR *copy = (U_CHAR *) alloca (length + 1); - bcopy ((const PTR) buf, (PTR) copy, length); - copy[length] = 0; - SKIP_WHITE_SPACE (copy); - - switch (keyword->type) { - case T_ERROR: - error ("#error %s", copy); - break; - - case T_WARNING: - if (pedantic && !instack[indepth].system_header_p) - pedwarn ("ANSI C does not allow `#warning'"); - warning ("#warning %s", copy); - break; - - default: - abort (); - } - - return 0; -} -/* Remember the name of the current file being read from so that we can - avoid ever including it again. */ - -static void -do_once () -{ - int i; - - for (i = indepth; i >= 0; i--) - if (instack[i].inc) { - record_control_macro (instack[i].inc, (const U_CHAR *) ""); - break; - } -} - -/* Report program identification. */ - -static int -do_ident (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword ATTRIBUTE_UNUSED; -{ - FILE_BUF trybuf; - int len; - - /* Allow #ident in system headers, since that's not user's fault. */ - if (pedantic && !instack[indepth].system_header_p) - pedwarn ("ANSI C does not allow `#ident'"); - - trybuf = expand_to_temp_buffer (buf, limit, 0, 0); - buf = trybuf.buf; - len = trybuf.bufp - buf; - - /* Output expanded directive. */ - check_expand (op, 7 + len); - bcopy ("#ident ", (char *) op->bufp, 7); - op->bufp += 7; - bcopy ((const PTR) buf, (PTR) op->bufp, len); - op->bufp += len; - - free (buf); - return 0; -} - -/* #pragma and its argument line have already been copied to the output file. - Just check for some recognized pragmas that need validation here. */ - -static int -do_pragma (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword; -{ - SKIP_WHITE_SPACE (buf); - if (!strncmp ((char *) buf, "once", 4)) { - /* Allow #pragma once in system headers, since that's not the user's - fault. */ - if (!instack[indepth].system_header_p) - warning ("`#pragma once' is obsolete"); - do_once (); - } - - if (!strncmp ((char *) buf, "poison", 6)) { - /* Poison these symbols so that all subsequent usage produces an - error message. */ - U_CHAR *p = buf + 6; - - SKIP_WHITE_SPACE (p); - while (p < limit) - { - U_CHAR *end = p; - - while (end < limit && is_idchar[*end]) - end++; - if (end < limit && !is_space[*end]) - { - error ("invalid #pragma poison"); - return 0; - } - do_define(p, end, op, keyword); - p = end; - SKIP_WHITE_SPACE (p); - } - } - - if (!strncmp ((char *) buf, "implementation", 14)) { - /* Be quiet about `#pragma implementation' for a file only if it hasn't - been included yet. */ - - int h; - U_CHAR *p = buf + 14, *fname; - SKIP_WHITE_SPACE (p); - if (*p != '\"') - return 0; - - fname = p + 1; - p = skip_quoted_string (p, limit, 0, NULL_PTR, NULL_PTR, NULL_PTR); - if (p[-1] == '"') - *--p = '\0'; - - for (h = 0; h < INCLUDE_HASHSIZE; h++) { - struct include_file *inc; - for (inc = include_hashtab[h]; inc; inc = inc->next) { - if (!strcmp (base_name (inc->fname), (char *) fname)) { - warning ("`#pragma implementation' for \"%s\" appears after its #include",fname); - return 0; - } - } - } - } - return 0; -} - -#if 0 -/* This was a fun hack, but #pragma seems to start to be useful. - By failing to recognize it, we pass it through unchanged to cc1. */ - -/* The behavior of the #pragma directive is implementation defined. - this implementation defines it as follows. */ - -static int -do_pragma () -{ - close (0); - if (open ("/dev/tty", O_RDONLY, 0666) != 0) - goto nope; - close (1); - if (open ("/dev/tty", O_WRONLY, 0666) != 1) - goto nope; - execl ("/usr/games/hack", "#pragma", 0); - execl ("/usr/games/rogue", "#pragma", 0); - execl ("/usr/new/emacs", "-f", "hanoi", "9", "-kill", 0); - execl ("/usr/local/emacs", "-f", "hanoi", "9", "-kill", 0); -nope: - fatal ("You are in a maze of twisty compiler features, all different"); -} -#endif - -#ifdef SCCS_DIRECTIVE - -/* Just ignore #sccs, on systems where we define it at all. */ - -static int -do_sccs (buf, limit, op, keyword) - U_CHAR *buf ATTRIBUTE_UNUSED; - U_CHAR *limit ATTRIBUTE_UNUSED; - FILE_BUF *op ATTRIBUTE_UNUSED; - struct directive *keyword ATTRIBUTE_UNUSED; -{ - if (pedantic) - pedwarn ("ANSI C does not allow `#sccs'"); - return 0; -} - -#endif /* defined (SCCS_DIRECTIVE) */ - -/* Handle #if directive by - 1) inserting special `defined' keyword into the hash table - that gets turned into 0 or 1 by special_symbol (thus, - if the luser has a symbol called `defined' already, it won't - work inside the #if directive) - 2) rescan the input into a temporary output buffer - 3) pass the output buffer to the yacc parser and collect a value - 4) clean up the mess left from steps 1 and 2. - 5) call conditional_skip to skip til the next #endif (etc.), - or not, depending on the value from step 3. */ - -static int -do_if (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword ATTRIBUTE_UNUSED; -{ - HOST_WIDEST_INT value; - FILE_BUF *ip = &instack[indepth]; - - value = eval_if_expression (buf, limit - buf); - conditional_skip (ip, value == 0, T_IF, NULL_PTR, op); - return 0; -} - -/* Handle a #elif directive by not changing if_stack either. - see the comment above do_else. */ - -static int -do_elif (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword ATTRIBUTE_UNUSED; -{ - HOST_WIDEST_INT value; - FILE_BUF *ip = &instack[indepth]; - - if (if_stack == instack[indepth].if_stack) { - error ("`#elif' not within a conditional"); - return 0; - } else { - if (if_stack->type != T_IF && if_stack->type != T_ELIF) { - error ("`#elif' after `#else'"); - fprintf (stderr, " (matches line %d", if_stack->lineno); - if (! (if_stack->fname_len == ip->nominal_fname_len - && !bcmp (if_stack->fname, ip->nominal_fname, - if_stack->fname_len))) { - fprintf (stderr, ", file "); - fwrite (if_stack->fname, sizeof if_stack->fname[0], - if_stack->fname_len, stderr); - } - fprintf (stderr, ")\n"); - } - if_stack->type = T_ELIF; - } - - if (if_stack->if_succeeded) - skip_if_group (ip, 0, op); - else { - value = eval_if_expression (buf, limit - buf); - if (value == 0) - skip_if_group (ip, 0, op); - else { - ++if_stack->if_succeeded; /* continue processing input */ - output_line_directive (ip, op, 1, same_file); - } - } - return 0; -} - -/* Evaluate a #if expression in BUF, of length LENGTH, then parse the - result as a C expression and return the value as an int. */ - -static HOST_WIDEST_INT -eval_if_expression (buf, length) - const U_CHAR *buf; - int length; -{ - FILE_BUF temp_obuf; - HASHNODE *save_defined; - HOST_WIDEST_INT value; - - save_defined = install ((const U_CHAR *) "defined", -1, T_SPEC_DEFINED, - NULL_PTR, -1); - pcp_inside_if = 1; - temp_obuf = expand_to_temp_buffer (buf, buf + length, 0, 1); - pcp_inside_if = 0; - delete_macro (save_defined); /* clean up special symbol */ - - *temp_obuf.bufp = '\n'; - value = parse_c_expression ((char *) temp_obuf.buf, - warn_undef && !instack[indepth].system_header_p); - - free (temp_obuf.buf); - - return value; -} - -/* routine to handle ifdef/ifndef. Try to look up the symbol, then do - or don't skip to the #endif/#else/#elif depending on what directive - is actually being processed. */ - -static int -do_xifdef (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword; -{ - int skip; - FILE_BUF *ip = &instack[indepth]; - U_CHAR *end; - int start_of_file = 0; - U_CHAR *control_macro = 0; - - /* Detect a #ifndef at start of file (not counting comments). */ - if (ip->fname != 0 && keyword->type == T_IFNDEF) { - U_CHAR *p = ip->buf; - while (p != directive_start) { - U_CHAR c = *p++; - if (is_space[c]) - ; - /* Make no special provision for backslash-newline here; this is - slower if backslash-newlines are present, but it's correct, - and it's not worth it to tune for the rare backslash-newline. */ - else if (c == '/' - && (*p == '*' || (cplusplus_comments && *p == '/'))) { - /* Skip this comment. */ - int junk = 0; - U_CHAR *save_bufp = ip->bufp; - ip->bufp = p + 1; - p = skip_to_end_of_comment (ip, &junk, 1); - ip->bufp = save_bufp; - } else { - goto fail; - } - } - /* If we get here, this conditional is the beginning of the file. */ - start_of_file = 1; - fail: ; - } - - /* Discard leading and trailing whitespace. */ - SKIP_WHITE_SPACE (buf); - while (limit != buf && is_hor_space[limit[-1]]) limit--; - - /* Find the end of the identifier at the beginning. */ - for (end = buf; is_idchar[*end]; end++); - - if (end == buf) { - skip = (keyword->type == T_IFDEF); - if (! traditional) - { - if (end == limit) - pedwarn ("`#%s' with no argument", keyword->name); - else - pedwarn ("`#%s' argument starts with punctuation", keyword->name); - } - } else { - HASHNODE *hp; - - if (! traditional) { - if (ISDIGIT (buf[0])) - pedwarn ("`#%s' argument starts with a digit", keyword->name); - else if (end != limit) - pedwarn ("garbage at end of `#%s' argument", keyword->name); - } - - hp = lookup (buf, end-buf, -1); - - if (pcp_outfile) { - /* Output a precondition for this macro. */ - if (hp - && (hp->type == T_CONST - || (hp->type == T_MACRO && hp->value.defn->predefined))) - fprintf (pcp_outfile, "#define %s\n", hp->name); - else { - U_CHAR *cp = buf; - fprintf (pcp_outfile, "#undef "); - while (is_idchar[*cp]) /* Ick! */ - fputc (*cp++, pcp_outfile); - putc ('\n', pcp_outfile); - } - } - - if ((hp != NULL) && (hp->type == T_POISON)) { - error("attempt to use poisoned `%s'.", hp->name); - hp = NULL; - } - skip = (hp == NULL) ^ (keyword->type == T_IFNDEF); - if (start_of_file && !skip) { - control_macro = (U_CHAR *) xmalloc (end - buf + 1); - bcopy ((const PTR) buf, (PTR) control_macro, end - buf); - control_macro[end - buf] = 0; - } - } - - conditional_skip (ip, skip, T_IF, control_macro, op); - return 0; -} - -/* Push TYPE on stack; then, if SKIP is nonzero, skip ahead. - If this is a #ifndef starting at the beginning of a file, - CONTROL_MACRO is the macro name tested by the #ifndef. - Otherwise, CONTROL_MACRO is 0. */ - -static void -conditional_skip (ip, skip, type, control_macro, op) - FILE_BUF *ip; - int skip; - enum node_type type; - const U_CHAR *control_macro; - FILE_BUF *op; -{ - IF_STACK_FRAME *temp; - - temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME)); - temp->fname = ip->nominal_fname; - temp->fname_len = ip->nominal_fname_len; - temp->lineno = ip->lineno; - temp->next = if_stack; - temp->control_macro = control_macro; - if_stack = temp; - - if_stack->type = type; - - if (skip != 0) { - skip_if_group (ip, 0, op); - return; - } else { - ++if_stack->if_succeeded; - output_line_directive (ip, &outbuf, 1, same_file); - } -} - -/* Skip to #endif, #else, or #elif. adjust line numbers, etc. - Leaves input ptr at the sharp sign found. - If ANY is nonzero, return at next directive of any sort. */ - -static void -skip_if_group (ip, any, op) - FILE_BUF *ip; - int any; - FILE_BUF *op; -{ - register U_CHAR *bp = ip->bufp, *cp; - register U_CHAR *endb = ip->buf + ip->length; - struct directive *kt; - IF_STACK_FRAME *save_if_stack = if_stack; /* don't pop past here */ - U_CHAR *beg_of_line = bp; - register int ident_length; - U_CHAR *ident, *after_ident; - /* Save info about where the group starts. */ - U_CHAR *beg_of_group = bp; - int beg_lineno = ip->lineno; - int skipping_include_directive = 0; - - if (output_conditionals && op != 0) { - static const char * const ptr = "#failed\n"; - int len = strlen (ptr); - - if (op->bufp > op->buf && op->bufp[-1] != '\n') - { - *op->bufp++ = '\n'; - op->lineno++; - } - check_expand (op, len); - bcopy (ptr, (char *) op->bufp, len); - op->bufp += len; - op->lineno++; - output_line_directive (ip, op, 1, 0); - } - - while (bp < endb) { - switch (*bp++) { - case '/': /* possible comment */ - if (*bp == '\\') - newline_fix (bp); - if (*bp == '*' - || (cplusplus_comments && *bp == '/')) { - ip->bufp = ++bp; - bp = skip_to_end_of_comment (ip, &ip->lineno, 0); - } - break; - case '<': - if (skipping_include_directive) { - while (bp < endb && *bp != '>' && *bp != '\n') { - if (*bp == '\\' && bp[1] == '\n') { - ip->lineno++; - bp++; - } - bp++; - } - } - break; - case '\"': - if (skipping_include_directive) { - while (bp < endb && *bp != '\n') { - if (*bp == '"') { - bp++; - break; - } - if (*bp == '\\' && bp[1] == '\n') { - ip->lineno++; - bp++; - } - bp++; - } - break; - } - /* Fall through. */ - case '\'': - bp = skip_quoted_string (bp - 1, endb, ip->lineno, &ip->lineno, - NULL_PTR, NULL_PTR); - break; - case '\\': - /* Char after backslash loses its special meaning in some cases. */ - if (*bp == '\n') { - ++ip->lineno; - bp++; - } else if (traditional && bp < endb) - bp++; - break; - case '\n': - ++ip->lineno; - beg_of_line = bp; - skipping_include_directive = 0; - break; - case '%': - if (beg_of_line == 0 || traditional) - break; - ip->bufp = bp - 1; - while (bp[0] == '\\' && bp[1] == '\n') - bp += 2; - if (*bp == ':') - goto sharp_token; - break; - case '#': - /* # keyword: a # must be first nonblank char on the line */ - if (beg_of_line == 0) - break; - ip->bufp = bp - 1; - sharp_token: - /* Scan from start of line, skipping whitespace, comments - and backslash-newlines, and see if we reach this #. - If not, this # is not special. */ - bp = beg_of_line; - /* If -traditional, require # to be at beginning of line. */ - if (!traditional) { - while (1) { - if (is_hor_space[*bp]) - bp++; - else if (*bp == '\\' && bp[1] == '\n') - bp += 2; - else if (*bp == '/' && bp[1] == '*') { - bp += 2; - while (1) - { - if (*bp == '*') - { - if (bp[1] == '/') - { - bp += 2; - break; - } - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (bp, endb - bp); - if (length > 1) - bp += (length - 1); -#endif - } - bp++; - } - } - /* There is no point in trying to deal with C++ // comments here, - because if there is one, then this # must be part of the - comment and we would never reach here. */ - else break; - } - } - if (bp != ip->bufp) { - bp = ip->bufp + 1; /* Reset bp to after the #. */ - break; - } - - bp = ip->bufp + 1; /* Point after the '#' */ - if (ip->bufp[0] == '%') { - /* Skip past the ':' again. */ - while (*bp == '\\') { - ip->lineno++; - bp += 2; - } - bp++; - } - - /* Skip whitespace and \-newline. */ - while (1) { - if (is_hor_space[*bp]) - bp++; - else if (*bp == '\\' && bp[1] == '\n') - bp += 2; - else if (*bp == '/') { - if (bp[1] == '\\') - newline_fix (bp + 1); - if (bp[1] == '*') { - for (bp += 2; ; bp++) { - if (*bp == '\n') - ip->lineno++; - else if (*bp == '*') { - if (bp[-1] == '/' && warn_comments) - warning ("`/*' within comment"); - if (bp[1] == '\\') - newline_fix (bp + 1); - if (bp[1] == '/') - break; - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (bp, endb - bp); - if (length > 1) - bp += (length - 1); -#endif - } - } - bp += 2; - } else if (bp[1] == '/' && cplusplus_comments) { - for (bp += 2; ; bp++) { - if (*bp == '\n') - break; - if (*bp == '\\' && bp[1] == '\n') - { - if (warn_comments) - warning ("multiline `//' comment"); - ip->lineno++; - bp++; - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (bp, endb - bp); - if (length > 1) - bp += (length - 1); -#endif - } - } - } else - break; - } else - break; - } - - cp = bp; - - /* Now find end of directive name. - If we encounter a backslash-newline, exchange it with any following - symbol-constituents so that we end up with a contiguous name. */ - - while (1) { - if (is_idchar[*bp]) - bp++; - else { - if (*bp == '\\') - name_newline_fix (bp); - if (is_idchar[*bp]) - bp++; - else break; - } - } - ident_length = bp - cp; - ident = cp; - after_ident = bp; - - /* A line of just `#' becomes blank. */ - - if (ident_length == 0 && *after_ident == '\n') { - continue; - } - - if (ident_length == 0 || !is_idstart[*ident]) { - U_CHAR *p = ident; - while (is_idchar[*p]) { - if (*p < '0' || *p > '9') - break; - p++; - } - /* Handle # followed by a line number. */ - if (p != ident && !is_idchar[*p]) { - if (pedantic) - pedwarn ("`#' followed by integer"); - continue; - } - - /* Avoid error for `###' and similar cases unless -pedantic. */ - if (p == ident) { - while (*p == '#' || is_hor_space[*p]) p++; - if (*p == '\n') { - if (pedantic && !lang_asm) - pedwarn ("invalid preprocessing directive"); - continue; - } - } - - if (!lang_asm && pedantic) - pedwarn ("invalid preprocessing directive name"); - continue; - } - - for (kt = directive_table; kt->length >= 0; kt++) { - IF_STACK_FRAME *temp; - if (ident_length == kt->length - && bcmp (cp, kt->name, kt->length) == 0) { - /* If we are asked to return on next directive, do so now. */ - if (any) - goto done; - - switch (kt->type) { - case T_IF: - case T_IFDEF: - case T_IFNDEF: - temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME)); - temp->next = if_stack; - if_stack = temp; - temp->lineno = ip->lineno; - temp->fname = ip->nominal_fname; - temp->fname_len = ip->nominal_fname_len; - temp->type = kt->type; - break; - case T_ELSE: - case T_ENDIF: - if (pedantic && if_stack != save_if_stack) - validate_else (bp, endb); - case T_ELIF: - if (if_stack == instack[indepth].if_stack) { - error ("`#%s' not within a conditional", kt->name); - break; - } - else if (if_stack == save_if_stack) - goto done; /* found what we came for */ - - if (kt->type != T_ENDIF) { - if (if_stack->type == T_ELSE) - error ("`#else' or `#elif' after `#else'"); - if_stack->type = kt->type; - break; - } - - temp = if_stack; - if_stack = if_stack->next; - free (temp); - break; - - case T_INCLUDE: - case T_INCLUDE_NEXT: - case T_IMPORT: - skipping_include_directive = 1; - break; - - default: - break; - } - break; - } - } - /* Don't let erroneous code go by. */ - if (kt->length < 0 && !lang_asm && pedantic) - pedwarn ("invalid preprocessing directive name"); - } - } - - ip->bufp = bp; - /* after this returns, rescan will exit because ip->bufp - now points to the end of the buffer. - rescan is responsible for the error message also. */ - - done: - if (output_conditionals && op != 0) { - static const char * const ptr = "#endfailed\n"; - int len = strlen (ptr); - - if (op->bufp > op->buf && op->bufp[-1] != '\n') - { - *op->bufp++ = '\n'; - op->lineno++; - } - check_expand (op, beg_of_line - beg_of_group); - bcopy ((const PTR) beg_of_group, (PTR) op->bufp, - beg_of_line - beg_of_group); - op->bufp += beg_of_line - beg_of_group; - op->lineno += ip->lineno - beg_lineno; - check_expand (op, len); - bcopy (ptr, (char *) op->bufp, len); - op->bufp += len; - op->lineno++; - } -} - -/* Handle a #else directive. Do this by just continuing processing - without changing if_stack ; this is so that the error message - for missing #endif's etc. will point to the original #if. It - is possible that something different would be better. */ - -static int -do_else (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword ATTRIBUTE_UNUSED; -{ - FILE_BUF *ip = &instack[indepth]; - - if (pedantic) { - SKIP_WHITE_SPACE (buf); - if (buf != limit) - pedwarn ("text following `#else' violates ANSI standard"); - } - - if (if_stack == instack[indepth].if_stack) { - error ("`#else' not within a conditional"); - return 0; - } else { - /* #ifndef can't have its special treatment for containing the whole file - if it has a #else clause. */ - if_stack->control_macro = 0; - - if (if_stack->type != T_IF && if_stack->type != T_ELIF) { - error ("`#else' after `#else'"); - fprintf (stderr, " (matches line %d", if_stack->lineno); - if (! (if_stack->fname_len == ip->nominal_fname_len - && !bcmp (if_stack->fname, ip->nominal_fname, - if_stack->fname_len))) { - fprintf (stderr, ", file "); - fwrite (if_stack->fname, sizeof if_stack->fname[0], - if_stack->fname_len, stderr); - } - fprintf (stderr, ")\n"); - } - if_stack->type = T_ELSE; - } - - if (if_stack->if_succeeded) - skip_if_group (ip, 0, op); - else { - ++if_stack->if_succeeded; /* continue processing input */ - output_line_directive (ip, op, 1, same_file); - } - return 0; -} - -/* Unstack after #endif directive. */ - -static int -do_endif (buf, limit, op, keyword) - U_CHAR *buf, *limit; - FILE_BUF *op; - struct directive *keyword ATTRIBUTE_UNUSED; -{ - if (pedantic) { - SKIP_WHITE_SPACE (buf); - if (buf != limit) - pedwarn ("text following `#endif' violates ANSI standard"); - } - - if (if_stack == instack[indepth].if_stack) - error ("unbalanced `#endif'"); - else { - IF_STACK_FRAME *temp = if_stack; - if_stack = if_stack->next; - if (temp->control_macro != 0) { - /* This #endif matched a #ifndef at the start of the file. - See if it is at the end of the file. */ - FILE_BUF *ip = &instack[indepth]; - U_CHAR *p = ip->bufp; - U_CHAR *ep = ip->buf + ip->length; - - while (p != ep) { - U_CHAR c = *p++; - if (!is_space[c]) { - if (c == '/' - && (*p == '*' || (cplusplus_comments && *p == '/'))) { - /* Skip this comment. */ - int junk = 0; - U_CHAR *save_bufp = ip->bufp; - ip->bufp = p + 1; - p = skip_to_end_of_comment (ip, &junk, 1); - ip->bufp = save_bufp; - } else - goto fail; - } - } - /* If we get here, this #endif ends a #ifndef - that contains all of the file (aside from whitespace). - Arrange not to include the file again - if the macro that was tested is defined. - - Do not do this for the top-level file in a -include or any - file in a -imacros. */ - if (indepth != 0 - && ! (indepth == 1 && no_record_file) - && ! (no_record_file && no_output)) - record_control_macro (ip->inc, temp->control_macro); - fail: ; - } - free (temp); - output_line_directive (&instack[indepth], op, 1, same_file); - } - return 0; -} - -/* When an #else or #endif is found while skipping failed conditional, - if -pedantic was specified, this is called to warn about text after - the directive name. P points to the first char after the directive - name. */ - -static void -validate_else (p, limit) - register const U_CHAR *p; - register const U_CHAR *limit; -{ - /* Advance P over whitespace and comments. */ - while (1) { - while (*p == '\\' && p[1] == '\n') - p += 2; - if (is_hor_space[*p]) - p++; - else if (*p == '/') { - while (p[1] == '\\' && p[2] == '\n') - p += 2; - if (p[1] == '*') { - /* Don't bother warning about unterminated comments - since that will happen later. Just be sure to exit. */ - for (p += 2; ; p++) { - if (p == limit) - return; - if (*p == '*') { - while (p[1] == '\\' && p[2] == '\n') - p += 2; - if (p[1] == '/') { - p += 2; - break; - } - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (p, limit - p); - if (length > 1) - p += (length - 1); -#endif - } - } - } - else if (cplusplus_comments && p[1] == '/') - return; - else break; - } else break; - } - if (*p != '\n') - pedwarn ("text following `#else' or `#endif' violates ANSI standard"); -} - -/* Skip a comment, assuming the input ptr immediately follows the - initial slash-star. Bump *LINE_COUNTER for each newline. - (The canonical line counter is &ip->lineno.) - Don't use this routine (or the next one) if bumping the line - counter is not sufficient to deal with newlines in the string. - - If NOWARN is nonzero, don't warn about slash-star inside a comment. - This feature is useful when processing a comment that is going to - be processed or was processed at another point in the preprocessor, - to avoid a duplicate warning. Likewise for unterminated comment - errors. */ - -static U_CHAR * -skip_to_end_of_comment (ip, line_counter, nowarn) - register FILE_BUF *ip; - int *line_counter; /* place to remember newlines, or NULL */ - int nowarn; -{ - register U_CHAR *limit = ip->buf + ip->length; - register U_CHAR *bp = ip->bufp; - FILE_BUF *op = put_out_comments && !line_counter ? &outbuf : (FILE_BUF *) 0; - int start_line = line_counter ? *line_counter : 0; - - /* JF this line_counter stuff is a crock to make sure the - comment is only put out once, no matter how many times - the comment is skipped. It almost works */ - if (op) { - *op->bufp++ = '/'; - *op->bufp++ = bp[-1]; - } - if (cplusplus_comments && bp[-1] == '/') { - for (; bp < limit; bp++) { - if (*bp == '\n') - break; - if (*bp == '\\' && bp + 1 < limit && bp[1] == '\n') - { - if (!nowarn && warn_comments) - warning ("multiline `//' comment"); - if (line_counter) - ++*line_counter; - if (op) - { - ++op->lineno; - *op->bufp++ = *bp; - } - ++bp; - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (bp, limit - bp); - if (length > 1) - { - if (op) - { - bcopy (bp, op->bufp, length - 1); - op->bufp += (length - 1); - } - bp += (length - 1); - } -#endif - } - if (op) - *op->bufp++ = *bp; - } - ip->bufp = bp; - return bp; - } - while (bp < limit) { - if (op) - *op->bufp++ = *bp; - switch (*bp++) { - case '\n': - /* If this is the end of the file, we have an unterminated comment. - Don't swallow the newline. We are guaranteed that there will be a - trailing newline and various pieces assume it's there. */ - if (bp == limit) - { - --bp; - --limit; - break; - } - if (line_counter != NULL) - ++*line_counter; - if (op) - ++op->lineno; - break; - case '*': - if (bp[-2] == '/' && !nowarn && warn_comments) - warning ("`/*' within comment"); - if (*bp == '\\') - newline_fix (bp); - if (*bp == '/') { - if (op) - *op->bufp++ = '/'; - ip->bufp = ++bp; - return bp; - } - break; -#ifdef MULTIBYTE_CHARS - default: - { - int length; - bp--; - length = local_mblen (bp, limit - bp); - if (length <= 0) - length = 1; - if (op) - { - op->bufp--; - bcopy (bp, op->bufp, length); - op->bufp += length; - } - bp += length; - } -#endif - } - } - - if (!nowarn) - error_with_line (line_for_error (start_line), "unterminated comment"); - ip->bufp = bp; - return bp; -} - -/* Skip over a quoted string. BP points to the opening quote. - Returns a pointer after the closing quote. Don't go past LIMIT. - START_LINE is the line number of the starting point (but it need - not be valid if the starting point is inside a macro expansion). - - The input stack state is not changed. - - If COUNT_NEWLINES is nonzero, it points to an int to increment - for each newline passed; also, warn about any white space - just before line end. - - If BACKSLASH_NEWLINES_P is nonzero, store 1 thru it - if we pass a backslash-newline. - - If EOFP is nonzero, set *EOFP to 1 if the string is unterminated. */ - -static U_CHAR * -skip_quoted_string (bp, limit, start_line, count_newlines, backslash_newlines_p, eofp) - register const U_CHAR *bp; - register const U_CHAR *limit; - int start_line; - int *count_newlines; - int *backslash_newlines_p; - int *eofp; -{ - register U_CHAR c, match; - - match = *bp++; - while (1) { - if (bp >= limit) { - error_with_line (line_for_error (start_line), - "unterminated string or character constant"); - error_with_line (multiline_string_line, - "possible real start of unterminated constant"); - multiline_string_line = 0; - if (eofp) - *eofp = 1; - break; - } - c = *bp++; - if (c == '\\') { - while (*bp == '\\' && bp[1] == '\n') { - if (backslash_newlines_p) - *backslash_newlines_p = 1; - if (count_newlines) - ++*count_newlines; - bp += 2; - } - if (*bp == '\n') { - if (backslash_newlines_p) - *backslash_newlines_p = 1; - if (count_newlines) - ++*count_newlines; - } - bp++; - } else if (c == '\n') { - if (traditional) { - /* Unterminated strings and character constants are 'valid'. */ - bp--; /* Don't consume the newline. */ - if (eofp) - *eofp = 1; - break; - } - if (match == '\'') { - error_with_line (line_for_error (start_line), - "unterminated character constant"); - bp--; - if (eofp) - *eofp = 1; - break; - } - /* If not traditional, then allow newlines inside strings. */ - if (count_newlines) { - if (warn_white_space && is_hor_space[bp[-2]]) - warning ("white space at end of line in string"); - ++*count_newlines; - } - if (multiline_string_line == 0) { - if (pedantic) - pedwarn_with_line (line_for_error (start_line), - "string constant runs past end of line"); - multiline_string_line = start_line; - } - } else if (c == match) - break; -#ifdef MULTIBYTE_CHARS - { - int length; - --bp; - length = local_mblen (bp, limit - bp); - if (length <= 0) - length = 1; - bp += length; - } -#endif - } - return (U_CHAR *) bp; -} - -/* Place into DST a quoted string representing the string SRC. - SRCLEN is the length of SRC; SRC may contain null bytes. - Return the address of DST's terminating null. */ - -static char * -quote_string (dst, src, srclen) - char *dst; - const char *src; - size_t srclen; -{ - U_CHAR c; - const char *srclim = src + srclen; - - *dst++ = '\"'; - while (src != srclim) - switch ((c = *src++)) - { - default: - if (ISPRINT (c)) - *dst++ = c; - else - { - sprintf (dst, "\\%03o", c); - dst += 4; - } - break; - - case '\"': - case '\\': - *dst++ = '\\'; - *dst++ = c; - break; - } - - *dst++ = '\"'; - *dst = '\0'; - return dst; -} - -/* Skip across a group of balanced parens, starting from IP->bufp. - IP->bufp is updated. Use this with IP->bufp pointing at an open-paren. - - This does not handle newlines, because it's used for the arg of #if, - where there aren't any newlines. Also, backslash-newline can't appear. */ - -static U_CHAR * -skip_paren_group (ip) - register FILE_BUF *ip; -{ - U_CHAR *limit = ip->buf + ip->length; - U_CHAR *p = ip->bufp; - int depth = 0; - int lines_dummy = 0; - - while (p != limit) { - int c = *p++; - switch (c) { - case '(': - depth++; - break; - - case ')': - depth--; - if (depth == 0) - return ip->bufp = p; - break; - - case '/': - if (*p == '*') { - ip->bufp = p; - p = skip_to_end_of_comment (ip, &lines_dummy, 0); - p = ip->bufp; - } - - case '"': - case '\'': - { - int eofp = 0; - p = skip_quoted_string (p - 1, limit, 0, NULL_PTR, NULL_PTR, &eofp); - if (eofp) - return ip->bufp = p; - } - break; - } - } - - ip->bufp = p; - return p; -} - -/* Write out a #line directive, for instance, after an #include file. - If CONDITIONAL is nonzero, we can omit the #line if it would - appear to be a no-op, and we can output a few newlines instead - if we want to increase the line number by a small amount. - FILE_CHANGE says whether we are entering a file, leaving, or neither. */ - -static void -output_line_directive (ip, op, conditional, file_change) - FILE_BUF *ip, *op; - int conditional; - enum file_change_code file_change; -{ - int len; - char *line_directive_buf, *line_end; - - if (no_line_directives - || ip->fname == NULL - || no_output) { - op->lineno = ip->lineno; - return; - } - - if (conditional) { - if (ip->lineno == op->lineno) - return; - - /* If the inherited line number is a little too small, - output some newlines instead of a #line directive. */ - if (ip->lineno > op->lineno && ip->lineno < op->lineno + 8) { - check_expand (op, 10); - while (ip->lineno > op->lineno) { - *op->bufp++ = '\n'; - op->lineno++; - } - return; - } - } - - /* Output a positive line number if possible. */ - while (ip->lineno <= 0 && ip->bufp - ip->buf < ip->length - && *ip->bufp == '\n') { - ip->lineno++; - ip->bufp++; - } - - line_directive_buf = (char *) alloca (4 * ip->nominal_fname_len + 100); - sprintf (line_directive_buf, "# %d ", ip->lineno); - line_end = quote_string (line_directive_buf + strlen (line_directive_buf), - ip->nominal_fname, ip->nominal_fname_len); - if (file_change != same_file) { - *line_end++ = ' '; - *line_end++ = file_change == enter_file ? '1' : '2'; - } - /* Tell cc1 if following text comes from a system header file. */ - if (ip->system_header_p) { - *line_end++ = ' '; - *line_end++ = '3'; - } -#ifndef NO_IMPLICIT_EXTERN_C - /* Tell cc1plus if following text should be treated as C. */ - if (ip->system_header_p == 2 && cplusplus) { - *line_end++ = ' '; - *line_end++ = '4'; - } -#endif - *line_end++ = '\n'; - len = line_end - line_directive_buf; - check_expand (op, len + 1); - if (op->bufp > op->buf && op->bufp[-1] != '\n') - *op->bufp++ = '\n'; - bcopy ((const PTR) line_directive_buf, (PTR) op->bufp, len); - op->bufp += len; - op->lineno = ip->lineno; -} - -/* This structure represents one parsed argument in a macro call. - `raw' points to the argument text as written (`raw_length' is its length). - `expanded' points to the argument's macro-expansion - (its length is `expand_length', and its allocated size is `expand_size'). - `stringified_length_bound' is an upper bound on the length - the argument would have if stringified. - `use_count' is the number of times this macro arg is substituted - into the macro. If the actual use count exceeds 10, - the value stored is 10. - `free1' and `free2', if nonzero, point to blocks to be freed - when the macro argument data is no longer needed. - `free_ptr', if nonzero, points to a value of instack[i].free_ptr - where the raw field points somewhere into this string. The purpose - of this is to hold onto instack[i].buf for macro arguments, even - when the element has been popped off the input stack. -*/ - -struct argdata { - U_CHAR *raw, *expanded; - int raw_length, expand_length, expand_size; - int stringified_length_bound; - U_CHAR *free1, *free2; - U_CHAR *free_ptr; - int newlines; - char use_count; -}; - -/* Expand a macro call. - HP points to the symbol that is the macro being called. - Put the result of expansion onto the input stack - so that subsequent input by our caller will use it. - - If macro wants arguments, caller has already verified that - an argument list follows; arguments come from the input stack. */ - -static void -macroexpand (hp, op) - HASHNODE *hp; - FILE_BUF *op; -{ - int nargs; - DEFINITION *defn = hp->value.defn; - register U_CHAR *xbuf; - int xbuf_len; - int start_line = instack[indepth].lineno; - int rest_args, rest_zero; - - CHECK_DEPTH (return;); - - /* it might not actually be a macro. */ - if (hp->type != T_MACRO) { - special_symbol (hp, op); - return; - } - - /* This macro is being used inside a #if, which means it must be */ - /* recorded as a precondition. */ - if (pcp_inside_if && pcp_outfile && defn->predefined) - dump_single_macro (hp, pcp_outfile); - - nargs = defn->nargs; - - if (nargs >= 0) { - register int i; - struct argdata *args; - int parse_error = 0; - - args = (struct argdata *) alloca ((nargs + 1) * sizeof (struct argdata)); - - for (i = 0; i < nargs; i++) { - args[i].raw = (U_CHAR *) ""; - args[i].expanded = 0; - args[i].raw_length = args[i].expand_length = args[i].expand_size - = args[i].stringified_length_bound = 0; - args[i].free1 = args[i].free2 = 0; - args[i].free_ptr = 0; - args[i].use_count = 0; - } - - /* Parse all the macro args that are supplied. I counts them. - The first NARGS args are stored in ARGS. - The rest are discarded. - If rest_args is set then we assume macarg absorbed the rest of the args. - */ - i = 0; - rest_args = 0; - do { - /* Discard the open-parenthesis or comma before the next arg. */ - ++instack[indepth].bufp; - if (rest_args) - continue; - if (i < nargs || (nargs == 0 && i == 0)) { - /* If we are working on last arg which absorbs rest of args... */ - if (i == nargs - 1 && defn->rest_args) - rest_args = 1; - parse_error = macarg (&args[i], rest_args); - } - else - parse_error = macarg (NULL_PTR, 0); - if (parse_error) { - error_with_line (line_for_error (start_line), - "unterminated macro call"); - break; - } - i++; - } while (*instack[indepth].bufp != ')'); - - /* If we got one arg but it was just whitespace, call that 0 args. */ - if (i == 1) { - register const U_CHAR *bp = args[0].raw; - register const U_CHAR *lim = bp + args[0].raw_length; - /* cpp.texi says for foo ( ) we provide one argument. - However, if foo wants just 0 arguments, treat this as 0. */ - if (nargs == 0) - while (bp != lim && is_space[*bp]) bp++; - if (bp == lim) - i = 0; - } - - /* Don't output an error message if we have already output one for - a parse error above. */ - rest_zero = 0; - if (nargs == 0 && i > 0) { - if (! parse_error) - error ("arguments given to macro `%s'", hp->name); - } else if (i < nargs) { - /* traditional C allows foo() if foo wants one argument. */ - if (nargs == 1 && i == 0 && traditional) - ; - /* the rest args token is allowed to absorb 0 tokens */ - else if (i == nargs - 1 && defn->rest_args) - rest_zero = 1; - else if (parse_error) - ; - else if (i == 0) - error ("macro `%s' used without args", hp->name); - else if (i == 1) - error ("macro `%s' used with just one arg", hp->name); - else - error ("macro `%s' used with only %d args", hp->name, i); - } else if (i > nargs) { - if (! parse_error) - error ("macro `%s' used with too many (%d) args", hp->name, i); - } - - /* Swallow the closeparen. */ - ++instack[indepth].bufp; - - /* If macro wants zero args, we parsed the arglist for checking only. - Read directly from the macro definition. */ - if (nargs == 0) { - xbuf = defn->expansion; - xbuf_len = defn->length; - } else { - register U_CHAR *exp = defn->expansion; - register int offset; /* offset in expansion, - copied a piece at a time */ - register int totlen; /* total amount of exp buffer filled so far */ - - register struct reflist *ap, *last_ap; - - /* Macro really takes args. Compute the expansion of this call. */ - - /* Compute length in characters of the macro's expansion. - Also count number of times each arg is used. */ - xbuf_len = defn->length; - for (ap = defn->pattern; ap != NULL; ap = ap->next) { - if (ap->stringify && args[ap->argno].stringified_length_bound == 0) - /* macarg is not called for omitted arguments, as a result - stringified_length_bound will be zero. We need to make - enough space for "". */ - xbuf_len += 2; - else if (ap->stringify) - xbuf_len += args[ap->argno].stringified_length_bound; - else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional) - /* Add 4 for two newline-space markers to prevent - token concatenation. */ - xbuf_len += args[ap->argno].raw_length + 4; - else { - /* We have an ordinary (expanded) occurrence of the arg. - So compute its expansion, if we have not already. */ - if (args[ap->argno].expanded == 0) { - FILE_BUF obuf; - obuf = expand_to_temp_buffer (args[ap->argno].raw, - args[ap->argno].raw + args[ap->argno].raw_length, - 1, 0); - - args[ap->argno].expanded = obuf.buf; - args[ap->argno].expand_length = obuf.bufp - obuf.buf; - args[ap->argno].expand_size = obuf.length; - args[ap->argno].free2 = obuf.buf; - - xbuf_len += args[ap->argno].expand_length; - } else { - /* If the arg appears more than once, its later occurrences - may have newline turned into backslash-'n', which is a - factor of 2 expansion. */ - xbuf_len += 2 * args[ap->argno].expand_length; - } - /* Add 4 for two newline-space markers to prevent - token concatenation. */ - xbuf_len += 4; - } - if (args[ap->argno].use_count < 10) - args[ap->argno].use_count++; - } - - xbuf = (U_CHAR *) xmalloc (xbuf_len + 1); - - /* Generate in XBUF the complete expansion - with arguments substituted in. - TOTLEN is the total size generated so far. - OFFSET is the index in the definition - of where we are copying from. */ - offset = totlen = 0; - for (last_ap = NULL, ap = defn->pattern; ap != NULL; - last_ap = ap, ap = ap->next) { - register struct argdata *arg = &args[ap->argno]; - int count_before = totlen; - - /* Add chars to XBUF. */ - for (i = 0; i < ap->nchars; i++, offset++) - xbuf[totlen++] = exp[offset]; - - /* If followed by an empty rest arg with concatenation, - delete the last run of nonwhite chars. */ - if (rest_zero && totlen > count_before - && ((ap->rest_args && ap->raw_before != 0) - || (last_ap != NULL && last_ap->rest_args - && last_ap->raw_after != 0))) { - /* Delete final whitespace. */ - while (totlen > count_before && is_space[xbuf[totlen - 1]]) { - totlen--; - } - - /* Delete the nonwhites before them. */ - while (totlen > count_before && ! is_space[xbuf[totlen - 1]]) { - totlen--; - } - } - - if (ap->stringify != 0) { - int arglen = arg->raw_length; - int escaped = 0; - int in_string = 0; - int c; - i = 0; - while (i < arglen - && (c = arg->raw[i], is_space[c])) - i++; - while (i < arglen - && (c = arg->raw[arglen - 1], is_space[c])) - arglen--; - if (!traditional) - xbuf[totlen++] = '\"'; /* insert beginning quote */ - for (; i < arglen; i++) { - c = arg->raw[i]; - - if (in_string) { - /* Generate nothing for backslash-newline in a string. */ - if (c == '\\' && arg->raw[i + 1] == '\n') { - i++; - continue; - } - } else { - /* Special markers - generate nothing for a stringified argument. */ - if (c == '\n') { - i++; - continue; - } - - /* Internal sequences of whitespace are replaced by one space - except within a string or char token. */ - if (is_space[c]) { - i++; - while (is_space[(c = arg->raw[i])]) - /* Newline markers can occur within a whitespace sequence; - consider them part of the sequence. */ - i += (c == '\n') + 1; - i--; - c = ' '; - } - } - - if (escaped) - escaped = 0; - else { - if (c == '\\') - escaped = 1; - else if (in_string) { - if (c == in_string) - in_string = 0; - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (arg->raw + i, arglen - i); - if (length > 1) - { - bcopy (arg->raw + i, xbuf + totlen, length); - i += length - 1; - totlen += length; - continue; - } -#endif - } - } else if (c == '\"' || c == '\'') - in_string = c; - } - - /* Escape double-quote, and backslashes in strings. - Newlines in strings are best escaped as \n, since - otherwise backslash-backslash-newline-newline is - mishandled. The C Standard doesn't allow newlines in - strings, so we can escape newlines as we please. */ - if (c == '\"' - || (in_string - && (c == '\\' - || (c == '\n' ? (c = 'n', 1) : 0)))) - xbuf[totlen++] = '\\'; - /* We used to output e.g. \008 for control characters here, - but this doesn't conform to the C Standard. - Just output the characters as-is. */ - xbuf[totlen++] = c; - } - if (!traditional) - xbuf[totlen++] = '\"'; /* insert ending quote */ - } else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional) { - const U_CHAR *p1 = arg->raw; - const U_CHAR *l1 = p1 + arg->raw_length; - if (ap->raw_before != 0) { - while (p1 != l1 && is_space[*p1]) p1++; - while (p1 != l1 && is_idchar[*p1]) - xbuf[totlen++] = *p1++; - /* Delete any no-reexpansion marker that follows - an identifier at the beginning of the argument - if the argument is concatenated with what precedes it. */ - if (p1[0] == '\n' && p1[1] == '-') - p1 += 2; - } else if (!traditional) { - /* Ordinary expanded use of the argument. - Put in newline-space markers to prevent token pasting. */ - xbuf[totlen++] = '\n'; - xbuf[totlen++] = ' '; - } - if (ap->raw_after != 0) { - /* Arg is concatenated after: delete trailing whitespace, - whitespace markers, and no-reexpansion markers. */ - while (p1 != l1) { - if (is_space[l1[-1]]) l1--; - else if (l1[-1] == '-') { - const U_CHAR *p2 = l1 - 1; - /* If a `-' is preceded by an odd number of newlines then it - and the last newline are a no-reexpansion marker. */ - while (p2 != p1 && p2[-1] == '\n') p2--; - if ((l1 - 1 - p2) & 1) { - l1 -= 2; - } - else break; - } - else break; - } - } - - bcopy ((const PTR) p1, (PTR) (xbuf + totlen), l1 - p1); - totlen += l1 - p1; - if (!traditional && ap->raw_after == 0) { - /* Ordinary expanded use of the argument. - Put in newline-space markers to prevent token pasting. */ - xbuf[totlen++] = '\n'; - xbuf[totlen++] = ' '; - } - } else { - /* Ordinary expanded use of the argument. - Put in newline-space markers to prevent token pasting. */ - if (!traditional) { - xbuf[totlen++] = '\n'; - xbuf[totlen++] = ' '; - } - bcopy ((const PTR) arg->expanded, (PTR) (xbuf + totlen), - arg->expand_length); - totlen += arg->expand_length; - if (!traditional) { - xbuf[totlen++] = '\n'; - xbuf[totlen++] = ' '; - } - /* If a macro argument with newlines is used multiple times, - then only expand the newlines once. This avoids creating output - lines which don't correspond to any input line, which confuses - gdb and gcov. */ - if (arg->use_count > 1 && arg->newlines > 0) { - /* Don't bother doing change_newlines for subsequent - uses of arg. */ - arg->use_count = 1; - change_newlines (arg); - } - } - - if (totlen > xbuf_len) - abort (); - } - - /* If there is anything left of the definition after handling - the arg list, copy that in too. */ - - for (i = offset; i < defn->length; i++) { - /* if we've reached the end of the macro */ - if (exp[i] == ')') - rest_zero = 0; - if (! (rest_zero && last_ap != NULL && last_ap->rest_args - && last_ap->raw_after != 0)) - xbuf[totlen++] = exp[i]; - } - - xbuf[totlen] = 0; - xbuf_len = totlen; - - for (i = 0; i < nargs; i++) { - if (args[i].free_ptr != 0) { - U_CHAR *buf = args[i].free_ptr; - int d; - for (d = indepth; d >= 0; --d) { - if (instack[d].buf == buf) { - instack[d].free_ptr = buf; /* Give ownership back to instack */ - goto no_free; - } - } - free (buf); /* buf is not on the stack; must have been popped */ - no_free:; - } - if (args[i].free1 != 0) - free (args[i].free1); - if (args[i].free2 != 0) - free (args[i].free2); - } - } - } else { - xbuf = defn->expansion; - xbuf_len = defn->length; - } - - /* Now put the expansion on the input stack - so our caller will commence reading from it. */ - { - register FILE_BUF *ip2; - - ip2 = &instack[++indepth]; - - ip2->fname = 0; - ip2->nominal_fname = 0; - ip2->nominal_fname_len = 0; - ip2->inc = 0; - /* This may not be exactly correct, but will give much better error - messages for nested macro calls than using a line number of zero. */ - ip2->lineno = start_line; - ip2->buf = xbuf; - ip2->length = xbuf_len; - ip2->bufp = xbuf; - ip2->free_ptr = (nargs > 0) ? xbuf : 0; - ip2->macro = hp; - ip2->if_stack = if_stack; - ip2->system_header_p = 0; - - /* Recursive macro use sometimes works traditionally. - #define foo(x,y) bar (x (y,0), y) - foo (foo, baz) */ - - if (!traditional) - hp->type = T_DISABLED; - } -} - -/* Parse a macro argument and store the info on it into *ARGPTR. - REST_ARGS is passed to macarg1 to make it absorb the rest of the args. - Return nonzero to indicate a syntax error. */ - -static int -macarg (argptr, rest_args) - register struct argdata *argptr; - int rest_args; -{ - FILE_BUF *ip = &instack[indepth]; - int paren = 0; - int lineno0 = ip->lineno; - int comments = 0; - int result = 0; - - /* Try to parse as much of the argument as exists at this - input stack level. */ - U_CHAR *bp = macarg1 (ip->bufp, ip->buf + ip->length, ip->macro, - &paren, &ip->lineno, &comments, rest_args); - - /* If we find the end of the argument at this level, - set up *ARGPTR to point at it in the input stack. */ - if (!(ip->fname != 0 && (ip->lineno != lineno0 || comments != 0)) - && bp != ip->buf + ip->length) { - if (argptr != 0) { - argptr->raw = ip->bufp; - argptr->raw_length = bp - ip->bufp; - argptr->newlines = ip->lineno - lineno0; - /* The next two statements transfer ownership of the the buffer - from ip to argptr. Note that the second statement ensures that - a given free_ptr is owned by at most one macro argument. */ - argptr->free_ptr = ip->free_ptr; - ip->free_ptr = 0; - } - ip->bufp = bp; - } else { - /* This input stack level ends before the macro argument does. - We must pop levels and keep parsing. - Therefore, we must allocate a temporary buffer and copy - the macro argument into it. */ - int bufsize = bp - ip->bufp; - int extra = ip->lineno - lineno0; - U_CHAR *buffer = (U_CHAR *) xmalloc (bufsize + extra + 1); - int final_start = 0; - - bcopy ((const PTR) ip->bufp, (PTR) buffer, bufsize); - ip->bufp = bp; - - while (bp == ip->buf + ip->length) { - if (instack[indepth].macro == 0) { - result = 1; - break; - } - ip->macro->type = T_MACRO; - if (ip->free_ptr) - free (ip->free_ptr); - ip = &instack[--indepth]; - lineno0 = ip->lineno; - comments = 0; - bp = macarg1 (ip->bufp, ip->buf + ip->length, ip->macro, &paren, - &ip->lineno, &comments, rest_args); - final_start = bufsize; - bufsize += bp - ip->bufp; - extra += ip->lineno - lineno0; - buffer = (U_CHAR *) xrealloc (buffer, bufsize + extra + 1); - bcopy ((const PTR) ip->bufp, (PTR) (buffer + bufsize - (bp - ip->bufp)), - bp - ip->bufp); - ip->bufp = bp; - } - - /* Now, if arg is actually wanted, record its raw form, - discarding comments and duplicating newlines in whatever - part of it did not come from a macro expansion. - EXTRA space has been preallocated for duplicating the newlines. - FINAL_START is the index of the start of that part. */ - if (argptr != 0) { - argptr->raw = buffer; - argptr->raw_length = bufsize; - argptr->free1 = buffer; - argptr->newlines = ip->lineno - lineno0; - if ((argptr->newlines || comments) && ip->fname != 0) - argptr->raw_length - = final_start + - discard_comments (argptr->raw + final_start, - argptr->raw_length - final_start, - argptr->newlines); - argptr->raw[argptr->raw_length] = 0; - if (argptr->raw_length > bufsize + extra) - abort (); - } - } - - /* If we are not discarding this argument, - macroexpand it and compute its length as stringified. - All this info goes into *ARGPTR. */ - - if (argptr != 0) { - register const U_CHAR *buf, *lim; - register int totlen; - - buf = argptr->raw; - lim = buf + argptr->raw_length; - - while (buf != lim && is_space[*buf]) - buf++; - while (buf != lim && is_space[lim[-1]]) - lim--; - totlen = traditional ? 0 : 2; /* Count opening and closing quote. */ - while (buf != lim) { - register U_CHAR c = *buf++; - totlen++; - /* Internal sequences of whitespace are replaced by one space - in most cases, but not always. So count all the whitespace - in case we need to keep it all. */ -#if 0 - if (is_space[c]) - SKIP_ALL_WHITE_SPACE (buf); - else -#endif - if (c == '\"' || c == '\\' || c == '\n') /* escape these chars */ - totlen++; - } - argptr->stringified_length_bound = totlen; - } - return result; -} - -/* Scan text from START (inclusive) up to LIMIT (exclusive), - taken from the expansion of MACRO, - counting parens in *DEPTHPTR, - and return if reach LIMIT - or before a `)' that would make *DEPTHPTR negative - or before a comma when *DEPTHPTR is zero. - Single and double quotes are matched and termination - is inhibited within them. Comments also inhibit it. - Value returned is pointer to stopping place. - - Increment *NEWLINES each time a newline is passed. - REST_ARGS notifies macarg1 that it should absorb the rest of the args. - Set *COMMENTS to 1 if a comment is seen. */ - -static U_CHAR * -macarg1 (start, limit, macro, depthptr, newlines, comments, rest_args) - U_CHAR *start; - register const U_CHAR *limit; - struct hashnode *macro; - int *depthptr, *newlines, *comments; - int rest_args; -{ - register U_CHAR *bp = start; - - while (bp < limit) { - switch (*bp) { - case '(': - (*depthptr)++; - break; - case ')': - if (--(*depthptr) < 0) - return bp; - break; - case '\\': - /* Traditionally, backslash makes following char not special. */ - if (traditional && bp + 1 < limit && bp[1] != '\n') - bp++; - break; - case '\n': - ++*newlines; - break; - case '/': - if (macro) - break; - if (bp[1] == '\\') - newline_fix (bp + 1); - if (bp[1] == '*') { - *comments = 1; - for (bp += 2; bp < limit; bp++) { - if (*bp == '\n') - ++*newlines; - else if (*bp == '*') { - if (bp[-1] == '/' && warn_comments) - warning ("`/*' within comment"); - if (bp[1] == '\\') - newline_fix (bp + 1); - if (bp[1] == '/') { - bp++; - break; - } - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (bp, limit - bp); - if (length > 1) - bp += (length - 1); -#endif - } - } - } else if (bp[1] == '/' && cplusplus_comments) { - *comments = 1; - for (bp += 2; bp < limit; bp++) { - if (*bp == '\n') { - ++*newlines; - break; - } - if (*bp == '\\' && bp + 1 < limit && bp[1] == '\n') - { - ++*newlines; - if (warn_comments) - warning ("multiline `//' comment"); - ++bp; - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (bp, limit - bp); - if (length > 1) - bp += (length - 1); -#endif - } - } - } - break; - case '\'': - case '\"': - { - int quotec; - for (quotec = *bp++; bp < limit && *bp != quotec; bp++) { - if (*bp == '\\') { - bp++; - if (*bp == '\n') - ++*newlines; - while (*bp == '\\' && bp[1] == '\n') { - bp += 2; - ++*newlines; - } - } else if (*bp == '\n') { - if (warn_white_space && is_hor_space[bp[-1]] && ! macro) - warning ("white space at end of line in string"); - ++*newlines; - if (quotec == '\'') - break; - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - length = local_mblen (bp, limit - bp); - if (length > 1) - bp += (length - 1); -#endif - } - } - } - break; - case ',': - /* if we've returned to lowest level and we aren't absorbing all args */ - if ((*depthptr) == 0 && rest_args == 0) - return bp; - break; - } - bp++; - } - - return bp; -} - -/* Discard comments and duplicate newlines - in the string of length LENGTH at START, - except inside of string constants. - The string is copied into itself with its beginning staying fixed. - - NEWLINES is the number of newlines that must be duplicated. - We assume that that much extra space is available past the end - of the string. */ - -static int -discard_comments (start, length, newlines) - U_CHAR *start; - int length; - int newlines; -{ - register U_CHAR *ibp; - register U_CHAR *obp; - register U_CHAR *limit; - register int c; - - /* If we have newlines to duplicate, copy everything - that many characters up. Then, in the second part, - we will have room to insert the newlines - while copying down. - NEWLINES may actually be too large, because it counts - newlines in string constants, and we don't duplicate those. - But that does no harm. */ - if (newlines > 0) { - ibp = start + length; - obp = ibp + newlines; - limit = start; - while (limit != ibp) - *--obp = *--ibp; - } - - ibp = start + newlines; - limit = start + length + newlines; - obp = start; - - while (ibp < limit) { - *obp++ = c = *ibp++; - switch (c) { - case '\n': - /* Duplicate the newline. */ - *obp++ = '\n'; - break; - - case '\\': - if (*ibp == '\n') { - obp--; - ibp++; - } - break; - - case '/': - if (*ibp == '\\') - newline_fix (ibp); - /* Delete any comment. */ - if (cplusplus_comments && ibp[0] == '/') { - /* Comments are equivalent to spaces. */ - obp[-1] = ' '; - ibp++; - while (ibp < limit) - { - if (*ibp == '\n') - break; - if (*ibp == '\\' && ibp + 1 < limit && ibp[1] == '\n') - ibp++; - else - { -#ifdef MULTIBYTE_CHARS - int length = local_mblen (ibp, limit - ibp); - if (length > 1) - ibp += (length - 1); -#endif - } - ibp++; - } - break; - } - if (ibp[0] != '*' || ibp + 1 >= limit) - break; - /* Comments are equivalent to spaces. - For -traditional, a comment is equivalent to nothing. */ - if (traditional) - obp--; - else - obp[-1] = ' '; - while (++ibp < limit) { - if (ibp[0] == '*') { - if (ibp[1] == '\\') - newline_fix (ibp + 1); - if (ibp[1] == '/') { - ibp += 2; - break; - } - } - else - { -#ifdef MULTIBYTE_CHARS - int length = local_mblen (ibp, limit - ibp); - if (length > 1) - ibp += (length - 1); -#endif - } - } - break; - - case '\'': - case '\"': - /* Notice and skip strings, so that we don't - think that comments start inside them, - and so we don't duplicate newlines in them. */ - { - int quotec = c; - while (ibp < limit) { - *obp++ = c = *ibp++; - if (c == quotec) - break; - if (c == '\n') - { - if (quotec == '\'') - break; - } - else if (c == '\\') { - if (ibp < limit && *ibp == '\n') { - ibp++; - obp--; - } else { - while (*ibp == '\\' && ibp[1] == '\n') - ibp += 2; - if (ibp < limit) - *obp++ = *ibp++; - } - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - ibp--; - length = local_mblen (ibp, limit - ibp); - if (length > 1) - { - obp--; - bcopy (ibp, obp, length); - ibp += length; - obp += length; - } - else - ibp++; -#endif - } - } - } - break; - } - } - - return obp - start; -} - -/* Turn newlines to spaces in the macro argument ARG. - Remove backslash-newline from string constants, - and turn other newlines in string constants to backslash-'n'. */ - -static void -change_newlines (arg) - struct argdata *arg; -{ - U_CHAR *start = arg->expanded; - int length = arg->expand_length; - register U_CHAR *ibp; - register U_CHAR *obp; - register const U_CHAR *limit; - register int c; - - ibp = start; - limit = start + length; - obp = start; - - while (ibp < limit) { - *obp++ = c = *ibp++; - switch (c) { - case '\n': - /* If this is a NEWLINE NEWLINE, then this is a real newline in the - string. Skip past the newline and its duplicate. - Put a space in the output. */ - if (*ibp == '\n') - { - ibp++; - obp--; - *obp++ = ' '; - } - break; - - case '\'': - case '\"': - /* Notice and skip strings, so that we don't delete newlines in them. */ - { - int quotec = c; - while (ibp < limit) { - *obp++ = c = *ibp++; - if (c == quotec) - break; - else if (c == '\\' && ibp < limit && *ibp == '\n') - *obp++ = *ibp++; - else if (c == '\n') - { - if (quotec == '\'') - break; - } - else - { -#ifdef MULTIBYTE_CHARS - int length; - ibp--; - length = local_mblen (ibp, limit - ibp); - if (length > 1) - { - obp--; - bcopy (ibp, obp, length); - ibp += length; - obp += length; - } - else - ibp++; -#endif - } - } - } - break; - } - } - - arg->expand_length = obp - arg->expanded; - - if (start != arg->expanded) - free (start); -} - -/* notice - output message to stderr */ - -static void -notice VPARAMS ((const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - const char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, const char *); -#endif - - vnotice (msgid, args); - va_end (args); -} - -static void -vnotice (msgid, args) - const char *msgid; - va_list args; -{ - vfprintf (stderr, _(msgid), args); -} - -/* error - print error message and increment count of errors. */ - -void -error VPARAMS ((const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - const char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, const char *); -#endif - - verror (msgid, args); - va_end (args); -} - -void -verror (msgid, args) - const char *msgid; - va_list args; -{ - int i; - FILE_BUF *ip = NULL; - - print_containing_files (); - - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) { - ip = &instack[i]; - break; - } - - if (ip != NULL) { - fwrite (ip->nominal_fname, sizeof ip->nominal_fname[0], - ip->nominal_fname_len, stderr); - fprintf (stderr, ":%d: ", ip->lineno); - } - vnotice (msgid, args); - fprintf (stderr, "\n"); - errors++; -} - -/* Error including a message from `errno'. */ - -static void -error_from_errno (name) - const char *name; -{ - int e = errno; - int i; - FILE_BUF *ip = NULL; - - print_containing_files (); - - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) { - ip = &instack[i]; - break; - } - - if (ip != NULL) { - fwrite (ip->nominal_fname, sizeof ip->nominal_fname[0], - ip->nominal_fname_len, stderr); - fprintf (stderr, ":%d: ", ip->lineno); - } - - fprintf (stderr, "%s: %s\n", name, xstrerror (e)); - - errors++; -} - -/* Print error message but don't count it. */ - -void -warning VPARAMS ((const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - const char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, const char *); -#endif - - vwarning (msgid, args); - va_end (args); -} - -static void -vwarning (msgid, args) - const char *msgid; - va_list args; -{ - int i; - FILE_BUF *ip = NULL; - - if (inhibit_warnings) - return; - - if (warnings_are_errors) - errors++; - - print_containing_files (); - - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) { - ip = &instack[i]; - break; - } - - if (ip != NULL) { - fwrite (ip->nominal_fname, sizeof ip->nominal_fname[0], - ip->nominal_fname_len, stderr); - fprintf (stderr, ":%d: ", ip->lineno); - } - notice ("warning: "); - vnotice (msgid, args); - fprintf (stderr, "\n"); -} - -static void -error_with_line VPARAMS ((int line, const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - int line; - const char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - line = va_arg (args, int); - msgid = va_arg (args, const char *); -#endif - - verror_with_line (line, msgid, args); - va_end (args); -} - - -static void -verror_with_line (line, msgid, args) - int line; - const char *msgid; - va_list args; -{ - int i; - FILE_BUF *ip = NULL; - - print_containing_files (); - - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) { - ip = &instack[i]; - break; - } - - if (ip != NULL) { - fwrite (ip->nominal_fname, sizeof ip->nominal_fname[0], - ip->nominal_fname_len, stderr); - fprintf (stderr, ":%d: ", line); - } - vnotice (msgid, args); - fprintf (stderr, "\n"); - errors++; -} - -static void -warning_with_line VPARAMS ((int line, const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - int line; - const char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - line = va_arg (args, int); - msgid = va_arg (args, const char *); -#endif - - vwarning_with_line (line, msgid, args); - va_end (args); -} - -static void -vwarning_with_line (line, msgid, args) - int line; - const char *msgid; - va_list args; -{ - int i; - FILE_BUF *ip = NULL; - - if (inhibit_warnings) - return; - - if (warnings_are_errors) - errors++; - - print_containing_files (); - - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) { - ip = &instack[i]; - break; - } - - if (ip != NULL) { - fwrite (ip->nominal_fname, sizeof ip->nominal_fname[0], - ip->nominal_fname_len, stderr); - if (line) - fprintf (stderr, ":%d: ", line); - else - fputs (": ", stderr); - } - notice ("warning: "); - vnotice (msgid, args); - fprintf (stderr, "\n"); -} - -/* Print an error message and maybe count it. */ - -void -pedwarn VPARAMS ((const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - const char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, const char *); -#endif - - if (pedantic_errors) - verror (msgid, args); - else - vwarning (msgid, args); - va_end (args); -} - -void -pedwarn_with_line VPARAMS ((int line, const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - int line; - const char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - line = va_arg (args, int); - msgid = va_arg (args, const char *); -#endif - - if (pedantic_errors) - verror_with_line (line, msgid, args); - else - vwarning_with_line (line, msgid, args); - va_end (args); -} - -/* Report a warning (or an error if pedantic_errors) - giving specified file name and line number, not current. */ - -static void -pedwarn_with_file_and_line VPARAMS ((const char *file, size_t file_len, - int line, const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - const char *file; - size_t file_len; - int line; - const char * msgid; -#endif - va_list args; - - if (!pedantic_errors && inhibit_warnings) - return; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - file = va_arg (args, const char *); - file_len = va_arg (args, size_t); - line = va_arg (args, int); - msgid = va_arg (args, const char *); -#endif - - if (file) { - fwrite (file, sizeof file[0], file_len, stderr); - fprintf (stderr, ":%d: ", line); - } - if (pedantic_errors) - errors++; - if (!pedantic_errors) - notice ("warning: "); - vnotice (msgid, args); - va_end (args); - fprintf (stderr, "\n"); -} - -static void -pedwarn_strange_white_space (ch) - int ch; -{ - switch (ch) - { - case '\f': pedwarn ("formfeed in preprocessing directive"); break; - case '\r': pedwarn ("carriage return in preprocessing directive"); break; - case '\v': pedwarn ("vertical tab in preprocessing directive"); break; - default: abort (); - } -} - -/* Print the file names and line numbers of the #include - directives which led to the current file. */ - -static void -print_containing_files () -{ - FILE_BUF *ip = NULL; - int i; - int first = 1; - - /* If stack of files hasn't changed since we last printed - this info, don't repeat it. */ - if (last_error_tick == input_file_stack_tick) - return; - - for (i = indepth; i >= 0; i--) - if (instack[i].fname != NULL) { - ip = &instack[i]; - break; - } - - /* Give up if we don't find a source file. */ - if (ip == NULL) - return; - - /* Find the other, outer source files. */ - for (i--; i >= 0; i--) - if (instack[i].fname != NULL) { - ip = &instack[i]; - if (first) { - first = 0; - notice ( "In file included from "); - } else { - notice (",\n from "); - } - - fwrite (ip->nominal_fname, sizeof ip->nominal_fname[0], - ip->nominal_fname_len, stderr); - fprintf (stderr, ":%d", ip->lineno); - } - if (! first) - fprintf (stderr, ":\n"); - - /* Record we have printed the status as of this time. */ - last_error_tick = input_file_stack_tick; -} - -/* Return the line at which an error occurred. - The error is not necessarily associated with the current spot - in the input stack, so LINE says where. LINE will have been - copied from ip->lineno for the current input level. - If the current level is for a file, we return LINE. - But if the current level is not for a file, LINE is meaningless. - In that case, we return the lineno of the innermost file. */ - -static int -line_for_error (line) - int line; -{ - int i; - int line1 = line; - - for (i = indepth; i >= 0; ) { - if (instack[i].fname != 0) - return line1; - i--; - if (i < 0) - return 0; - line1 = instack[i].lineno; - } - abort (); - /*NOTREACHED*/ - return 0; -} - -/* - * If OBUF doesn't have NEEDED bytes after OPTR, make it bigger. - * - * As things stand, nothing is ever placed in the output buffer to be - * removed again except when it's KNOWN to be part of an identifier, - * so flushing and moving down everything left, instead of expanding, - * should work ok. - */ - -/* You might think void was cleaner for the return type, - but that would get type mismatch in check_expand in strict ANSI. */ - -static int -grow_outbuf (obuf, needed) - register FILE_BUF *obuf; - register int needed; -{ - register U_CHAR *p; - int minsize; - - if (obuf->length - (obuf->bufp - obuf->buf) > needed) - return 0; - - /* Make it at least twice as big as it is now. */ - obuf->length *= 2; - /* Make it have at least 150% of the free space we will need. */ - minsize = (3 * needed) / 2 + (obuf->bufp - obuf->buf); - if (minsize > obuf->length) - obuf->length = minsize; - - p = (U_CHAR *) xrealloc (obuf->buf, obuf->length); - - obuf->bufp = p + (obuf->bufp - obuf->buf); - obuf->buf = p; - - return 0; -} - -/* Symbol table for macro names and special symbols */ - -/* - * install a name in the main hash table, even if it is already there. - * name stops with first non alphanumeric, except leading '#'. - * caller must check against redefinition if that is desired. - * delete_macro () removes things installed by install () in fifo order. - * this is important because of the `defined' special symbol used - * in #if, and also if pushdef/popdef directives are ever implemented. - * - * If LEN is >= 0, it is the length of the name. - * Otherwise, compute the length by scanning the entire name. - * - * If HASH is >= 0, it is the precomputed hash code. - * Otherwise, compute the hash code. - */ - -static HASHNODE * -install (name, len, type, value, hash) - const U_CHAR *name; - int len; - enum node_type type; - const char *value; - int hash; -{ - register HASHNODE *hp; - register int i, bucket; - register U_CHAR *p; - register const U_CHAR *q; - - if (len < 0) { - q = name; - while (is_idchar[*q]) - q++; - len = q - name; - } - - if (hash < 0) - hash = hashf (name, len, HASHSIZE); - - i = sizeof (HASHNODE) + len + 1; - hp = (HASHNODE *) xmalloc (i); - bucket = hash; - hp->bucket_hdr = &hashtab[bucket]; - hp->next = hashtab[bucket]; - hashtab[bucket] = hp; - hp->prev = NULL; - if (hp->next != NULL) - hp->next->prev = hp; - hp->type = type; - hp->length = len; - hp->value.cpval = value; - hp->name = ((U_CHAR *) hp) + sizeof (HASHNODE); - p = hp->name; - q = name; - for (i = 0; i < len; i++) - *p++ = *q++; - hp->name[len] = 0; - return hp; -} - -/* - * find the most recent hash node for name "name" (ending with first - * non-identifier char) installed by install - * - * If LEN is >= 0, it is the length of the name. - * Otherwise, compute the length by scanning the entire name. - * - * If HASH is >= 0, it is the precomputed hash code. - * Otherwise, compute the hash code. - */ - -HASHNODE * -lookup (name, len, hash) - const U_CHAR *name; - int len; - int hash; -{ - register const U_CHAR *bp; - register HASHNODE *bucket; - - if (len < 0) { - for (bp = name; is_idchar[*bp]; bp++) ; - len = bp - name; - } - - if (hash < 0) - hash = hashf (name, len, HASHSIZE); - - bucket = hashtab[hash]; - while (bucket) { - if (bucket->length == len && bcmp (bucket->name, name, len) == 0) - return bucket; - bucket = bucket->next; - } - return NULL; -} - -/* - * Delete a hash node. Some weirdness to free junk from macros. - * More such weirdness will have to be added if you define more hash - * types that need it. - */ - -/* Note that the DEFINITION of a macro is removed from the hash table - but its storage is not freed. This would be a storage leak - except that it is not reasonable to keep undefining and redefining - large numbers of macros many times. - In any case, this is necessary, because a macro can be #undef'd - in the middle of reading the arguments to a call to it. - If #undef freed the DEFINITION, that would crash. */ - -static void -delete_macro (hp) - HASHNODE *hp; -{ - - if (hp->prev != NULL) - hp->prev->next = hp->next; - if (hp->next != NULL) - hp->next->prev = hp->prev; - - /* Make sure that the bucket chain header that the deleted guy was - on points to the right thing afterwards. */ - if (hp == *hp->bucket_hdr) - *hp->bucket_hdr = hp->next; - -#if 0 - if (hp->type == T_MACRO) { - DEFINITION *d = hp->value.defn; - struct reflist *ap, *nextap; - - for (ap = d->pattern; ap != NULL; ap = nextap) { - nextap = ap->next; - free (ap); - } - free (d); - } -#endif - free (hp); -} - -/* - * return hash function on name. must be compatible with the one - * computed a step at a time, elsewhere - */ - -static int -hashf (name, len, hashsize) - register const U_CHAR *name; - register int len; - int hashsize; -{ - register int r = 0; - - while (len--) - r = HASHSTEP (r, *name++); - - return MAKE_POS (r) % hashsize; -} - - -/* Dump the definition of a single macro HP to OF. */ - -static void -dump_single_macro (hp, of) - register HASHNODE *hp; - FILE *of; -{ - register DEFINITION *defn = hp->value.defn; - struct reflist *ap; - int offset; - int concat; - - - /* Print the definition of the macro HP. */ - - fprintf (of, "#define %s", hp->name); - - if (defn->nargs >= 0) { - int i; - - fprintf (of, "("); - for (i = 0; i < defn->nargs; i++) { - dump_arg_n (defn, i, of); - if (i + 1 < defn->nargs) - fprintf (of, ", "); - } - fprintf (of, ")"); - } - - fprintf (of, " "); - - offset = 0; - concat = 0; - for (ap = defn->pattern; ap != NULL; ap = ap->next) { - dump_defn_1 (defn->expansion, offset, ap->nchars, of); - offset += ap->nchars; - if (!traditional) { - if (ap->nchars != 0) - concat = 0; - if (ap->stringify) { - switch (ap->stringify) { - case SHARP_TOKEN: fprintf (of, "#"); break; - case WHITE_SHARP_TOKEN: fprintf (of, "# "); break; - case PERCENT_COLON_TOKEN: fprintf (of, "%%:"); break; - case WHITE_PERCENT_COLON_TOKEN: fprintf (of, "%%: "); break; - default: abort (); - } - } - if (ap->raw_before != 0) { - if (concat) { - switch (ap->raw_before) { - case WHITE_SHARP_TOKEN: - case WHITE_PERCENT_COLON_TOKEN: - fprintf (of, " "); - break; - default: - break; - } - } else { - switch (ap->raw_before) { - case SHARP_TOKEN: fprintf (of, "##"); break; - case WHITE_SHARP_TOKEN: fprintf (of, "## "); break; - case PERCENT_COLON_TOKEN: fprintf (of, "%%:%%:"); break; - case WHITE_PERCENT_COLON_TOKEN: fprintf (of, "%%:%%: "); break; - default: abort (); - } - } - } - concat = 0; - } - dump_arg_n (defn, ap->argno, of); - if (!traditional && ap->raw_after != 0) { - switch (ap->raw_after) { - case SHARP_TOKEN: fprintf (of, "##"); break; - case WHITE_SHARP_TOKEN: fprintf (of, " ##"); break; - case PERCENT_COLON_TOKEN: fprintf (of, "%%:%%:"); break; - case WHITE_PERCENT_COLON_TOKEN: fprintf (of, " %%:%%:"); break; - default: abort (); - } - concat = 1; - } - } - dump_defn_1 (defn->expansion, offset, defn->length - offset, of); - fprintf (of, "\n"); -} - -/* Dump all macro definitions as #defines to stdout. */ - -static void -dump_all_macros () -{ - int bucket; - - for (bucket = 0; bucket < HASHSIZE; bucket++) { - register HASHNODE *hp; - - for (hp = hashtab[bucket]; hp; hp= hp->next) { - if (hp->type == T_MACRO) - dump_single_macro (hp, stdout); - } - } -} - -/* Output to OF a substring of a macro definition. - BASE is the beginning of the definition. - Output characters START thru LENGTH. - Unless traditional, discard newlines outside of strings, thus - converting funny-space markers to ordinary spaces. */ - -static void -dump_defn_1 (base, start, length, of) - const U_CHAR *base; - int start; - int length; - FILE *of; -{ - const U_CHAR *p = base + start; - const U_CHAR *limit = base + start + length; - - if (traditional) - fwrite (p, sizeof (*p), length, of); - else { - while (p < limit) { - if (*p == '\"' || *p =='\'') { - const U_CHAR *p1 = skip_quoted_string (p, limit, 0, NULL_PTR, - NULL_PTR, NULL_PTR); - fwrite (p, sizeof (*p), p1 - p, of); - p = p1; - } else { - if (*p != '\n') - putc (*p, of); - p++; - } - } - } -} - -/* Print the name of argument number ARGNUM of macro definition DEFN - to OF. - Recall that DEFN->args.argnames contains all the arg names - concatenated in reverse order with comma-space in between. */ - -static void -dump_arg_n (defn, argnum, of) - DEFINITION *defn; - int argnum; - FILE *of; -{ - register U_CHAR *p = defn->args.argnames; - while (argnum + 1 < defn->nargs) { - p = (U_CHAR *) index ((char *) p, ' ') + 1; - argnum++; - } - - while (*p && *p != ',') { - putc (*p, of); - p++; - } -} - -/* Initialize syntactic classifications of characters. */ - -static void -initialize_char_syntax () -{ - register int i; - - /* - * Set up is_idchar and is_idstart tables. These should be - * faster than saying (is_alpha (c) || c == '_'), etc. - * Set up these things before calling any routines tthat - * refer to them. - */ - for (i = 'a'; i <= 'z'; i++) { - /* SKIP EBCIDIC holes, char must be a valid low case char */ - if (ISLOWER(i)) { - is_idchar[TOUPPER(i)] = 1; - is_idchar[i] = 1; - is_idstart[TOUPPER(i)] = 1; - is_idstart[i] = 1; - } - } - for (i = '0'; i <= '9'; i++) - is_idchar[i] = 1; - is_idchar['_'] = 1; - is_idstart['_'] = 1; - is_idchar['$'] = 1; - is_idstart['$'] = 1; - - /* horizontal space table */ - is_hor_space[' '] = 1; - is_hor_space['\t'] = 1; - is_hor_space['\v'] = 1; - is_hor_space['\f'] = 1; - is_hor_space['\r'] = 1; - - is_space[' '] = 1; - is_space['\t'] = 1; - is_space['\v'] = 1; - is_space['\f'] = 1; - is_space['\n'] = 1; - is_space['\r'] = 1; -} - -/* Initialize the built-in macros. */ - -static void -initialize_builtins (inp, outp) - FILE_BUF *inp; - FILE_BUF *outp; -{ - install ((const U_CHAR *) "__LINE__", -1, T_SPECLINE, NULL_PTR, -1); - install ((const U_CHAR *) "__DATE__", -1, T_DATE, NULL_PTR, -1); - install ((const U_CHAR *) "__FILE__", -1, T_FILE, NULL_PTR, -1); - install ((const U_CHAR *) "__BASE_FILE__", -1, T_BASE_FILE, NULL_PTR, -1); - install ((const U_CHAR *) "__INCLUDE_LEVEL__", -1, T_INCLUDE_LEVEL, NULL_PTR, -1); - install ((const U_CHAR *) "__VERSION__", -1, T_VERSION, NULL_PTR, -1); -#ifndef NO_BUILTIN_SIZE_TYPE - install ((const U_CHAR *) "__SIZE_TYPE__", -1, T_SIZE_TYPE, NULL_PTR, -1); -#endif -#ifndef NO_BUILTIN_PTRDIFF_TYPE - install ((const U_CHAR *) "__PTRDIFF_TYPE__ ", -1, T_PTRDIFF_TYPE, NULL_PTR, -1); -#endif -#ifndef NO_BUILTIN_WCHAR_TYPE - install ((const U_CHAR *) "__WCHAR_TYPE__", -1, T_WCHAR_TYPE, NULL_PTR, -1); -#endif - install ((const U_CHAR *) "__USER_LABEL_PREFIX__", -1, T_USER_LABEL_PREFIX_TYPE, - NULL_PTR, -1); - install ((const U_CHAR *) "__REGISTER_PREFIX__", -1, T_REGISTER_PREFIX_TYPE, - NULL_PTR, -1); - install ((const U_CHAR *) "__IMMEDIATE_PREFIX__", -1, T_IMMEDIATE_PREFIX_TYPE, - NULL_PTR, -1); - install ((const U_CHAR *) "__TIME__", -1, T_TIME, NULL_PTR, -1); - if (!traditional) { - install ((const U_CHAR *) "__STDC__", -1, T_CONST, "1", -1); - install ((const U_CHAR *) "__STDC_VERSION__", -1, T_CONST, "199409L", -1); - } -/* This is supplied using a -D by the compiler driver - so that it is present only when truly compiling with GNU C. */ -/* install ((U_CHAR *) "__GNUC__", -1, T_CONST, "2", -1); */ - install ((const U_CHAR *) "__HAVE_BUILTIN_SETJMP__", -1, T_CONST, "1", -1); - - if (debug_output) - { - char directive[2048]; - U_CHAR *udirective = (U_CHAR *) directive; - register struct directive *dp = &directive_table[0]; - struct tm *timebuf = timestamp (); - - sprintf (directive, " __BASE_FILE__ \"%s\"\n", - instack[0].nominal_fname); - output_line_directive (inp, outp, 0, same_file); - pass_thru_directive (udirective, &udirective[strlen (directive)], - outp, dp); - - sprintf (directive, " __VERSION__ \"%s\"\n", version_string); - output_line_directive (inp, outp, 0, same_file); - pass_thru_directive (udirective, &udirective[strlen (directive)], - outp, dp); - -#ifndef NO_BUILTIN_SIZE_TYPE - sprintf (directive, " __SIZE_TYPE__ %s\n", SIZE_TYPE); - output_line_directive (inp, outp, 0, same_file); - pass_thru_directive (udirective, &udirective[strlen (directive)], - outp, dp); -#endif - -#ifndef NO_BUILTIN_PTRDIFF_TYPE - sprintf (directive, " __PTRDIFF_TYPE__ %s\n", PTRDIFF_TYPE); - output_line_directive (inp, outp, 0, same_file); - pass_thru_directive (udirective, &udirective[strlen (directive)], - outp, dp); -#endif - -#ifndef NO_BUILTIN_WCHAR_TYPE - sprintf (directive, " __WCHAR_TYPE__ %s\n", wchar_type); - output_line_directive (inp, outp, 0, same_file); - pass_thru_directive (udirective, &udirective[strlen (directive)], - outp, dp); -#endif - - sprintf (directive, " __DATE__ \"%s %2d %4d\"\n", - monthnames[timebuf->tm_mon], - timebuf->tm_mday, timebuf->tm_year + 1900); - output_line_directive (inp, outp, 0, same_file); - pass_thru_directive (udirective, &udirective[strlen (directive)], - outp, dp); - - sprintf (directive, " __TIME__ \"%02d:%02d:%02d\"\n", - timebuf->tm_hour, timebuf->tm_min, timebuf->tm_sec); - output_line_directive (inp, outp, 0, same_file); - pass_thru_directive (udirective, &udirective[strlen (directive)], - outp, dp); - - if (!traditional) - { - sprintf (directive, " __STDC__ 1"); - output_line_directive (inp, outp, 0, same_file); - pass_thru_directive (udirective, &udirective[strlen (directive)], - outp, dp); - } - if (objc) - { - sprintf (directive, " __OBJC__ 1"); - output_line_directive (inp, outp, 0, same_file); - pass_thru_directive (udirective, &udirective[strlen (directive)], - outp, dp); - } - } -} - -/* - * process a given definition string, for initialization - * If STR is just an identifier, define it with value 1. - * If STR has anything after the identifier, then it should - * be identifier=definition. - */ - -static void -make_definition (str) - char *str; -{ - FILE_BUF *ip; - struct directive *kt; - U_CHAR *buf, *p; - - p = buf = (U_CHAR *) str; - if (!is_idstart[*p]) { - error ("malformed option `-D %s'", str); - return; - } - while (is_idchar[*++p]) - ; - if (*p == '(') { - while (is_idchar[*++p] || *p == ',' || is_hor_space[*p]) - ; - if (*p++ != ')') - p = (U_CHAR *) str; /* Error */ - } - if (*p == 0) { - buf = (U_CHAR *) alloca (p - buf + 4); - strcpy ((char *)buf, str); - strcat ((char *)buf, " 1"); - } else if (*p != '=') { - error ("malformed option `-D %s'", str); - return; - } else { - U_CHAR *q; - /* Copy the entire option so we can modify it. */ - buf = (U_CHAR *) alloca (2 * strlen (str) + 1); - strncpy ((char *) buf, str, p - (U_CHAR *) str); - /* Change the = to a space. */ - buf[p - (U_CHAR *) str] = ' '; - /* Scan for any backslash-newline and remove it. */ - p++; - q = &buf[p - (U_CHAR *) str]; - while (*p) { - if (*p == '\"' || *p == '\'') { - int unterminated = 0; - const U_CHAR *p1 = skip_quoted_string (p, p + strlen ((char *) p), 0, - NULL_PTR, NULL_PTR, &unterminated); - if (unterminated) - return; - while (p != p1) { - if (*p == '\\' && p[1] == '\n') - p += 2; - else if (*p == '\n') - { - *q++ = '\\'; - *q++ = 'n'; - p++; - } - else - *q++ = *p++; - } - } else if (*p == '\\' && p[1] == '\n') - p += 2; - /* Change newline chars into newline-markers. */ - else if (*p == '\n') - { - *q++ = '\n'; - *q++ = '\n'; - p++; - } - else - *q++ = *p++; - } - *q = 0; - } - - ip = &instack[++indepth]; - ip->nominal_fname = ip->fname = "*Initialization*"; - ip->nominal_fname_len = strlen (ip->nominal_fname); - - ip->buf = ip->bufp = buf; - ip->length = strlen ((char *) buf); - ip->lineno = 1; - ip->macro = 0; - ip->free_ptr = 0; - ip->if_stack = if_stack; - ip->system_header_p = 0; - - for (kt = directive_table; kt->type != T_DEFINE; kt++) - ; - - /* Pass NULL instead of OP, since this is a "predefined" macro. */ - do_define (buf, buf + strlen ((char *) buf), NULL_PTR, kt); - --indepth; -} - -/* JF, this does the work for the -U option */ - -static void -make_undef (str, op) - char *str; - FILE_BUF *op; -{ - FILE_BUF *ip; - struct directive *kt; - - ip = &instack[++indepth]; - ip->nominal_fname = ip->fname = "*undef*"; - ip->nominal_fname_len = strlen (ip->nominal_fname); - - ip->buf = ip->bufp = (U_CHAR *) str; - ip->length = strlen (str); - ip->lineno = 1; - ip->macro = 0; - ip->free_ptr = 0; - ip->if_stack = if_stack; - ip->system_header_p = 0; - - for (kt = directive_table; kt->type != T_UNDEF; kt++) - ; - - do_undef ((U_CHAR *) str, (U_CHAR *) str + strlen (str), op, kt); - --indepth; -} - -/* Process the string STR as if it appeared as the body of a #assert. - OPTION is the option name for which STR was the argument. */ - -static void -make_assertion (option, str) - const char *option; - const char *str; -{ - FILE_BUF *ip; - struct directive *kt; - U_CHAR *buf, *p, *q; - - /* Copy the entire option so we can modify it. */ - buf = (U_CHAR *) alloca (strlen (str) + 1); - strcpy ((char *) buf, str); - /* Scan for any backslash-newline and remove it. */ - p = q = buf; - while (*p) { - if (*p == '\\' && p[1] == '\n') - p += 2; - else - *q++ = *p++; - } - *q = 0; - - p = buf; - if (!is_idstart[*p]) { - error ("malformed option `%s %s'", option, str); - return; - } - while (is_idchar[*++p]) - ; - SKIP_WHITE_SPACE (p); - if (! (*p == 0 || *p == '(')) { - error ("malformed option `%s %s'", option, str); - return; - } - - ip = &instack[++indepth]; - ip->nominal_fname = ip->fname = "*Initialization*"; - ip->nominal_fname_len = strlen (ip->nominal_fname); - - ip->buf = ip->bufp = buf; - ip->length = strlen ((char *) buf); - ip->lineno = 1; - ip->macro = 0; - ip->free_ptr = 0; - ip->if_stack = if_stack; - ip->system_header_p = 0; - - for (kt = directive_table; kt->type != T_ASSERT; kt++) - ; - - /* Pass NULL as output ptr to do_define since we KNOW it never does - any output.... */ - do_assert (buf, buf + strlen ((char *) buf) , NULL_PTR, kt); - --indepth; -} - -/* The previous include prefix, if any, is PREV_FILE_NAME. - Translate any pathnames with COMPONENT. - Allocate a new include prefix whose name is the - simplified concatenation of PREFIX and NAME, - with a trailing / added if needed. - But return 0 if the include prefix should be ignored, - e.g. because it is a duplicate of PREV_FILE_NAME. */ - -static struct file_name_list * -new_include_prefix (prev_file_name, component, prefix, name) - struct file_name_list *prev_file_name; - const char *component; - const char *prefix; - const char *name; -{ - if (name == 0) - fatal ("Directory name missing after command line option"); - - if (*name == 0) - /* Ignore the empty string. */ - return 0; - - prefix = update_path (prefix, component); - name = update_path (name, component); - - { - struct file_name_list *dir - = ((struct file_name_list *) - xmalloc (sizeof (struct file_name_list) - + strlen (prefix) + strlen (name) + 2)); - size_t len; - strcpy (dir->fname, prefix); - strcat (dir->fname, name); - len = simplify_filename (dir->fname); - - /* Convert directory name to a prefix. */ - if (len && dir->fname[len - 1] != DIR_SEPARATOR) { - if (len == 1 && dir->fname[len - 1] == '.') - len = 0; - else -#ifdef VMS - /* must be '/', hack_vms_include_specification triggers on it. */ - dir->fname[len++] = '/'; -#else - dir->fname[len++] = DIR_SEPARATOR; -#endif - dir->fname[len] = 0; - } - - /* Ignore a directory whose name matches the previous one. */ - if (prev_file_name && !strcmp (prev_file_name->fname, dir->fname)) { - /* But treat `-Idir -I- -Idir' as `-I- -Idir'. */ - if (!first_bracket_include) - first_bracket_include = prev_file_name; - free (dir); - return 0; - } - -#ifndef VMS - /* VMS can't stat dir prefixes, so skip these optimizations in VMS. */ - - /* Add a trailing "." if there is a filename. This increases the number - of systems that can stat directories. We remove it below. */ - if (len != 0) - { - dir->fname[len] = '.'; - dir->fname[len + 1] = 0; - } - - /* Ignore a nonexistent directory. */ - if (stat (len ? dir->fname : ".", &dir->st) != 0) { - if (errno != ENOENT && errno != ENOTDIR) - error_from_errno (dir->fname); - free (dir); - return 0; - } - - if (len != 0) - dir->fname[len] = 0; - - /* Ignore a directory whose identity matches the previous one. */ - if (prev_file_name - && INO_T_EQ (prev_file_name->st.st_ino, dir->st.st_ino) - && prev_file_name->st.st_dev == dir->st.st_dev) { - /* But treat `-Idir -I- -Idir' as `-I- -Idir'. */ - if (!first_bracket_include) - first_bracket_include = prev_file_name; - free (dir); - return 0; - } -#endif /* ! VMS */ - - dir->next = 0; - dir->c_system_include_path = 0; - dir->got_name_map = 0; - - return dir; - } -} - -/* Append a chain of `struct file_name_list's - to the end of the main include chain. - FIRST is the beginning of the chain to append, and LAST is the end. */ - -static void -append_include_chain (first, last) - struct file_name_list *first, *last; -{ - struct file_name_list *dir; - - if (!first || !last) - return; - - if (include == 0) - include = first; - else - last_include->next = first; - - if (first_bracket_include == 0) - first_bracket_include = first; - - for (dir = first; ; dir = dir->next) { - int len = strlen (dir->fname) + INCLUDE_LEN_FUDGE; - if (len > max_include_len) - max_include_len = len; - if (dir == last) - break; - } - - last->next = NULL; - last_include = last; -} - -/* Place into DST a representation of the file named SRC that is suitable - for `make'. Do not null-terminate DST. Return its length. */ -static int -quote_string_for_make (dst, src) - char *dst; - const char *src; -{ - const char *p = src; - int i = 0; - for (;;) - { - char c = *p++; - switch (c) - { - case '\0': - case ' ': - case '\t': - { - /* GNU make uses a weird quoting scheme for white space. - A space or tab preceded by 2N+1 backslashes represents - N backslashes followed by space; a space or tab - preceded by 2N backslashes represents N backslashes at - the end of a file name; and backslashes in other - contexts should not be doubled. */ - const char *q; - for (q = p - 1; src < q && q[-1] == '\\'; q--) - { - if (dst) - dst[i] = '\\'; - i++; - } - } - if (!c) - return i; - if (dst) - dst[i] = '\\'; - i++; - goto ordinary_char; - - case '$': - if (dst) - dst[i] = c; - i++; - /* Fall through. This can mishandle things like "$(" but - there's no easy fix. */ - default: - ordinary_char: - /* This can mishandle characters in the string "\0\n%*?[\\~"; - exactly which chars are mishandled depends on the `make' version. - We know of no portable solution for this; - even GNU make 3.76.1 doesn't solve the problem entirely. - (Also, '\0' is mishandled due to our calling conventions.) */ - if (dst) - dst[i] = c; - i++; - break; - } - } -} - - -/* Add output to `deps_buffer' for the -M switch. - STRING points to the text to be output. - SPACER is ':' for targets, ' ' for dependencies. */ - -static void -deps_output (string, spacer) - const char *string; - int spacer; -{ - int size = quote_string_for_make ((char *) 0, string); - - if (size == 0) - return; - -#ifndef MAX_OUTPUT_COLUMNS -#define MAX_OUTPUT_COLUMNS 72 -#endif - if (MAX_OUTPUT_COLUMNS - 1 /*spacer*/ - 2 /*` \'*/ < deps_column + size - && 1 < deps_column) { - bcopy (" \\\n ", &deps_buffer[deps_size], 4); - deps_size += 4; - deps_column = 1; - if (spacer == ' ') - spacer = 0; - } - - if (deps_size + 2 * size + 8 > deps_allocated_size) { - deps_allocated_size = (deps_size + 2 * size + 50) * 2; - deps_buffer = xrealloc (deps_buffer, deps_allocated_size); - } - if (spacer == ' ') { - deps_buffer[deps_size++] = ' '; - deps_column++; - } - quote_string_for_make (&deps_buffer[deps_size], string); - deps_size += size; - deps_column += size; - if (spacer == ':') { - deps_buffer[deps_size++] = ':'; - deps_column++; - } - deps_buffer[deps_size] = 0; -} - -void -fatal VPARAMS ((const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - const char * msgid; -#endif - va_list args; - - fprintf (stderr, "%s: ", progname); - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, const char *); -#endif - vnotice (msgid, args); - va_end (args); - fprintf (stderr, "\n"); - exit (FATAL_EXIT_CODE); -} - -/* More 'friendly' abort that prints the line and file. - config.h can #define abort fancy_abort if you like that sort of thing. */ - -void -fancy_abort () -{ - fatal ("Internal gcc abort."); -} - -static void -perror_with_name (name) - const char *name; -{ - fprintf (stderr, "%s: %s: %s\n", progname, name, xstrerror (errno)); - errors++; -} - -static void -pfatal_with_name (name) - const char *name; -{ - perror_with_name (name); -#ifdef VMS - exit (vaxc$errno); -#else - exit (FATAL_EXIT_CODE); -#endif -} - -/* Handler for SIGPIPE. */ - -static void -pipe_closed (signo) - /* If this is missing, some compilers complain. */ - int signo ATTRIBUTE_UNUSED; -{ - fatal ("output pipe has been closed"); -} - -static void -memory_full () -{ - fatal ("Memory exhausted."); -} - -#ifdef VMS - -/* Under VMS we need to fix up the "include" specification filename. - - Rules for possible conversions - - fullname tried paths - - name name - ./dir/name [.dir]name - /dir/name dir:name - /name [000000]name, name - dir/name dir:[000000]name, dir:name, dir/name - dir1/dir2/name dir1:[dir2]name, dir1:[000000.dir2]name - path:/name path:[000000]name, path:name - path:/dir/name path:[000000.dir]name, path:[dir]name - path:dir/name path:[dir]name - [path]:[dir]name [path.dir]name - path/[dir]name [path.dir]name - - The path:/name input is constructed when expanding <> includes. - - return 1 if name was changed, 0 else. */ - -static int -hack_vms_include_specification (fullname, vaxc_include) - char *fullname; - int vaxc_include; -{ - register char *basename, *unixname, *local_ptr, *first_slash; - int f, check_filename_before_returning, must_revert; - char Local[512]; - - check_filename_before_returning = 0; - must_revert = 0; - /* See if we can find a 1st slash. If not, there's no path information. */ - first_slash = index (fullname, '/'); - if (first_slash == 0) - return 0; /* Nothing to do!!! */ - - /* construct device spec if none given. */ - - if (index (fullname, ':') == 0) - { - - /* If fullname has a slash, take it as device spec. */ - - if (first_slash == fullname) - { - first_slash = index (fullname+1, '/'); /* 2nd slash ? */ - if (first_slash) - *first_slash = ':'; /* make device spec */ - for (basename = fullname; *basename != 0; basename++) - *basename = *(basename+1); /* remove leading slash */ - } - else if ((first_slash[-1] != '.') /* keep ':/', './' */ - && (first_slash[-1] != ':') - && (first_slash[-1] != ']')) /* or a vms path */ - { - *first_slash = ':'; - } - else if ((first_slash[1] == '[') /* skip './' in './[dir' */ - && (first_slash[-1] == '.')) - fullname += 2; - } - - /* Get part after first ':' (basename[-1] == ':') - or last '/' (basename[-1] == '/'). */ - - basename = base_name (fullname); - - /* - * Check if we have a vax-c style '#include filename' - * and add the missing .h - */ - - if (vaxc_include && !index (basename,'.')) - strcat (basename, ".h"); - - local_ptr = Local; /* initialize */ - - /* We are trying to do a number of things here. First of all, we are - trying to hammer the filenames into a standard format, such that later - processing can handle them. - - If the file name contains something like [dir.], then it recognizes this - as a root, and strips the ".]". Later processing will add whatever is - needed to get things working properly. - - If no device is specified, then the first directory name is taken to be - a device name (or a rooted logical). */ - - /* Point to the UNIX filename part (which needs to be fixed!) - but skip vms path information. - [basename != fullname since first_slash != 0]. */ - - if ((basename[-1] == ':') /* vms path spec. */ - || (basename[-1] == ']') - || (basename[-1] == '>')) - unixname = basename; - else - unixname = fullname; - - if (*unixname == '/') - unixname++; - - /* If the directory spec is not rooted, we can just copy - the UNIX filename part and we are done. */ - - if (((basename - fullname) > 1) - && ( (basename[-1] == ']') - || (basename[-1] == '>'))) - { - if (basename[-2] != '.') - { - - /* The VMS part ends in a `]', and the preceding character is not a `.'. - -> PATH]:/name (basename = '/name', unixname = 'name') - We strip the `]', and then splice the two parts of the name in the - usual way. Given the default locations for include files in cccp.c, - we will only use this code if the user specifies alternate locations - with the /include (-I) switch on the command line. */ - - basename -= 1; /* Strip "]" */ - unixname--; /* backspace */ - } - else - { - - /* The VMS part has a ".]" at the end, and this will not do. Later - processing will add a second directory spec, and this would be a syntax - error. Thus we strip the ".]", and thus merge the directory specs. - We also backspace unixname, so that it points to a '/'. This inhibits the - generation of the 000000 root directory spec (which does not belong here - in this case). */ - - basename -= 2; /* Strip ".]" */ - unixname--; /* backspace */ - } - } - - else - - { - - /* We drop in here if there is no VMS style directory specification yet. - If there is no device specification either, we make the first dir a - device and try that. If we do not do this, then we will be essentially - searching the users default directory (as if they did a #include "asdf.h"). - - Then all we need to do is to push a '[' into the output string. Later - processing will fill this in, and close the bracket. */ - - if ((unixname != fullname) /* vms path spec found. */ - && (basename[-1] != ':')) - *local_ptr++ = ':'; /* dev not in spec. take first dir */ - - *local_ptr++ = '['; /* Open the directory specification */ - } - - if (unixname == fullname) /* no vms dir spec. */ - { - must_revert = 1; - if ((first_slash != 0) /* unix dir spec. */ - && (*unixname != '/') /* not beginning with '/' */ - && (*unixname != '.')) /* or './' or '../' */ - *local_ptr++ = '.'; /* dir is local ! */ - } - - /* at this point we assume that we have the device spec, and (at least - the opening "[" for a directory specification. We may have directories - specified already. - - If there are no other slashes then the filename will be - in the "root" directory. Otherwise, we need to add - directory specifications. */ - - if (index (unixname, '/') == 0) - { - /* if no directories specified yet and none are following. */ - if (local_ptr[-1] == '[') - { - /* Just add "000000]" as the directory string */ - strcpy (local_ptr, "000000]"); - local_ptr += strlen (local_ptr); - check_filename_before_returning = 1; /* we might need to fool with this later */ - } - } - else - { - - /* As long as there are still subdirectories to add, do them. */ - while (index (unixname, '/') != 0) - { - /* If this token is "." we can ignore it - if it's not at the beginning of a path. */ - if ((unixname[0] == '.') && (unixname[1] == '/')) - { - /* remove it at beginning of path. */ - if ( ((unixname == fullname) /* no device spec */ - && (fullname+2 != basename)) /* starts with ./ */ - /* or */ - || ((basename[-1] == ':') /* device spec */ - && (unixname-1 == basename))) /* and ./ afterwards */ - *local_ptr++ = '.'; /* make '[.' start of path. */ - unixname += 2; - continue; - } - - /* Add a subdirectory spec. Do not duplicate "." */ - if ( local_ptr[-1] != '.' - && local_ptr[-1] != '[' - && local_ptr[-1] != '<') - *local_ptr++ = '.'; - - /* If this is ".." then the spec becomes "-" */ - if ( (unixname[0] == '.') - && (unixname[1] == '.') - && (unixname[2] == '/')) - { - /* Add "-" and skip the ".." */ - if ((local_ptr[-1] == '.') - && (local_ptr[-2] == '[')) - local_ptr--; /* prevent [.- */ - *local_ptr++ = '-'; - unixname += 3; - continue; - } - - /* Copy the subdirectory */ - while (*unixname != '/') - *local_ptr++= *unixname++; - - unixname++; /* Skip the "/" */ - } - - /* Close the directory specification */ - if (local_ptr[-1] == '.') /* no trailing periods */ - local_ptr--; - - if (local_ptr[-1] == '[') /* no dir needed */ - local_ptr--; - else - *local_ptr++ = ']'; - } - - /* Now add the filename. */ - - while (*unixname) - *local_ptr++ = *unixname++; - *local_ptr = 0; - - /* Now append it to the original VMS spec. */ - - strcpy ((must_revert==1)?fullname:basename, Local); - - /* If we put a [000000] in the filename, try to open it first. If this fails, - remove the [000000], and return that name. This provides flexibility - to the user in that they can use both rooted and non-rooted logical names - to point to the location of the file. */ - - if (check_filename_before_returning) - { - f = open (fullname, O_RDONLY, 0666); - if (f >= 0) - { - /* The file name is OK as it is, so return it as is. */ - close (f); - return 1; - } - - /* The filename did not work. Try to remove the [000000] from the name, - and return it. */ - - basename = index (fullname, '['); - local_ptr = index (fullname, ']') + 1; - strcpy (basename, local_ptr); /* this gets rid of it */ - - } - - return 1; -} -#endif /* VMS */ - -#ifdef VMS - -/* The following wrapper functions supply additional arguments to the VMS - I/O routines to optimize performance with file handling. The arguments - are: - "mbc=16" - Set multi-block count to 16 (use a 8192 byte buffer). - "deq=64" - When extending the file, extend it in chunks of 32Kbytes. - "fop=tef"- Truncate unused portions of file when closing file. - "shr=nil"- Disallow file sharing while file is open. */ - -static FILE * -VMS_freopen (fname, type, oldfile) - char *fname; - char *type; - FILE *oldfile; -{ -#undef freopen /* Get back the real freopen routine. */ - if (strcmp (type, "w") == 0) - return freopen (fname, type, oldfile, - "mbc=16", "deq=64", "fop=tef", "shr=nil"); - return freopen (fname, type, oldfile, "mbc=16"); -} - -static FILE * -VMS_fopen (fname, type) - char *fname; - char *type; -{ -#undef fopen /* Get back the real fopen routine. */ - /* The gcc-vms-1.42 distribution's header files prototype fopen with two - fixed arguments, which matches ANSI's specification but not VAXCRTL's - pre-ANSI implementation. This hack circumvents the mismatch problem. */ - FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen; - - if (*type == 'w') - return (*vmslib_fopen) (fname, type, "mbc=32", - "deq=64", "fop=tef", "shr=nil"); - else - return (*vmslib_fopen) (fname, type, "mbc=32"); -} - -static int -VMS_open (fname, flags, prot) - char *fname; - int flags; - int prot; -{ -#undef open /* Get back the real open routine. */ - return open (fname, flags, prot, "mbc=16", "deq=64", "fop=tef"); -} - -/* more VMS hackery */ -#include -#include - -extern unsigned long SYS$PARSE(), SYS$SEARCH(); - -/* Work around another library bug. If a file is located via a searchlist, - and if the device it's on is not the same device as the one specified - in the first element of that searchlist, then both stat() and fstat() - will fail to return info about it. `errno' will be set to EVMSERR, and - `vaxc$errno' will be set to SS$_NORMAL due yet another bug in stat()! - We can get around this by fully parsing the filename and then passing - that absolute name to stat(). - - Without this fix, we can end up failing to find header files, which is - bad enough, but then compounding the problem by reporting the reason for - failure as "normal successful completion." */ - -#undef fstat /* Get back to the library version. */ - -static int -VMS_fstat (fd, statbuf) - int fd; - struct stat *statbuf; -{ - int result = fstat (fd, statbuf); - - if (result < 0) - { - FILE *fp; - char nambuf[NAM$C_MAXRSS+1]; - - if ((fp = fdopen (fd, "r")) != 0 && fgetname (fp, nambuf) != 0) - result = VMS_stat (nambuf, statbuf); - /* No fclose(fp) here; that would close(fd) as well. */ - } - - return result; -} - -static int -VMS_stat (name, statbuf) - const char *name; - struct stat *statbuf; -{ - int result = stat (name, statbuf); - - if (result < 0) - { - struct FAB fab; - struct NAM nam; - char exp_nam[NAM$C_MAXRSS+1], /* expanded name buffer for SYS$PARSE */ - res_nam[NAM$C_MAXRSS+1]; /* resultant name buffer for SYS$SEARCH */ - - fab = cc$rms_fab; - fab.fab$l_fna = (char *) name; - fab.fab$b_fns = (unsigned char) strlen (name); - fab.fab$l_nam = (void *) &nam; - nam = cc$rms_nam; - nam.nam$l_esa = exp_nam, nam.nam$b_ess = sizeof exp_nam - 1; - nam.nam$l_rsa = res_nam, nam.nam$b_rss = sizeof res_nam - 1; - nam.nam$b_nop = NAM$M_PWD | NAM$M_NOCONCEAL; - if (SYS$PARSE (&fab) & 1) - { - if (SYS$SEARCH (&fab) & 1) - { - res_nam[nam.nam$b_rsl] = '\0'; - result = stat (res_nam, statbuf); - } - /* Clean up searchlist context cached by the system. */ - nam.nam$b_nop = NAM$M_SYNCHK; - fab.fab$l_fna = 0, fab.fab$b_fns = 0; - (void) SYS$PARSE (&fab); - } - } - - return result; -} - -static size_t -VMS_fwrite (ptr, size, nitems, stream) - void const *ptr; - size_t size; - size_t nitems; - FILE *stream; -{ - /* VMS fwrite has undesirable results - if STREAM happens to be a record oriented file. - Work around this problem by writing each character individually. */ - char const *p = ptr; - size_t bytes = size * nitems; - char *lim = p + bytes; - - while (p < lim) - if (putc (*p++, stream) == EOF) - return 0; - - return bytes; -} -#endif /* VMS */ diff --git a/gcc/cexp.c b/gcc/cexp.c deleted file mode 100644 index 9e8fdd5056f..00000000000 --- a/gcc/cexp.c +++ /dev/null @@ -1,2209 +0,0 @@ - -/* A Bison parser, made from cexp.y - by GNU Bison version 1.28 */ - -#define YYBISON 1 /* Identify Bison output. */ - -#define INT 257 -#define CHAR 258 -#define NAME 259 -#define ERROR 260 -#define OR 261 -#define AND 262 -#define EQUAL 263 -#define NOTEQUAL 264 -#define LEQ 265 -#define GEQ 266 -#define LSH 267 -#define RSH 268 -#define UNARY 269 - -#line 28 "cexp.y" - -#include "config.h" - -#include "system.h" -#include "intl.h" -#include -/* #define YYDEBUG 1 */ - -#ifdef MULTIBYTE_CHARS -#include "mbchar.h" -#include -#endif /* MULTIBYTE_CHARS */ - -typedef unsigned char U_CHAR; - -/* This is used for communicating lists of keywords with cccp.c. */ -struct arglist { - struct arglist *next; - U_CHAR *name; - int length; - int argno; -}; - -HOST_WIDEST_INT parse_c_expression PARAMS ((char *, int)); - -static int yylex PARAMS ((void)); -static void yyerror PARAMS ((const char *, ...)) - ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; -static HOST_WIDEST_INT expression_value; -#ifdef TEST_EXP_READER -static int expression_signedp; -#endif - -static jmp_buf parse_return_error; - -/* Nonzero means count most punctuation as part of a name. */ -static int keyword_parsing = 0; - -/* Nonzero means do not evaluate this expression. - This is a count, since unevaluated expressions can nest. */ -static int skip_evaluation; - -/* Nonzero means warn if undefined identifiers are evaluated. */ -static int warn_undef; - -/* some external tables of character types */ -extern unsigned char is_idstart[], is_idchar[], is_space[]; - -/* Flag for -pedantic. */ -extern int pedantic; - -/* Flag for -traditional. */ -extern int traditional; - -/* Flag for -lang-c89. */ -extern int c89; - -#ifndef CHAR_TYPE_SIZE -#define CHAR_TYPE_SIZE BITS_PER_UNIT -#endif - -#ifndef INT_TYPE_SIZE -#define INT_TYPE_SIZE BITS_PER_WORD -#endif - -#ifndef LONG_TYPE_SIZE -#define LONG_TYPE_SIZE BITS_PER_WORD -#endif - -#ifndef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE INT_TYPE_SIZE -#endif - -#ifndef MAX_CHAR_TYPE_SIZE -#define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE -#endif - -#ifndef MAX_INT_TYPE_SIZE -#define MAX_INT_TYPE_SIZE INT_TYPE_SIZE -#endif - -#ifndef MAX_LONG_TYPE_SIZE -#define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE -#endif - -#ifndef MAX_WCHAR_TYPE_SIZE -#define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE -#endif - -#define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \ - ? (~ (~ (HOST_WIDEST_INT) 0 << MAX_CHAR_TYPE_SIZE)) \ - : ~ (HOST_WIDEST_INT) 0) - -#define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \ - ? ~ (~ (HOST_WIDEST_INT) 0 << MAX_WCHAR_TYPE_SIZE) \ - : ~ (HOST_WIDEST_INT) 0) - -/* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow. - Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1. - Suppose SIGNEDP is negative if the result is signed, zero if unsigned. - Then this yields nonzero if overflow occurred during the addition. - Overflow occurs if A and B have the same sign, but A and SUM differ in sign, - and SIGNEDP is negative. - Use `^' to test whether signs differ, and `< 0' to isolate the sign. */ -#define overflow_sum_sign(a, b, sum, signedp) \ - ((~((a) ^ (b)) & ((a) ^ (sum)) & (signedp)) < 0) - -struct constant; - -HOST_WIDEST_INT parse_escape PARAMS ((char **, HOST_WIDEST_INT)); -int check_assertion PARAMS ((U_CHAR *, int, int, struct arglist *)); -struct hashnode *lookup PARAMS ((U_CHAR *, int, int)); -void error PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; -void verror PARAMS ((const char *, va_list)); -void pedwarn PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; -void warning PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; - -static int parse_number PARAMS ((int)); -static HOST_WIDEST_INT left_shift PARAMS ((struct constant *, unsigned HOST_WIDEST_INT)); -static HOST_WIDEST_INT right_shift PARAMS ((struct constant *, unsigned HOST_WIDEST_INT)); -static void integer_overflow PARAMS ((void)); - -/* `signedp' values */ -#define SIGNED (~0) -#define UNSIGNED 0 - -#line 155 "cexp.y" -typedef union { - struct constant {HOST_WIDEST_INT value; int signedp;} integer; - struct name {U_CHAR *address; int length;} name; - struct arglist *keywords; -} YYSTYPE; -#include - -#ifndef __cplusplus -#ifndef __STDC__ -#define const -#endif -#endif - - - -#define YYFINAL 77 -#define YYFLAG -32768 -#define YYNTBASE 34 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 269 ? yytranslate[x] : 43) - -static const char yytranslate[] = { 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 29, 2, 31, 2, 27, 14, 2, 32, - 33, 25, 23, 9, 24, 2, 26, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 8, 2, 17, - 2, 18, 7, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 13, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 12, 2, 30, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, - 10, 11, 15, 16, 19, 20, 21, 22, 28 -}; - -#if YYDEBUG != 0 -static const short yyprhs[] = { 0, - 0, 2, 4, 8, 11, 14, 17, 20, 23, 24, - 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, - 71, 75, 79, 83, 87, 91, 95, 99, 100, 105, - 106, 111, 112, 113, 121, 123, 125, 127, 128, 133 -}; - -static const short yyrhs[] = { 35, - 0, 36, 0, 35, 9, 36, 0, 24, 36, 0, - 29, 36, 0, 23, 36, 0, 30, 36, 0, 31, - 5, 0, 0, 31, 5, 37, 32, 42, 33, 0, - 32, 35, 33, 0, 36, 25, 36, 0, 36, 26, - 36, 0, 36, 27, 36, 0, 36, 23, 36, 0, - 36, 24, 36, 0, 36, 21, 36, 0, 36, 22, - 36, 0, 36, 15, 36, 0, 36, 16, 36, 0, - 36, 19, 36, 0, 36, 20, 36, 0, 36, 17, - 36, 0, 36, 18, 36, 0, 36, 14, 36, 0, - 36, 13, 36, 0, 36, 12, 36, 0, 0, 36, - 11, 38, 36, 0, 0, 36, 10, 39, 36, 0, - 0, 0, 36, 7, 40, 36, 8, 41, 36, 0, - 3, 0, 4, 0, 5, 0, 0, 32, 42, 33, - 42, 0, 5, 42, 0 -}; - -#endif - -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 185, 195, 196, 203, 208, 211, 213, 216, 220, 222, - 227, 232, 245, 262, 275, 281, 287, 293, 299, 302, - 305, 312, 319, 326, 333, 336, 339, 342, 345, 348, - 351, 354, 356, 359, 362, 364, 366, 374, 376, 389 -}; -#endif - - -#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) - -static const char * const yytname[] = { "$","error","$undefined.","INT","CHAR", -"NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL", -"'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'", -"'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords", NULL -}; -#endif - -static const short yyr1[] = { 0, - 34, 35, 35, 36, 36, 36, 36, 36, 37, 36, - 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, - 36, 36, 36, 36, 36, 36, 36, 38, 36, 39, - 36, 40, 41, 36, 36, 36, 36, 42, 42, 42 -}; - -static const short yyr2[] = { 0, - 1, 1, 3, 2, 2, 2, 2, 2, 0, 6, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 0, 4, 0, - 4, 0, 0, 7, 1, 1, 1, 0, 4, 2 -}; - -static const short yydefact[] = { 0, - 35, 36, 37, 0, 0, 0, 0, 0, 0, 1, - 2, 6, 4, 5, 7, 8, 0, 0, 32, 30, - 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 11, 3, - 0, 0, 0, 27, 26, 25, 19, 20, 23, 24, - 21, 22, 17, 18, 15, 16, 12, 13, 14, 38, - 0, 31, 29, 38, 38, 0, 33, 40, 0, 10, - 0, 38, 34, 39, 0, 0, 0 -}; - -static const short yydefgoto[] = { 75, - 10, 11, 38, 43, 42, 41, 71, 66 -}; - -static const short yypact[] = { 12, --32768,-32768,-32768, 12, 12, 12, 12, 1, 12, 4, - 79,-32768,-32768,-32768,-32768, -21, 31, 12,-32768,-32768, --32768, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 30,-32768, 79, - 12, 12, 12, 110, 124, 137, 148, 148, 155, 155, - 155, 155, 160, 160, -17, -17,-32768,-32768,-32768, 2, - 58, 34, 95, 2, 2, 54,-32768,-32768, 55,-32768, - 12, 2, 79,-32768, 63, 188,-32768 -}; - -static const short yypgoto[] = {-32768, - 180, -4,-32768,-32768,-32768,-32768,-32768, -60 -}; - - -#define YYLAST 189 - - -static const short yytable[] = { 12, - 13, 14, 15, 68, 69, 16, 64, 35, 36, 37, - -9, 74, 18, 40, 1, 2, 3, 44, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 58, 59, 65, 4, 5, 61, 62, 63, 18, - 6, 7, 8, 9, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 60, 76, 39, 19, 67, 73, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 19, 70, 72, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 31, 32, 33, 34, 35, - 36, 37, 33, 34, 35, 36, 37, 77, 17 -}; - -static const short yycheck[] = { 4, - 5, 6, 7, 64, 65, 5, 5, 25, 26, 27, - 32, 72, 9, 18, 3, 4, 5, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 32, 23, 24, 41, 42, 43, 9, - 29, 30, 31, 32, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 32, 0, 33, 7, 8, 71, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 7, 33, 33, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 21, 22, 23, 24, 25, - 26, 27, 23, 24, 25, 26, 27, 0, 9 -}; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/share/misc/bison.simple" -/* This file comes from bison-1.28. */ - -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -#ifndef YYSTACK_USE_ALLOCA -#ifdef alloca -#define YYSTACK_USE_ALLOCA -#else /* alloca not defined */ -#ifdef __GNUC__ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) -#define YYSTACK_USE_ALLOCA -#include -#else /* not sparc */ -/* We think this test detects Watcom and Microsoft C. */ -/* This used to test MSDOS, but that is a bad idea - since that symbol is in the user namespace. */ -#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) -#if 0 /* No need for malloc.h, which pollutes the namespace; - instead, just don't use alloca. */ -#include -#endif -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -/* I don't know what this was needed for, but it pollutes the namespace. - So I turned it off. rms, 2 May 1997. */ -/* #include */ - #pragma alloca -#define YYSTACK_USE_ALLOCA -#else /* not MSDOS, or __TURBOC__, or _AIX */ -#if 0 -#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, - and on HPUX 10. Eventually we can turn this on. */ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#endif /* __hpux */ -#endif -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc */ -#endif /* not GNU C */ -#endif /* alloca not defined */ -#endif /* YYSTACK_USE_ALLOCA not defined */ - -#ifdef YYSTACK_USE_ALLOCA -#define YYSTACK_ALLOC alloca -#else -#define YYSTACK_ALLOC malloc -#endif - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -#ifndef YYPURE -#define YYLEX yylex() -#endif - -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) -#endif -#else /* not YYLSP_NEEDED */ -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval) -#endif -#endif /* not YYLSP_NEEDED */ -#endif - -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE - -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ - -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif - -/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ - -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -/* Define __yy_memcpy. Note that the size argument - should be passed with type unsigned int, because that is what the non-GCC - definitions require. With GCC, __builtin_memcpy takes an arg - of type size_t, but it can handle unsigned int. */ - -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (to, from, count) - char *to; - char *from; - unsigned int count; -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#else /* __cplusplus */ - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (char *to, char *from, unsigned int count) -{ - register char *t = to; - register char *f = from; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#endif -#endif - -#line 217 "/usr/share/misc/bison.simple" - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -#ifdef __cplusplus -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* not __cplusplus */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif /* not __cplusplus */ -#else /* not YYPARSE_PARAM */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* not YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -#ifdef YYPARSE_PARAM -int yyparse (void *); -#else -int yyparse (void); -#endif -#endif - -int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ - -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -#define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - int yystacksize = YYINITDEPTH; - int yyfree_stacks = 0; - -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif - - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ - - int yylen; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss - 1; - yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif - -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - - *++yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - - /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; - -#ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif -#else /* no yyoverflow */ - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 2; - } - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; -#ifndef YYSTACK_USE_ALLOCA - yyfree_stacks = 1; -#endif - yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, - size * (unsigned int) sizeof (*yyssp)); - yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, - size * (unsigned int) sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, - size * (unsigned int) sizeof (*yylsp)); -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif - - goto yybackup; - yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif - } - else - { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; - - yystate = yyn; - goto yynewstate; - -/* Do the default action for the current state. */ -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -/* Do a reduction. yyn is the number of a rule to reduce with. */ -yyreduce: - yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - - switch (yyn) { - -case 1: -#line 186 "cexp.y" -{ - expression_value = yyvsp[0].integer.value; -#ifdef TEST_EXP_READER - expression_signedp = yyvsp[0].integer.signedp; -#endif - ; - break;} -case 3: -#line 197 "cexp.y" -{ if (pedantic) - pedwarn ("comma operator in operand of `#if'"); - yyval.integer = yyvsp[0].integer; ; - break;} -case 4: -#line 204 "cexp.y" -{ yyval.integer.value = - yyvsp[0].integer.value; - yyval.integer.signedp = yyvsp[0].integer.signedp; - if ((yyval.integer.value & yyvsp[0].integer.value & yyval.integer.signedp) < 0) - integer_overflow (); ; - break;} -case 5: -#line 209 "cexp.y" -{ yyval.integer.value = ! yyvsp[0].integer.value; - yyval.integer.signedp = SIGNED; ; - break;} -case 6: -#line 212 "cexp.y" -{ yyval.integer = yyvsp[0].integer; ; - break;} -case 7: -#line 214 "cexp.y" -{ yyval.integer.value = ~ yyvsp[0].integer.value; - yyval.integer.signedp = yyvsp[0].integer.signedp; ; - break;} -case 8: -#line 217 "cexp.y" -{ yyval.integer.value = check_assertion (yyvsp[0].name.address, yyvsp[0].name.length, - 0, NULL_PTR); - yyval.integer.signedp = SIGNED; ; - break;} -case 9: -#line 221 "cexp.y" -{ keyword_parsing = 1; ; - break;} -case 10: -#line 223 "cexp.y" -{ yyval.integer.value = check_assertion (yyvsp[-4].name.address, yyvsp[-4].name.length, - 1, yyvsp[-1].keywords); - keyword_parsing = 0; - yyval.integer.signedp = SIGNED; ; - break;} -case 11: -#line 228 "cexp.y" -{ yyval.integer = yyvsp[-1].integer; ; - break;} -case 12: -#line 233 "cexp.y" -{ yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; - if (yyval.integer.signedp) - { - yyval.integer.value = yyvsp[-2].integer.value * yyvsp[0].integer.value; - if (yyvsp[-2].integer.value - && (yyval.integer.value / yyvsp[-2].integer.value != yyvsp[0].integer.value - || (yyval.integer.value & yyvsp[-2].integer.value & yyvsp[0].integer.value) < 0)) - integer_overflow (); - } - else - yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value - * yyvsp[0].integer.value); ; - break;} -case 13: -#line 246 "cexp.y" -{ if (yyvsp[0].integer.value == 0) - { - if (!skip_evaluation) - error ("division by zero in #if"); - yyvsp[0].integer.value = 1; - } - yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; - if (yyval.integer.signedp) - { - yyval.integer.value = yyvsp[-2].integer.value / yyvsp[0].integer.value; - if ((yyval.integer.value & yyvsp[-2].integer.value & yyvsp[0].integer.value) < 0) - integer_overflow (); - } - else - yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value - / yyvsp[0].integer.value); ; - break;} -case 14: -#line 263 "cexp.y" -{ if (yyvsp[0].integer.value == 0) - { - if (!skip_evaluation) - error ("division by zero in #if"); - yyvsp[0].integer.value = 1; - } - yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; - if (yyval.integer.signedp) - yyval.integer.value = yyvsp[-2].integer.value % yyvsp[0].integer.value; - else - yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value - % yyvsp[0].integer.value); ; - break;} -case 15: -#line 276 "cexp.y" -{ yyval.integer.value = yyvsp[-2].integer.value + yyvsp[0].integer.value; - yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; - if (overflow_sum_sign (yyvsp[-2].integer.value, yyvsp[0].integer.value, - yyval.integer.value, yyval.integer.signedp)) - integer_overflow (); ; - break;} -case 16: -#line 282 "cexp.y" -{ yyval.integer.value = yyvsp[-2].integer.value - yyvsp[0].integer.value; - yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; - if (overflow_sum_sign (yyval.integer.value, yyvsp[0].integer.value, - yyvsp[-2].integer.value, yyval.integer.signedp)) - integer_overflow (); ; - break;} -case 17: -#line 288 "cexp.y" -{ yyval.integer.signedp = yyvsp[-2].integer.signedp; - if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0) - yyval.integer.value = right_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value); - else - yyval.integer.value = left_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ; - break;} -case 18: -#line 294 "cexp.y" -{ yyval.integer.signedp = yyvsp[-2].integer.signedp; - if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0) - yyval.integer.value = left_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value); - else - yyval.integer.value = right_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ; - break;} -case 19: -#line 300 "cexp.y" -{ yyval.integer.value = (yyvsp[-2].integer.value == yyvsp[0].integer.value); - yyval.integer.signedp = SIGNED; ; - break;} -case 20: -#line 303 "cexp.y" -{ yyval.integer.value = (yyvsp[-2].integer.value != yyvsp[0].integer.value); - yyval.integer.signedp = SIGNED; ; - break;} -case 21: -#line 306 "cexp.y" -{ yyval.integer.signedp = SIGNED; - if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) - yyval.integer.value = yyvsp[-2].integer.value <= yyvsp[0].integer.value; - else - yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value - <= yyvsp[0].integer.value); ; - break;} -case 22: -#line 313 "cexp.y" -{ yyval.integer.signedp = SIGNED; - if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) - yyval.integer.value = yyvsp[-2].integer.value >= yyvsp[0].integer.value; - else - yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value - >= yyvsp[0].integer.value); ; - break;} -case 23: -#line 320 "cexp.y" -{ yyval.integer.signedp = SIGNED; - if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) - yyval.integer.value = yyvsp[-2].integer.value < yyvsp[0].integer.value; - else - yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value - < yyvsp[0].integer.value); ; - break;} -case 24: -#line 327 "cexp.y" -{ yyval.integer.signedp = SIGNED; - if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) - yyval.integer.value = yyvsp[-2].integer.value > yyvsp[0].integer.value; - else - yyval.integer.value = ((unsigned HOST_WIDEST_INT) yyvsp[-2].integer.value - > yyvsp[0].integer.value); ; - break;} -case 25: -#line 334 "cexp.y" -{ yyval.integer.value = yyvsp[-2].integer.value & yyvsp[0].integer.value; - yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; - break;} -case 26: -#line 337 "cexp.y" -{ yyval.integer.value = yyvsp[-2].integer.value ^ yyvsp[0].integer.value; - yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; - break;} -case 27: -#line 340 "cexp.y" -{ yyval.integer.value = yyvsp[-2].integer.value | yyvsp[0].integer.value; - yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; - break;} -case 28: -#line 343 "cexp.y" -{ skip_evaluation += !yyvsp[-1].integer.value; ; - break;} -case 29: -#line 345 "cexp.y" -{ skip_evaluation -= !yyvsp[-3].integer.value; - yyval.integer.value = (yyvsp[-3].integer.value && yyvsp[0].integer.value); - yyval.integer.signedp = SIGNED; ; - break;} -case 30: -#line 349 "cexp.y" -{ skip_evaluation += !!yyvsp[-1].integer.value; ; - break;} -case 31: -#line 351 "cexp.y" -{ skip_evaluation -= !!yyvsp[-3].integer.value; - yyval.integer.value = (yyvsp[-3].integer.value || yyvsp[0].integer.value); - yyval.integer.signedp = SIGNED; ; - break;} -case 32: -#line 355 "cexp.y" -{ skip_evaluation += !yyvsp[-1].integer.value; ; - break;} -case 33: -#line 357 "cexp.y" -{ skip_evaluation += !!yyvsp[-4].integer.value - !yyvsp[-4].integer.value; ; - break;} -case 34: -#line 359 "cexp.y" -{ skip_evaluation -= !!yyvsp[-6].integer.value; - yyval.integer.value = yyvsp[-6].integer.value ? yyvsp[-3].integer.value : yyvsp[0].integer.value; - yyval.integer.signedp = yyvsp[-3].integer.signedp & yyvsp[0].integer.signedp; ; - break;} -case 35: -#line 363 "cexp.y" -{ yyval.integer = yylval.integer; ; - break;} -case 36: -#line 365 "cexp.y" -{ yyval.integer = yylval.integer; ; - break;} -case 37: -#line 367 "cexp.y" -{ if (warn_undef && !skip_evaluation) - warning ("`%.*s' is not defined", - yyvsp[0].name.length, yyvsp[0].name.address); - yyval.integer.value = 0; - yyval.integer.signedp = SIGNED; ; - break;} -case 38: -#line 375 "cexp.y" -{ yyval.keywords = 0; ; - break;} -case 39: -#line 377 "cexp.y" -{ struct arglist *temp; - yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist)); - yyval.keywords->next = yyvsp[-2].keywords; - yyval.keywords->name = (U_CHAR *) "("; - yyval.keywords->length = 1; - temp = yyval.keywords; - while (temp != 0 && temp->next != 0) - temp = temp->next; - temp->next = (struct arglist *) xmalloc (sizeof (struct arglist)); - temp->next->next = yyvsp[0].keywords; - temp->next->name = (U_CHAR *) ")"; - temp->next->length = 1; ; - break;} -case 40: -#line 390 "cexp.y" -{ yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist)); - yyval.keywords->name = yyvsp[-1].name.address; - yyval.keywords->length = yyvsp[-1].name.length; - yyval.keywords->next = yyvsp[0].keywords; ; - break;} -} - /* the action file gets copied in in place of this dollarsign */ -#line 543 "/usr/share/misc/bison.simple" - - yyvsp -= yylen; - yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yyerrlab: /* here on detecting error */ - - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); - - if (count < 5) - { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else - yyerror ("parse error; also virtual memory exceeded"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } - - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ - - if (yyerrstatus == 3) - { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - -yyerrdefault: /* current state does not do anything special for the error token. */ - -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif - -yyerrpop: /* pop the current state because it cannot handle the error token */ - - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; - - yyacceptlab: - /* YYACCEPT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 0; - - yyabortlab: - /* YYABORT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 1; -} -#line 395 "cexp.y" - - -/* During parsing of a C expression, the pointer to the next character - is in this variable. */ - -static char *lexptr; - -/* Take care of parsing a number (anything that starts with a digit). - Set yylval and return the token type; update lexptr. - LEN is the number of characters in it. */ - -/* maybe needs to actually deal with floating point numbers */ - -static int -parse_number (olen) - int olen; -{ - register char *p = lexptr; - register int c; - register unsigned HOST_WIDEST_INT n = 0, nd, max_over_base; - register int base = 10; - register int len = olen; - register int overflow = 0; - register int digit, largest_digit = 0; - int spec_long = 0; - - yylval.integer.signedp = SIGNED; - - if (*p == '0') { - base = 8; - if (len >= 3 && (p[1] == 'x' || p[1] == 'X')) { - p += 2; - base = 16; - len -= 2; - } - } - - max_over_base = (unsigned HOST_WIDEST_INT) -1 / base; - - for (; len > 0; len--) { - c = *p++; - - if (c >= '0' && c <= '9') - digit = c - '0'; - else if (base == 16 && c >= 'a' && c <= 'f') - digit = c - 'a' + 10; - else if (base == 16 && c >= 'A' && c <= 'F') - digit = c - 'A' + 10; - else { - /* `l' means long, and `u' means unsigned. */ - while (1) { - if (c == 'l' || c == 'L') - { - if (!pedantic < spec_long) - yyerror ("too many `l's in integer constant"); - spec_long++; - } - else if (c == 'u' || c == 'U') - { - if (! yylval.integer.signedp) - yyerror ("two `u's in integer constant"); - yylval.integer.signedp = UNSIGNED; - } - else { - if (c == '.' || c == 'e' || c == 'E' || c == 'p' || c == 'P') - yyerror ("Floating point numbers not allowed in #if expressions"); - else - yyerror ("missing white space after number `%.*s'", - (int) (p - lexptr - 1), lexptr); - } - - if (--len == 0) - break; - c = *p++; - } - /* Don't look for any more digits after the suffixes. */ - break; - } - if (largest_digit < digit) - largest_digit = digit; - nd = n * base + digit; - overflow |= (max_over_base < n) | (nd < n); - n = nd; - } - - if (base <= largest_digit) - pedwarn ("integer constant contains digits beyond the radix"); - - if (overflow) - pedwarn ("integer constant out of range"); - - /* If too big to be signed, consider it unsigned. */ - if (((HOST_WIDEST_INT) n & yylval.integer.signedp) < 0) - { - if (base == 10) - warning ("integer constant is so large that it is unsigned"); - yylval.integer.signedp = UNSIGNED; - } - - lexptr = p; - yylval.integer.value = n; - return INT; -} - -struct token { - const char *operator; - int token; -}; - -static struct token tokentab2[] = { - {"&&", AND}, - {"||", OR}, - {"<<", LSH}, - {">>", RSH}, - {"==", EQUAL}, - {"!=", NOTEQUAL}, - {"<=", LEQ}, - {">=", GEQ}, - {"++", ERROR}, - {"--", ERROR}, - {NULL, ERROR} -}; - -/* Read one token, getting characters through lexptr. */ - -static int -yylex () -{ - register int c; - register int namelen; - register unsigned char *tokstart; - register struct token *toktab; - int wide_flag; - HOST_WIDEST_INT mask; - - retry: - - tokstart = (unsigned char *) lexptr; - c = *tokstart; - /* See if it is a special token of length 2. */ - if (! keyword_parsing) - for (toktab = tokentab2; toktab->operator != NULL; toktab++) - if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) { - lexptr += 2; - if (toktab->token == ERROR) - yyerror ("`%s' not allowed in operand of `#if'", toktab->operator); - return toktab->token; - } - - switch (c) { - case '\n': - return 0; - - case ' ': - case '\t': - case '\r': - lexptr++; - goto retry; - - case 'L': - /* Capital L may start a wide-string or wide-character constant. */ - if (lexptr[1] == '\'') - { - lexptr++; - wide_flag = 1; - mask = MAX_WCHAR_TYPE_MASK; - goto char_constant; - } - if (lexptr[1] == '"') - { - lexptr++; - wide_flag = 1; - mask = MAX_WCHAR_TYPE_MASK; - goto string_constant; - } - break; - - case '\'': - wide_flag = 0; - mask = MAX_CHAR_TYPE_MASK; - char_constant: - lexptr++; - if (keyword_parsing) { - char *start_ptr = lexptr - 1; - while (1) { - c = *lexptr++; - if (c == '\\') - c = parse_escape (&lexptr, mask); - else if (c == '\'') - break; - } - yylval.name.address = tokstart; - yylval.name.length = lexptr - start_ptr; - return NAME; - } - - /* This code for reading a character constant - handles multicharacter constants and wide characters. - It is mostly copied from c-lex.c. */ - { - register HOST_WIDEST_INT result = 0; - register int num_chars = 0; - int chars_seen = 0; - unsigned width = MAX_CHAR_TYPE_SIZE; - int max_chars; -#ifdef MULTIBYTE_CHARS - int longest_char = local_mb_cur_max (); - char *token_buffer = (char *) alloca (longest_char); - (void) local_mbtowc (NULL_PTR, NULL_PTR, 0); -#endif - - max_chars = MAX_LONG_TYPE_SIZE / width; - if (wide_flag) - width = MAX_WCHAR_TYPE_SIZE; - - while (1) - { - c = *lexptr++; - - if (c == '\'' || c == EOF) - break; - - ++chars_seen; - if (c == '\\') - { - c = parse_escape (&lexptr, mask); - } - else - { -#ifdef MULTIBYTE_CHARS - wchar_t wc; - int i; - int char_len = -1; - for (i = 1; i <= longest_char; ++i) - { - token_buffer[i - 1] = c; - char_len = local_mbtowc (& wc, token_buffer, i); - if (char_len != -1) - break; - c = *lexptr++; - } - if (char_len > 1) - { - /* mbtowc sometimes needs an extra char before accepting */ - if (char_len < i) - lexptr--; - if (! wide_flag) - { - /* Merge character into result; ignore excess chars. */ - for (i = 1; i <= char_len; ++i) - { - if (i > max_chars) - break; - if (width < HOST_BITS_PER_INT) - result = (result << width) - | (token_buffer[i - 1] - & ((1 << width) - 1)); - else - result = token_buffer[i - 1]; - } - num_chars += char_len; - continue; - } - } - else - { - if (char_len == -1) - warning ("Ignoring invalid multibyte character"); - } - if (wide_flag) - c = wc; -#endif /* ! MULTIBYTE_CHARS */ - } - - if (wide_flag) - { - if (chars_seen == 1) /* only keep the first one */ - result = c; - continue; - } - - /* Merge character into result; ignore excess chars. */ - num_chars++; - if (num_chars <= max_chars) - { - if (width < HOST_BITS_PER_INT) - result = (result << width) | (c & ((1 << width) - 1)); - else - result = c; - } - } - - if (c != '\'') - error ("malformatted character constant"); - else if (chars_seen == 0) - error ("empty character constant"); - else if (num_chars > max_chars) - { - num_chars = max_chars; - error ("character constant too long"); - } - else if (chars_seen != 1 && ! traditional) - warning ("multi-character character constant"); - - /* If char type is signed, sign-extend the constant. */ - if (! wide_flag) - { - int num_bits = num_chars * width; - if (num_bits == 0) - /* We already got an error; avoid invalid shift. */ - yylval.integer.value = 0; - else if (lookup ((U_CHAR *) "__CHAR_UNSIGNED__", - sizeof ("__CHAR_UNSIGNED__") - 1, -1) - || ((result >> (num_bits - 1)) & 1) == 0) - yylval.integer.value - = result & (~ (unsigned HOST_WIDEST_INT) 0 - >> (HOST_BITS_PER_WIDEST_INT - num_bits)); - else - yylval.integer.value - = result | ~(~ (unsigned HOST_WIDEST_INT) 0 - >> (HOST_BITS_PER_WIDEST_INT - num_bits)); - } - else - { - yylval.integer.value = result; - } - } - - /* This is always a signed type. */ - yylval.integer.signedp = SIGNED; - - return CHAR; - - /* some of these chars are invalid in constant expressions; - maybe do something about them later */ - case '/': - case '+': - case '-': - case '*': - case '%': - case '|': - case '&': - case '^': - case '~': - case '!': - case '@': - case '<': - case '>': - case '[': - case ']': - case '.': - case '?': - case ':': - case '=': - case '{': - case '}': - case ',': - case '#': - if (keyword_parsing) - break; - case '(': - case ')': - lexptr++; - return c; - - case '"': - mask = MAX_CHAR_TYPE_MASK; - string_constant: - if (keyword_parsing) { - char *start_ptr = lexptr; - lexptr++; - while (1) { - c = *lexptr++; - if (c == '\\') - c = parse_escape (&lexptr, mask); - else if (c == '"') - break; - } - yylval.name.address = tokstart; - yylval.name.length = lexptr - start_ptr; - return NAME; - } - yyerror ("string constants not allowed in #if expressions"); - return ERROR; - } - - if (c >= '0' && c <= '9' && !keyword_parsing) { - /* It's a number */ - for (namelen = 1; ; namelen++) { - int d = tokstart[namelen]; - if (! ((is_idchar[d] || d == '.') - || ((d == '-' || d == '+') - && (c == 'e' || c == 'E' - || ((c == 'p' || c == 'P') && ! c89)) - && ! traditional))) - break; - c = d; - } - return parse_number (namelen); - } - - /* It is a name. See how long it is. */ - - if (keyword_parsing) { - for (namelen = 0;; namelen++) { - if (is_space[tokstart[namelen]]) - break; - if (tokstart[namelen] == '(' || tokstart[namelen] == ')') - break; - if (tokstart[namelen] == '"' || tokstart[namelen] == '\'') - break; - } - } else { - if (!is_idstart[c]) { - yyerror ("Invalid token in expression"); - return ERROR; - } - - for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++) - ; - } - - lexptr += namelen; - yylval.name.address = tokstart; - yylval.name.length = namelen; - return NAME; -} - - -/* Parse a C escape sequence. STRING_PTR points to a variable - containing a pointer to the string to parse. That pointer - is updated past the characters we use. The value of the - escape sequence is returned. - - RESULT_MASK is used to mask out the result; - an error is reported if bits are lost thereby. - - A negative value means the sequence \ newline was seen, - which is supposed to be equivalent to nothing at all. - - If \ is followed by a null character, we return a negative - value and leave the string pointer pointing at the null character. - - If \ is followed by 000, we return 0 and leave the string pointer - after the zeros. A value of 0 does not mean end of string. */ - -HOST_WIDEST_INT -parse_escape (string_ptr, result_mask) - char **string_ptr; - HOST_WIDEST_INT result_mask; -{ - register int c = *(*string_ptr)++; - switch (c) - { - case 'a': - return TARGET_BELL; - case 'b': - return TARGET_BS; - case 'e': - case 'E': - if (pedantic) - pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c); - return TARGET_ESC; - case 'f': - return TARGET_FF; - case 'n': - return TARGET_NEWLINE; - case 'r': - return TARGET_CR; - case 't': - return TARGET_TAB; - case 'v': - return TARGET_VT; - case '\n': - return -2; - case 0: - (*string_ptr)--; - return 0; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - register HOST_WIDEST_INT i = c - '0'; - register int count = 0; - while (++count < 3) - { - c = *(*string_ptr)++; - if (c >= '0' && c <= '7') - i = (i << 3) + c - '0'; - else - { - (*string_ptr)--; - break; - } - } - if (i != (i & result_mask)) - { - i &= result_mask; - pedwarn ("octal escape sequence out of range"); - } - return i; - } - case 'x': - { - register unsigned HOST_WIDEST_INT i = 0, overflow = 0; - register int digits_found = 0, digit; - for (;;) - { - c = *(*string_ptr)++; - if (c >= '0' && c <= '9') - digit = c - '0'; - else if (c >= 'a' && c <= 'f') - digit = c - 'a' + 10; - else if (c >= 'A' && c <= 'F') - digit = c - 'A' + 10; - else - { - (*string_ptr)--; - break; - } - overflow |= i ^ (i << 4 >> 4); - i = (i << 4) + digit; - digits_found = 1; - } - if (!digits_found) - yyerror ("\\x used with no following hex digits"); - if (overflow | (i != (i & result_mask))) - { - i &= result_mask; - pedwarn ("hex escape sequence out of range"); - } - return i; - } - default: - return c; - } -} - -static void -integer_overflow () -{ - if (!skip_evaluation && pedantic) - pedwarn ("integer overflow in preprocessor expression"); -} - -static HOST_WIDEST_INT -left_shift (a, b) - struct constant *a; - unsigned HOST_WIDEST_INT b; -{ - /* It's unclear from the C standard whether shifts can overflow. - The following code ignores overflow; perhaps a C standard - interpretation ruling is needed. */ - if (b >= HOST_BITS_PER_WIDEST_INT) - return 0; - else - return (unsigned HOST_WIDEST_INT) a->value << b; -} - -static HOST_WIDEST_INT -right_shift (a, b) - struct constant *a; - unsigned HOST_WIDEST_INT b; -{ - if (b >= HOST_BITS_PER_WIDEST_INT) - return a->signedp ? a->value >> (HOST_BITS_PER_WIDEST_INT - 1) : 0; - else if (a->signedp) - return a->value >> b; - else - return (unsigned HOST_WIDEST_INT) a->value >> b; -} - -/* This page contains the entry point to this file. */ - -/* Parse STRING as an expression, and complain if this fails - to use up all of the contents of STRING. - STRING may contain '\0' bytes; it is terminated by the first '\n' - outside a string constant, so that we can diagnose '\0' properly. - If WARN_UNDEFINED is nonzero, warn if undefined identifiers are evaluated. - We do not support C comments. They should be removed before - this function is called. */ - -HOST_WIDEST_INT -parse_c_expression (string, warn_undefined) - char *string; - int warn_undefined; -{ - lexptr = string; - warn_undef = warn_undefined; - - /* if there is some sort of scanning error, just return 0 and assume - the parsing routine has printed an error message somewhere. - there is surely a better thing to do than this. */ - if (setjmp (parse_return_error)) - return 0; - - if (yyparse () != 0) - abort (); - - if (*lexptr != '\n') - error ("Junk after end of expression."); - - return expression_value; /* set by yyparse () */ -} - -static void -yyerror VPARAMS ((const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - const char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, const char *); -#endif - - verror (msgid, args); - va_end (args); - skip_evaluation = 0; - longjmp (parse_return_error, 1); -} - - -#ifdef TEST_EXP_READER - -#if YYDEBUG -extern int yydebug; -#endif - -int pedantic; -int traditional; -int c89; - -int main PARAMS ((int, char **)); -static void initialize_random_junk PARAMS ((void)); -static void print_unsigned_host_widest_int PARAMS ((unsigned HOST_WIDEST_INT)); - -/* Main program for testing purposes. */ -int -main (argc, argv) - int argc; - char **argv; -{ - int n, c; - char buf[1024]; - unsigned HOST_WIDEST_INT u; - - pedantic = 1 < argc; - traditional = 2 < argc; - c89 = 3 < argc; -#if YYDEBUG - yydebug = 4 < argc; -#endif - initialize_random_junk (); - - for (;;) { - printf ("enter expression: "); - n = 0; - while ((buf[n] = c = getchar ()) != '\n' && c != EOF) - n++; - if (c == EOF) - break; - parse_c_expression (buf, 1); - printf ("parser returned "); - u = (unsigned HOST_WIDEST_INT) expression_value; - if (expression_value < 0 && expression_signedp) { - u = -u; - printf ("-"); - } - if (u == 0) - printf ("0"); - else - print_unsigned_host_widest_int (u); - if (! expression_signedp) - printf("u"); - printf ("\n"); - } - - return 0; -} - -static void -print_unsigned_host_widest_int (u) - unsigned HOST_WIDEST_INT u; -{ - if (u) { - print_unsigned_host_widest_int (u / 10); - putchar ('0' + (int) (u % 10)); - } -} - -/* table to tell if char can be part of a C identifier. */ -unsigned char is_idchar[256]; -/* table to tell if char can be first char of a c identifier. */ -unsigned char is_idstart[256]; -/* table to tell if c is horizontal or vertical space. */ -unsigned char is_space[256]; - -/* - * initialize random junk in the hash table and maybe other places - */ -static void -initialize_random_junk () -{ - register int i; - - /* - * Set up is_idchar and is_idstart tables. These should be - * faster than saying (is_alpha (c) || c == '_'), etc. - * Must do set up these things before calling any routines tthat - * refer to them. - */ - for (i = 'a'; i <= 'z'; i++) { - /* SKIP EBCIDIC holes, char must be a valid low case char */ - if (ISLOWER(i)) { - ++is_idchar[TOUPPER(i)]; - ++is_idchar[i]; - ++is_idstart[TOUPPER(i)]; - ++is_idstart[i]; - } - } - for (i = '0'; i <= '9'; i++) - ++is_idchar[i]; - ++is_idchar['_']; - ++is_idstart['_']; - ++is_idchar['$']; - ++is_idstart['$']; - - ++is_space[' ']; - ++is_space['\t']; - ++is_space['\v']; - ++is_space['\f']; - ++is_space['\n']; - ++is_space['\r']; -} - -void -error VPARAMS ((char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, char *); -#endif - - fprintf (stderr, "error: "); - vfprintf (stderr, _(msgid), args); - fprintf (stderr, "\n"); - va_end (args); -} - -void -pedwarn VPARAMS ((char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, char *); -#endif - - fprintf (stderr, "pedwarn: "); - vfprintf (stderr, _(msgid), args); - fprintf (stderr, "\n"); - va_end (args); -} - -void -warning VPARAMS ((char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, char *); -#endif - - fprintf (stderr, "warning: "); - vfprintf (stderr, _(msgid), args); - fprintf (stderr, "\n"); - va_end (args); -} - - -int -check_assertion (name, sym_length, tokens_specified, tokens) - U_CHAR *name; - int sym_length; - int tokens_specified; - struct arglist *tokens; -{ - return 0; -} - -struct hashnode * -lookup (name, len, hash) - U_CHAR *name; - int len; - int hash; -{ - return (DEFAULT_SIGNED_CHAR) ? 0 : ((struct hashnode *) -1); -} - -PTR -xmalloc (size) - size_t size; -{ - return (PTR) malloc (size); -} -#endif diff --git a/gcc/cexp.y b/gcc/cexp.y deleted file mode 100644 index 83f4cede637..00000000000 --- a/gcc/cexp.y +++ /dev/null @@ -1,1226 +0,0 @@ -/* Parse C expressions for CCCP. - Copyright (C) 1987, 1992, 1994, 1995, 1996, 1997, 1998, - 1999, 2000 Free Software Foundation. - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, 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! - - Adapted from expread.y of GDB by Paul Rubin, July 1986. */ - -/* Parse a C expression from text in a string */ - -%{ -#include "config.h" - -#include "system.h" -#include "intl.h" -#include -/* #define YYDEBUG 1 */ - -#ifdef MULTIBYTE_CHARS -#include "mbchar.h" -#include -#endif /* MULTIBYTE_CHARS */ - -typedef unsigned char U_CHAR; - -/* This is used for communicating lists of keywords with cccp.c. */ -struct arglist { - struct arglist *next; - U_CHAR *name; - int length; - int argno; -}; - -HOST_WIDEST_INT parse_c_expression PARAMS ((char *, int)); - -static int yylex PARAMS ((void)); -static void yyerror PARAMS ((const char *, ...)) - ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; -static HOST_WIDEST_INT expression_value; -#ifdef TEST_EXP_READER -static int expression_signedp; -#endif - -static jmp_buf parse_return_error; - -/* Nonzero means count most punctuation as part of a name. */ -static int keyword_parsing = 0; - -/* Nonzero means do not evaluate this expression. - This is a count, since unevaluated expressions can nest. */ -static int skip_evaluation; - -/* Nonzero means warn if undefined identifiers are evaluated. */ -static int warn_undef; - -/* some external tables of character types */ -extern unsigned char is_idstart[], is_idchar[], is_space[]; - -/* Flag for -pedantic. */ -extern int pedantic; - -/* Flag for -traditional. */ -extern int traditional; - -/* Flag for -lang-c89. */ -extern int c89; - -#ifndef CHAR_TYPE_SIZE -#define CHAR_TYPE_SIZE BITS_PER_UNIT -#endif - -#ifndef INT_TYPE_SIZE -#define INT_TYPE_SIZE BITS_PER_WORD -#endif - -#ifndef LONG_TYPE_SIZE -#define LONG_TYPE_SIZE BITS_PER_WORD -#endif - -#ifndef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE INT_TYPE_SIZE -#endif - -#ifndef MAX_CHAR_TYPE_SIZE -#define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE -#endif - -#ifndef MAX_INT_TYPE_SIZE -#define MAX_INT_TYPE_SIZE INT_TYPE_SIZE -#endif - -#ifndef MAX_LONG_TYPE_SIZE -#define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE -#endif - -#ifndef MAX_WCHAR_TYPE_SIZE -#define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE -#endif - -#define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \ - ? (~ (~ (HOST_WIDEST_INT) 0 << MAX_CHAR_TYPE_SIZE)) \ - : ~ (HOST_WIDEST_INT) 0) - -#define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \ - ? ~ (~ (HOST_WIDEST_INT) 0 << MAX_WCHAR_TYPE_SIZE) \ - : ~ (HOST_WIDEST_INT) 0) - -/* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow. - Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1. - Suppose SIGNEDP is negative if the result is signed, zero if unsigned. - Then this yields nonzero if overflow occurred during the addition. - Overflow occurs if A and B have the same sign, but A and SUM differ in sign, - and SIGNEDP is negative. - Use `^' to test whether signs differ, and `< 0' to isolate the sign. */ -#define overflow_sum_sign(a, b, sum, signedp) \ - ((~((a) ^ (b)) & ((a) ^ (sum)) & (signedp)) < 0) - -struct constant; - -HOST_WIDEST_INT parse_escape PARAMS ((char **, HOST_WIDEST_INT)); -int check_assertion PARAMS ((U_CHAR *, int, int, struct arglist *)); -struct hashnode *lookup PARAMS ((U_CHAR *, int, int)); -void error PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; -void verror PARAMS ((const char *, va_list)); -void pedwarn PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; -void warning PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; - -static int parse_number PARAMS ((int)); -static HOST_WIDEST_INT left_shift PARAMS ((struct constant *, unsigned HOST_WIDEST_INT)); -static HOST_WIDEST_INT right_shift PARAMS ((struct constant *, unsigned HOST_WIDEST_INT)); -static void integer_overflow PARAMS ((void)); - -/* `signedp' values */ -#define SIGNED (~0) -#define UNSIGNED 0 -%} - -%union { - struct constant {HOST_WIDEST_INT value; int signedp;} integer; - struct name {U_CHAR *address; int length;} name; - struct arglist *keywords; -} - -%type exp exp1 start -%type keywords -%token INT CHAR -%token NAME -%token ERROR - -%right '?' ':' -%left ',' -%left OR -%left AND -%left '|' -%left '^' -%left '&' -%left EQUAL NOTEQUAL -%left '<' '>' LEQ GEQ -%left LSH RSH -%left '+' '-' -%left '*' '/' '%' -%right UNARY - -/* %expect 40 */ - -%% - -start : exp1 - { - expression_value = $1.value; -#ifdef TEST_EXP_READER - expression_signedp = $1.signedp; -#endif - } - ; - -/* Expressions, including the comma operator. */ -exp1 : exp - | exp1 ',' exp - { if (pedantic) - pedwarn ("comma operator in operand of `#if'"); - $$ = $3; } - ; - -/* Expressions, not including the comma operator. */ -exp : '-' exp %prec UNARY - { $$.value = - $2.value; - $$.signedp = $2.signedp; - if (($$.value & $2.value & $$.signedp) < 0) - integer_overflow (); } - | '!' exp %prec UNARY - { $$.value = ! $2.value; - $$.signedp = SIGNED; } - | '+' exp %prec UNARY - { $$ = $2; } - | '~' exp %prec UNARY - { $$.value = ~ $2.value; - $$.signedp = $2.signedp; } - | '#' NAME - { $$.value = check_assertion ($2.address, $2.length, - 0, NULL_PTR); - $$.signedp = SIGNED; } - | '#' NAME - { keyword_parsing = 1; } - '(' keywords ')' - { $$.value = check_assertion ($2.address, $2.length, - 1, $5); - keyword_parsing = 0; - $$.signedp = SIGNED; } - | '(' exp1 ')' - { $$ = $2; } - ; - -/* Binary operators in order of decreasing precedence. */ -exp : exp '*' exp - { $$.signedp = $1.signedp & $3.signedp; - if ($$.signedp) - { - $$.value = $1.value * $3.value; - if ($1.value - && ($$.value / $1.value != $3.value - || ($$.value & $1.value & $3.value) < 0)) - integer_overflow (); - } - else - $$.value = ((unsigned HOST_WIDEST_INT) $1.value - * $3.value); } - | exp '/' exp - { if ($3.value == 0) - { - if (!skip_evaluation) - error ("division by zero in #if"); - $3.value = 1; - } - $$.signedp = $1.signedp & $3.signedp; - if ($$.signedp) - { - $$.value = $1.value / $3.value; - if (($$.value & $1.value & $3.value) < 0) - integer_overflow (); - } - else - $$.value = ((unsigned HOST_WIDEST_INT) $1.value - / $3.value); } - | exp '%' exp - { if ($3.value == 0) - { - if (!skip_evaluation) - error ("division by zero in #if"); - $3.value = 1; - } - $$.signedp = $1.signedp & $3.signedp; - if ($$.signedp) - $$.value = $1.value % $3.value; - else - $$.value = ((unsigned HOST_WIDEST_INT) $1.value - % $3.value); } - | exp '+' exp - { $$.value = $1.value + $3.value; - $$.signedp = $1.signedp & $3.signedp; - if (overflow_sum_sign ($1.value, $3.value, - $$.value, $$.signedp)) - integer_overflow (); } - | exp '-' exp - { $$.value = $1.value - $3.value; - $$.signedp = $1.signedp & $3.signedp; - if (overflow_sum_sign ($$.value, $3.value, - $1.value, $$.signedp)) - integer_overflow (); } - | exp LSH exp - { $$.signedp = $1.signedp; - if (($3.value & $3.signedp) < 0) - $$.value = right_shift (&$1, -$3.value); - else - $$.value = left_shift (&$1, $3.value); } - | exp RSH exp - { $$.signedp = $1.signedp; - if (($3.value & $3.signedp) < 0) - $$.value = left_shift (&$1, -$3.value); - else - $$.value = right_shift (&$1, $3.value); } - | exp EQUAL exp - { $$.value = ($1.value == $3.value); - $$.signedp = SIGNED; } - | exp NOTEQUAL exp - { $$.value = ($1.value != $3.value); - $$.signedp = SIGNED; } - | exp LEQ exp - { $$.signedp = SIGNED; - if ($1.signedp & $3.signedp) - $$.value = $1.value <= $3.value; - else - $$.value = ((unsigned HOST_WIDEST_INT) $1.value - <= $3.value); } - | exp GEQ exp - { $$.signedp = SIGNED; - if ($1.signedp & $3.signedp) - $$.value = $1.value >= $3.value; - else - $$.value = ((unsigned HOST_WIDEST_INT) $1.value - >= $3.value); } - | exp '<' exp - { $$.signedp = SIGNED; - if ($1.signedp & $3.signedp) - $$.value = $1.value < $3.value; - else - $$.value = ((unsigned HOST_WIDEST_INT) $1.value - < $3.value); } - | exp '>' exp - { $$.signedp = SIGNED; - if ($1.signedp & $3.signedp) - $$.value = $1.value > $3.value; - else - $$.value = ((unsigned HOST_WIDEST_INT) $1.value - > $3.value); } - | exp '&' exp - { $$.value = $1.value & $3.value; - $$.signedp = $1.signedp & $3.signedp; } - | exp '^' exp - { $$.value = $1.value ^ $3.value; - $$.signedp = $1.signedp & $3.signedp; } - | exp '|' exp - { $$.value = $1.value | $3.value; - $$.signedp = $1.signedp & $3.signedp; } - | exp AND - { skip_evaluation += !$1.value; } - exp - { skip_evaluation -= !$1.value; - $$.value = ($1.value && $4.value); - $$.signedp = SIGNED; } - | exp OR - { skip_evaluation += !!$1.value; } - exp - { skip_evaluation -= !!$1.value; - $$.value = ($1.value || $4.value); - $$.signedp = SIGNED; } - | exp '?' - { skip_evaluation += !$1.value; } - exp ':' - { skip_evaluation += !!$1.value - !$1.value; } - exp - { skip_evaluation -= !!$1.value; - $$.value = $1.value ? $4.value : $7.value; - $$.signedp = $4.signedp & $7.signedp; } - | INT - { $$ = yylval.integer; } - | CHAR - { $$ = yylval.integer; } - | NAME - { if (warn_undef && !skip_evaluation) - warning ("`%.*s' is not defined", - $1.length, $1.address); - $$.value = 0; - $$.signedp = SIGNED; } - ; - -keywords : - { $$ = 0; } - | '(' keywords ')' keywords - { struct arglist *temp; - $$ = (struct arglist *) xmalloc (sizeof (struct arglist)); - $$->next = $2; - $$->name = (U_CHAR *) "("; - $$->length = 1; - temp = $$; - while (temp != 0 && temp->next != 0) - temp = temp->next; - temp->next = (struct arglist *) xmalloc (sizeof (struct arglist)); - temp->next->next = $4; - temp->next->name = (U_CHAR *) ")"; - temp->next->length = 1; } - | NAME keywords - { $$ = (struct arglist *) xmalloc (sizeof (struct arglist)); - $$->name = $1.address; - $$->length = $1.length; - $$->next = $2; } - ; -%% - -/* During parsing of a C expression, the pointer to the next character - is in this variable. */ - -static char *lexptr; - -/* Take care of parsing a number (anything that starts with a digit). - Set yylval and return the token type; update lexptr. - LEN is the number of characters in it. */ - -/* maybe needs to actually deal with floating point numbers */ - -static int -parse_number (olen) - int olen; -{ - register char *p = lexptr; - register int c; - register unsigned HOST_WIDEST_INT n = 0, nd, max_over_base; - register int base = 10; - register int len = olen; - register int overflow = 0; - register int digit, largest_digit = 0; - int spec_long = 0; - - yylval.integer.signedp = SIGNED; - - if (*p == '0') { - base = 8; - if (len >= 3 && (p[1] == 'x' || p[1] == 'X')) { - p += 2; - base = 16; - len -= 2; - } - } - - max_over_base = (unsigned HOST_WIDEST_INT) -1 / base; - - for (; len > 0; len--) { - c = *p++; - - if (c >= '0' && c <= '9') - digit = c - '0'; - else if (base == 16 && c >= 'a' && c <= 'f') - digit = c - 'a' + 10; - else if (base == 16 && c >= 'A' && c <= 'F') - digit = c - 'A' + 10; - else { - /* `l' means long, and `u' means unsigned. */ - while (1) { - if (c == 'l' || c == 'L') - { - if (!pedantic < spec_long) - yyerror ("too many `l's in integer constant"); - spec_long++; - } - else if (c == 'u' || c == 'U') - { - if (! yylval.integer.signedp) - yyerror ("two `u's in integer constant"); - yylval.integer.signedp = UNSIGNED; - } - else { - if (c == '.' || c == 'e' || c == 'E' || c == 'p' || c == 'P') - yyerror ("Floating point numbers not allowed in #if expressions"); - else - yyerror ("missing white space after number `%.*s'", - (int) (p - lexptr - 1), lexptr); - } - - if (--len == 0) - break; - c = *p++; - } - /* Don't look for any more digits after the suffixes. */ - break; - } - if (largest_digit < digit) - largest_digit = digit; - nd = n * base + digit; - overflow |= (max_over_base < n) | (nd < n); - n = nd; - } - - if (base <= largest_digit) - pedwarn ("integer constant contains digits beyond the radix"); - - if (overflow) - pedwarn ("integer constant out of range"); - - /* If too big to be signed, consider it unsigned. */ - if (((HOST_WIDEST_INT) n & yylval.integer.signedp) < 0) - { - if (base == 10) - warning ("integer constant is so large that it is unsigned"); - yylval.integer.signedp = UNSIGNED; - } - - lexptr = p; - yylval.integer.value = n; - return INT; -} - -struct token { - const char *operator; - int token; -}; - -static struct token tokentab2[] = { - {"&&", AND}, - {"||", OR}, - {"<<", LSH}, - {">>", RSH}, - {"==", EQUAL}, - {"!=", NOTEQUAL}, - {"<=", LEQ}, - {">=", GEQ}, - {"++", ERROR}, - {"--", ERROR}, - {NULL, ERROR} -}; - -/* Read one token, getting characters through lexptr. */ - -static int -yylex () -{ - register int c; - register int namelen; - register unsigned char *tokstart; - register struct token *toktab; - int wide_flag; - HOST_WIDEST_INT mask; - - retry: - - tokstart = (unsigned char *) lexptr; - c = *tokstart; - /* See if it is a special token of length 2. */ - if (! keyword_parsing) - for (toktab = tokentab2; toktab->operator != NULL; toktab++) - if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) { - lexptr += 2; - if (toktab->token == ERROR) - yyerror ("`%s' not allowed in operand of `#if'", toktab->operator); - return toktab->token; - } - - switch (c) { - case '\n': - return 0; - - case ' ': - case '\t': - case '\r': - lexptr++; - goto retry; - - case 'L': - /* Capital L may start a wide-string or wide-character constant. */ - if (lexptr[1] == '\'') - { - lexptr++; - wide_flag = 1; - mask = MAX_WCHAR_TYPE_MASK; - goto char_constant; - } - if (lexptr[1] == '"') - { - lexptr++; - wide_flag = 1; - mask = MAX_WCHAR_TYPE_MASK; - goto string_constant; - } - break; - - case '\'': - wide_flag = 0; - mask = MAX_CHAR_TYPE_MASK; - char_constant: - lexptr++; - if (keyword_parsing) { - char *start_ptr = lexptr - 1; - while (1) { - c = *lexptr++; - if (c == '\\') - c = parse_escape (&lexptr, mask); - else if (c == '\'') - break; - } - yylval.name.address = tokstart; - yylval.name.length = lexptr - start_ptr; - return NAME; - } - - /* This code for reading a character constant - handles multicharacter constants and wide characters. - It is mostly copied from c-lex.c. */ - { - register HOST_WIDEST_INT result = 0; - register int num_chars = 0; - int chars_seen = 0; - unsigned width = MAX_CHAR_TYPE_SIZE; - int max_chars; -#ifdef MULTIBYTE_CHARS - int longest_char = local_mb_cur_max (); - char *token_buffer = (char *) alloca (longest_char); - (void) local_mbtowc (NULL_PTR, NULL_PTR, 0); -#endif - - max_chars = MAX_LONG_TYPE_SIZE / width; - if (wide_flag) - width = MAX_WCHAR_TYPE_SIZE; - - while (1) - { - c = *lexptr++; - - if (c == '\'' || c == EOF) - break; - - ++chars_seen; - if (c == '\\') - { - c = parse_escape (&lexptr, mask); - } - else - { -#ifdef MULTIBYTE_CHARS - wchar_t wc; - int i; - int char_len = -1; - for (i = 1; i <= longest_char; ++i) - { - token_buffer[i - 1] = c; - char_len = local_mbtowc (& wc, token_buffer, i); - if (char_len != -1) - break; - c = *lexptr++; - } - if (char_len > 1) - { - /* mbtowc sometimes needs an extra char before accepting */ - if (char_len < i) - lexptr--; - if (! wide_flag) - { - /* Merge character into result; ignore excess chars. */ - for (i = 1; i <= char_len; ++i) - { - if (i > max_chars) - break; - if (width < HOST_BITS_PER_INT) - result = (result << width) - | (token_buffer[i - 1] - & ((1 << width) - 1)); - else - result = token_buffer[i - 1]; - } - num_chars += char_len; - continue; - } - } - else - { - if (char_len == -1) - warning ("Ignoring invalid multibyte character"); - } - if (wide_flag) - c = wc; -#endif /* ! MULTIBYTE_CHARS */ - } - - if (wide_flag) - { - if (chars_seen == 1) /* only keep the first one */ - result = c; - continue; - } - - /* Merge character into result; ignore excess chars. */ - num_chars++; - if (num_chars <= max_chars) - { - if (width < HOST_BITS_PER_INT) - result = (result << width) | (c & ((1 << width) - 1)); - else - result = c; - } - } - - if (c != '\'') - error ("malformatted character constant"); - else if (chars_seen == 0) - error ("empty character constant"); - else if (num_chars > max_chars) - { - num_chars = max_chars; - error ("character constant too long"); - } - else if (chars_seen != 1 && ! traditional) - warning ("multi-character character constant"); - - /* If char type is signed, sign-extend the constant. */ - if (! wide_flag) - { - int num_bits = num_chars * width; - if (num_bits == 0) - /* We already got an error; avoid invalid shift. */ - yylval.integer.value = 0; - else if (lookup ((U_CHAR *) "__CHAR_UNSIGNED__", - sizeof ("__CHAR_UNSIGNED__") - 1, -1) - || ((result >> (num_bits - 1)) & 1) == 0) - yylval.integer.value - = result & (~ (unsigned HOST_WIDEST_INT) 0 - >> (HOST_BITS_PER_WIDEST_INT - num_bits)); - else - yylval.integer.value - = result | ~(~ (unsigned HOST_WIDEST_INT) 0 - >> (HOST_BITS_PER_WIDEST_INT - num_bits)); - } - else - { - yylval.integer.value = result; - } - } - - /* This is always a signed type. */ - yylval.integer.signedp = SIGNED; - - return CHAR; - - /* some of these chars are invalid in constant expressions; - maybe do something about them later */ - case '/': - case '+': - case '-': - case '*': - case '%': - case '|': - case '&': - case '^': - case '~': - case '!': - case '@': - case '<': - case '>': - case '[': - case ']': - case '.': - case '?': - case ':': - case '=': - case '{': - case '}': - case ',': - case '#': - if (keyword_parsing) - break; - case '(': - case ')': - lexptr++; - return c; - - case '"': - mask = MAX_CHAR_TYPE_MASK; - string_constant: - if (keyword_parsing) { - char *start_ptr = lexptr; - lexptr++; - while (1) { - c = *lexptr++; - if (c == '\\') - c = parse_escape (&lexptr, mask); - else if (c == '"') - break; - } - yylval.name.address = tokstart; - yylval.name.length = lexptr - start_ptr; - return NAME; - } - yyerror ("string constants not allowed in #if expressions"); - return ERROR; - } - - if (c >= '0' && c <= '9' && !keyword_parsing) { - /* It's a number */ - for (namelen = 1; ; namelen++) { - int d = tokstart[namelen]; - if (! ((is_idchar[d] || d == '.') - || ((d == '-' || d == '+') - && (c == 'e' || c == 'E' - || ((c == 'p' || c == 'P') && ! c89)) - && ! traditional))) - break; - c = d; - } - return parse_number (namelen); - } - - /* It is a name. See how long it is. */ - - if (keyword_parsing) { - for (namelen = 0;; namelen++) { - if (is_space[tokstart[namelen]]) - break; - if (tokstart[namelen] == '(' || tokstart[namelen] == ')') - break; - if (tokstart[namelen] == '"' || tokstart[namelen] == '\'') - break; - } - } else { - if (!is_idstart[c]) { - yyerror ("Invalid token in expression"); - return ERROR; - } - - for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++) - ; - } - - lexptr += namelen; - yylval.name.address = tokstart; - yylval.name.length = namelen; - return NAME; -} - - -/* Parse a C escape sequence. STRING_PTR points to a variable - containing a pointer to the string to parse. That pointer - is updated past the characters we use. The value of the - escape sequence is returned. - - RESULT_MASK is used to mask out the result; - an error is reported if bits are lost thereby. - - A negative value means the sequence \ newline was seen, - which is supposed to be equivalent to nothing at all. - - If \ is followed by a null character, we return a negative - value and leave the string pointer pointing at the null character. - - If \ is followed by 000, we return 0 and leave the string pointer - after the zeros. A value of 0 does not mean end of string. */ - -HOST_WIDEST_INT -parse_escape (string_ptr, result_mask) - char **string_ptr; - HOST_WIDEST_INT result_mask; -{ - register int c = *(*string_ptr)++; - switch (c) - { - case 'a': - return TARGET_BELL; - case 'b': - return TARGET_BS; - case 'e': - case 'E': - if (pedantic) - pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c); - return TARGET_ESC; - case 'f': - return TARGET_FF; - case 'n': - return TARGET_NEWLINE; - case 'r': - return TARGET_CR; - case 't': - return TARGET_TAB; - case 'v': - return TARGET_VT; - case '\n': - return -2; - case 0: - (*string_ptr)--; - return 0; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - register HOST_WIDEST_INT i = c - '0'; - register int count = 0; - while (++count < 3) - { - c = *(*string_ptr)++; - if (c >= '0' && c <= '7') - i = (i << 3) + c - '0'; - else - { - (*string_ptr)--; - break; - } - } - if (i != (i & result_mask)) - { - i &= result_mask; - pedwarn ("octal escape sequence out of range"); - } - return i; - } - case 'x': - { - register unsigned HOST_WIDEST_INT i = 0, overflow = 0; - register int digits_found = 0, digit; - for (;;) - { - c = *(*string_ptr)++; - if (c >= '0' && c <= '9') - digit = c - '0'; - else if (c >= 'a' && c <= 'f') - digit = c - 'a' + 10; - else if (c >= 'A' && c <= 'F') - digit = c - 'A' + 10; - else - { - (*string_ptr)--; - break; - } - overflow |= i ^ (i << 4 >> 4); - i = (i << 4) + digit; - digits_found = 1; - } - if (!digits_found) - yyerror ("\\x used with no following hex digits"); - if (overflow | (i != (i & result_mask))) - { - i &= result_mask; - pedwarn ("hex escape sequence out of range"); - } - return i; - } - default: - return c; - } -} - -static void -integer_overflow () -{ - if (!skip_evaluation && pedantic) - pedwarn ("integer overflow in preprocessor expression"); -} - -static HOST_WIDEST_INT -left_shift (a, b) - struct constant *a; - unsigned HOST_WIDEST_INT b; -{ - /* It's unclear from the C standard whether shifts can overflow. - The following code ignores overflow; perhaps a C standard - interpretation ruling is needed. */ - if (b >= HOST_BITS_PER_WIDEST_INT) - return 0; - else - return (unsigned HOST_WIDEST_INT) a->value << b; -} - -static HOST_WIDEST_INT -right_shift (a, b) - struct constant *a; - unsigned HOST_WIDEST_INT b; -{ - if (b >= HOST_BITS_PER_WIDEST_INT) - return a->signedp ? a->value >> (HOST_BITS_PER_WIDEST_INT - 1) : 0; - else if (a->signedp) - return a->value >> b; - else - return (unsigned HOST_WIDEST_INT) a->value >> b; -} - -/* This page contains the entry point to this file. */ - -/* Parse STRING as an expression, and complain if this fails - to use up all of the contents of STRING. - STRING may contain '\0' bytes; it is terminated by the first '\n' - outside a string constant, so that we can diagnose '\0' properly. - If WARN_UNDEFINED is nonzero, warn if undefined identifiers are evaluated. - We do not support C comments. They should be removed before - this function is called. */ - -HOST_WIDEST_INT -parse_c_expression (string, warn_undefined) - char *string; - int warn_undefined; -{ - lexptr = string; - warn_undef = warn_undefined; - - /* if there is some sort of scanning error, just return 0 and assume - the parsing routine has printed an error message somewhere. - there is surely a better thing to do than this. */ - if (setjmp (parse_return_error)) - return 0; - - if (yyparse () != 0) - abort (); - - if (*lexptr != '\n') - error ("Junk after end of expression."); - - return expression_value; /* set by yyparse () */ -} - -static void -yyerror VPARAMS ((const char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - const char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, const char *); -#endif - - verror (msgid, args); - va_end (args); - skip_evaluation = 0; - longjmp (parse_return_error, 1); -} - - -#ifdef TEST_EXP_READER - -#if YYDEBUG -extern int yydebug; -#endif - -int pedantic; -int traditional; -int c89; - -int main PARAMS ((int, char **)); -static void initialize_random_junk PARAMS ((void)); -static void print_unsigned_host_widest_int PARAMS ((unsigned HOST_WIDEST_INT)); - -/* Main program for testing purposes. */ -int -main (argc, argv) - int argc; - char **argv; -{ - int n, c; - char buf[1024]; - unsigned HOST_WIDEST_INT u; - - pedantic = 1 < argc; - traditional = 2 < argc; - c89 = 3 < argc; -#if YYDEBUG - yydebug = 4 < argc; -#endif - initialize_random_junk (); - - for (;;) { - printf ("enter expression: "); - n = 0; - while ((buf[n] = c = getchar ()) != '\n' && c != EOF) - n++; - if (c == EOF) - break; - parse_c_expression (buf, 1); - printf ("parser returned "); - u = (unsigned HOST_WIDEST_INT) expression_value; - if (expression_value < 0 && expression_signedp) { - u = -u; - printf ("-"); - } - if (u == 0) - printf ("0"); - else - print_unsigned_host_widest_int (u); - if (! expression_signedp) - printf("u"); - printf ("\n"); - } - - return 0; -} - -static void -print_unsigned_host_widest_int (u) - unsigned HOST_WIDEST_INT u; -{ - if (u) { - print_unsigned_host_widest_int (u / 10); - putchar ('0' + (int) (u % 10)); - } -} - -/* table to tell if char can be part of a C identifier. */ -unsigned char is_idchar[256]; -/* table to tell if char can be first char of a c identifier. */ -unsigned char is_idstart[256]; -/* table to tell if c is horizontal or vertical space. */ -unsigned char is_space[256]; - -/* - * initialize random junk in the hash table and maybe other places - */ -static void -initialize_random_junk () -{ - register int i; - - /* - * Set up is_idchar and is_idstart tables. These should be - * faster than saying (is_alpha (c) || c == '_'), etc. - * Must do set up these things before calling any routines tthat - * refer to them. - */ - for (i = 'a'; i <= 'z'; i++) { - /* SKIP EBCIDIC holes, char must be a valid low case char */ - if (ISLOWER(i)) { - ++is_idchar[TOUPPER(i)]; - ++is_idchar[i]; - ++is_idstart[TOUPPER(i)]; - ++is_idstart[i]; - } - } - for (i = '0'; i <= '9'; i++) - ++is_idchar[i]; - ++is_idchar['_']; - ++is_idstart['_']; - ++is_idchar['$']; - ++is_idstart['$']; - - ++is_space[' ']; - ++is_space['\t']; - ++is_space['\v']; - ++is_space['\f']; - ++is_space['\n']; - ++is_space['\r']; -} - -void -error VPARAMS ((char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, char *); -#endif - - fprintf (stderr, "error: "); - vfprintf (stderr, _(msgid), args); - fprintf (stderr, "\n"); - va_end (args); -} - -void -pedwarn VPARAMS ((char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, char *); -#endif - - fprintf (stderr, "pedwarn: "); - vfprintf (stderr, _(msgid), args); - fprintf (stderr, "\n"); - va_end (args); -} - -void -warning VPARAMS ((char * msgid, ...)) -{ -#ifndef ANSI_PROTOTYPES - char * msgid; -#endif - va_list args; - - VA_START (args, msgid); - -#ifndef ANSI_PROTOTYPES - msgid = va_arg (args, char *); -#endif - - fprintf (stderr, "warning: "); - vfprintf (stderr, _(msgid), args); - fprintf (stderr, "\n"); - va_end (args); -} - - -int -check_assertion (name, sym_length, tokens_specified, tokens) - U_CHAR *name; - int sym_length; - int tokens_specified; - struct arglist *tokens; -{ - return 0; -} - -struct hashnode * -lookup (name, len, hash) - U_CHAR *name; - int len; - int hash; -{ - return (DEFAULT_SIGNED_CHAR) ? 0 : ((struct hashnode *) -1); -} - -PTR -xmalloc (size) - size_t size; -{ - return (PTR) malloc (size); -} -#endif diff --git a/gcc/ch/ChangeLog b/gcc/ch/ChangeLog index 4b7e2253abb..9e6eb47f5f4 100644 --- a/gcc/ch/ChangeLog +++ b/gcc/ch/ChangeLog @@ -1,3 +1,7 @@ +2000-04-18 Zack Weinberg + + * ch/lex.c: Remove references to cccp.c. + 2000-04-03 Zack Weinberg * lang-specs.h: Pass -fno-show-column to the preprocessor. diff --git a/gcc/ch/decl.c b/gcc/ch/decl.c index ddeb45f94f2..83caf0b003d 100644 --- a/gcc/ch/decl.c +++ b/gcc/ch/decl.c @@ -619,9 +619,7 @@ const char *chill_tree_code_name[] = { }; #undef DEFTREECODE -/* Nonzero means `$' can be in an identifier. - See cccp.c for reasons why this breaks some obscure ANSI C programs. */ - +/* Nonzero means `$' can be in an identifier. */ #ifndef DOLLARS_IN_IDENTIFIERS #define DOLLARS_IN_IDENTIFIERS 0 #endif diff --git a/gcc/ch/lex.c b/gcc/ch/lex.c index 21a9aa0d60e..5f0eb524d11 100644 --- a/gcc/ch/lex.c +++ b/gcc/ch/lex.c @@ -1677,7 +1677,7 @@ check_newline () && getlc (finput) == 't' && ((c = getlc (finput)) == ' ' || c == '\t')) { - /* #ident. The pedantic warning is now in cccp.c. */ + /* #ident. The pedantic warning is now in cpp. */ /* Here we have just seen `#ident '. A string constant should follow. */ diff --git a/gcc/config/convex/convex.h b/gcc/config/convex/convex.h index 86dc07ea1ab..f59959f5775 100644 --- a/gcc/config/convex/convex.h +++ b/gcc/config/convex/convex.h @@ -491,7 +491,6 @@ extern int target_flags; #define FLOAT_TYPE_SIZE 32 #define DOUBLE_TYPE_SIZE 64 #define LONG_DOUBLE_TYPE_SIZE 64 -/* This prevents cexp.c from depending on LONG_TYPE_SIZE. */ #define MAX_LONG_TYPE_SIZE 64 /* Declare the standard types used by builtins to match convex stddef.h -- diff --git a/gcc/config/fx80/fx80.h b/gcc/config/fx80/fx80.h index 35a9211dadc..ec320102a3e 100644 --- a/gcc/config/fx80/fx80.h +++ b/gcc/config/fx80/fx80.h @@ -179,9 +179,7 @@ extern int target_flags; #define INT_TYPE_SIZE (TARGET_SHORT ? 16 : 32) -/* Define these to avoid dependence on meaning of `int'. - Note that WCHAR_TYPE_SIZE is used in cexp.y, - where TARGET_SHORT is not available. */ +/* Define these to avoid dependence on meaning of `int'. */ #define WCHAR_TYPE "long int" #define WCHAR_TYPE_SIZE 32 diff --git a/gcc/config/i386/xm-os2.h b/gcc/config/i386/xm-os2.h index b8a5ad057a3..83476c0a87d 100644 --- a/gcc/config/i386/xm-os2.h +++ b/gcc/config/i386/xm-os2.h @@ -36,7 +36,6 @@ Boston, MA 02111-1307, USA. */ #ifdef __EMX__ #define EMX #define USG -#define BSTRING #define HAVE_PUTENV #define HAVE_VPRINTF #define HAVE_STRERROR diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h index 5d170429bf0..acde9c099b7 100644 --- a/gcc/config/m68k/m68k.h +++ b/gcc/config/m68k/m68k.h @@ -337,10 +337,8 @@ extern int target_flags; #define INT_TYPE_SIZE (TARGET_SHORT ? 16 : 32) -/* Define these to avoid dependence on meaning of `int'. - Note that WCHAR_TYPE_SIZE is used in cexp.y, - where TARGET_SHORT is not available. */ - +/* Define these to avoid dependence on meaning of `int'. */ + #define WCHAR_TYPE "long int" #define WCHAR_TYPE_SIZE 32 diff --git a/gcc/config/mips/t-ecoff b/gcc/config/mips/t-ecoff index 0bd0dd67d97..143126e2d49 100644 --- a/gcc/config/mips/t-ecoff +++ b/gcc/config/mips/t-ecoff @@ -70,7 +70,6 @@ INSTALL_LIBGCC = install-multilib # cse.c (cost functions) # insn-output.c (possible ifdef changes in tm.h) # regclass.c (fixed/call used register changes) -# cccp.c (new preprocessor macros, -v version #) # explow.c (GO_IF_LEGITIMATE_ADDRESS) # recog.c (GO_IF_LEGITIMATE_ADDRESS) # reload.c (GO_IF_LEGITIMATE_ADDRESS) @@ -85,7 +84,6 @@ varasm.o: $(CONFIG2_H) cse.o: $(CONFIG2_H) insn-output.o: $(CONFIG2_H) regclass.o: $(CONFIG2_H) -cccp.o: $(CONFIG2_H) explow.o: $(CONFIG2_H) recog.o: $(CONFIG2_H) reload.o: $(CONFIG2_H) diff --git a/gcc/config/mips/t-elf b/gcc/config/mips/t-elf index 1ce60499e9e..410646e1a4a 100644 --- a/gcc/config/mips/t-elf +++ b/gcc/config/mips/t-elf @@ -74,7 +74,6 @@ INSTALL_LIBGCC = install-multilib # cse.c (cost functions) # insn-output.c (possible ifdef changes in tm.h) # regclass.c (fixed/call used register changes) -# cccp.c (new preprocessor macros, -v version #) # explow.c (GO_IF_LEGITIMATE_ADDRESS) # recog.c (GO_IF_LEGITIMATE_ADDRESS) # reload.c (GO_IF_LEGITIMATE_ADDRESS) @@ -89,7 +88,6 @@ varasm.o: $(CONFIG2_H) cse.o: $(CONFIG2_H) insn-output.o: $(CONFIG2_H) regclass.o: $(CONFIG2_H) -cccp.o: $(CONFIG2_H) explow.o: $(CONFIG2_H) recog.o: $(CONFIG2_H) reload.o: $(CONFIG2_H) diff --git a/gcc/config/mips/t-r3900 b/gcc/config/mips/t-r3900 index a7317665d08..f499da9b1ff 100644 --- a/gcc/config/mips/t-r3900 +++ b/gcc/config/mips/t-r3900 @@ -73,7 +73,6 @@ INSTALL_LIBGCC = install-multilib # cse.c (cost functions) # insn-output.c (possible ifdef changes in tm.h) # regclass.c (fixed/call used register changes) -# cccp.c (new preprocessor macros, -v version #) # explow.c (GO_IF_LEGITIMATE_ADDRESS) # recog.c (GO_IF_LEGITIMATE_ADDRESS) # reload.c (GO_IF_LEGITIMATE_ADDRESS) @@ -88,7 +87,6 @@ varasm.o: $(CONFIG2_H) cse.o: $(CONFIG2_H) insn-output.o: $(CONFIG2_H) regclass.o: $(CONFIG2_H) -cccp.o: $(CONFIG2_H) explow.o: $(CONFIG2_H) recog.o: $(CONFIG2_H) reload.o: $(CONFIG2_H) diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h index 6ca396256cb..56aecc6eceb 100644 --- a/gcc/config/pdp11/pdp11.h +++ b/gcc/config/pdp11/pdp11.h @@ -147,11 +147,6 @@ extern int target_flags; /* machine types from ansi */ #define SIZE_TYPE "unsigned int" /* definition of size_t */ - -/* is used in cexp.y - we don't have target_flags there, - so just give default definition - - hope it does not come back to haunt us! */ #define WCHAR_TYPE "int" /* or long int???? */ #define WCHAR_TYPE_SIZE 16 diff --git a/gcc/config/romp/xm-romp.h b/gcc/config/romp/xm-romp.h index 37de6de8d38..acb5b8cecb1 100644 --- a/gcc/config/romp/xm-romp.h +++ b/gcc/config/romp/xm-romp.h @@ -47,8 +47,3 @@ Boston, MA 02111-1307, USA. */ #define bcopy(s,d,l) memcpy(d,s,l) #define FUNCTION_CONVERSION_BUG #endif - -/* We cannot allow cccp.o to contain a copy of BCOPY as this will - cause multiple definitions since BLT and BCOPY share an object file - in libc.a and the library references BLT. */ -#define BSTRING diff --git a/gcc/config/xm-linux.h b/gcc/config/xm-linux.h index fc0848b5604..d3aec5f8b79 100644 --- a/gcc/config/xm-linux.h +++ b/gcc/config/xm-linux.h @@ -25,6 +25,3 @@ Boston, MA 02111-1307, USA. */ /* We do have one, but I'd like to use the one come with gcc since we have been doing that for a long time with USG defined. H.J. */ #undef HAVE_STAB_H - -#undef BSTRING -#define BSTRING diff --git a/gcc/configure b/gcc/configure index a79556bda47..59809736f57 100755 --- a/gcc/configure +++ b/gcc/configure @@ -40,8 +40,6 @@ ac_help="$ac_help --with-cpp-install-dir=DIR install the user visible C preprocessor in DIR (relative to PREFIX) as well as PREFIX/bin." -ac_help="$ac_help - --disable-cpplib use the old isolated C preprocessor." ac_help="$ac_help --enable-c-mbchar Enable multibyte characters for C and C++." ac_help="$ac_help @@ -605,7 +603,7 @@ copy=cp # - two terminals occur directly after each other # - the path contains an element with a dot in it echo $ac_n "checking LIBRARY_PATH variable""... $ac_c" 1>&6 -echo "configure:609: checking LIBRARY_PATH variable" >&5 +echo "configure:607: checking LIBRARY_PATH variable" >&5 case ${LIBRARY_PATH} in [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* ) library_path_setting="contains current directory" @@ -630,7 +628,7 @@ fi # - two terminals occur directly after each other # - the path contains an element with a dot in it echo $ac_n "checking GCC_EXEC_PREFIX variable""... $ac_c" 1>&6 -echo "configure:634: checking GCC_EXEC_PREFIX variable" >&5 +echo "configure:632: checking GCC_EXEC_PREFIX variable" >&5 case ${GCC_EXEC_PREFIX} in [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* ) gcc_exec_prefix_setting="contains current directory" @@ -841,17 +839,6 @@ fi fi -# Use cpplib+cppmain for the preprocessor, but don't link it with the compiler. -cpp_main=cppmain -# Check whether --enable-cpplib or --disable-cpplib was given. -if test "${enable_cpplib+set}" = set; then - enableval="$enable_cpplib" - if test x$enable_cpplib = xno; then - cpp_main=cccp -fi -fi - - # Enable Multibyte Characters for C/C++ # Check whether --enable-c-mbchar or --disable-c-mbchar was given. @@ -968,7 +955,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:972: checking host system type" >&5 +echo "configure:959: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -989,7 +976,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:993: checking target system type" >&5 +echo "configure:980: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -1007,7 +994,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:1011: checking build system type" >&5 +echo "configure:998: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -1034,7 +1021,7 @@ test "$host_alias" != "$target_alias" && # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1038: checking for $ac_word" >&5 +echo "configure:1025: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1064,7 +1051,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1068: checking for $ac_word" >&5 +echo "configure:1055: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1115,7 +1102,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1119: checking for $ac_word" >&5 +echo "configure:1106: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1147,7 +1134,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1151: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1138: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1158,12 +1145,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 1162 "configure" +#line 1149 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1167: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1154: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1189,12 +1176,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1193: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1180: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1198: checking whether we are using GNU C" >&5 +echo "configure:1185: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1203,7 +1190,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1207: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1194: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1222,7 +1209,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1226: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1213: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1254,7 +1241,7 @@ else fi echo $ac_n "checking for long double""... $ac_c" 1>&6 -echo "configure:1258: checking for long double" >&5 +echo "configure:1245: checking for long double" >&5 if eval "test \"`echo '$''{'gcc_cv_c_long_double'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1262,7 +1249,7 @@ else gcc_cv_c_long_double=yes else cat > conftest.$ac_ext <= sizeof(double)):; ; return 0; } EOF -if { (eval echo configure:1276: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1263: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_c_long_double=yes else @@ -1305,7 +1292,7 @@ fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:1309: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:1296: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1333,7 +1320,7 @@ fi echo $ac_n "checking whether a default assembler was specified""... $ac_c" 1>&6 -echo "configure:1337: checking whether a default assembler was specified" >&5 +echo "configure:1324: checking whether a default assembler was specified" >&5 if test x"${DEFAULT_ASSEMBLER+set}" = x"set"; then if test x"$gas_flag" = x"no"; then echo "$ac_t""yes ($DEFAULT_ASSEMBLER)" 1>&6 @@ -1345,7 +1332,7 @@ else fi echo $ac_n "checking whether a default linker was specified""... $ac_c" 1>&6 -echo "configure:1349: checking whether a default linker was specified" >&5 +echo "configure:1336: checking whether a default linker was specified" >&5 if test x"${DEFAULT_LINKER+set}" = x"set"; then if test x"$gnu_ld_flag" = x"no"; then echo "$ac_t""yes ($DEFAULT_LINKER)" 1>&6 @@ -1362,7 +1349,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1366: checking for $ac_word" >&5 +echo "configure:1353: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1394,7 +1381,7 @@ done # Extract the first word of "flex", so it can be a program name with args. set dummy flex; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1398: checking for $ac_word" >&5 +echo "configure:1385: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1428,7 +1415,7 @@ then *) ac_lib=l ;; esac echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6 -echo "configure:1432: checking for yywrap in -l$ac_lib" >&5 +echo "configure:1419: checking for yywrap in -l$ac_lib" >&5 ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1436,7 +1423,7 @@ else ac_save_LIBS="$LIBS" LIBS="-l$ac_lib $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1438: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1470,7 +1457,7 @@ fi fi echo $ac_n "checking whether ln works""... $ac_c" 1>&6 -echo "configure:1474: checking whether ln works" >&5 +echo "configure:1461: checking whether ln works" >&5 if eval "test \"`echo '$''{'gcc_cv_prog_LN'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1502,7 +1489,7 @@ else fi echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1506: checking whether ln -s works" >&5 +echo "configure:1493: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'gcc_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1534,19 +1521,19 @@ else fi echo $ac_n "checking for volatile""... $ac_c" 1>&6 -echo "configure:1538: checking for volatile" >&5 +echo "configure:1525: checking for volatile" >&5 if eval "test \"`echo '$''{'gcc_cv_c_volatile'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1537: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_c_volatile=yes else @@ -1569,7 +1556,7 @@ fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1573: checking for $ac_word" >&5 +echo "configure:1560: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1601,7 +1588,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1605: checking for $ac_word" >&5 +echo "configure:1592: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1642,7 +1629,7 @@ test -n "$YACC" || YACC="yacc" # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1646: checking for a BSD compatible install" >&5 +echo "configure:1633: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1693,7 +1680,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1697: checking how to run the C preprocessor" >&5 +echo "configure:1684: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1708,13 +1695,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1718: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1705: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1725,13 +1712,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1735: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1722: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1742,13 +1729,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1752: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1739: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1773,12 +1760,12 @@ fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1777: checking for ANSI C header files" >&5 +echo "configure:1764: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1786,7 +1773,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1790: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1777: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1803,7 +1790,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1821,7 +1808,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1842,7 +1829,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1853,7 +1840,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:1857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1844: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1877,12 +1864,12 @@ EOF fi echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:1881: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:1868: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1891,7 +1878,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:1895: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1882: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -1912,12 +1899,12 @@ EOF fi echo $ac_n "checking whether string.h and strings.h may both be included""... $ac_c" 1>&6 -echo "configure:1916: checking whether string.h and strings.h may both be included" >&5 +echo "configure:1903: checking whether string.h and strings.h may both be included" >&5 if eval "test \"`echo '$''{'gcc_cv_header_string'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1925,7 +1912,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1929: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1916: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_header_string=yes else @@ -1946,12 +1933,12 @@ EOF fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:1950: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:1937: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1967,7 +1954,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:1971: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1958: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -1994,17 +1981,17 @@ for ac_hdr in limits.h stddef.h string.h strings.h stdlib.h time.h \ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1998: checking for $ac_hdr" >&5 +echo "configure:1985: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2008: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1995: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2034,17 +2021,17 @@ done # Check for thread headers. ac_safe=`echo "thread.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for thread.h""... $ac_c" 1>&6 -echo "configure:2038: checking for thread.h" >&5 +echo "configure:2025: checking for thread.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2048: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2035: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2068,17 +2055,17 @@ fi ac_safe=`echo "pthread.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for pthread.h""... $ac_c" 1>&6 -echo "configure:2072: checking for pthread.h" >&5 +echo "configure:2059: checking for pthread.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2082: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2069: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2105,7 +2092,7 @@ fi # Extract the first word of "gnatbind", so it can be a program name with args. set dummy gnatbind; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2109: checking for $ac_word" >&5 +echo "configure:2096: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gnat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2138,12 +2125,12 @@ fi echo $ac_n "checking for preprocessor stringizing operator""... $ac_c" 1>&6 -echo "configure:2142: checking for preprocessor stringizing operator" >&5 +echo "configure:2129: checking for preprocessor stringizing operator" >&5 if eval "test \"`echo '$''{'ac_cv_c_stringize'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 # Use only if it exists, # doesn't clash with , and declares intmax_t. echo $ac_n "checking for inttypes.h""... $ac_c" 1>&6 -echo "configure:2180: checking for inttypes.h" >&5 +echo "configure:2167: checking for inttypes.h" >&5 if eval "test \"`echo '$''{'gcc_cv_header_inttypes_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2189,7 +2176,7 @@ int main() { intmax_t i = -1; ; return 0; } EOF -if { (eval echo configure:2193: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2180: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_header_inttypes_h=yes else @@ -2214,7 +2201,7 @@ fi # be either signed or unsigned. # echo $ac_n "checking for unsigned enumerated bitfields""... $ac_c" 1>&6 -echo "configure:2218: checking for unsigned enumerated bitfields" >&5 +echo "configure:2205: checking for unsigned enumerated bitfields" >&5 if eval "test \"`echo '$''{'gcc_cv_enum_bf_unsigned'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2222,7 +2209,7 @@ else gcc_cv_enum_bf_unsigned=yes else cat > conftest.$ac_ext < enum t { BLAH = 128 } ; @@ -2235,7 +2222,7 @@ int main(void) } EOF -if { (eval echo configure:2239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then gcc_cv_enum_bf_unsigned=yes else @@ -2264,12 +2251,12 @@ for ac_func in strtoul bsearch putenv popen bcopy bzero bcmp \ fputs_unlocked getrusage valloc do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2268: checking for $ac_func" >&5 +echo "configure:2255: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2283: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2322,12 +2308,12 @@ done #AC_CHECK_TYPE(wchar_t, unsigned int) echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:2326: checking for vprintf" >&5 +echo "configure:2312: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2340: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -2375,12 +2360,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:2379: checking for _doprnt" >&5 +echo "configure:2364: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2392: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -2440,7 +2424,7 @@ fi echo $ac_n "checking whether the printf functions support %p""... $ac_c" 1>&6 -echo "configure:2444: checking whether the printf functions support %p" >&5 +echo "configure:2428: checking whether the printf functions support %p" >&5 if eval "test \"`echo '$''{'gcc_cv_func_printf_ptr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2448,7 +2432,7 @@ else gcc_cv_func_printf_ptr=no else cat > conftest.$ac_ext < @@ -2461,7 +2445,7 @@ main() exit (p != q); } EOF -if { (eval echo configure:2465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then gcc_cv_func_printf_ptr=yes else @@ -2494,12 +2478,12 @@ case "${host}" in ;; esac echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:2498: checking for pid_t" >&5 +echo "configure:2482: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2528,17 +2512,17 @@ fi ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for vfork.h""... $ac_c" 1>&6 -echo "configure:2532: checking for vfork.h" >&5 +echo "configure:2516: checking for vfork.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2542: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2526: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2563,18 +2547,18 @@ else fi echo $ac_n "checking for working vfork""... $ac_c" 1>&6 -echo "configure:2567: checking for working vfork" >&5 +echo "configure:2551: checking for working vfork" >&5 if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then echo $ac_n "checking for vfork""... $ac_c" 1>&6 -echo "configure:2573: checking for vfork" >&5 +echo "configure:2557: checking for vfork" >&5 if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vfork=yes" else @@ -2620,7 +2603,7 @@ fi ac_cv_func_vfork_works=$ac_cv_func_vfork else cat > conftest.$ac_ext < @@ -2715,7 +2698,7 @@ main() { } } EOF -if { (eval echo configure:2719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_vfork_works=yes else @@ -2741,17 +2724,17 @@ for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2745: checking for $ac_hdr" >&5 +echo "configure:2728: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2755: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2738: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2780,12 +2763,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2784: checking for $ac_func" >&5 +echo "configure:2767: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2795: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2834,7 +2816,7 @@ fi done echo $ac_n "checking for working mmap from /dev/zero""... $ac_c" 1>&6 -echo "configure:2838: checking for working mmap from /dev/zero" >&5 +echo "configure:2820: checking for working mmap from /dev/zero" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_anywhere'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2842,7 +2824,7 @@ else ac_cv_func_mmap_anywhere=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_anywhere=yes else @@ -2937,7 +2919,7 @@ EOF fi echo $ac_n "checking for working mmap of a file""... $ac_c" 1>&6 -echo "configure:2941: checking for working mmap of a file" >&5 +echo "configure:2923: checking for working mmap of a file" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_file'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2952,7 +2934,7 @@ if test "$cross_compiling" = yes; then ac_cv_func_mmap_file=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_file=yes else @@ -3017,12 +2999,12 @@ for ac_func in bcopy bzero bcmp \ strsignal putc_unlocked fputs_unlocked strstr environ do echo $ac_n "checking whether $ac_func must be declared""... $ac_c" 1>&6 -echo "configure:3021: checking whether $ac_func must be declared" >&5 +echo "configure:3003: checking whether $ac_func must be declared" >&5 if eval "test \"`echo '$''{'gcc_cv_decl_needed_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -3059,7 +3041,7 @@ int main() { char *(*pfn) = (char *(*)) $ac_func ; return 0; } EOF -if { (eval echo configure:3063: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3045: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "gcc_cv_decl_needed_$ac_func=no" else @@ -3088,12 +3070,12 @@ done for ac_func in malloc realloc calloc free do echo $ac_n "checking whether $ac_func must be declared""... $ac_c" 1>&6 -echo "configure:3092: checking whether $ac_func must be declared" >&5 +echo "configure:3074: checking whether $ac_func must be declared" >&5 if eval "test \"`echo '$''{'gcc_cv_decl_needed_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -3133,7 +3115,7 @@ int main() { char *(*pfn) = (char *(*)) $ac_func ; return 0; } EOF -if { (eval echo configure:3137: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3119: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "gcc_cv_decl_needed_$ac_func=no" else @@ -3162,12 +3144,12 @@ done for ac_func in getrlimit setrlimit getrusage do echo $ac_n "checking whether $ac_func must be declared""... $ac_c" 1>&6 -echo "configure:3166: checking whether $ac_func must be declared" >&5 +echo "configure:3148: checking whether $ac_func must be declared" >&5 if eval "test \"`echo '$''{'gcc_cv_decl_needed_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -3208,7 +3190,7 @@ int main() { char *(*pfn) = (char *(*)) $ac_func ; return 0; } EOF -if { (eval echo configure:3212: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3194: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "gcc_cv_decl_needed_$ac_func=no" else @@ -3236,12 +3218,12 @@ done # mkdir takes a single argument on some systems. echo $ac_n "checking if mkdir takes one argument""... $ac_c" 1>&6 -echo "configure:3240: checking if mkdir takes one argument" >&5 +echo "configure:3222: checking if mkdir takes one argument" >&5 if eval "test \"`echo '$''{'gcc_cv_mkdir_takes_one_arg'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -3258,7 +3240,7 @@ int main() { mkdir ("foo", 0); ; return 0; } EOF -if { (eval echo configure:3262: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3244: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_mkdir_takes_one_arg=no else @@ -6699,7 +6681,7 @@ fi echo $ac_n "checking for strerror in -lcposix""... $ac_c" 1>&6 -echo "configure:6703: checking for strerror in -lcposix" >&5 +echo "configure:6685: checking for strerror in -lcposix" >&5 ac_lib_var=`echo cposix'_'strerror | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6707,7 +6689,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcposix $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6704: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6741,18 +6723,18 @@ fi echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:6745: checking for working const" >&5 +echo "configure:6727: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6781: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -6816,21 +6798,21 @@ EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 -echo "configure:6820: checking for inline" >&5 +echo "configure:6802: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6816: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else @@ -6856,12 +6838,12 @@ EOF esac echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:6860: checking for off_t" >&5 +echo "configure:6842: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -6889,12 +6871,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:6893: checking for size_t" >&5 +echo "configure:6875: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -6924,19 +6906,19 @@ fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:6928: checking for working alloca.h" >&5 +echo "configure:6910: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { -char *p = alloca(2 * sizeof(int)); +void *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:6940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6922: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -6957,12 +6939,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:6961: checking for alloca" >&5 +echo "configure:6943: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -7022,12 +7004,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:7026: checking whether alloca needs Cray hooks" >&5 +echo "configure:7008: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7056: checking for $ac_func" >&5 +echo "configure:7038: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7066: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7108,7 +7089,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:7112: checking stack direction for C alloca" >&5 +echo "configure:7093: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7116,7 +7097,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -7162,17 +7143,17 @@ unistd.h sys/param.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:7166: checking for $ac_hdr" >&5 +echo "configure:7147: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:7176: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:7157: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -7202,12 +7183,12 @@ done strdup __argz_count __argz_stringify __argz_next do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7206: checking for $ac_func" >&5 +echo "configure:7187: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7260,12 +7240,12 @@ done for ac_func in stpcpy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7264: checking for $ac_func" >&5 +echo "configure:7244: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7272: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7323,19 +7302,19 @@ EOF if test $ac_cv_header_locale_h = yes; then echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6 -echo "configure:7327: checking for LC_MESSAGES" >&5 +echo "configure:7306: checking for LC_MESSAGES" >&5 if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return LC_MESSAGES ; return 0; } EOF -if { (eval echo configure:7339: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* am_cv_val_LC_MESSAGES=yes else @@ -7356,7 +7335,7 @@ EOF fi fi echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6 -echo "configure:7360: checking whether NLS is requested" >&5 +echo "configure:7339: checking whether NLS is requested" >&5 # Check whether --enable-nls or --disable-nls was given. if test "${enable_nls+set}" = set; then enableval="$enable_nls" @@ -7376,7 +7355,7 @@ fi EOF echo $ac_n "checking whether included gettext is requested""... $ac_c" 1>&6 -echo "configure:7380: checking whether included gettext is requested" >&5 +echo "configure:7359: checking whether included gettext is requested" >&5 # Check whether --with-included-gettext or --without-included-gettext was given. if test "${with_included_gettext+set}" = set; then withval="$with_included_gettext" @@ -7395,17 +7374,17 @@ fi ac_safe=`echo "libintl.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for libintl.h""... $ac_c" 1>&6 -echo "configure:7399: checking for libintl.h" >&5 +echo "configure:7378: checking for libintl.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:7409: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:7388: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -7422,19 +7401,19 @@ fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for gettext in libc""... $ac_c" 1>&6 -echo "configure:7426: checking for gettext in libc" >&5 +echo "configure:7405: checking for gettext in libc" >&5 if eval "test \"`echo '$''{'gt_cv_func_gettext_libc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return (int) gettext ("") ; return 0; } EOF -if { (eval echo configure:7438: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* gt_cv_func_gettext_libc=yes else @@ -7450,7 +7429,7 @@ echo "$ac_t""$gt_cv_func_gettext_libc" 1>&6 if test "$gt_cv_func_gettext_libc" != "yes"; then echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6 -echo "configure:7454: checking for bindtextdomain in -lintl" >&5 +echo "configure:7433: checking for bindtextdomain in -lintl" >&5 ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7458,7 +7437,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7485,12 +7464,12 @@ fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking for gettext in libintl""... $ac_c" 1>&6 -echo "configure:7489: checking for gettext in libintl" >&5 +echo "configure:7468: checking for gettext in libintl" >&5 if eval "test \"`echo '$''{'gt_cv_func_gettext_libintl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo $ac_n "checking for gettext in -lintl""... $ac_c" 1>&6 -echo "configure:7494: checking for gettext in -lintl" >&5 +echo "configure:7473: checking for gettext in -lintl" >&5 ac_lib_var=`echo intl'_'gettext | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7498,7 +7477,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7492: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7548,7 +7527,7 @@ EOF # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7552: checking for $ac_word" >&5 +echo "configure:7531: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7582,12 +7561,12 @@ fi for ac_func in dcgettext do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7586: checking for $ac_func" >&5 +echo "configure:7565: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7638,7 +7616,7 @@ done # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7642: checking for $ac_word" >&5 +echo "configure:7620: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7674,7 +7652,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7678: checking for $ac_word" >&5 +echo "configure:7656: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7706,7 +7684,7 @@ else fi cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7696: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* CATOBJEXT=.gmo DATADIRNAME=share @@ -7737,7 +7715,7 @@ fi if test "$CATOBJEXT" = "NONE"; then echo $ac_n "checking whether catgets can be used""... $ac_c" 1>&6 -echo "configure:7741: checking whether catgets can be used" >&5 +echo "configure:7719: checking whether catgets can be used" >&5 # Check whether --with-catgets or --without-catgets was given. if test "${with_catgets+set}" = set; then withval="$with_catgets" @@ -7750,7 +7728,7 @@ fi if test "$nls_cv_use_catgets" = "yes"; then echo $ac_n "checking for main in -li""... $ac_c" 1>&6 -echo "configure:7754: checking for main in -li" >&5 +echo "configure:7732: checking for main in -li" >&5 ac_lib_var=`echo i'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7758,14 +7736,14 @@ else ac_save_LIBS="$LIBS" LIBS="-li $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -7793,12 +7771,12 @@ else fi echo $ac_n "checking for catgets""... $ac_c" 1>&6 -echo "configure:7797: checking for catgets" >&5 +echo "configure:7775: checking for catgets" >&5 if eval "test \"`echo '$''{'ac_cv_func_catgets'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_catgets=yes" else @@ -7844,7 +7821,7 @@ EOF # Extract the first word of "gencat", so it can be a program name with args. set dummy gencat; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7848: checking for $ac_word" >&5 +echo "configure:7825: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GENCAT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7880,7 +7857,7 @@ fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7884: checking for $ac_word" >&5 +echo "configure:7861: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7917,7 +7894,7 @@ fi # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7921: checking for $ac_word" >&5 +echo "configure:7898: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7952,7 +7929,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7956: checking for $ac_word" >&5 +echo "configure:7933: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8010,7 +7987,7 @@ fi # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:8014: checking for $ac_word" >&5 +echo "configure:7991: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8044,7 +8021,7 @@ fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:8048: checking for $ac_word" >&5 +echo "configure:8025: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8080,7 +8057,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:8084: checking for $ac_word" >&5 +echo "configure:8061: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8173,7 +8150,7 @@ fi LINGUAS= else echo $ac_n "checking for catalogs to be installed""... $ac_c" 1>&6 -echo "configure:8177: checking for catalogs to be installed" >&5 +echo "configure:8154: checking for catalogs to be installed" >&5 NEW_LINGUAS= for lang in ${LINGUAS=$ALL_LINGUAS}; do case "$ALL_LINGUAS" in @@ -8201,17 +8178,17 @@ echo "configure:8177: checking for catalogs to be installed" >&5 if test "$CATOBJEXT" = ".cat"; then ac_safe=`echo "linux/version.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for linux/version.h""... $ac_c" 1>&6 -echo "configure:8205: checking for linux/version.h" >&5 +echo "configure:8182: checking for linux/version.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:8215: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:8192: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -8286,7 +8263,7 @@ fi echo $ac_n "checking whether windows registry support is requested""... $ac_c" 1>&6 -echo "configure:8290: checking whether windows registry support is requested" >&5 +echo "configure:8267: checking whether windows registry support is requested" >&5 if test x$enable_win32_registry != xno; then cat >> confdefs.h <<\EOF #define ENABLE_WIN32_REGISTRY 1 @@ -8315,7 +8292,7 @@ esac if test x$enable_win32_registry != xno; then echo $ac_n "checking registry key on windows hosts""... $ac_c" 1>&6 -echo "configure:8319: checking registry key on windows hosts" >&5 +echo "configure:8296: checking registry key on windows hosts" >&5 cat >> confdefs.h <&6 -echo "configure:8495: checking assembler alignment features" >&5 +echo "configure:8472: checking assembler alignment features" >&5 gcc_cv_as= gcc_cv_as_alignment_features= gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas @@ -8612,7 +8589,7 @@ fi echo "$ac_t""$gcc_cv_as_alignment_features" 1>&6 echo $ac_n "checking assembler subsection support""... $ac_c" 1>&6 -echo "configure:8616: checking assembler subsection support" >&5 +echo "configure:8593: checking assembler subsection support" >&5 gcc_cv_as_subsections= if test x$gcc_cv_as != x; then # Check if we have .subsection @@ -8652,7 +8629,7 @@ fi echo "$ac_t""$gcc_cv_as_subsections" 1>&6 echo $ac_n "checking assembler weak support""... $ac_c" 1>&6 -echo "configure:8656: checking assembler weak support" >&5 +echo "configure:8633: checking assembler weak support" >&5 gcc_cv_as_weak= if test x$gcc_cv_as != x; then # Check if we have .weak @@ -8669,7 +8646,7 @@ fi echo "$ac_t""$gcc_cv_as_weak" 1>&6 echo $ac_n "checking assembler hidden support""... $ac_c" 1>&6 -echo "configure:8673: checking assembler hidden support" >&5 +echo "configure:8650: checking assembler hidden support" >&5 gcc_cv_as_hidden= if test x$gcc_cv_as != x; then # Check if we have .hidden @@ -8689,7 +8666,7 @@ echo "$ac_t""$gcc_cv_as_hidden" 1>&6 case "$target" in sparc*-*-*) echo $ac_n "checking assembler .register pseudo-op support""... $ac_c" 1>&6 -echo "configure:8693: checking assembler .register pseudo-op support" >&5 +echo "configure:8670: checking assembler .register pseudo-op support" >&5 if eval "test \"`echo '$''{'gcc_cv_as_register_pseudo_op'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8719,7 +8696,7 @@ EOF case "$tm_file" in *64*) echo $ac_n "checking for 64 bit support in assembler ($gcc_cv_as)""... $ac_c" 1>&6 -echo "configure:8723: checking for 64 bit support in assembler ($gcc_cv_as)" >&5 +echo "configure:8700: checking for 64 bit support in assembler ($gcc_cv_as)" >&5 if eval "test \"`echo '$''{'gcc_cv_as_flags64'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8764,7 +8741,7 @@ EOF if test "x$gcc_cv_as_flags64" != xno; then echo $ac_n "checking for assembler offsetable %lo() support""... $ac_c" 1>&6 -echo "configure:8768: checking for assembler offsetable %lo() support" >&5 +echo "configure:8745: checking for assembler offsetable %lo() support" >&5 if eval "test \"`echo '$''{'gcc_cv_as_offsetable_lo10'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8803,7 +8780,7 @@ EOF i[34567]86-*-*) echo $ac_n "checking assembler instructions""... $ac_c" 1>&6 -echo "configure:8807: checking assembler instructions" >&5 +echo "configure:8784: checking assembler instructions" >&5 gcc_cv_as_instructions= if test x$gcc_cv_as != x; then set "filds fists" "filds mem; fists mem" @@ -8929,7 +8906,7 @@ fi # Build a new-libstdc++ system (ie libstdc++-v3) echo $ac_n "checking for libstdc++ to install""... $ac_c" 1>&6 -echo "configure:8933: checking for libstdc++ to install" >&5 +echo "configure:8910: checking for libstdc++ to install" >&5 # Check whether --enable-libstdcxx-v3 or --disable-libstdcxx-v3 was given. if test "${enable_libstdcxx_v3+set}" = set; then enableval="$enable_libstdcxx_v3" @@ -9199,7 +9176,6 @@ ${CONFIG_SHELL-/bin/sh} $srcdir/configure.frag $srcdir "$subdirs" "$dep_host_xma - # Echo that links are built @@ -9453,7 +9429,6 @@ s%@build_xm_file_list@%$build_xm_file_list%g s%@cc_set_by_configure@%$cc_set_by_configure%g s%@quoted_cc_set_by_configure@%$quoted_cc_set_by_configure%g s%@cpp_install_dir@%$cpp_install_dir%g -s%@cpp_main@%$cpp_main%g s%@dep_host_xmake_file@%$dep_host_xmake_file%g s%@dep_tmake_file@%$dep_tmake_file%g s%@extra_c_flags@%$extra_c_flags%g diff --git a/gcc/configure.in b/gcc/configure.in index e7243bb64a8..50273e19a34 100644 --- a/gcc/configure.in +++ b/gcc/configure.in @@ -217,14 +217,6 @@ elif test x$withval != xno; then cpp_install_dir=$withval fi]) -# Use cpplib+cppmain for the preprocessor, but don't link it with the compiler. -cpp_main=cppmain -AC_ARG_ENABLE(cpplib, -[ --disable-cpplib use the old isolated C preprocessor.], -if test x$enable_cpplib = xno; then - cpp_main=cccp -fi) - dnl Disable this for the moment; the library interface is changing. dnl # Link cpplib into the compiler proper, for C/C++/ObjC. dnl AC_ARG_ENABLE(c-cpplib, @@ -234,7 +226,6 @@ dnl if test x$enable_c_cpplib != xno; then dnl extra_c_objs="${extra_c_objs} libcpp.a" dnl extra_cxx_objs="${extra_cxx_objs} ../libcpp.a" dnl extra_c_flags="${extra_c_flags} -DUSE_CPPLIB=1" -dnl cpp_main=cppmain dnl fi) # Enable Multibyte Characters for C/C++ @@ -4811,7 +4802,6 @@ AC_SUBST(build_xm_file_list) AC_SUBST(cc_set_by_configure) AC_SUBST(quoted_cc_set_by_configure) AC_SUBST(cpp_install_dir) -AC_SUBST(cpp_main) AC_SUBST(dep_host_xmake_file) AC_SUBST(dep_tmake_file) AC_SUBST(extra_c_flags) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5d60aa017c2..94c12aea43d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2000-04-18 Zack Weinberg + + * lex.c: Remove references to cccp.c. + 2000-04-18 Mark Mitchell * cp-tree.h (lang_decl_flags): Remove const_memfunc and diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index b25693170cd..da03c742852 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -2302,7 +2302,7 @@ check_newline () } else if (!strcmp (name, "ident")) { - /* #ident. The pedantic warning is now in cccp.c. */ + /* #ident. The pedantic warning is now in cpp. */ /* Here we have just seen `#ident '. A string constant should follow. */ diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index f7cdd3197e8..ddf4439ce6d 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -1097,7 +1097,7 @@ hack_vms_include_specification (fullname) /* The VMS part ends in a `]', and the preceding character is not a `.'. -> PATH]:/name (basename = '/name', unixname = 'name') We strip the `]', and then splice the two parts of the name in the - usual way. Given the default locations for include files in cccp.c, + usual way. Given the default locations for include files, we will only use this code if the user specifies alternate locations with the /include (-I) switch on the command line. */ diff --git a/gcc/cpplib.h b/gcc/cpplib.h index 366196d686a..e6f2529b98a 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -135,7 +135,7 @@ struct htab; /* Values for opts.dump_macros. 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. + macros in a form suitable for use as input to cpp. dump_names means pass #define and the macro name through to output. dump_definitions means pass the whole definition (plus #define) through */ diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index cfe74fb4155..854802cf206 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,6 +1,11 @@ +2000-04-18 Zack Weinberg + + * lex.c: Remove references to cccp.c. + * g77install.texi: Remove references to cexp.c/cexp.y. + 2000-04-15 David Edelsohn - * f/target.h (FFETARGET_32bit_longs): Define for 64-bit PowerPC + * target.h (FFETARGET_32bit_longs): Define for 64-bit PowerPC as well. Wed Apr 12 15:15:26 2000 Mark Mitchell diff --git a/gcc/f/g77install.texi b/gcc/f/g77install.texi index baa72ea76e7..67651a6db27 100644 --- a/gcc/f/g77install.texi +++ b/gcc/f/g77install.texi @@ -1992,7 +1992,7 @@ type these commands: @example sh# @kbd{cd gcc} -sh# @kbd{touch bi-parser.c bi-parser.h c-parse.c c-parse.h cexp.c} +sh# @kbd{touch bi-parser.c bi-parser.h c-parse.c c-parse.h} sh# @kbd{touch cp/parse.c cp/parse.h objc-parse.c} sh# @kbd{cd ..} sh# diff --git a/gcc/f/lex.c b/gcc/f/lex.c index 0a5435c3753..a79bab37fee 100644 --- a/gcc/f/lex.c +++ b/gcc/f/lex.c @@ -1224,7 +1224,7 @@ ffelex_hash_ (FILE *finput) && getc (finput) == 't' && ((c = getc (finput)) == ' ' || c == '\t')) { - /* #ident. The pedantic warning is now in cccp.c. */ + /* #ident. The pedantic warning is now in cpp. */ /* Here we have just seen `#ident '. A string constant should follow. */ diff --git a/gcc/install.texi b/gcc/install.texi index 5c31cb20f2b..1e660a818a2 100644 --- a/gcc/install.texi +++ b/gcc/install.texi @@ -53,10 +53,9 @@ On a System V release 4 system, make sure @file{/usr/bin} precedes @cindex Bison parser generator @cindex parser generator, Bison @item -Make sure the Bison parser generator is installed. (This is -unnecessary if the Bison output files @file{c-parse.c} and -@file{cexp.c} are more recent than @file{c-parse.y} and @file{cexp.y} -and you do not plan to change the @samp{.y} files.) +Make sure the Bison parser generator is installed. (This is unnecessary +if the Bison output file @file{c-parse.c} is more recent than +@file{c-parse.y},and you do not plan to change the @samp{.y} file.) Bison versions older than Sept 8, 1988 will produce incorrect output for @file{c-parse.c}. @@ -396,9 +395,8 @@ Ignore any warnings you may see about ``statement not reached'' in escape sequence'' are normal in @file{genopinit.c} and perhaps some other files. Likewise, you should ignore warnings about ``constant is so large that it is unsigned'' in @file{insn-emit.c} and -@file{insn-recog.c}, a warning about a comparison always being zero -in @file{enquire.o}, and warnings about shift counts exceeding type -widths in @file{cexp.y}. Any other compilation errors may represent bugs in +@file{insn-recog.c}, and a warning about a comparison always being zero +in @file{enquire.o}. Any other compilation errors may represent bugs in the port to your machine or operating system, and @ifclear INSTALLONLY should be investigated and reported (@pxref{Bugs}). @@ -1260,47 +1258,11 @@ You will also a patched version of @file{/bin/ld} there that raises some of the arbitrary limits found in the original. @item m68k-att-sysv -AT&T 3b1, a.k.a. 7300 PC. Special procedures are needed to compile GNU -CC with this machine's standard C compiler, due to bugs in that -compiler. You can bootstrap it more easily with -previous versions of GNU CC if you have them. - -Installing GNU CC on the 3b1 is difficult if you do not already have -GNU CC running, due to bugs in the installed C compiler. However, -the following procedure might work. We are unable to test it. - -@enumerate -@item -Comment out the @samp{#include "config.h"} line near the start of -@file{cccp.c} and do @samp{make cpp}. This makes a preliminary version -of GNU cpp. - -@item -Save the old @file{/lib/cpp} and copy the preliminary GNU cpp to that -file name. - -@item -Undo your change in @file{cccp.c}, or reinstall the original version, -and do @samp{make cpp} again. - -@item -Copy this final version of GNU cpp into @file{/lib/cpp}. - -@findex obstack_free -@item -Replace every occurrence of @code{obstack_free} in the file -@file{tree.c} with @code{_obstack_free}. - -@item -Run @code{make} to get the first-stage GNU CC. - -@item -Reinstall the original version of @file{/lib/cpp}. - -@item -Now you can compile GNU CC with itself and install it in the normal -fashion. -@end enumerate +AT&T 3b1, a.k.a. 7300 PC. This version of GNU CC cannot +be compiled with the system C compiler, which is too buggy. +You will need to get a previous version of GCC and use it to +bootstrap. Binaries are available from the OSU-CIS archive, at +@url{ftp://archive.cis.ohio-state.edu/pub/att7300/}. @item m68k-bull-sysv Bull DPX/2 series 200 and 300 with BOS-2.00.45 up to BOS-2.01. GNU CC works diff --git a/gcc/jump.c b/gcc/jump.c index 18303e6eea8..6b5fecdc91f 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -939,7 +939,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, /* ??? This is disabled in genconfig, as this simple-minded transformation can incredibly lengthen register lifetimes. - Consider this example from cexp.c's yyparse: + Consider this example: 234 (set (pc) (if_then_else (ne (reg:DI 149) (const_int 0 [0x0])) diff --git a/gcc/po/ChangeLog b/gcc/po/ChangeLog index 68ec053c3ed..f0e3041bbbe 100644 --- a/gcc/po/ChangeLog +++ b/gcc/po/ChangeLog @@ -1,3 +1,8 @@ +2000-04-18 Zack Weinberg + + * POTFILES.in: Remove cccp.c and cexp.c. Comment out + alpha/vms-tramp.asm. + 2000-04-05 Geoff Keating * POTFILES.in: Remove config/rs6000/eabi-ctors.c, which was diff --git a/gcc/po/POTFILES.in b/gcc/po/POTFILES.in index 1e4e63b5f87..994e94d867f 100644 --- a/gcc/po/POTFILES.in +++ b/gcc/po/POTFILES.in @@ -68,8 +68,6 @@ c-tree.h c-typeck.c caller-save.c calls.c -cccp.c -cexp.c ../libiberty/choose-temp.c collect2.c combine.c @@ -94,7 +92,7 @@ config/alpha/openbsd.h config/alpha/osf.h config/alpha/osf12.h config/alpha/osf2or3.h -config/alpha/vms-tramp.asm +#config/alpha/vms-tramp.asm is part of the GCC library config/alpha/vms.h config/alpha/vxworks.h config/alpha/win-nt.h diff --git a/gcc/protoize.c b/gcc/protoize.c index 37e7ff83a75..7a58df23ef7 100644 --- a/gcc/protoize.c +++ b/gcc/protoize.c @@ -192,7 +192,7 @@ static const unexpansion unexpansions[] = { static const int hash_mask = (HASH_TABLE_SIZE - 1); /* Make a table of default system include directories - just as it is done in cccp.c. */ + just as it is done in cpp. */ #ifndef STANDARD_INCLUDE_DIR #define STANDARD_INCLUDE_DIR "/usr/include"