Add original cproto-4.6
authorNick Downing <downing.nick@gmail.com>
Thu, 12 Jan 2017 08:28:54 +0000 (19:28 +1100)
committerNick Downing <downing.nick@gmail.com>
Thu, 12 Jan 2017 08:28:54 +0000 (19:28 +1100)
82 files changed:
cproto-4.6/CHANGES [new file with mode: 0644]
cproto-4.6/Makefile.in [new file with mode: 0644]
cproto-4.6/README [new file with mode: 0644]
cproto-4.6/aclocal.m4 [new file with mode: 0644]
cproto-4.6/config_h.in [new file with mode: 0644]
cproto-4.6/configure [new file with mode: 0755]
cproto-4.6/configure.in [new file with mode: 0644]
cproto-4.6/cproto.1 [new file with mode: 0644]
cproto-4.6/cproto.c [new file with mode: 0644]
cproto-4.6/cproto.h [new file with mode: 0644]
cproto-4.6/emx/Makefile [new file with mode: 0644]
cproto-4.6/emx/README [new file with mode: 0644]
cproto-4.6/grammar.y [new file with mode: 0644]
cproto-4.6/install.sh [new file with mode: 0755]
cproto-4.6/lex.l [new file with mode: 0644]
cproto-4.6/lex_yy.c [new file with mode: 0644]
cproto-4.6/lintlibs.c [new file with mode: 0644]
cproto-4.6/mkdirs.sh [new file with mode: 0755]
cproto-4.6/msdos/README [new file with mode: 0644]
cproto-4.6/msdos/borland.mak [new file with mode: 0644]
cproto-4.6/msdos/micrsoft.lnk [new file with mode: 0644]
cproto-4.6/msdos/micrsoft.mak [new file with mode: 0644]
cproto-4.6/msdos/turboc.mak [new file with mode: 0644]
cproto-4.6/os2/README [new file with mode: 0644]
cproto-4.6/os2/run_test.cmd [new file with mode: 0644]
cproto-4.6/os2/watcom.mak [new file with mode: 0644]
cproto-4.6/porting/README [new file with mode: 0644]
cproto-4.6/porting/getopt.c [new file with mode: 0644]
cproto-4.6/porting/getopt.h [new file with mode: 0644]
cproto-4.6/porting/popen.c [new file with mode: 0644]
cproto-4.6/semantic.c [new file with mode: 0644]
cproto-4.6/semantic.h [new file with mode: 0644]
cproto-4.6/strkey.c [new file with mode: 0644]
cproto-4.6/strstr.c [new file with mode: 0644]
cproto-4.6/symbol.c [new file with mode: 0644]
cproto-4.6/symbol.h [new file with mode: 0644]
cproto-4.6/system.h [new file with mode: 0644]
cproto-4.6/testing/README [new file with mode: 0644]
cproto-4.6/testing/apollo.c [new file with mode: 0644]
cproto-4.6/testing/case01.ref [new file with mode: 0644]
cproto-4.6/testing/case02.ref [new file with mode: 0644]
cproto-4.6/testing/case03.ref [new file with mode: 0644]
cproto-4.6/testing/case04.ref [new file with mode: 0644]
cproto-4.6/testing/case05.ref [new file with mode: 0644]
cproto-4.6/testing/case06.ref [new file with mode: 0644]
cproto-4.6/testing/case07.ref [new file with mode: 0644]
cproto-4.6/testing/case08.ref [new file with mode: 0644]
cproto-4.6/testing/case09.ref [new file with mode: 0644]
cproto-4.6/testing/case10.ref [new file with mode: 0644]
cproto-4.6/testing/case11.ref [new file with mode: 0644]
cproto-4.6/testing/case12.ref [new file with mode: 0644]
cproto-4.6/testing/case13.ref [new file with mode: 0644]
cproto-4.6/testing/case14.ref [new file with mode: 0644]
cproto-4.6/testing/case15.ref [new file with mode: 0644]
cproto-4.6/testing/case16.ref [new file with mode: 0644]
cproto-4.6/testing/case17.ref [new file with mode: 0644]
cproto-4.6/testing/case18.ref [new file with mode: 0644]
cproto-4.6/testing/case19.ref [new file with mode: 0644]
cproto-4.6/testing/case20.ref [new file with mode: 0644]
cproto-4.6/testing/case21.ref [new file with mode: 0644]
cproto-4.6/testing/case22.ref [new file with mode: 0644]
cproto-4.6/testing/descrip.mms [new file with mode: 0644]
cproto-4.6/testing/linux.c [new file with mode: 0644]
cproto-4.6/testing/make_bat.sh [new file with mode: 0755]
cproto-4.6/testing/make_dcl.sh [new file with mode: 0755]
cproto-4.6/testing/makefile [new file with mode: 0644]
cproto-4.6/testing/run_test.com [new file with mode: 0644]
cproto-4.6/testing/run_test.sh [new file with mode: 0755]
cproto-4.6/testing/run_test.txt [new file with mode: 0644]
cproto-4.6/testing/solaris.c [new file with mode: 0644]
cproto-4.6/testing/syntax.c [new file with mode: 0644]
cproto-4.6/testing/test_dos.bat [new file with mode: 0644]
cproto-4.6/testing/testunix.sh [new file with mode: 0755]
cproto-4.6/testing/turboc.c [new file with mode: 0644]
cproto-4.6/trace.c [new file with mode: 0644]
cproto-4.6/trace.h [new file with mode: 0644]
cproto-4.6/vms/README [new file with mode: 0644]
cproto-4.6/vms/descrip.mms [new file with mode: 0644]
cproto-4.6/win32/README [new file with mode: 0644]
cproto-4.6/win32/watcom.mak [new file with mode: 0644]
cproto-4.6/y_tab.c [new file with mode: 0644]
cproto-4.6/yyerror.c [new file with mode: 0644]

diff --git a/cproto-4.6/CHANGES b/cproto-4.6/CHANGES
new file mode 100644 (file)
index 0000000..3d55297
--- /dev/null
@@ -0,0 +1,529 @@
+Version 4.6
+
+- Since cproto is no longer being distributed on USENET in shar file format,
+  the patchlev.h and MANIFEST files have been removed.
+  The patchlevel number has been removed from the version number.
+
+- Moved files out of the porting directory into separate platform specific
+  directories.  The emx directory has files used to compile using EMX.
+  The os2 directory has files used to compile on OS/2 using Watcom C/C++.
+  The win32 directory has files to compile on Windows 95 and Windows NT
+  using Watcom C/C++.
+
+- correct order of include-path to keep standard include (e.g., /usr/include)
+  at the end of the search list.
+
+- modified lint-library include-stack recovery to work on OSF/1.
+
+- supply default initializer for lint-library const data
+
+- corrected reset of __attribute__((noreturn))
+
+- added '__volatile', '__const__', '__inline' keywords to grammar to
+  accommodate gcc.
+
+- modified configure script to add several development/debugging options (i.e.,
+  --with-trace, --with-dbmalloc, --with-dmalloc).
+
+- modified ifdefs to avoid using predefined 'unix' (not defined on AIX or CLIX)
+
+Patchlevel 5 (April 1996)
+
+- corrected instance of fclose on a file pointer after pclose was done (found
+  with Electric Fence).
+
+- corrected script make_bat.sh to prevent expansion of \n in argument-string.
+
+- Modified handling of lint library option to allow generation of lint libraries
+  for ANSI compilers (set -a -l).
+
+- corrected a missing 'void' in parameter list
+
+- modified to allow compile/test with 'dmalloc' library in addition to
+  'dbmalloc'.
+
+- corrected memory leak in yyerror.c, and allocation-size for cpp command.
+
+- added keywords to work with gcc 2.7.0
+
+- corrected unresolved references to flush_varargs() when OPT_LINTLIBRARY
+  is not defined                                                         
+
+Patchlevel 4 (August 1995)
+
+- Added -S option to only output static declarations.
+
+- Fix: The configure script didn't replace @CFLAGS@, @CPPFLAGS@ and @LDFLAGS@
+  in the makefile generated from makefile.in.
+
+- Fix: The -a option generated incorrect function definitions.
+
+- update test-cases for the -f2 fix in patch 3.
+
+- remove dependency on GNU-make from makefile.in
+
+- corrected configuration script that tests whether yyerror can be extended
+  (had cached wrong flag, preventing some configurations from being
+  recognized).
+
+- added calls for 'flush_varargs()' to correct situation in lint-library output
+  where VARARGS comments were not reset properly when a function
+  was skipped.
+
+- improved the logic of 'strip_name()' (used to compute include-directives for
+  the lint-library option) so that it recognizes the conventional include
+  directory created by a GCC install.
+
+Patchlevel 3 (January 1995)
+
+- check for a special case in lint-library generation, i.e., prototype
+  arguments of the form "*()", which need more parentheses for SunOS's lint.
+
+- modified configure.in, aclocal.m4, makefile.in to work with autoconf 2.1
+  (also added install.sh - note that "install-sh" is not an MS-DOS-compatible
+  filename).
+
+- derive the program name from the argv[0] entry, in case it's installed
+  under a different name.
+
+- Fix: The -f2 option generated incorrect prototypes for functions that
+  take a variable argument list.
+
+- use 'sed' rather than 'flip' to apply trailing CR's to MS-DOS scripts.
+
+Patchlevel 2 (October 1994)
+
+- modified grammar to recognize C++ ref-variables (i.e., '&' as a prefix to
+  identifiers at the top lexical level).  Lint libraries are formatted without
+  this '&', since lint doesn't grok C++.  This corrects an error in cproto 4.0
+  which caused '&' characters to be suppressed altogether, e.g., when filtering
+  with the "-t" option.
+
+- modified rules that generate MANIFEST to put auto-generated scripts there
+  also, if they've been created (e.g., cd testing; make scripts).
+
+- modified makefile.in to have shar target for both GNU shar and Rick Salz's
+  cshar utility.
+
+- use 'const' in yyerror.c, otherwise the error-reporting auto-configuration
+  does not work.
+
+- don't use "#elif" preprocessor control; not all systems support it.
+
+Patchlevel 1 (October 1994)
+
+- Added testing scripts for MS-DOS and VMS.
+
+- Added makefile for Borland C++ for OS/2.
+
+- Fix: When the -a, -t or -b options were used, '&' characters were stripped
+  from the output files.
+
+- Fix: The system.h file should define EXIT_SUCCESS and EXIT_FAILURE
+  regardless of the presence of <stdlib.h>.
+
+Patchlevel 0 (dickey, September 1994)
+
+- corrected two malloc-defects in lint library generation (one place where
+  generated parameter name was copied rather than allocated, and another memory
+  leak).
+
+- corrected generation of lint library function body, to handle function
+  pointers.
+
+- changed the implicit lint library function type from "" to "void", to avoid
+  special-cases in the function-body generation.
+
+- added logic using 'NestedParams' to suppress prototype-arguments in lint
+  library function-pointer arguments.
+
+- corrected lint-library function parameter derived from prototype "char [2]"
+  (parameter name wasn't supplied).
+
+- added PRINTFLIKE and SCANFLIKE to the comments interpreted for the lint
+  library translation.
+
+- modified "LINT_PREPRO" comment to pass-thru all comment text if no count is
+  given.
+
+- added new comment keyword "LINT_SHADOWED" to generate "#undef symbol" before
+  each function template in lint libraries (useful for processing files that
+  define both macros and functions with the same names).
+
+- interpret GCC's __attribute__ noreturn and format for lint-library text
+  (GCC 2.5.8 preprocessor passes these macros through, GCC 2.6 apparently does
+  not).
+
+- treat carriage-return (^M) as whitespace where appropriate.
+
+- added configuration-test to avoid conflict with prototype for 'popen()'
+
+- added several function-pointer regression test-cases
+
+Version 3
+
+Patchlevel 9 (dickey, August 1994)
+
+- use 'autoconf' to make a UNIX configure-script.
+
+- recognize GCC extensions '__inline' and '__attribute__'
+
+- added ifdef OPT_LINTLIBRARY to allow compiling without the lint library
+  code (saves about 4kb).
+
+- corrected some logic that made incorrect commenting for options -c -f1
+  (e.g., "void (*Sigdisp(int sig, void (*func)(int sig)))(int sig)").
+
+- corrected logic that macroizes (e.g., with P_) functions like 'Sigdisp'
+  (it wasn't doing anything about the trailing "(int sig)").
+
+- corrected handling of K&R conversion of mixed-mode functions (K&R style
+  with prototypes in arguments) to avoid losing comments.
+
+- modified logic for options -c -f2 so that cproto inserts a space before
+  the beginning of a comment when it immediately follows an '*'.
+
+- enhanced error reporting with new module yyerror.c which (attempts to)
+  report the expected token type/name when a syntax error is encountered.
+
+- modified the grammar.y file to try to recover from errors at the next
+  semicolon (as well as the next right curly bracket).
+
+- modified to process lex/yacc files with gcc as C-preprocessor.
+
+- Added option "-O" to force redirection of errors without shell operations
+  (useful for VAX/VMS and MS-DOS in particular).
+
+- added "\s" as a synonym for space in the format options (-P, -F, -C)
+
+- tested on Solaris with lex/yacc and flex 2.4.6 / bison 1.22
+  (SunOS explorer 5.3 Generic_101318-42 sun4m sparc; gcc 2.6.0)
+
+- tested on SunOS 4.1.1 with lex/yacc and flex 2.4.6 / bison 1.22
+  (SunOS calvin 4.1.1 1 sun4c)
+
+- tested on IRIX with lex/yacc
+  (IRIX dbs3 5.2 02282015 IP19 mips)
+
+- tested on Linux 0.99.15 with lex/yacc and flex 2.4.6 / bison 1.22 / byacc 1.9
+
+- tested on MS-DOS with flex 2.37 / byacc 1.9 (built with turboc.mak).
+  (Bison uses too much stack space).
+
+- tested on VAX/VMS 6.1 with VAX-C 3.2 and flex 2.4.6 / bison 1.22.
+
+- moved non-UNIX files into 'porting' subdirectory.
+
+- added 'testing' subdirectory, for simple regression tests.
+
+- tested for memory leaks with dbmalloc (on Linux).
+
+Patchlevel 8 (internal: dickey/cthuang, June 1993)
+
+- added files 'lintlibs.c' and 'strkey.c'
+
+- Allow dollar signs in identifiers
+
+- Defined FAIL, SUCCESS to use in 'exit()' calls (VMS is approximately the
+  reverse of UNIX).
+
+- Added option "-o" to force redirection without shell operations (useful for
+  VAX/VMS in particular).
+
+- Added options "-l" (lintlibrary format), "-T" (typedefs), "-x" (externs
+  in include-files).
+
+- Added "-C" option to cpp-invocation (to support VARARGS-decoding for -l
+  option).
+
+- Modified grammar.y so that if -T option is turned on, instances of untagged
+  struct, union or enum are shown with the contents of the curly braces.
+
+- Modified lex.l so that it sets 'return_val' iff at least one return statement
+  within curly braces returns an expression.  Use this to support -l option.
+
+- Modified semantic.c (for -l option) to put tabs after short names for better
+  readability.  Also (only -l option), put a blank line before function
+  definitions and typedefs.
+
+- Corrected lex.l so that it recognizes preprocessor lines within curly braces.
+
+- Modified 'gen_prototype()' to trim 'extern' and 'auto' keywords from the text
+  (so that 'extern' is emitted in this function only if the -e option is
+  specified).  Do this to support -l option (and to correct normal usage, which
+  implies that -e option is needed to put an 'extern' before declaration).
+
+- Corrected test in 'put_decl_spec()' by using 'strkey()' (which tests for a
+  name, not simply a substring).
+
+- Modified semantic.c to use 'put_string()' and related procedures to simplify
+  pretty-printing of lint-library text (mainly to control blank lines).  (See
+  'fmt_library()').
+
+- linted some xmalloc calls using ALLOC macro.
+
+Patchlevel 7
+
+- Fix: The processing of string literals is now more robust.
+
+- Removed the -f4 option which generated prototypes like
+
+       int main P_((int argc, char **argv));
+
+  Use the -m option now to put a guard macro around the prototype
+  parameter list.  Use the -m option together with -f3 (which is the
+  default) to produce the same output as the old -f4 option.  The option
+  to set the guard macro name is now -M.
+
+- Comments in prototype parameter lists are now disabled by default.
+  Use the -c option now to output these comments.
+
+- Can now process #include directives in which the file is specified with
+  a #define macro.
+
+- Now does not convert function definitions that take the formal
+  parameter va_alist from <varargs.h>.
+
+- Now recognizes the GNU C modifiers __const and __inline__.
+
+Patchlevel 6
+
+- Fix: A function in lex.l exploited the ANSI C feature of concatenating
+  string literals.  This prevented the module from being compiled with
+  pre-ANSI C compilers.
+
+Patchlevel 5
+
+- Fix: The -v option did not output declarations for function pointers.
+
+- Fix: String literals continued over more than one line messed up the
+  line number count.
+
+- Fix: The program generated incorrect prototypes for functions that
+  take a variable argument list using <varargs.h>.
+
+- Fix: When converting functions from the standard input, cproto
+  generated no output if no functions needed to be converted.
+
+- Fix: Now does not output a warning if an untagged struct is found in a
+  typedef declaration.
+
+- Added the -b option which rewrites function definition heads to
+  include both old style and new style declarations separated by a
+  conditional compilation directive.  For example, the program can
+  generate
+
+       #ifdef ANSI_FUNC
+
+       int
+       main (int argc, char *argv[])
+       #else
+
+       int
+       main (argc, argv)
+       int argc;
+       char *argv[]
+       #endif
+       {
+       }
+
+  Added the -B option to set the preprocessor directive that appears at
+  the beginning of such definitions.
+
+- Added the keyword "interrupt" to the set of type qualifiers when
+  compiled on a UNIX system.
+
+- The MS-DOS version now recognizes the type modifiers introduced by
+  Microsoft C/C++ 7.00.
+
+- Now recognizes ANSI C trigraphs (yuck!).
+
+- Now use "#if __STDC__" instead of "#if defined(__STDC__)".
+
+- GNU bison orders the y.tab.c sections differently than yacc, which
+  resulted in references to variables before they were declared.  The
+  grammar specification was modified to also be compatible with bison.
+
+Patchlevel 4
+
+- Fix: A typedef name defined as a pointer to char, short or float was
+  incorrectly promoted if it was used to specify a formal parameter.
+  For example, for the definition
+
+       typedef char *caddr_t;
+
+       int strlen (s)
+       caddr_t s;
+       {
+       }
+
+  cproto generated the incorrect prototype
+
+       int strlen(int s);
+
+- Added implementation of the ANSI function tmpfile() for systems that
+  don't have it.
+- If compiled with Microsoft C, cproto preprocesses its input by running
+  the command "cl /E".  To eliminate the error messages when the file
+  <malloc.h> is included, the program now recognizes the specifier
+  _based(void).
+
+Patchlevel 3
+
+- Fix: The program didn't generate prototypes for functions defined with
+  the extern specifier.
+- Fix: The -c option didn't output a space before parameter names in
+  generated prototypes.
+- Added the -E option to specify a particular C preprocessor to run or
+  to stop the program from running the C preprocessor.
+- Added the -q option to stop the program from outputting error messages
+  when it cannot read the file specified in an #include directive.
+- Made the yacc specification compatible with UNIX SYSVR4 yacc.
+  
+Patchlevel 2
+
+- Fix: The function definition conversion may produce a mangled function
+  definition if an #include directive appears before the function and
+  no comments appear between the directive and the function.
+- Fix: The size of the buffer allocated for the C preprocessor command
+  string did not include enough space for options set in the environment
+  variable CPROTO.
+- Replaced the -n option with -c which disables all comments in the
+  generated prototypes.
+- Replaced the enum's with #define constants to accommodate C compilers
+  that don't like enumerators in constant expressions.
+
+Patchlevel 1
+
+- Fix: The program was calling ftell() on an invalid FILE pointer.
+
+Patchlevel 0
+
+- Added options to convert function definitions between the old style
+  and ANSI C style.
+- Options can be specified from the environment variable CPROTO.
+- The MS-DOS version recognizes more Microsoft C and Borland C++ type
+  modifiers (such as _cdecl, _far, _near).
+- Fix: Formal parameters specified with typedef names were not promoted.
+  For example, for the definition
+
+       typedef unsigned short ushort;
+
+       void test (x)
+       ushort x;
+       {
+       }
+
+  cproto generated the incorrect prototype
+
+       void test(ushort x);
+
+  while the correct one is
+
+       void test(int x);
+
+- Fix: Incorrect prototypes were generated for functions that returned
+  function pointers.  For example, cproto generated an incorrect
+  prototype for the function definition
+
+       void (*signal(int x, void (*func)(int y)))(int z)
+       {
+       }
+
+- Fix: Changed calls to memory allocation functions to abort the program
+  if they fail.
+
+Version 2
+
+Patchlevel 3
+
+- Made cproto compatible with GNU flex.
+- After compiling with the preprocessor symbol TURBO_CPP defined, on
+  MS-DOS systems, cproto will pipe its input through the Turbo C
+  preprocessor.
+- Fix: Typedef names may now be omitted from typedef declarations.
+  For example, every C compiler I tried accepts
+
+       typedef int;
+
+  and some even give warnings when encountering this statement.
+
+Patchlevel 2
+
+- Cproto is now able to generate prototypes for functions defined in lex
+  and yacc source files named on the command line.  Lex and yacc source
+  files are recognized by the .l or .y extension.
+- Fix: The memory allocated to the typedef symbol table was not being
+  freed after scanning each source file.
+- Fix: Failure to reset a variable during error recovery caused
+  segmentation faults.
+
+Patchlevel 1
+
+- Fix: Cproto incorrectly generated the parameter "int ..." in
+  prototypes of functions taking variable parameters.
+- Fix: Function definitions can now be followed by an optional
+  semicolon.  I found this feature in every C compiler I tried.
+
+Patchlevel 0
+
+- Added formal parameter promotion.
+- Added prototype style that surrounds prototypes with a guard macro.
+- Handles C++ style comment //.
+- Nifty new way to set prototype output format.
+- Got rid of the shell wrapper used to pipe the input through the C
+  preprocessor (cpp).
+- For the port to MS-DOS, I modified cproto to run without cpp, but
+  since I didn't want to reimplement cpp, the program processes only the
+  #include and #define directives and ignores all others.  Macro names
+  defined by the #define directive are treated like typedef names if
+  they appear in declaration specifiers.
+
+Version 1
+
+Patchlevel 3
+
+- Fix: identical typedef names and struct tags should be allowed.
+  For example:
+
+       typedef struct egg_salad egg_salad;
+
+       struct egg_salad {
+           int mayo;
+       };
+
+       void dine(egg_salad l)
+       {
+       }
+
+Patchlevel 2
+
+- Fix: A typedef statement should allow a list of typedefs to be declared.
+  Example:
+
+       typedef int a, *b;
+
+- Fix: When run with the -v option on this input, cproto did not output
+  a declaration for variable "b":
+
+       char *a="one"; char *b="two";
+
+- The options were renamed.  Added new options that change the output
+  format of the prototypes.
+
+Patchlevel 1
+
+- Fix: Incorrect prototypes were produced for functions that take
+  function pointer parameters or return a function pointer.  For example,
+  cproto produced an erroneous prototype for this function definition:
+
+       void
+       (*signal (sig, func))()
+       int sig;
+       void (*func)();
+       {
+           /* stuff */
+       }
+
+- The lexical analyser now uses LEX.  It should still be compatible with
+  FLEX.
diff --git a/cproto-4.6/Makefile.in b/cproto-4.6/Makefile.in
new file mode 100644 (file)
index 0000000..72bd89a
--- /dev/null
@@ -0,0 +1,200 @@
+# @configure_input@
+# $Id: Makefile.in,v 4.7 1998/01/24 01:42:00 cthuang Exp $
+#
+# UNIX template-makefile for C prototype generator
+
+THIS = cproto
+RELEASE = 4_6
+
+#### Start of system configuration section. ####
+
+srcdir = @srcdir@
+VPATH  = @srcdir@
+
+CC             = @CC@
+CPP            = @CPP@
+LEX            = @LEX@
+YACC           = @YACC@
+LINT           = @LINT@
+
+INSTALL                = @INSTALL@
+INSTALL_PROGRAM        = @INSTALL_PROGRAM@
+INSTALL_DATA   = @INSTALL_DATA@
+
+DEFINES                =
+CPPFLAGS       = -I$(srcdir) $(DEFINES) -DHAVE_CONFIG_H @CPPFLAGS@
+CFLAGS         = @CFLAGS@ $(CPPFLAGS)
+LIBS           = @LIBS@ @LEXLIB@
+
+prefix         = @prefix@
+exec_prefix    = @exec_prefix@
+
+bindir         = $(exec_prefix)/bin
+mandir         = $(prefix)/man/man1
+manext         = 1
+
+#### End of system configuration section. ####
+
+SHELL          = /bin/sh
+@SET_MAKE@
+
+LDFLAGS                = @LDFLAGS@
+
+DOC_FILES = \
+       README \
+       CHANGES \
+       $(THIS).1
+
+MAK_FILES = \
+       Makefile.in \
+       configure.in \
+       aclocal.m4 \
+       config_h.in
+
+H_FILES = \
+       yyerror.c \
+       system.h \
+       $(THIS).h \
+       semantic.h \
+       symbol.h
+
+C_FILES = \
+       $(THIS).c \
+       lintlibs.c \
+       semantic.c \
+       strkey.c \
+       strstr.c \
+       symbol.c
+
+AUX_FILES = \
+       mkdirs.sh \
+       lex.l \
+       grammar.y
+
+JUNK = \
+       lex.yy.c \
+       y.tab.c
+
+EXTRA_OBJS = @EXTRA_OBJS@
+OBJECTS = $(THIS).o lintlibs.o semantic.o strkey.o strstr.o symbol.o y.tab.o \
+       $(EXTRA_OBJS)
+SOURCES = $(DOC_FILES) $(MAK_FILES) $(H_FILES) $(C_FILES) $(AUX_FILES)
+
+all : $(THIS) # $(THIS).man
+
+install: all installdirs
+       $(INSTALL_PROGRAM) $(THIS) $(bindir)/$(THIS)
+       - $(INSTALL_DATA) $(srcdir)/$(THIS).1 $(mandir)/$(THIS).$(manext)
+
+installdirs:
+       $(SHELL) ${srcdir}/mkdirs.sh $(bindir)
+       - $(SHELL) ${srcdir}/mkdirs.sh $(mandir)
+
+uninstall:
+       - rm -f $(bindir)/$(THIS) $(mandir)/$(THIS).$(manext)
+
+$(THIS) : $(OBJECTS)
+       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJECTS) $(LIBS)
+
+y.tab.c : grammar.y
+       $(YACC) $(srcdir)/grammar.y
+
+lex.yy.c : lex.l
+       $(LEX) $(srcdir)/lex.l
+
+$(THIS).man : $(THIS).1
+       - nroff -man $(srcdir)/$(THIS).1 >$@
+
+mostlyclean :
+       - rm -f core .nfs* *.o *.bak *.BAK *.log *.man *.out $(JUNK) default.h
+       - rm -f Part?? part.*
+
+clean : mostlyclean
+       - rm -f $(THIS)
+       cd testing; $(MAKE) $@
+
+distclean : clean
+       - rm -f stamp-h config.log config.cache config.status config.h Makefile
+       - rm -f .version .fname
+       cd testing; $(MAKE) $@
+
+realclean: distclean
+       - rm -f tags
+       cd testing; $(MAKE) $@
+
+check: $(THIS)
+       cd testing; $(MAKE) run_test
+
+# configure might not change config.h
+config.h : stamp-h
+stamp-h : config.status
+       ./config.status
+
+Makefile: Makefile.in config.status
+       ./config.status
+
+config.status : configure
+       ./config.status --recheck
+
+configure : configure.in aclocal.m4
+       autoconf
+
+# I keep my sources in RCS, and assign a symbolic release to the current patch
+# level.  The 'manifest' script knows how to build a list of files for a given
+# revision.
+MANIFEST:
+       manifest -rv$(RELEASE) \
+               $(THIS).man testing/case*.dcl testing/case*.bat
+
+dist: MANIFEST
+       - rm -f .fname .files
+       echo '$(THIS)-$(RELEASE)' >.fname
+       cat MANIFEST | grep ' ' | egrep -v ' subdirectory$$' | sed -e 's/\ .*//' | uniq >.files
+       rm -rf `cat .fname`
+       TOP=`cat .fname`; mkdir $$TOP `cat .files | grep / | sed -e 's@/.*@@' | sed -e s@\^@$$TOP/@ | uniq`
+       for file in `cat .files`; do \
+         ln $(srcdir)/$$file `cat .fname`/$$file \
+           || { echo copying $$file instead; cp $$file `cat .fname`/$$file; }; \
+       done
+       tar -cf - `cat .fname` | gzip >`cat .fname`.tgz
+       rm -rf `cat .fname` .fname .files
+
+# Some of the output will be uuencoded because the test scripts include
+# <CR><LF> terminated ".bat" files for MS-DOS.
+dist-shar: MANIFEST
+       - rm -f .fname .files
+       echo '$(THIS)-$(RELEASE)' >.fname
+       cat MANIFEST | grep ' ' | egrep -v ' subdirectory$$' | sed -e 's/\ .*//' | uniq >.files
+       shar -M -n`cat .fname` -opart -l50 `cat .files`
+       - rm -f .fname .files
+
+# This uses Rick Salz's cshar to make a set of shar-files.
+# (It'll clobber the version info in MANIFEST, and doesn't restore timestamps,
+# but that's another bag of worms).
+dist-cshar: MANIFEST
+       makekit -m
+
+default.h: $(C_FILES) lex.yy.c
+       ./$(THIS) -e -v -m -M ARGS -d $(DEFINES) $(C_FILES) grammar.y >$@
+
+lint: $(C_FILES) $(JUNK)
+       $(LINT) $(CPPFLAGS) -lyacc $(C_FILES) y.tab.c >$@.out
+
+llib: $(C_FILES) $(JUNK)
+       ./$(THIS) -l $(CPPFLAGS) $(C_FILES) y.tab.c >$@.out
+
+tags: $(H_FILES) $(C_FILES) $(AUX_FILES)
+       ctags -t $(C_FILES) $(AUX_FILES) $(H_FILES)
+
+depend:
+       makedepend -- $(CPPFLAGS) -- $(C_FILES) y.tab.c
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
+
+cproto.o: cproto.h config.h system.h
+lintlibs.o: cproto.h config.h system.h semantic.h symbol.h
+semantic.o: cproto.h config.h system.h semantic.h
+strkey.o: cproto.h config.h system.h 
+strstr.o: cproto.h config.h system.h
+symbol.o: cproto.h config.h system.h symbol.h
+y.tab.o: cproto.h config.h system.h symbol.h semantic.h lex.yy.c yyerror.c
diff --git a/cproto-4.6/README b/cproto-4.6/README
new file mode 100644 (file)
index 0000000..6fce971
--- /dev/null
@@ -0,0 +1,17 @@
+Cproto is a program that generates function prototypes and variable
+declarations from C source code.  It can also convert function definitions
+between the old style and the ANSI C style.  This conversion overwrites the
+original files, so make a backup copy of your files in case something goes
+wrong.
+
+The program isn't confused by complex function definitions as much as other
+prototype generators because it uses a yacc generated parser.  By ignoring all
+the input between braces, I avoided implementing the entire C language grammar.
+
+Cproto is in the public domain, except for the configure script which is
+copyrighted by the Free Software Foundation, Inc.  If you have any comments
+or find any bugs, please let me know.
+
+Chin Huang
+cthuang@vex.net
+cthuang@interlog.com
diff --git a/cproto-4.6/aclocal.m4 b/cproto-4.6/aclocal.m4
new file mode 100644 (file)
index 0000000..e3f9cd8
--- /dev/null
@@ -0,0 +1,96 @@
+dnl $Id: aclocal.m4,v 4.3 1995/08/23 21:29:04 cthuang Exp $
+dnl
+dnl    Test the supplied version of yacc to see which (if any) of the
+dnl    error-reporting enhancements will work.
+dnl
+dnl    Also, test the preprocessor to see if it will handle non-C files.
+dnl    (gcc 2.5.8 doesn't).
+dnl
+AC_DEFUN([TD_YACC_ERROR],
+[
+rm -f yacctest.y
+cat >yacctest.y <<EOF
+%{
+#define xstrdup(s) s
+#include "system.h"
+#include <stdio.h>
+#include <ctype.h>
+#include "yyerror.c"
+static void yaccError(s) char *s; { exit(0); }
+int yylex ARGS((void))
+{ return 1; }
+%}
+%%
+dummy
+       : /* empty */
+       | error '.'
+       ;
+%%
+EOF
+$CPP yacctest.y >yacctest.out 2>/dev/null
+if test ! -s yacctest.out
+then
+       AC_DEFINE(CPP_DOES_ONLY_C_FILES)
+fi
+$YACC yacctest.y
+rm -f yacctest.*
+td_incl='#include "y.tab.c"'
+for COND in BISON_HAS_YYTNAME YACC_HAS_YYTOKS YACC_HAS_YYTOKS_2 YACC_HAS_YYNAME
+do
+AC_MSG_CHECKING(for error-reporting with $COND)
+AC_CACHE_VAL(ac_cv_$COND,
+AC_TRY_LINK([
+#define $COND 1
+#define YYDEBUG 1
+$td_incl],,
+eval 'ac_cv_'$COND'=yes',
+eval 'ac_cv_'$COND'=no'))
+eval 'td_result=$ac_cv_'$COND
+AC_MSG_RESULT($td_result)
+if test $td_result = yes; then
+       AC_DEFINE_UNQUOTED($COND)
+       break
+fi
+done
+rm -f y.tab.c
+])dnl
+dnl
+dnl    Check to ensure that our prototype for 'popen()' doesn't conflict
+dnl    with the system's (this is a problem on AIX and CLIX).
+dnl
+AC_DEFUN([TD_POPEN_TEST],
+[AC_MSG_CHECKING(for conflicting prototype for popen)
+AC_CACHE_VAL(ac_cv_td_popen,
+AC_TRY_LINK([
+#include <stdio.h>
+#include "system.h"
+extern int pclose ARGS((FILE *p));
+extern FILE *popen ARGS((const char *c, const char *m));],,
+ac_cv_td_popen=no,
+ac_cv_td_popen=yes))
+AC_MSG_RESULT($ac_cv_td_popen)
+if test $ac_cv_td_popen = yes; then
+       AC_DEFINE(HAVE_POPEN_PROTOTYPE)
+fi
+])dnl
+dnl
+dnl    This is a more stringent test for size_t than the one distributed with
+dnl    autoconf 2.1: some systems (CLIX, Ultrix) define size_t in <stdio.h>
+dnl
+AC_DEFUN([TD_SIZE_T],
+[AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_MSG_CHECKING(for size_t in <sys/types.h> or <stdio.h>)
+AC_CACHE_VAL(ac_cv_td_size_t,
+AC_TRY_LINK([
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#endif
+#include <stdio.h>],[size_t f = 0],
+ac_cv_td_size_t=yes,
+ac_cv_td_size_t=no))
+AC_MSG_RESULT($ac_cv_td_size_t)
+if test $ac_cv_td_size_t = no; then
+       AC_DEFINE(size_t, unsigned)
+fi
+])dnl
diff --git a/cproto-4.6/config_h.in b/cproto-4.6/config_h.in
new file mode 100644 (file)
index 0000000..d993fd5
--- /dev/null
@@ -0,0 +1,3 @@
+/* @configure_input@ */
+/* $Id: config_h.in,v 4.2 1995/01/01 19:34:59 cthuang Exp $ */
+@DEFS@
diff --git a/cproto-4.6/configure b/cproto-4.6/configure
new file mode 100755 (executable)
index 0000000..6b4fca6
--- /dev/null
@@ -0,0 +1,2038 @@
+#! /bin/sh
+
+# From configure.in Revision: 4.5 
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.12 
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+  --with-warnings         use gcc warnings (used for developing this tool)"
+ac_help="$ac_help
+  --with-trace            use trace.c for memory-testing"
+ac_help="$ac_help
+  --with-dmalloc          use Gray Watson's dmalloc"
+ac_help="$ac_help
+  --with-dbmalloc         use Conor Cahill's dbmalloc"
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval "$ac_prev=\$ac_option"
+    ac_prev=
+    continue
+  fi
+
+  case "$ac_option" in
+  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) ac_optarg= ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case "$ac_option" in
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir="$ac_optarg" ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build="$ac_optarg" ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file="$ac_optarg" ;;
+
+  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+  | --da=*)
+    datadir="$ac_optarg" ;;
+
+  -disable-* | --disable-*)
+    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+    fi
+    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+    eval "enable_${ac_feature}=no" ;;
+
+  -enable-* | --enable-*)
+    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+    fi
+    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+    case "$ac_option" in
+      *=*) ;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix="$ac_optarg" ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he)
+    # Omit some internal or obsolete options to make the list less imposing.
+    # This message is too long to be a string in the A/UX 3.1 sh.
+    cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+  --cache-file=FILE       cache test results in FILE
+  --help                  print this message
+  --no-create             do not create output files
+  --quiet, --silent       do not print \`checking...' messages
+  --version               print the version of autoconf that created configure
+Directory and file names:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [same as prefix]
+  --bindir=DIR            user executables in DIR [EPREFIX/bin]
+  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
+  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
+  --datadir=DIR           read-only architecture-independent data in DIR
+                          [PREFIX/share]
+  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
+                          [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
+  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
+  --includedir=DIR        C header files in DIR [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
+  --infodir=DIR           info documentation in DIR [PREFIX/info]
+  --mandir=DIR            man documentation in DIR [PREFIX/man]
+  --srcdir=DIR            find the sources in DIR [configure dir or ..]
+  --program-prefix=PREFIX prepend PREFIX to installed program names
+  --program-suffix=SUFFIX append SUFFIX to installed program names
+  --program-transform-name=PROGRAM
+                          run sed PROGRAM on installed program names
+EOF
+    cat << EOF
+Host type:
+  --build=BUILD           configure for building on BUILD [BUILD=HOST]
+  --host=HOST             configure for HOST [guessed]
+  --target=TARGET         configure for TARGET [TARGET=HOST]
+Features and packages:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --x-includes=DIR        X include files are in DIR
+  --x-libraries=DIR       X library files are in DIR
+EOF
+    if test -n "$ac_help"; then
+      echo "--enable and --with options recognized:$ac_help"
+    fi
+    exit 0 ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host="$ac_optarg" ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir="$ac_optarg" ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir="$ac_optarg" ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir="$ac_optarg" ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir="$ac_optarg" ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst \
+  | --locals | --local | --loca | --loc | --lo)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+    localstatedir="$ac_optarg" ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir="$ac_optarg" ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir="$ac_optarg" ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix="$ac_optarg" ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix="$ac_optarg" ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix="$ac_optarg" ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name="$ac_optarg" ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir="$ac_optarg" ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir="$ac_optarg" ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site="$ac_optarg" ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir="$ac_optarg" ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir="$ac_optarg" ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target="$ac_optarg" ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers)
+    echo "configure generated by autoconf version 2.12"
+    exit 0 ;;
+
+  -with-* | --with-*)
+    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+    fi
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    case "$ac_option" in
+      *=*) ;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "with_${ac_package}='$ac_optarg'" ;;
+
+  -without-* | --without-*)
+    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+    fi
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    eval "with_${ac_package}=no" ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes="$ac_optarg" ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries="$ac_optarg" ;;
+
+  -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+    ;;
+
+  *)
+    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+      echo "configure: warning: $ac_option: invalid host type" 1>&2
+    fi
+    if test "x$nonopt" != xNONE; then
+      { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+    fi
+    nonopt="$ac_option"
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+  exec 6>/dev/null
+else
+  exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+  case "$ac_arg" in
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c) ;;
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+  *" "*|*"     "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+  ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+  *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+  esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set.  These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=cproto.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then its parent.
+  ac_prog=$0
+  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+  srcdir=$ac_confdir
+  if test ! -r $srcdir/$ac_unique_file; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+  if test "$ac_srcdir_defaulted" = yes; then
+    { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+  else
+    { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+  fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+  if test "x$prefix" != xNONE; then
+    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+  else
+    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+  fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+  if test -r "$ac_site_file"; then
+    echo "loading site script $ac_site_file"
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  echo "loading cache $cache_file"
+  . $cache_file
+else
+  echo "creating cache $cache_file"
+  > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+    ac_n= ac_c='
+' ac_t='       '
+  else
+    ac_n=-n ac_c= ac_t=
+  fi
+else
+  ac_n= ac_c='\c' ac_t=
+fi
+
+
+# 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:534: 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
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CC="gcc"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+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:563: 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
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  ac_prog_rejected=no
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+        ac_prog_rejected=yes
+       continue
+      fi
+      ac_cv_prog_CC="cc"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# -gt 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    set dummy "$ac_dir/$ac_word" "$@"
+    shift
+    ac_cv_prog_CC="$@"
+  fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+  echo "$ac_t""$CC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:611: 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.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext <<EOF
+#line 621 "configure"
+#include "confdefs.h"
+main(){return(0);}
+EOF
+if { (eval echo configure:625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; 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
+    ac_cv_prog_cc_cross=no
+  else
+    ac_cv_prog_cc_cross=yes
+  fi
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+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:645: 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:650: 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
+  cat > conftest.c <<EOF
+#ifdef __GNUC__
+  yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:659: \"$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
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+  GCC=yes
+  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:674: 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
+  echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+  ac_cv_prog_cc_g=yes
+else
+  ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+  if test "$ac_test_CFLAGS" = set; then
+    CFLAGS="$ac_save_CFLAGS"
+  elif test $ac_cv_prog_cc_g = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-O2"
+  fi
+else
+  GCC=
+  test "${CFLAGS+set}" = set || CFLAGS="-g"
+fi
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:702: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+    # This must be in double quotes, not single quotes, because CPP may get
+  # substituted into the Makefile and "${CC-cc}" will confuse make.
+  CPP="${CC-cc} -E"
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp.
+  cat > conftest.$ac_ext <<EOF
+#line 717 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:723: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP="${CC-cc} -E -traditional-cpp"
+  cat > conftest.$ac_ext <<EOF
+#line 734 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:740: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+  ac_cv_prog_CPP="$CPP"
+fi
+  CPP="$ac_cv_prog_CPP"
+else
+  ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+# 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:765: 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
+  if test -n "$LEX"; then
+  ac_cv_prog_LEX="$LEX" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_LEX="flex"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_prog_LEX" && ac_cv_prog_LEX="lex"
+fi
+fi
+LEX="$ac_cv_prog_LEX"
+if test -n "$LEX"; then
+  echo "$ac_t""$LEX" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$LEXLIB"
+then
+  case "$LEX" in
+  flex*) ac_lib=fl ;;
+  *) ac_lib=l ;;
+  esac
+  echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6
+echo "configure:798: 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
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-l$ac_lib  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 806 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char yywrap();
+
+int main() {
+yywrap()
+; return 0; }
+EOF
+if { (eval echo configure:817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  LEXLIB="-l$ac_lib"
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+fi
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:840: 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
+else
+  cat > conftestmake <<\EOF
+all:
+       @echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+  eval ac_cv_prog_make_${ac_make}_set=yes
+else
+  eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  SET_MAKE=
+else
+  echo "$ac_t""no" 1>&6
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+for ac_prog in 'bison -y' byacc
+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:871: 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
+  if test -n "$YACC"; then
+  ac_cv_prog_YACC="$YACC" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_YACC="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+YACC="$ac_cv_prog_YACC"
+if test -n "$YACC"; then
+  echo "$ac_t""$YACC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$YACC" && break
+done
+test -n "$YACC" || YACC="yacc"
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+  if test -f $ac_dir/install-sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install-sh -c"
+    break
+  elif test -f $ac_dir/install.sh; then
+    ac_aux_dir=$ac_dir
+    ac_install_sh="$ac_aux_dir/install.sh -c"
+    break
+  fi
+done
+if test -z "$ac_aux_dir"; then
+  { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# 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:930: 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
+else
+    IFS="${IFS=        }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+  for ac_dir in $PATH; do
+    # Account for people who put trailing slashes in PATH elements.
+    case "$ac_dir/" in
+    /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+    *)
+      # OSF1 and SCO ODT 3.0 have their own names for install.
+      for ac_prog in ginstall installbsd scoinst install; do
+        if test -f $ac_dir/$ac_prog; then
+         if test $ac_prog = install &&
+            grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           # OSF/1 installbsd also uses dspmsg, but is usable.
+           :
+         else
+           ac_cv_path_install="$ac_dir/$ac_prog -c"
+           break 2
+         fi
+       fi
+      done
+      ;;
+    esac
+  done
+  IFS="$ac_save_IFS"
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL="$ac_cv_path_install"
+  else
+    # As a last resort, use the slow shell script.  We don't cache a
+    # path for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the path is relative.
+    INSTALL="$ac_install_sh"
+  fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+if test $ac_cv_prog_gcc = yes; then
+    echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
+echo "configure:981: checking whether ${CC-cc} needs -traditional" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+    ac_pattern="Autoconf.*'x'"
+  cat > conftest.$ac_ext <<EOF
+#line 987 "configure"
+#include "confdefs.h"
+#include <sgtty.h>
+Autoconf TIOCGETP
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "$ac_pattern" >/dev/null 2>&1; then
+  rm -rf conftest*
+  ac_cv_prog_gcc_traditional=yes
+else
+  rm -rf conftest*
+  ac_cv_prog_gcc_traditional=no
+fi
+rm -f conftest*
+
+
+  if test $ac_cv_prog_gcc_traditional = no; then
+    cat > conftest.$ac_ext <<EOF
+#line 1005 "configure"
+#include "confdefs.h"
+#include <termio.h>
+Autoconf TCGETA
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "$ac_pattern" >/dev/null 2>&1; then
+  rm -rf conftest*
+  ac_cv_prog_gcc_traditional=yes
+fi
+rm -f conftest*
+
+  fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6
+  if test $ac_cv_prog_gcc_traditional = yes; then
+    CC="$CC -traditional"
+  fi
+fi
+
+
+for ac_prog in lint alint
+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:1032: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_LINT'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$LINT"; then
+  ac_cv_prog_LINT="$LINT" # Let the user override the test.
+else
+  IFS="${IFS=  }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_LINT="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+LINT="$ac_cv_prog_LINT"
+if test -n "$LINT"; then
+  echo "$ac_t""$LINT" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$LINT" && break
+done
+
+if test -n "$LINT" ; then
+       cat >> confdefs.h <<\EOF
+#define HAVE_PROG_LINT 1
+EOF
+
+fi
+
+###    use option -with-warnings to turn on all gcc warnings
+if test -n "$GCC"
+then
+# Check whether --with-warnings or --without-warnings was given.
+if test "${with_warnings+set}" = set; then
+  withval="$with_warnings"
+  CFLAGS="$CFLAGS -Wall -Wshadow -Wconversion -Wstrict-prototypes -Wmissing-prototypes"
+fi
+
+fi
+
+###    extra things that we'll substitute in the makefile
+
+
+echo $ac_n "checking for working const""... $ac_c" 1>&6
+echo "configure:1082: 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 <<EOF
+#line 1087 "configure"
+#include "confdefs.h"
+
+int main() {
+
+/* Ultrix mips cc rejects this.  */
+typedef int charset[2]; const charset x;
+/* SunOS 4.1.1 cc rejects this.  */
+char const *const *ccp;
+char **p;
+/* NEC SVR4.0.2 mips cc rejects this.  */
+struct point {int x, y;};
+static struct point const zero = {0,0};
+/* AIX XL C 1.02.0.0 rejects this.
+   It does not let you subtract one const X* pointer from another in an arm
+   of an if-expression whose if-part is not a constant expression */
+const char *g = "string";
+ccp = &g + (g ? g-g : 0);
+/* HPUX 7.0 cc rejects these. */
+++ccp;
+p = (char**) ccp;
+ccp = (char const *const *) p;
+{ /* SCO 3.2v4 cc rejects this.  */
+  char *t;
+  char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+  *t++ = 0;
+}
+{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+  int x[] = {25, 17};
+  const int *foo = &x[0];
+  ++foo;
+}
+{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+  typedef const int *iptr;
+  iptr p = 0;
+  ++p;
+}
+{ /* AIX XL C 1.02.0.0 rejects this saying
+     "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+  struct s { int j; const int *ap[3]; };
+  struct s *b; b->j = 5;
+}
+{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+  const int foo = 10;
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:1136: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_cv_c_const=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_c_const=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_c_const" 1>&6
+if test $ac_cv_c_const = no; then
+  cat >> confdefs.h <<\EOF
+#define const 
+EOF
+
+fi
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:1157: 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 <<EOF
+#line 1162 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1170: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  ac_cv_header_stdc=yes
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_header_stdc=no
+fi
+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
+#line 1187 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "memchr" >/dev/null 2>&1; then
+  :
+else
+  rm -rf conftest*
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+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
+#line 1205 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "free" >/dev/null 2>&1; then
+  :
+else
+  rm -rf conftest*
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+  :
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1226 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:1237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+  :
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+  cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+for ac_hdr in stdlib.h unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1264: 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
+#line 1269 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1274: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_hdr in getopt.h string.h memory.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1304: 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
+#line 1309 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1314: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+
+for ac_func in strstr tmpfile link unlink mktemp
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1344: 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 <<EOF
+#line 1349 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1372: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+
+###    special configuration tests
+echo $ac_n "checking for size_t in <sys/types.h> or <stdio.h>""... $ac_c" 1>&6
+echo "configure:1399: checking for size_t in <sys/types.h> or <stdio.h>" >&5
+if eval "test \"`echo '$''{'ac_cv_td_size_t'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1404 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#endif
+#include <stdio.h>
+int main() {
+size_t f = 0
+; return 0; }
+EOF
+if { (eval echo configure:1416: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  ac_cv_td_size_t=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_td_size_t=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_td_size_t" 1>&6
+if test $ac_cv_td_size_t = no; then
+       cat >> confdefs.h <<\EOF
+#define size_t unsigned
+EOF
+
+fi
+
+
+rm -f yacctest.y
+cat >yacctest.y <<EOF
+%{
+#define xstrdup(s) s
+#include "system.h"
+#include <stdio.h>
+#include <ctype.h>
+#include "yyerror.c"
+static void yaccError(s) char *s; { exit(0); }
+int yylex ARGS((void))
+{ return 1; }
+%}
+%%
+dummy
+       : /* empty */
+       | error '.'
+       ;
+%%
+EOF
+$CPP yacctest.y >yacctest.out 2>/dev/null
+if test ! -s yacctest.out
+then
+       cat >> confdefs.h <<\EOF
+#define CPP_DOES_ONLY_C_FILES 1
+EOF
+
+fi
+$YACC yacctest.y
+rm -f yacctest.*
+td_incl='#include "y.tab.c"'
+for COND in BISON_HAS_YYTNAME YACC_HAS_YYTOKS YACC_HAS_YYTOKS_2 YACC_HAS_YYNAME
+do
+echo $ac_n "checking for error-reporting with $COND""... $ac_c" 1>&6
+echo "configure:1470: checking for error-reporting with $COND" >&5
+if eval "test \"`echo '$''{'ac_cv_$COND'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1475 "configure"
+#include "confdefs.h"
+
+#define $COND 1
+#define YYDEBUG 1
+$td_incl
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval 'ac_cv_'$COND'=yes'
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval 'ac_cv_'$COND'=no'
+fi
+rm -f conftest*
+fi
+
+eval 'td_result=$ac_cv_'$COND
+echo "$ac_t""$td_result" 1>&6
+if test $td_result = yes; then
+       cat >> confdefs.h <<EOF
+#define $COND 1
+EOF
+
+       break
+fi
+done
+rm -f y.tab.c
+
+echo $ac_n "checking for conflicting prototype for popen""... $ac_c" 1>&6
+echo "configure:1510: checking for conflicting prototype for popen" >&5
+if eval "test \"`echo '$''{'ac_cv_td_popen'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1515 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+#include "system.h"
+extern int pclose ARGS((FILE *p));
+extern FILE *popen ARGS((const char *c, const char *m));
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1526: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  ac_cv_td_popen=no
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_td_popen=yes
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_td_popen" 1>&6
+if test $ac_cv_td_popen = yes; then
+       cat >> confdefs.h <<\EOF
+#define HAVE_POPEN_PROTOTYPE 1
+EOF
+
+fi
+
+
+###    debugging/testing
+# Check whether --with-trace or --without-trace was given.
+if test "${with_trace+set}" = set; then
+  withval="$with_trace"
+  
+       echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+echo "configure:1553: 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 <<EOF
+#line 1558 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+int main() {
+struct tm *tp;
+; return 0; }
+EOF
+if { (eval echo configure:1567: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_cv_header_time=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_header_time=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_header_time" 1>&6
+if test $ac_cv_header_time = yes; then
+  cat >> confdefs.h <<\EOF
+#define TIME_WITH_SYS_TIME 1
+EOF
+
+fi
+
+       for ac_func in gettimeofday
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1590: 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 <<EOF
+#line 1595 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+       cat >> confdefs.h <<\EOF
+#define DOALLOC 10000
+EOF
+
+       EXTRA_OBJS="$EXTRA_OBJS trace.o dump.o"
+fi
+
+# Check whether --with-dmalloc or --without-dmalloc was given.
+if test "${with_dmalloc+set}" = set; then
+  withval="$with_dmalloc"
+  
+       echo $ac_n "checking for dmalloc_debug in -ldmalloc""... $ac_c" 1>&6
+echo "configure:1654: checking for dmalloc_debug in -ldmalloc" >&5
+ac_lib_var=`echo dmalloc'_'dmalloc_debug | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ldmalloc  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1662 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char dmalloc_debug();
+
+int main() {
+dmalloc_debug()
+; return 0; }
+EOF
+if { (eval echo configure:1673: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo dmalloc | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+  LIBS="-ldmalloc $LIBS"
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+fi
+
+# Check whether --with-dbmalloc or --without-dbmalloc was given.
+if test "${with_dbmalloc+set}" = set; then
+  withval="$with_dbmalloc"
+  
+       echo $ac_n "checking for debug_malloc in -ldbmalloc""... $ac_c" 1>&6
+echo "configure:1707: checking for debug_malloc in -ldbmalloc" >&5
+ac_lib_var=`echo dbmalloc'_'debug_malloc | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ldbmalloc  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1715 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char debug_malloc();
+
+int main() {
+debug_malloc()
+; return 0; }
+EOF
+if { (eval echo configure:1726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_lib=HAVE_LIB`echo dbmalloc | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+  LIBS="-ldbmalloc $LIBS"
+
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+fi
+
+
+echo setting other definitions
+cat >> confdefs.h <<EOF
+#define CPP "$CPP"
+EOF
+
+
+###    output makefile and config.h
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs.  It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already.  You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+  case `(ac_space=' '; set) 2>&1` in
+  *ac_space=\ *)
+    # `set' does not quote correctly, so add quotes (double-quote substitution
+    # turns \\\\ into \\, and sed turns \\ into \).
+    sed -n \
+      -e "s/'/'\\\\''/g" \
+      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+    ;;
+  *)
+    # `set' quotes correctly as required by POSIX, so do not add quotes.
+    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+    ;;
+  esac >> confcache
+if cmp -s $cache_file confcache; then
+  :
+else
+  if test -w $cache_file; then
+    echo "updating cache $cache_file"
+    cat confcache > $cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[        ]*VPATH[        ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+cat > conftest.defs <<\EOF
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
+s%[    `~#$^&*(){}\\|;'"<>?]%\\&%g
+s%\[%\\&%g
+s%\]%\\&%g
+s%\$%$$%g
+EOF
+DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
+rm -f conftest.defs
+
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+  case "\$ac_option" in
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+    exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+  -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+    echo "$CONFIG_STATUS generated by autoconf version 2.12"
+    exit 0 ;;
+  -help | --help | --hel | --he | --h)
+    echo "\$ac_cs_usage"; exit 0 ;;
+  *) echo "\$ac_cs_usage"; exit 1 ;;
+  esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile config_h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@CC@%$CC%g
+s%@CPP@%$CPP%g
+s%@LEX@%$LEX%g
+s%@LEXLIB@%$LEXLIB%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@YACC@%$YACC%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@LINT@%$LINT%g
+s%@EXTRA_OBJS@%$EXTRA_OBJS%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+  if test $ac_beg -gt 1; then
+    sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+  else
+    sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+  fi
+  if test ! -s conftest.s$ac_file; then
+    ac_more_lines=false
+    rm -f conftest.s$ac_file
+  else
+    if test -z "$ac_sed_cmds"; then
+      ac_sed_cmds="sed -f conftest.s$ac_file"
+    else
+      ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+    fi
+    ac_file=`expr $ac_file + 1`
+    ac_beg=$ac_end
+    ac_end=`expr $ac_end + $ac_max_sed_cmds`
+  fi
+done
+if test -z "$ac_sed_cmds"; then
+  ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile config_h"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case "$ac_file" in
+  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+  *) ac_file_in="${ac_file}.in" ;;
+  esac
+
+  # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+  # Remove last slash and all that follows it.  Not all systems have dirname.
+  ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+    # The file is in a subdirectory.
+    test ! -d "$ac_dir" && mkdir "$ac_dir"
+    ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+    # A "../" for each directory in $ac_dir_suffix.
+    ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+  else
+    ac_dir_suffix= ac_dots=
+  fi
+
+  case "$ac_given_srcdir" in
+  .)  srcdir=.
+      if test -z "$ac_dots"; then top_srcdir=.
+      else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+  /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+  *) # Relative path.
+    srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+    top_srcdir="$ac_dots$ac_given_srcdir" ;;
+  esac
+
+  case "$ac_given_INSTALL" in
+  [/$]*) INSTALL="$ac_given_INSTALL" ;;
+  *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+  esac
+
+  echo creating "$ac_file"
+  rm -f "$ac_file"
+  configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+  case "$ac_file" in
+  *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+  *) ac_comsub= ;;
+  esac
+
+  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+  sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+
+echo creating config.h
+sed    -e '/^# /d' \
+       -e 's/ -D/\
+#define /g' \
+       -e 's/\(#define [A-Za-z_][A-Za-z0-9_]*\)=/\1    /g' \
+       -e 's/\\//g' \
+       config_h >config.h
+
+echo removing config_h
+rm config_h
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
+touch stamp-h
diff --git a/cproto-4.6/configure.in b/cproto-4.6/configure.in
new file mode 100644 (file)
index 0000000..95bc634
--- /dev/null
@@ -0,0 +1,75 @@
+dnl Process this file with 'autoconf' to produce a 'configure' script
+dnl $Id: configure.in,v 4.6 1998/01/24 01:42:05 cthuang Exp $
+AC_REVISION($Revision: 4.6 $)
+AC_INIT(cproto.c)
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_LEX
+AC_PROG_MAKE_SET
+AC_PROG_YACC
+AC_PROG_INSTALL
+AC_GCC_TRADITIONAL
+
+AC_CHECK_PROGS(LINT, [lint alint])
+if test -n "$LINT" ; then
+       AC_DEFINE(HAVE_PROG_LINT)
+fi
+
+###    use option -with-warnings to turn on all gcc warnings
+if test -n "$GCC"
+then
+AC_ARG_WITH(warnings,
+[  --with-warnings         use gcc warnings (used for developing this tool)],
+[CFLAGS="$CFLAGS -Wall -Wshadow -Wconversion -Wstrict-prototypes -Wmissing-prototypes"])
+fi
+
+###    extra things that we'll substitute in the makefile
+dnl AC_SUBST(LIBS)
+AC_SUBST(EXTRA_OBJS)
+
+AC_CONST
+AC_STDC_HEADERS
+AC_HAVE_HEADERS(stdlib.h unistd.h)
+AC_HAVE_HEADERS(getopt.h string.h memory.h)
+
+AC_HAVE_FUNCS(strstr tmpfile link unlink mktemp)
+
+###    special configuration tests
+TD_SIZE_T
+TD_YACC_ERROR
+TD_POPEN_TEST
+
+###    debugging/testing
+AC_ARG_WITH(trace,
+[  --with-trace            use trace.c for memory-testing],[
+       AC_HEADER_TIME
+       AC_HAVE_FUNCS(gettimeofday)
+       AC_DEFINE(DOALLOC,10000)
+       EXTRA_OBJS="$EXTRA_OBJS trace.o dump.o"])
+AC_ARG_WITH(dmalloc,
+[  --with-dmalloc          use Gray Watson's dmalloc],[
+       AC_CHECK_LIB(dmalloc,dmalloc_debug)])
+AC_ARG_WITH(dbmalloc,
+[  --with-dbmalloc         use Conor Cahill's dbmalloc],[
+       AC_CHECK_LIB(dbmalloc,debug_malloc)])
+
+echo setting other definitions
+AC_DEFINE_UNQUOTED(CPP,"$CPP")
+
+###    output makefile and config.h
+changequote({,})dnl
+AC_OUTPUT(Makefile config_h,
+{
+echo creating config.h
+sed    -e '/^# /d' \
+       -e 's/ -D/\
+#define /g' \
+       -e 's/\(#define [A-Za-z_][A-Za-z0-9_]*\)=/\1    /g' \
+       -e 's/\\//g' \
+       config_h >config.h
+}
+echo removing config_h
+rm config_h
+)
+changequote([,])dnl
+touch stamp-h
diff --git a/cproto-4.6/cproto.1 b/cproto-4.6/cproto.1
new file mode 100644 (file)
index 0000000..5dff7bd
--- /dev/null
@@ -0,0 +1,365 @@
+.\" $Id: cproto.1,v 4.6 1998/01/20 00:19:07 cthuang Exp $
+.\"
+.de EX         \"Begin example
+.ne 5
+.if n .sp 1
+.if t .sp .5
+.nf
+.in +5n
+..
+.de EE         \"End example
+.fi
+.in -5n
+.if n .sp 1
+.if t .sp .5
+..
+.TH CPROTO 1 "January 1998"
+.
+.SH NAME
+cproto \- generate C function prototypes and convert function definitions
+.
+.SH SYNOPSIS
+.B cproto
+[ 
+.I option \fP...\fI
+] [
+.I file \fP...\fI
+]
+.
+.SH DESCRIPTION
+.B Cproto
+generates function prototypes for
+functions defined in the specified C source files to the standard output.
+The function definitions may be in the old style or ANSI C style.
+Optionally,
+.B cproto
+also outputs declarations for variables defined in the files.
+If no
+.I file
+argument is given,
+.B cproto
+reads its input from the standard input.
+.LP
+By giving a command line option,
+.B cproto
+will also convert function definitions in the specified files from the
+old style to the ANSI C style.
+The original source files along with files specified by
+.EX
+#include "file"
+.EE
+directives appearing in the source code will be overwritten
+with the converted code.
+If no file names are given on the command line, then the program reads
+the source code from the standard input and outputs the converted source
+to the standard output.
+.LP
+If any comments appear in the parameter declarations for a function definition,
+such as in the example,
+.EX
+main (argc, argv)
+int argc;       /* number of arguments */
+char *argv[];   /* arguments */
+{
+}
+.EE
+then the converted function definition will have the form
+.EX
+int
+main (
+    int argc,       /* number of arguments */
+    char *argv[]   /* arguments */
+)
+{
+}
+.EE
+Otherwise, the converted function definition will look like
+.EX
+int
+main (int argc, char *argv[])
+{
+}
+.EE
+.LP
+.B Cproto
+can optionally convert function definitions from the ANSI style to the old
+style.
+In this mode, the program also converts function declarators and prototypes
+that appear outside function bodies.
+This is not a complete ANSI C to old C conversion.
+The program does not change anything within function bodies.
+.LP
+.B Cproto
+can optionally generate source in lint-library format.
+This is useful in environments where the \fBlint\fR utility is
+used to supplement prototype checking of your program.
+.
+.SH OPTIONS
+.TP
+.B \-e
+Output the keyword
+.B extern
+in front of every generated prototype or declaration that has global scope.
+.TP
+.BI \-f " n"
+Set the style of generated function prototypes where
+.I n
+is a number from 0 to 3.
+For example, consider the function definition
+.EX
+main (argc, argv)
+int argc;
+char *argv[];
+{
+}
+.EE
+If the value is 0, then no prototypes are generated.
+When set to 1, the output is:
+.EX
+int main(/*int argc, char *argv[]*/);
+.EE
+For a value of 2, the output has the form:
+.EX
+int main(int /*argc*/, char */*argv*/[]);
+.EE
+The default value is 3.
+It produces the full function prototype:
+.EX
+int main(int argc, char *argv[]);
+.EE
+.TP
+.B \-l
+Generate text for a lint-library (overrides the "\fB\-f\fR" option).
+The output includes the comment
+.EX
+/* LINTLIBRARY */
+.EE
+Special comments LINT_EXTERN and LINT_PREPRO (a la "VARARGS")
+respectively turn on the "-x"
+option and copy comment-text to the output (for preprocessing in \fBlint\fR).
+Use the comment
+.EX
+/* LINT_EXTERN2 */
+.EE
+to include externs defined in the first level of include-files.
+Use the comment
+.EX
+/* LINT_SHADOWED */
+.EE
+to cause 
+.B cproto
+to put "#undef" directives before each lint library declaration
+(i.e., to avoid conflicts with macros that happen to have to have
+the same name as the functions, thus causing syntax errors).
+.P
+Note that these special comments
+are not supported under VAX/VMS, since there is no
+equivalent for the "-C" option of cpp with VAX-C.
+.TP
+.B \-c
+The parameter comments in the prototypes generated by
+the \-f1 and \-f2 options are omitted by default.
+Use this option to enable the output of these comments.
+.TP
+.B \-m
+Put a macro around the parameter list of every generated prototype.
+For example:
+.EX
+int main P_((int argc, char *argv[]));
+.EE
+.TP
+.BI \-M " name"
+Set the name of the macro used to surround prototype parameter lists
+when option \-m is selected.
+The default is "P_".
+.TP
+.B \-d
+Omit the definition of the prototype macro used by the \-m option.
+.TP
+.BI \-o " file"
+Specify the name of the output file (default: standard output).
+.TP
+.BI \-O " file"
+Specify the name of the error file (default: standard error).
+.TP
+.B \-p
+Disable promotion of formal parameters in old style function definitions.
+By default, parameters of type
+.B char
+or
+.B short
+in old style function definitions are promoted to type
+.B int
+in the function prototype or converted ANSI C function definition.
+Parameters of type
+.B float
+get promoted to 
+.B double
+as well.
+.TP
+.B \-q
+Do not output any error messages when the program cannot read the
+file specified in an
+.I #include
+directive.
+.TP
+.B \-s
+By default,
+.B cproto
+only generates declarations for functions and variables having global scope.
+This option will output
+.B static
+declarations as well.
+.TP
+.B \-S
+Output only static declarations.
+.TP
+.B \-T
+Copy type definitions from each file.
+(Definitions in included-files are copied, unlike the "-l" option).
+.TP
+.B \-v
+Also output declarations for variables defined in the source.
+.TP
+.B \-x
+This option causes procedures and variables which are declared "extern"
+to be included in the output.
+.TP
+.B \-a
+Convert function definitions from the old style to the ANSI C style.
+.TP
+.B \-t
+Convert function definitions from the ANSI C style to the traditional style.
+.TP
+.B \-b
+Rewrite function definition heads to include both old style and new style
+declarations separated by a conditional compilation directive.
+For example, the program can generate this function definition:
+.EX
+#ifdef ANSI_FUNC
+
+int
+main (int argc, char *argv[])
+#else
+
+int
+main (argc, argv)
+int argc;
+char *argv[]
+#endif
+{
+}
+.EE
+.TP
+.BI \-B " directive"
+Set the conditional compilation directive to output at the beginning of
+function definitions generated by the \-b option.
+The default is
+.EX
+#ifdef ANSI_FUNC
+.EE 
+.LP
+.nf
+.BI \-P " template"
+.BI \-F " template"
+.BI \-C " template"
+.fi
+.in +5n
+Set the output format for generated prototypes, function definitions,
+and function definitions with parameter comments respectively.
+The format is specified by a template in the form
+.EX
+" int f ( a, b )"
+.EE
+but you may replace each space in this string with any number of
+whitespace characters.
+For example, the option
+.EX
+-F"int f(\\n\\ta,\\n\\tb\\n\\t)"
+.EE
+will produce
+.EX
+int main(
+        int argc,
+        char *argv[]
+        )
+.EE
+.TP
+.BI \-D " name[=value]"
+This option is passed through to the preprocessor and is used to define 
+symbols for use with conditionals such as
+.I #ifdef.
+.TP
+.BI \-U " name"
+This option is passed through to the preprocessor and is used to remove
+any definitions of this symbol.
+.TP
+.BI \-I " directory"
+This option is passed through to the preprocessor and is used to specify
+a directory to search for files that are referenced with 
+.I #include.
+.TP
+.BI \-E " cpp"
+Pipe the input files through the specified C preprocessor command
+when generating prototypes.
+By default, the program uses /lib/cpp.
+.TP
+.BI \-E " 0"
+Do not run the C preprocessor.
+.TP
+.B \-V
+Print version information.
+.
+.SH ENVIRONMENT
+The environment variable CPROTO is scanned for
+a list of options in the same format as the command line options.
+Options given on the command line override any corresponding
+environment option.
+.
+.SH BUGS
+If an un-tagged struct, union or enum declaration appears in
+a generated function prototype or converted function definition,
+the content of the declaration between the braces is empty.
+.LP
+The program does not pipe the source files through the C preprocessor when
+it is converting function definitions.
+Instead, it tries to handle preprocessor directives and macros itself
+and can be confused by tricky macro expansions.
+The conversion also discards some comments in the function definition
+head.
+.LP
+The \-v option does not generate declarations for variables defined with the
+.B extern
+specifier.
+This doesn't strictly conform to the C language standard but this rule
+was implemented because include files commonly declare variables this way.
+.LP
+When the program encounters an error, it usually outputs the not very
+descriptive message "syntax error".
+(Your configuration may allow the extended error reporting in yyerror.c).
+.LP
+Options that take string arguments only interpret the following
+character escape sequences:
+.EX
+\\n    newline
+\\s    space
+\\t    tab
+.EE
+.LP
+VARARGS comments don't get passed through on systems whose C preprocessors
+don't support this (e.g., VAX/VMS, MS-DOS).
+.
+.SH AUTHOR
+.nf
+Chin Huang
+cthuang@vex.net
+cthuang@interlog.com
+.sp
+Thomas Dickey
+dickey@clark.net
+modifications to support lint library, type-copying, and port to VAX/VMS.
+.fi
+.
+.SH "SEE ALSO"
+cc(1),
+cpp(1)
diff --git a/cproto-4.6/cproto.c b/cproto-4.6/cproto.c
new file mode 100644 (file)
index 0000000..b6a5808
--- /dev/null
@@ -0,0 +1,885 @@
+/* $Id: cproto.c,v 4.8 1998/01/24 01:42:07 cthuang Exp $
+ *
+ * C function prototype generator and function definition converter
+ */
+#define VERSION "4.6"
+
+#include <stdio.h>
+#include <ctype.h>
+#include "cproto.h"
+
+/* getopt declarations */
+#if HAVE_GETOPT_H
+#include <getopt.h>
+#else
+extern int getopt ARGS((int argc, char *const *argv, const char *shortopts));
+extern char *optarg;
+extern int optind;
+#endif
+
+/* Name of the program (from argv[0]) */
+char *progname;
+
+/* Program options */
+
+/* If nonzero, output variables declared "extern" in include-files */
+int extern_in = 0;
+
+/* When TRUE, suppress return-statements in function-bodies */
+int exitlike_func = FALSE;
+
+/* If TRUE, output "extern" before global declarations */
+boolean extern_out = FALSE;
+
+/* By default, generate global declarations only */
+Scope scope_out = SCOPE_EXTERN;
+
+/* If TRUE, export typedef declarations (needed for lint-libs) */
+#if OPT_LINTLIBRARY
+boolean types_out = FALSE;
+#endif
+
+/* If TRUE, undef functions to avoid shadowing problems */
+#if OPT_LINTLIBRARY
+boolean lint_shadowed = FALSE;
+#endif
+
+/* If TRUE, generate variable declarations */
+boolean variables_out = FALSE;
+
+/* If TRUE, enable formal parameter promotion */
+boolean promote_param = TRUE;
+
+/* Style of function prototype to generate */
+PrototypeStyle proto_style = PROTO_ANSI;
+
+/* Function definition style converted to */
+FuncDefStyle func_style = FUNC_UNKNOWN;
+
+/* If TRUE, put guard macro around prototype parameters */
+boolean proto_macro = FALSE;
+
+/* Name of macro to guard prototypes */
+char *macro_name = "P_";
+
+/* If TRUE, output prototype macro definition */
+boolean define_macro = TRUE;
+
+/* If TRUE, output comments in prototypes */
+boolean proto_comments = FALSE;
+
+/* If TRUE, output comments naming source files */
+boolean file_comments = TRUE;
+
+/* Conditional compilation directive output in front of function definitions */
+char *func_directive = "#ifdef ANSI_FUNC";
+
+/* Output formats for function declarators */
+FuncFormat fmt[] = {
+    /* miscellaneous function declarator */
+    { "", " ", "", "", " ", "" },
+    /* prototype */
+    { "", " ", "", "", " ", "" },
+    /* function definition */
+    { "", "\n", " ", "", " ", "" },
+    /* function definition with parameter comments */
+    { "", "\n", " ", "\n    ", "\n    ", "\n" },
+};
+
+/* If TRUE, don't output message if unable to read an include file */
+boolean quiet = FALSE;
+
+/* Include file directories */
+#ifdef MSDOS
+# ifdef __TURBOC__
+int num_inc_dir = 2;
+char *inc_dir[MAX_INC_DIR] = { "" , "/tc/include" };
+# else
+int num_inc_dir = 1;
+char *inc_dir[MAX_INC_DIR] = { "" };
+# endif
+#else
+# ifdef vms
+int num_inc_dir = 2;
+char *inc_dir[MAX_INC_DIR] = { "[]", "sys$library:" };
+# else
+int num_inc_dir = 2;
+char *inc_dir[MAX_INC_DIR] = { "", "/usr/include" };
+# endif
+#endif
+
+/* Run the C preprocessor */
+#ifdef CPP
+# if !HAVE_POPEN_PROTOTYPE
+extern FILE *popen ARGS((const char *c, const char *m));
+# endif
+extern int pclose ARGS((FILE *p));
+static char *cpp = CPP, *cpp_opt, *cpp_cmd;
+#endif
+
+static char *  escape_string   ARGS((char *src));
+static void    usage           ARGS((void));
+static void    process_options ARGS((int *pargc, char ***pargv));
+static void    parse_options   ARGS((char *src, int maxargc, int *pargc, char **argv));
+
+/* Try to allocate some memory.
+ * If unsuccessful, output an error message and exit.
+ */
+#if !HAVE_LIBDMALLOC
+#ifdef NO_LEAKS
+char *xMalloc(n,f,l) unsigned n; char *f; int l;
+#else
+char *xmalloc (n) unsigned n;
+#endif
+{
+    char *p;
+#if HAVE_LIBDBMALLOC
+    p = debug_malloc(f, l, n);
+#else
+    p = malloc(n);
+#endif
+
+    if (p == NULL) {
+       fprintf(stderr, "%s: out of memory (cannot allocate %d bytes)\n",
+               progname, n);
+       exit(EXIT_FAILURE);
+    }
+    *p = '\0';
+    return p;
+}
+#endif /* if !HAVE_LIBDMALLOC */
+
+/* Copy the string into allocated memory.
+ * If unsuccessful, output an error message and exit.
+ */
+#if !HAVE_LIBDMALLOC
+#ifdef NO_LEAKS
+char *xStrdup(src, f, l) char *src; char *f; int l;
+#else
+char *xstrdup (src) char *src;
+#endif
+{
+#if defined(NO_LEAKS)
+    return strcpy(xMalloc(strlen(src)+1, f, l), src);
+#else
+    return strcpy(xmalloc(strlen(src)+1), src);
+#endif
+}
+#endif /* if !HAVE_LIBDMALLOC */
+
+/* Output the current source file name and line number.
+ */
+void
+put_error ()
+{
+    fprintf(stderr, "\"%s\", line %u: ", cur_file_name(), cur_line_num());
+}
+
+/* Scan for options from a string.
+ */
+static void
+parse_options (src, maxargc, pargc, argv)
+char *src;
+int maxargc, *pargc;
+char **argv;
+{
+    char *g, *p, c;
+    int argc;
+
+    argc = 0;
+    g = xstrdup(src);
+    c = *g;
+    while (c != '\0' && argc < maxargc) {
+       while (c == ' ' || c == '\t')
+           c = *++g;
+       if (c == '\0')
+           break;
+       argv[argc++] = g;
+
+       p = g;
+       while (1) {
+           if (c == ' ' || c == '\t' || c == '\0') {
+               *p = '\0';
+               break;
+           } else if (c == '"') {
+               while (1) {
+                   c = *++g;
+                   if (c == '"') {
+                       c = *++g;
+                       break;
+                   } else if (c == '\0') {
+                       break;
+                   } else {
+                       *p++ = c;
+                   }
+               }
+           } else {
+               *p++ = c;
+               c = *++g;
+           }
+       }
+       if (c != '\0')
+           c = *++g;
+    }
+
+    *pargc = argc;
+}
+
+/* Replace any character escape sequences in a string with the actual
+ * characters. Return a pointer to malloc'ed memory containing the result.
+ * This function knows only a few escape sequences.
+ */
+static char *
+escape_string (src)
+char *src;
+{
+    char *result, *get, *put;
+
+    result = xstrdup(src);
+    put = result;
+    get = src;
+    while (*get != '\0') {
+       if (*get == '\\') {
+           switch (*(++get)) {
+           case 'n':
+               *put++ = '\n';
+               ++get;
+               break;
+           case 's':
+               *put++ = ' ';
+               ++get;
+               break;
+           case 't':
+               *put++ = '\t';
+               ++get;
+               break;
+           default:
+               if (*get != '\0')
+                   *put++ = *get++;
+           }
+       } else {
+           *put++ = *get++;
+       }
+    }
+    *put = *get;
+    return result;
+}
+
+/* Returns true iff the character is a path leaf separator
+ */
+int
+is_path_sep (ch)
+int ch;
+{
+#if defined(MSDOS) || defined(OS2)
+    return ch == '/' || ch == '\\';
+#else
+    return ch == '/';
+#endif
+}
+
+/* Trim any path name separator from the end of the string.
+ * Return a pointer to the string.
+ */
+char *
+trim_path_sep (s)
+char *s;
+{
+    int n;
+
+    n = strlen(s);
+    if (n > 0) {
+       if (is_path_sep(s[n-1]))
+           s[n-1] = '\0';
+    }
+    return s;
+}
+
+/* Output usage message and exit.
+ */
+static void
+usage ()
+{
+    fprintf(stderr, "usage: %s [ option ... ] [ file ... ]\n", progname);
+    fputs("Options:\n", stderr);
+    fputs("  -a, -t           Convert function definitions to ANSI or traditional style\n", stderr);
+    fputs("  -b               Rewrite function definitions in both styles\n", stderr);
+    fputs("  -c               Enable comments in prototype parameters\n", stderr);
+    fputs("  -e               Output \"extern\" keyword before global declarations\n", stderr);
+    fputs("  -f n             Set function prototype style (0 to 3)\n", stderr);
+#if OPT_LINTLIBRARY
+    fputs("  -l               Generate output in lint-library style\n", stderr);
+#endif
+    fputs("  -o file          Redirect output to file\n", stderr);
+    fputs("  -O file          Redirect errors to file\n", stderr);
+    fputs("  -p               Disable formal parameter promotion\n", stderr);
+    fputs("  -q               Disable include file read failure messages\n", stderr);
+    fputs("  -s               Output static declarations also\n", stderr);
+    fputs("  -S               Output static declarations only\n", stderr);
+#if OPT_LINTLIBRARY
+    fputs("  -T               Output type definitions\n", stderr);
+#endif
+    fputs("  -v               Output variable declarations\n", stderr);
+    fputs("  -x               Output variables and functions declared \"extern\"\n", stderr);
+    fputs("  -m               Put macro around prototype parameters\n", stderr);
+    fputs("  -M name          Set name of prototype macro\n", stderr);
+    fputs("  -d               Omit prototype macro definition\n", stderr);
+    fputs("  -P template      Set prototype format template \" int f (a, b)\"\n", stderr);
+    fputs("  -F template      Set function definition format template \" int f (a, b)\"\n", stderr);
+    fputs("  -C template      Set format for function definition with parameter comments\n", stderr);
+    fputs("  -D name[=value]  Define C preprocessor symbol\n", stderr);
+    fputs("  -U name          Undefine C preprocessor symbol\n", stderr);
+    fputs("  -I directory     Add #include search directory\n", stderr);
+    fputs("  -E command       Run specified C preprocessor command\n", stderr);
+    fputs("  -E 0             Do not run any C preprocessor\n", stderr);
+    fputs("  -V               Print version information\n", stderr);
+    exit(EXIT_FAILURE);
+}
+
+#ifdef vms
+static char    *cpp_defines;
+static char    *cpp_include;
+static char    *cpp_undefns;
+
+static void    add2list ARGS((char *dst, char *src));
+static void    add_option ARGS((char *keyword, char *src));
+
+static void
+add2list(dst, src)
+char *dst;
+char *src;
+{
+    if (*dst)
+       strcat(dst, ",");
+    strcat(dst, src);
+}
+
+static void
+add_option(keyword, src)
+char *keyword;
+char *src;
+{
+    if (*src)
+       sprintf(cpp_opt + strlen(cpp_opt), " /%s=(%s)", keyword, src);
+}
+#endif /* vms */
+
+#ifdef QUOTE_POPEN_ARGS
+
+/* Calculate length of string including shell quoting characters that
+ * must be inserted to preserve the string when it is passed to /bin/sh.
+ * On UNIX systems, popen() runs /bin/sh.
+ */
+#define QUOTECHARS "\"\'\t\n "
+
+static int
+quote_length (s)
+char *s;
+{
+    int len = strlen(s);
+
+    if (strpbrk(s, QUOTECHARS))  {
+       len += 2;
+       while (*s)
+           if (*s++ == '\'')
+               len += 4; /* replace ' with '"'"' (ick!) */
+    }
+    return len;
+}
+
+/* Insert quoting characters to preserve the string when it is passed to
+ * /bin/sh.
+ */
+static char *
+quote_string (s) 
+char *s;
+{
+    if (strpbrk(s, QUOTECHARS))  {
+       char *src = s;
+       char *dup, *dup_orig;
+       
+       dup = dup_orig = xstrdup(s);
+
+       while (isspace(*src))
+           *src++ = *dup++;
+
+       *src++ = '\'';
+       while (*dup) {
+           if (*dup == '\'') {
+               *src++ = '\'';
+               *src++ = '"';
+               *src++ = '\'';
+               *src++ = '"';
+               *src++ = '\'';
+               dup++;
+           } else {
+               *src++ = *dup++;
+           }
+       }
+
+       *src++ = '\'';
+       *src = '\0';
+       free(dup_orig);
+    }
+
+    return s;
+}
+#else
+#define        quote_length(s) strlen(s)
+#define quote_string(s)        (s)
+#endif /*QUOTE_POPEN_ARGS*/
+
+#define MAX_OPTIONS 40
+
+/* Process the command line options.
+ */
+static void
+process_options (pargc, pargv)
+int *pargc;
+char ***pargv;
+{
+    int argc, eargc, nargc;
+    char **argv, *eargv[MAX_OPTIONS], **nargv;
+    int i, c;
+    char *s;
+#if defined(CPP)
+    unsigned n;
+#endif
+#if defined(CPP) && !defined(vms)
+    char tmp[MAX_TEXT_SIZE];
+#endif
+
+    argc = *pargc;
+    argv = *pargv;
+#ifndef vms    /* this conflicts with use of foreign commands... */
+    if ((s = getenv("CPROTO")) != NULL) {
+       parse_options(s, MAX_OPTIONS, &eargc, eargv);
+       nargv = (char **)xmalloc((eargc+argc+1)*sizeof(char *));
+       nargv[0] = argv[0];
+       nargc = 1;
+       for (i = 0; i < eargc; ++i)
+           nargv[nargc++] = eargv[i];
+       for (i = 1; i < argc; ++i)
+           nargv[nargc++] = argv[i];
+       nargv[nargc] = NULL;
+       argc = nargc;
+       argv = nargv;
+    }
+#endif
+
+#ifdef CPP
+    /* Allocate buffer for C preprocessor command line. */
+    n = strlen(cpp) + 1;
+    for (i = 0; i < argc; ++i) {
+       n += quote_length(argv[i]) + 1;  /* add more for possible quoting */
+    }
+#ifdef vms
+    *(cpp_include = xmalloc(n+argc)) = '\0';
+    *(cpp_defines = xmalloc(n+argc)) = '\0';
+    *(cpp_undefns = xmalloc(n+argc)) = '\0';
+    n += 30;   /* for keywords */
+#endif
+    *(cpp_opt = xmalloc(n)) = '\0';
+    n += (2 + strlen(CPP) + BUFSIZ);
+    *(cpp_cmd = xmalloc(n)) = '\0';
+#endif
+
+    while ((c = getopt(argc, argv, "aB:bC:cD:dE:eF:f:I:mM:P:pqSstU:Vvo:O:Tlx")) != EOF) {
+       switch (c) {
+       case 'I':
+#ifdef vms
+           add2list(cpp_include, optarg);
+           break;
+#else  /* unix */
+           if (num_inc_dir < MAX_INC_DIR) {
+               char *save = inc_dir[--num_inc_dir];
+               inc_dir[num_inc_dir++] = trim_path_sep(xstrdup(optarg));
+               inc_dir[num_inc_dir++] = save;
+           } else {
+               fprintf(stderr, "%s: too many include directories\n",
+                   progname);
+           }
+#endif
+               /*FALLTHRU*/
+       case 'D':
+#ifdef vms
+           add2list(cpp_defines, optarg);
+           break;
+#endif
+               /*FALLTHRU*/
+       case 'U':
+#ifdef vms
+           add2list(cpp_undefns, optarg);
+           break;
+#else  /* UNIX, etc. */
+#ifdef CPP
+           sprintf(tmp, " -%c%s", c, optarg);
+           strcat(cpp_opt, quote_string(tmp));
+#endif
+#endif
+           break;
+
+       case 'a':
+           func_style = FUNC_ANSI;
+           break;
+       case 'B':
+           func_directive = optarg;
+           break;
+       case 'b':
+           func_style = FUNC_BOTH;
+           break;
+       case 'c':
+           proto_comments = TRUE;
+           break;
+       case 'd':
+           define_macro = FALSE;
+           break;
+       case 'E':
+#ifdef CPP
+           if (strcmp(optarg, "0") == 0) {
+               cpp = NULL;
+           } else {
+               cpp = optarg;
+           }
+#endif
+           break;
+       case 'e':
+           extern_out = TRUE;
+           break;
+       case 'C':
+       case 'F':
+       case 'P':
+           s = escape_string(optarg);
+           i = (c == 'C') ? FMT_FUNC_COMMENT :
+               ((c == 'F') ? FMT_FUNC : FMT_PROTO);
+
+           fmt[i].decl_spec_prefix = s;
+           while (*s != '\0' && isascii(*s) && !isalnum(*s)) ++s;
+           if (*s == '\0') usage();
+           *s++ = '\0';
+           while (*s != '\0' && isascii(*s) && isalnum(*s)) ++s;
+           if (*s == '\0') usage();
+
+           fmt[i].declarator_prefix = s;
+           while (*s != '\0' && isascii(*s) && !isalnum(*s)) ++s;
+           if (*s == '\0') usage();
+           *s++ = '\0';
+           while (*s != '\0' && isascii(*s) && isalnum(*s)) ++s;
+           if (*s == '\0') usage();
+
+           fmt[i].declarator_suffix = s;
+           while (*s != '\0' && *s != '(') ++s;
+           if (*s == '\0') usage();
+           *s++ = '\0';
+
+           fmt[i].first_param_prefix = s;
+           while (*s != '\0' && isascii(*s) && !isalnum(*s)) ++s;
+           if (*s == '\0') usage();
+           *s++ = '\0';
+           while (*s != '\0' && *s != ',') ++s;
+           if (*s == '\0') usage();
+
+           fmt[i].middle_param_prefix = ++s;
+           while (*s != '\0' && isascii(*s) && !isalnum(*s)) ++s;
+           if (*s == '\0') usage();
+           *s++ = '\0';
+           while (*s != '\0' && isascii(*s) && isalnum(*s)) ++s;
+           if (*s == '\0') usage();
+
+           fmt[i].last_param_suffix = s;
+           while (*s != '\0' && *s != ')') ++s;
+           *s = '\0';
+
+           break;
+       case 'f':
+           proto_style = atoi(optarg);
+           if (proto_style < 0 || proto_style > PROTO_ANSI)
+               usage();
+           break;
+       case 'm':
+           proto_macro = TRUE;
+           break;
+       case 'M':
+           macro_name = optarg;
+           break;
+       case 'p':
+           promote_param = FALSE;
+           break;
+       case 'q':
+           quiet = TRUE;
+           break;
+       case 'S':
+           scope_out = SCOPE_STATIC;
+           break;
+       case 's':
+           scope_out = SCOPE_ALL;
+           break;
+       case 't':
+           func_style = FUNC_TRADITIONAL;
+           break;
+       case 'V':
+           fprintf(stderr, "%s\n", VERSION);
+           exit(EXIT_FAILURE);
+           break;
+       case 'v':
+           variables_out = TRUE;
+           break;
+       case 'o':
+           if (freopen(optarg, "w", stdout) == 0) {
+               perror(optarg);
+               exit(EXIT_FAILURE);
+           }
+           break;
+       case 'O':
+           if (freopen(optarg, "w", stderr) == 0) {
+               perror(optarg);
+               exit(EXIT_FAILURE);
+           }
+           break;
+#if OPT_LINTLIBRARY
+       case 'T':       /* emit typedefs */
+           types_out = TRUE;
+           break;
+       case 'l':
+           proto_style   = PROTO_LINTLIBRARY;
+           extern_out    = FALSE;
+           types_out     = TRUE;
+           variables_out = TRUE;
+# if !defined(vms) && !defined(MSDOS)
+           (void)strcat(cpp_opt, " -C");       /* pass-through comments */
+# endif
+           break;
+#endif
+       case 'x':
+           extern_in = MAX_INC_DEPTH;
+           break;
+       default:
+           usage();
+       }
+    }
+
+#ifdef vms
+    add_option("includes", cpp_include);
+    add_option("define",   cpp_defines);
+    add_option("undefine", cpp_undefns);
+#endif
+
+    *pargc = argc;
+    *pargv = argv;
+}
+
+int
+main (argc, argv)
+int argc;
+char *argv[];
+{
+    int i;
+    FILE *inf;
+    char *argv0;
+
+#ifdef __EMX__
+    /* Expand file wild cards. */
+    _wildcard(&argc, &argv);
+#endif
+
+    /* Get the program name from the 0th argument, stripping the pathname
+     * for readability.
+     */
+    progname = argv0 = xstrdup(argv[0]);
+#ifdef vms
+    for (i = strlen(progname)-1; i >= 0; i--) {
+       if (progname[i] == SQUARE_R
+        || progname[i] == ':') {
+           progname += (i + 1);
+           break;
+       } else if (progname[i] == '.') {
+           progname[i] = '\0';
+       }
+    }
+#else
+    for (i = strlen(progname)-1; i >= 0; i--) {
+       if (is_path_sep(progname[i])) {
+           progname += (i + 1);
+           break;
+# if defined(MSDOS) || defined(OS2)
+       } else if (progname[i] == '.') {
+           progname[i] = '\0';
+# endif
+       }
+    }
+#endif
+    argv[0] = progname;        /* do this so getopt is consistent with us */
+
+    process_options(&argc, &argv);
+
+#if OPT_LINTLIBRARY
+    if (lintLibrary()) {
+       put_string(stdout, "/* LINTLIBRARY */\n");
+       switch (func_style) {
+       case FUNC_ANSI:
+       case FUNC_BOTH:
+           lint_shadowed = TRUE;       /* e.g., ctype.h */
+           proto_style = PROTO_ANSI_LLIB;
+           break;
+       }
+       func_style = FUNC_NONE;
+    } else if (func_style == FUNC_UNKNOWN)
+       func_style = FUNC_NONE;
+#endif
+
+    if (proto_macro && define_macro) {
+       printf("#if __STDC__ || defined(__cplusplus)\n");
+       printf("#define %s(s) s\n", macro_name);
+       printf("#else\n");
+       printf("#define %s(s) ()\n", macro_name);
+       printf("#endif\n\n");
+    }
+
+    init_parser();
+    if (optind == argc) {
+       if (func_style != FUNC_NONE) {
+           proto_style = PROTO_NONE;
+           variables_out = FALSE;
+           file_comments = FALSE;
+       }
+       process_file(stdin, "stdin");
+       pop_file(FALSE);
+    } else {
+       if (!optind)
+           optind++;
+       for (i = optind; i < argc; ++i) {
+#ifdef CPP
+# if CPP_DOES_ONLY_C_FILES
+           /*
+            * GCC (and possibly other compilers) don't pass-through the ".l"
+            * and ".y" files to the C preprocessor stage.  Fix this by
+            * temporarily linking the input file to a temporary-file with a
+            * ".c" suffix.
+            *
+            * Of course, this solution assumes that the input directory is
+            * writeable.
+            */
+           char temp[BUFSIZ];
+           char *s = strcpy(temp, argv[i]);
+#  if HAVE_LINK
+           int len = strlen(temp);
+           s += len - 1;
+           if ((len > 2)
+            && (s[-1] == '.')
+            && (*s == 'l' || *s == 'y')) {
+               while (s != temp && s[-1] != '/')
+                   s--;
+               (void)strcpy(s, "XXXXXX.c");
+               mktemp(temp);
+               if (link(argv[i], temp) < 0)
+                   (void)strcpy(temp, argv[i]);
+           }
+#  endif
+#  define FileName temp
+# else
+#  define FileName argv[i]
+#  ifdef vms
+           char temp[BUFSIZ];
+           (void)strcpy(temp, FileName);
+#  endif
+# endif
+           if (func_style == FUNC_NONE && cpp != NULL) {
+#ifdef vms
+               /*
+                * Assume the 'cpp' command contains a "%s" for the name of
+                * the file that we're writing to.
+                */
+               sprintf(cpp_cmd, cpp,
+                       mktemp(strcpy(temp, "sys$scratch:XXXXXX.i")));
+               sprintf(cpp_cmd + strlen(cpp_cmd), "%s %s", cpp_opt, FileName);
+               system(cpp_cmd);
+               inf = fopen(temp, "r");
+#else
+               sprintf(cpp_cmd, "%s%s %s", cpp, cpp_opt, FileName);
+               inf = popen(cpp_cmd, "r");
+#endif
+               if (inf == NULL) {
+                   fprintf(stderr, "%s: error running %s\n", progname,
+                    cpp_cmd);
+                   continue;
+               }
+           } else {
+               if ((inf = fopen(argv[i], "r")) == NULL) {
+                   fprintf(stderr, "%s: cannot read file %s\n", progname,
+                    argv[i]);
+                   continue;
+               }
+           }
+#else
+           if ((inf = fopen(argv[i], "r")) == NULL) {
+               fprintf(stderr, "%s: cannot read file %s\n", progname, argv[i]);
+               continue;
+           }
+#endif
+           process_file(inf, argv[i]);
+#ifdef CPP
+           if (func_style == FUNC_NONE && cpp != NULL) {
+#ifdef vms
+               fclose(inf);
+#else
+               pclose(inf);
+#endif
+#if CPP_DOES_ONLY_C_FILES || defined(vms)
+               if (strcmp(argv[i], temp)) {
+                       (void)unlink(temp);
+               }
+               pop_file(TRUE);
+#endif
+           } else {
+               pop_file(FALSE);
+           }
+#else  /* no CPP defined */
+           pop_file(FALSE);
+#endif
+       }
+    }
+
+    if (proto_macro && define_macro) {
+       printf("\n#undef %s\n", macro_name);
+    }
+
+#ifdef NO_LEAKS
+# ifdef CPP
+    if (cpp_opt != 0) free(cpp_opt);
+    if (cpp_cmd != 0) free(cpp_cmd);
+#  ifdef vms
+    if (cpp_include != 0) free(cpp_include);
+    if (cpp_defines != 0) free(cpp_defines);
+    if (cpp_undefns != 0) free(cpp_undefns);
+#  endif
+# endif
+    while (--num_inc_dir > 1) {
+       free(inc_dir[num_inc_dir]);
+    }
+    free_parser();
+# if OPT_LINTLIBRARY
+    free_lintlibs();
+# endif
+
+# ifdef DOALLOC
+    show_alloc();
+# endif
+    free(argv0);
+#endif
+
+    return EXIT_SUCCESS;
+}
+
+/* Intercept 'exit()' for debugging.  (The Linux libc uses malloc/free in
+ * 'exit()', so we cannot get a trace unless we resort to this hack ;-)
+ */
+#if HAVE_LIBDBMALLOC
+#undef exit
+void ExitProgram(code)
+int code;
+{
+    extern int malloc_errfd;   /* FIXME: should be in dbmalloc.h */
+    malloc_dump(malloc_errfd);
+    exit(code);
+}
+#endif
diff --git a/cproto-4.6/cproto.h b/cproto-4.6/cproto.h
new file mode 100644 (file)
index 0000000..fab5da9
--- /dev/null
@@ -0,0 +1,280 @@
+/* $Id: cproto.h,v 4.6 1998/01/19 00:49:16 cthuang Exp $
+ *
+ * Declarations for C function prototype generator
+ */
+#ifndef CPROTO_H
+#define CPROTO_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+#if HAVE_LIBDMALLOC || HAVE_LIBDBMALLOC || defined(DOALLOC)
+#undef  NO_LEAKS
+#define NO_LEAKS 1
+#endif
+
+#ifdef lint
+#define        NEW(type)       (type *)0
+#else
+#define        NEW(type)       (type *)xmalloc(sizeof(type))
+#endif
+
+/* Useful constants (mainly to avoid problems balancing parentheses...) */
+#define ELLIPSIS      "..."
+#define PAREN_L       '('
+#define PAREN_R       ')'
+#define SQUARE_L      '['
+#define SQUARE_R      ']'
+#define CURL_L        '{'
+#define CURL_R        '}'
+#define        COMMENT_BEGIN "/*"
+#define COMMENT_END   "*/"
+
+/* Boolean type */
+typedef char boolean;
+
+/* Source file text */
+typedef struct text {
+    char text[MAX_TEXT_SIZE];  /* source text */
+    long begin;                /* offset in temporary file */
+} Text;
+
+/* This is a list of function parameters. */
+typedef struct parameter_list {
+    struct parameter *first;   /* pointer to first parameter in list */
+    struct parameter *last;    /* pointer to last parameter in list */  
+    long begin_comment;        /* begin offset of comment */
+    long end_comment;          /* end offset of comment */
+    char *comment;             /* comment at start of parameter list */
+} ParameterList;
+
+/* Declaration specifier flags */
+#define DS_NONE        0       /* default */
+#define DS_EXTERN      1       /* contains "extern" specifier */
+#define DS_STATIC      2       /* contains "static" specifier */
+#define DS_CHAR        4       /* contains "char" type specifier */
+#define DS_SHORT       8       /* contains "short" type specifier */
+#define DS_FLOAT       16      /* contains "float" type specifier */
+#define DS_JUNK        32      /* we're not interested in this declaration */
+
+/* This structure stores information about a declaration specifier. */
+typedef struct decl_spec {
+    unsigned short flags;      /* flags defined above */
+    char *text;                /* source text */
+    long begin;                /* offset in temporary file */
+} DeclSpec;
+
+/* Styles of function definitions */
+#if OPT_LINTLIBRARY
+#define FUNC_UNKNOWN           -1      /* unspecified */
+#else
+#define FUNC_UNKNOWN           0       /* unspecified (same as FUNC_NONE) */
+#endif
+#define FUNC_NONE              0       /* not a function definition */
+#define FUNC_TRADITIONAL       1       /* traditional style */
+#define FUNC_ANSI              2       /* ANSI style */
+#define FUNC_BOTH              3       /* both styles */
+typedef int FuncDefStyle;
+
+/* This structure stores information about a declarator. */
+typedef struct declarator {
+    char *name;                        /* name of variable or function */
+    char *text;                        /* source text */
+    long begin;                        /* offset in temporary file */
+    long begin_comment;                /* begin offset of comment */
+    long end_comment;                  /* end offset of comment */
+    FuncDefStyle func_def;             /* style of function definition */
+    ParameterList params;              /* function parameters */
+    boolean pointer;                   /* TRUE if it declares a pointer */
+    struct declarator *head;           /* head function declarator */
+    struct declarator *func_stack;     /* stack of function declarators */
+    struct declarator *next;           /* next declarator in list */
+} Declarator;
+
+/* This is a list of declarators. */
+typedef struct declarator_list {
+    Declarator *first;         /* pointer to first declarator in list */
+    Declarator *last;          /* pointer to last declarator in list */  
+} DeclaratorList;
+
+/* This structure stores information about a function parameter. */
+typedef struct parameter {
+    struct parameter *next;    /* next parameter in list */
+    DeclSpec decl_spec;
+    Declarator *declarator;
+    char *comment;             /* comment following the parameter */
+} Parameter;
+
+/* parser stack entry type */
+typedef union {
+    Text text;
+    DeclSpec decl_spec;
+    Parameter *parameter;
+    ParameterList param_list;
+    Declarator *declarator;
+    DeclaratorList decl_list;
+} YYSTYPE;
+
+/* Prototype styles */
+#if OPT_LINTLIBRARY
+#define PROTO_ANSI_LLIB                -2      /* form ANSI lint-library source */
+#define PROTO_LINTLIBRARY      -1      /* form lint-library source */
+#endif
+#define PROTO_NONE             0       /* do not output any prototypes */
+#define PROTO_TRADITIONAL      1       /* comment out parameters */
+#define PROTO_ABSTRACT         2       /* comment out parameter names */
+#define PROTO_ANSI             3       /* ANSI C prototype */
+typedef int PrototypeStyle;
+
+#define ansiLintLibrary() (proto_style == PROTO_ANSI_LLIB)
+#define knrLintLibrary()  (proto_style == PROTO_LINTLIBRARY)
+#define lintLibrary()     (knrLintLibrary() || ansiLintLibrary())
+
+/* The role of a function declarator */
+#define FUNC_OTHER     0       /* miscellaneous declaration */
+#define FUNC_PROTO     1       /* prototype */
+#define FUNC_DEF       2       /* function definition */
+typedef int FuncDeclRole;
+
+/* Prototype/function definition output formats */
+#define FMT_OTHER              0       /* miscellaneous */
+#define FMT_PROTO              1       /* prototype */
+#define FMT_FUNC               2       /* function definition */
+#define FMT_FUNC_COMMENT       3       /* func. def. with parameter comments */
+typedef int FuncFormatType;
+
+/* select scope of declarations to output */
+#define SCOPE_STATIC   1       /* only output declarations with local scope */
+#define SCOPE_EXTERN   2       /* only output declarations with global scope */
+#define SCOPE_ALL      3       /* output all declarations */
+typedef int Scope;
+
+/* Prototype/function definition output format */
+typedef struct func_format {
+    char *decl_spec_prefix;    /* output before declaration specifier */
+    char *declarator_prefix;   /* output before declarator name */
+    char *declarator_suffix;   /* output before '(' of parameter list */
+    char *first_param_prefix;  /* output before first parameter */
+    char *middle_param_prefix; /* output before each subsequent parameter */
+    char *last_param_suffix;   /* output after last parameter */
+} FuncFormat;
+
+/* Program options */
+extern boolean extern_out;
+extern Scope scope_out;
+#if OPT_LINTLIBRARY
+extern boolean types_out;
+extern boolean lint_shadowed;
+#endif
+extern boolean variables_out;
+extern boolean promote_param;
+extern PrototypeStyle proto_style;
+extern FuncDefStyle func_style;
+extern boolean proto_macro;
+extern boolean define_macro;
+extern char *macro_name;
+extern boolean proto_comments;
+extern boolean file_comments;
+extern boolean quiet;
+extern char *func_directive;
+extern int num_inc_dir;
+extern char *inc_dir[];
+extern FuncFormat fmt[4];
+
+/* Global declarations */
+extern char *progname;
+extern int varargs_num;                /* supports varargs-comment */
+extern char *varargs_str;      /* additional info, such as PRINTFLIKEnn */
+extern int extern_in;          /* supports "LINT_EXTERNnn" */
+extern int exitlike_func;      /* supports noreturn-attribute */
+extern int in_include;         /* current include-level */
+extern int debug_trace;
+extern char base_file[];
+
+/* cproto.c */
+#if HAVE_LIBDBMALLOC
+extern void ExitProgram     ARGS((int code));
+#define exit(code) ExitProgram(code)
+#endif
+#if !HAVE_LIBDMALLOC
+#ifdef NO_LEAKS
+extern char *xMalloc        ARGS((unsigned n, char *f, int l));
+extern char *xStrdup        ARGS((char *s,    char *f, int l));
+#define xmalloc(n)          xMalloc(n, __FILE__, __LINE__)
+#define xstrdup(s)          xStrdup(s, __FILE__, __LINE__)
+#else
+extern char *xmalloc        ARGS((unsigned n));
+extern char *xstrdup        ARGS((char *src));
+#endif
+#endif /* !HAVE_LIBDMALLOC */
+extern void put_error       ARGS((void));
+extern int is_path_sep      ARGS((int ch));
+extern char *trim_path_sep  ARGS((char *s));
+
+/* lintlibs.c */
+#if OPT_LINTLIBRARY
+extern void put_string      ARGS((FILE *outf, char *s));
+extern void put_char        ARGS((FILE *outf, int c));
+extern void put_newline     ARGS((FILE *outf));
+extern void put_blankline   ARGS((FILE *outf));
+extern void put_padded      ARGS((FILE *outf, char *s));
+extern void fmt_library     ARGS((int code));
+extern void begin_tracking  ARGS((void));
+extern int already_declared ARGS((char *name));
+extern void track_in        ARGS((void));
+extern int want_typedef     ARGS((void));
+extern void begin_typedef   ARGS((void));
+extern void copy_typedef    ARGS((char *s));
+extern void end_typedef     ARGS((void));
+extern void imply_typedef   ARGS((char *s));
+extern char *implied_typedef ARGS((void));
+extern void indent          ARGS((FILE *outf));
+extern int lint_ellipsis    ARGS((Parameter *p));
+#if OPT_LINTLIBRARY
+extern void flush_varargs   ARGS((void));
+#else
+#define flush_varargs() /* nothing */
+#endif
+extern void ellipsis_varargs ARGS((Declarator *d));
+extern char *supply_parm    ARGS((int count));
+extern int is_actual_func   ARGS((Declarator *d));
+extern void put_body        ARGS((FILE *outf, DeclSpec *decl_spec, Declarator *declarator));
+# ifdef NO_LEAKS
+extern void free_lintlibs   ARGS((void));
+# endif
+#else
+#define put_string(fp,S)    fputs(S, fp)
+#define put_char(fp,C)      fputc(C, fp)
+#define put_padded(fp,S)    fprintf(fp, "%s ", S)
+#define put_body(fp,s,d)    put_string(fp,";\n")
+#define track_in()
+#define begin_typedef()
+#define copy_typedef()
+#define end_typedef()
+#define imply_typedef(s)
+#define implied_typedef()   ((char *)0)
+#endif
+
+/* strkey.c */
+extern char *strkey         ARGS((char *src, char *key));
+extern void strcut          ARGS((char *src, char *key));
+
+/* grammar.y */
+extern boolean is_typedef_name ARGS((char *name));
+extern char *cur_file_name  ARGS((void));
+extern unsigned cur_line_num ARGS((void));
+extern FILE *cur_tmp_file   ARGS((void));
+extern void cur_file_changed ARGS((void));
+extern long cur_begin_comment ARGS((void));
+extern char *cur_text       ARGS((void));
+extern void pop_file        ARGS((int closed));
+extern void init_parser     ARGS((void));
+extern void process_file    ARGS((FILE *infile, char *name));
+#ifdef NO_LEAKS
+extern void free_parser     ARGS((void));
+#endif
+
+#endif /* CPROTO_H */
diff --git a/cproto-4.6/emx/Makefile b/cproto-4.6/emx/Makefile
new file mode 100644 (file)
index 0000000..ab3f699
--- /dev/null
@@ -0,0 +1,47 @@
+# $Id: Makefile,v 4.3 1998/01/22 19:49:36 cthuang Exp $
+#
+# EMX makefile for C prototype generator
+
+PROGRAM = cproto
+DEFINES =
+INCLUDES = -I..
+
+LEX = lex
+YACC = yacc
+CC = gcc
+CFLAGS = $(DEFINES) $(INCLUDES)
+LIBS =
+
+VPATH = ..
+
+O = .o
+OBJECTS = \
+       cproto$(O) \
+       lintlibs$(O) \
+       semantic$(O) \
+       strkey$(O) \
+       symbol$(O) \
+       y_tab$(O)
+
+all: cproto.exe
+
+cproto.exe: $(OBJECTS)
+       $(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LIBS)
+
+cproto.man: cproto.1
+       cawf -man $*.1 | bsfilt - >$*.man
+
+clean:
+       -del $(PROGRAM).exe
+       -del *$(O)
+       -del *.bak
+       -del *.log
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
+
+cproto.o: system.h cproto.h symbol.h
+lintlibs.o: system.h cproto.h symbol.h semantic.h
+semantic.o: system.h cproto.h symbol.h semantic.h
+strkey.o: cproto.h system.h
+symbol.o: system.h cproto.h symbol.h
+y_tab.o: lex_yy.c system.h cproto.h symbol.h semantic.h
diff --git a/cproto-4.6/emx/README b/cproto-4.6/emx/README
new file mode 100644 (file)
index 0000000..0290267
--- /dev/null
@@ -0,0 +1,3 @@
+The files in this directory are used to build using EMX.
+
+Makefile       makefile for EMX
diff --git a/cproto-4.6/grammar.y b/cproto-4.6/grammar.y
new file mode 100644 (file)
index 0000000..f54ebb0
--- /dev/null
@@ -0,0 +1,909 @@
+/* $Id: grammar.y,v 4.7 1998/01/21 00:55:55 cthuang Exp $
+ *
+ * yacc grammar for C function prototype generator
+ * This was derived from the grammar in Appendix A of
+ * "The C Programming Language" by Kernighan and Ritchie.
+ */
+
+%token <text> '(' '*' '&'
+       /* identifiers that are not reserved words */
+       T_IDENTIFIER T_TYPEDEF_NAME T_DEFINE_NAME
+
+       /* storage class */
+       T_AUTO T_EXTERN T_REGISTER T_STATIC T_TYPEDEF
+       /* This keyword included for compatibility with C++. */
+       T_INLINE
+
+       /* type specifiers */
+       T_CHAR T_DOUBLE T_FLOAT T_INT T_VOID
+       T_LONG T_SHORT T_SIGNED T_UNSIGNED
+       T_ENUM T_STRUCT T_UNION
+
+       /* type qualifiers */
+       T_TYPE_QUALIFIER
+
+       /* paired square brackets and everything between them: [ ... ] */
+       T_BRACKETS
+
+%token
+       /* left brace */
+       T_LBRACE
+       /* all input to the matching right brace */
+       T_MATCHRBRACE
+
+       /* three periods */
+       T_ELLIPSIS
+
+       /* constant expression or paired braces following an equal sign */
+       T_INITIALIZER
+
+       /* string literal */
+       T_STRING_LITERAL
+
+       /* asm */
+       T_ASM
+       /* ( "string literal" ) following asm keyword */
+       T_ASMARG
+
+       /* va_dcl from <varargs.h> */
+       T_VA_DCL
+
+%type <decl_spec> decl_specifiers decl_specifier
+%type <decl_spec> storage_class type_specifier type_qualifier
+%type <decl_spec> struct_or_union_specifier enum_specifier
+%type <decl_list> init_declarator_list
+%type <declarator> init_declarator declarator direct_declarator
+%type <declarator> abs_declarator direct_abs_declarator
+%type <param_list> parameter_type_list parameter_list
+%type <parameter> parameter_declaration
+%type <param_list> opt_identifier_list identifier_list
+%type <text> struct_or_union pointer opt_type_qualifiers type_qualifier_list
+       any_id identifier_or_ref
+%type <text> enumeration
+
+%{
+#include <stdio.h>
+#include <ctype.h>
+#include "cproto.h"
+#include "symbol.h"
+#include "semantic.h"
+
+#define YYMAXDEPTH 150
+
+extern int     yylex ARGS((void));
+
+/* declaration specifier attributes for the typedef statement currently being
+ * scanned
+ */
+static int cur_decl_spec_flags;
+
+/* pointer to parameter list for the current function definition */
+static ParameterList *func_params;
+
+/* A parser semantic action sets this pointer to the current declarator in
+ * a function parameter declaration in order to catch any comments following
+ * the parameter declaration on the same line.  If the lexer scans a comment
+ * and <cur_declarator> is not NULL, then the comment is attached to the
+ * declarator.  To ignore subsequent comments, the lexer sets this to NULL
+ * after scanning a comment or end of line.
+ */
+static Declarator *cur_declarator;
+
+/* temporary string buffer */
+static char buf[MAX_TEXT_SIZE];
+
+/* table of typedef names */
+static SymbolTable *typedef_names;
+
+/* table of define names */
+static SymbolTable *define_names;
+
+/* table of type qualifiers */
+static SymbolTable *type_qualifiers;
+
+/* information about the current input file */
+typedef struct {
+    char *base_name;           /* base input file name */
+    char *file_name;           /* current file name */
+    FILE *file;                /* input file */
+    unsigned line_num;         /* current line number in input file */
+    FILE *tmp_file;            /* temporary file */
+    long begin_comment;        /* tmp file offset after last written ) or ; */
+    long end_comment;          /* tmp file offset after last comment */
+    boolean convert;           /* if TRUE, convert function definitions */
+    boolean changed;           /* TRUE if conversion done in this file */
+} IncludeStack;
+
+static IncludeStack *cur_file; /* current input file */
+
+#include "yyerror.c"
+
+static int haveAnsiParam ARGS((void));
+
+
+/* Flags to enable us to find if a procedure returns a value.
+ */
+static int return_val, /* nonzero on BRACES iff return-expression found */
+          returned_at; /* marker for token-number to set 'return_val' */
+
+#if OPT_LINTLIBRARY
+static char *dft_decl_spec ARGS((void));
+
+static char *
+dft_decl_spec ()
+{
+    return (lintLibrary() && !return_val) ? "void" : "int";
+}
+
+#else
+#define dft_decl_spec() "int"
+#endif
+
+static int
+haveAnsiParam ()
+{
+    Parameter *p;
+    if (func_params != 0) {
+       for (p = func_params->first; p != 0; p = p->next) {
+           if (p->declarator->func_def == FUNC_ANSI) {
+               return TRUE;
+           }
+       }
+    }
+    return FALSE;
+}
+%}
+%%
+
+program
+       : /* empty */
+       | translation_unit
+       ;
+
+translation_unit
+       : external_declaration
+       | translation_unit external_declaration
+       ;
+
+external_declaration
+       : declaration
+       | function_definition
+       | ';'
+       | linkage_specification
+       | T_ASM T_ASMARG ';'
+       | error T_MATCHRBRACE
+       {
+           yyerrok;
+       }
+       | error ';'
+       {
+           yyerrok;
+       }
+       ;
+
+braces
+       : T_LBRACE T_MATCHRBRACE
+       ;
+
+linkage_specification
+       : T_EXTERN T_STRING_LITERAL braces
+       {
+           /* Provide an empty action here so bison will not complain about
+            * incompatible types in the default action it normally would
+            * have generated.
+            */
+       }
+       | T_EXTERN T_STRING_LITERAL declaration
+       {
+           /* empty */
+       }
+       ;
+
+declaration
+       : decl_specifiers ';'
+       {
+#if OPT_LINTLIBRARY
+           if (types_out && want_typedef()) {
+               gen_declarations(&$1, (DeclaratorList *)0);
+               flush_varargs();
+           }
+#endif
+           free_decl_spec(&$1);
+           end_typedef();
+       }
+       | decl_specifiers init_declarator_list ';'
+       {
+           if (func_params != NULL) {
+               set_param_types(func_params, &$1, &$2);
+           } else {
+               gen_declarations(&$1, &$2);
+#if OPT_LINTLIBRARY
+               flush_varargs();
+#endif
+               free_decl_list(&$2);
+           }
+           free_decl_spec(&$1);
+           end_typedef();
+       }
+       | any_typedef decl_specifiers
+       {
+           cur_decl_spec_flags = $2.flags;
+           free_decl_spec(&$2);
+       }
+         opt_declarator_list ';'
+       {
+           end_typedef();
+       }
+       ;
+
+any_typedef
+       : T_TYPEDEF
+       {
+           begin_typedef();
+       }
+       ;
+
+opt_declarator_list
+       : /* empty */
+       | declarator_list
+       ;
+
+declarator_list
+       : declarator
+       {
+           int flags = cur_decl_spec_flags;
+
+           /* If the typedef is a pointer type, then reset the short type
+            * flags so it does not get promoted.
+            */
+           if (strcmp($1->text, $1->name) != 0)
+               flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
+           new_symbol(typedef_names, $1->name, NULL, flags);
+           free_declarator($1);
+       }
+       | declarator_list ',' declarator
+       {
+           int flags = cur_decl_spec_flags;
+
+           if (strcmp($3->text, $3->name) != 0)
+               flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
+           new_symbol(typedef_names, $3->name, NULL, flags);
+           free_declarator($3);
+       }
+       ;
+
+function_definition
+       : decl_specifiers declarator
+       {
+           check_untagged(&$1);
+           if ($2->func_def == FUNC_NONE) {
+               yyerror("syntax error");
+               YYERROR;
+           }
+           func_params = &($2->head->params);
+           func_params->begin_comment = cur_file->begin_comment;
+           func_params->end_comment = cur_file->end_comment;
+       }
+         opt_declaration_list T_LBRACE
+       {
+           /* If we're converting to K&R and we've got a nominally K&R
+            * function which has a parameter which is ANSI (i.e., a prototyped
+            * function pointer), then we must override the deciphered value of
+            * 'func_def' so that the parameter will be converted.
+            */
+           if (func_style == FUNC_TRADITIONAL
+            && haveAnsiParam()
+            && $2->head->func_def == func_style) {
+               $2->head->func_def = FUNC_BOTH;
+           }
+
+           func_params = NULL;
+
+           if (cur_file->convert)
+               gen_func_definition(&$1, $2);
+           gen_prototype(&$1, $2);
+#if OPT_LINTLIBRARY
+           flush_varargs();
+#endif
+           free_decl_spec(&$1);
+           free_declarator($2);
+       }
+         T_MATCHRBRACE
+       | declarator
+       {
+           if ($1->func_def == FUNC_NONE) {
+               yyerror("syntax error");
+               YYERROR;
+           }
+           func_params = &($1->head->params);
+           func_params->begin_comment = cur_file->begin_comment;
+           func_params->end_comment = cur_file->end_comment;
+       }
+         opt_declaration_list T_LBRACE T_MATCHRBRACE
+       {
+           DeclSpec decl_spec;
+
+           func_params = NULL;
+
+           new_decl_spec(&decl_spec, dft_decl_spec(), $1->begin, DS_NONE);
+           if (cur_file->convert)
+               gen_func_definition(&decl_spec, $1);
+           gen_prototype(&decl_spec, $1);
+#if OPT_LINTLIBRARY
+           flush_varargs();
+#endif
+           free_decl_spec(&decl_spec);
+           free_declarator($1);
+       }
+       ;
+
+opt_declaration_list
+       : /* empty */
+       | T_VA_DCL
+       | declaration_list
+       ;
+
+declaration_list
+       : declaration
+       | declaration_list declaration
+       ;
+
+decl_specifiers
+       : decl_specifier
+       | decl_specifiers decl_specifier
+       {
+           join_decl_specs(&$$, &$1, &$2);
+           free($1.text);
+           free($2.text);
+       }
+       ;
+
+decl_specifier
+       : storage_class
+       | type_specifier
+       | type_qualifier
+       ;
+
+storage_class
+       : T_AUTO
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+       }
+       | T_EXTERN
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_EXTERN);
+       }
+       | T_REGISTER
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+       }
+       | T_STATIC
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_STATIC);
+       }
+       | T_INLINE
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_JUNK);
+       }
+       ;
+
+type_specifier
+       : T_CHAR
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_CHAR);
+       }
+       | T_DOUBLE
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+       }
+       | T_FLOAT
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_FLOAT);
+       }
+       | T_INT
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+       }
+       | T_LONG
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+       }
+       | T_SHORT
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_SHORT);
+       }
+       | T_SIGNED
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+       }
+       | T_UNSIGNED
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+       }
+       | T_VOID
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+       }
+       | T_TYPEDEF_NAME
+       {
+           Symbol *s;
+           s = find_symbol(typedef_names, $1.text);
+           if (s != NULL)
+               new_decl_spec(&$$, $1.text, $1.begin, s->flags);
+       }
+       | struct_or_union_specifier
+       | enum_specifier
+       ;
+
+type_qualifier
+       : T_TYPE_QUALIFIER
+       {
+           new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
+       }
+       | T_DEFINE_NAME
+       {
+           /* This rule allows the <pointer> nonterminal to scan #define
+            * names as if they were type modifiers.
+            */
+           Symbol *s;
+           s = find_symbol(define_names, $1.text);
+           if (s != NULL)
+               new_decl_spec(&$$, $1.text, $1.begin, s->flags);
+       }
+       ;
+
+struct_or_union_specifier
+       : struct_or_union any_id braces
+       {
+           char *s;
+           if ((s = implied_typedef()) == 0)
+               (void)sprintf(s = buf, "%s %s", $1.text, $2.text);
+           new_decl_spec(&$$, s, $1.begin, DS_NONE);
+       }
+       | struct_or_union braces
+       {
+           char *s;
+           if ((s = implied_typedef()) == 0)
+               (void)sprintf(s = buf, "%s {}", $1.text);
+           new_decl_spec(&$$, s, $1.begin, DS_NONE);
+       }
+       | struct_or_union any_id
+       {
+           (void)sprintf(buf, "%s %s", $1.text, $2.text);
+           new_decl_spec(&$$, buf, $1.begin, DS_NONE);
+       }
+       ;
+
+struct_or_union
+       : T_STRUCT
+       {
+           imply_typedef($$.text);
+       }
+       | T_UNION
+       {
+           imply_typedef($$.text);
+       }
+       ;
+
+init_declarator_list
+       : init_declarator
+       {
+           new_decl_list(&$$, $1);
+       }
+       | init_declarator_list ',' init_declarator
+       {
+           add_decl_list(&$$, &$1, $3);
+       }
+       ;
+
+init_declarator
+       : declarator
+       {
+           if ($1->func_def != FUNC_NONE && func_params == NULL &&
+               func_style == FUNC_TRADITIONAL && cur_file->convert) {
+               gen_func_declarator($1);
+               fputs(cur_text(), cur_file->tmp_file);
+           }
+           cur_declarator = $$;
+       }
+       | declarator '='
+       {
+           if ($1->func_def != FUNC_NONE && func_params == NULL &&
+               func_style == FUNC_TRADITIONAL && cur_file->convert) {
+               gen_func_declarator($1);
+               fputs(" =", cur_file->tmp_file);
+           }
+       }
+         T_INITIALIZER
+       ;
+
+enum_specifier
+       : enumeration any_id braces
+       {
+           char *s;
+           if ((s = implied_typedef()) == 0)
+               (void)sprintf(s = buf, "enum %s", $2.text);
+           new_decl_spec(&$$, s, $1.begin, DS_NONE);
+       }
+       | enumeration braces
+       {
+           char *s;
+           if ((s = implied_typedef()) == 0)
+               (void)sprintf(s = buf, "%s {}", $1.text);
+           new_decl_spec(&$$, s, $1.begin, DS_NONE);
+       }
+       | enumeration any_id
+       {
+           (void)sprintf(buf, "enum %s", $2.text);
+           new_decl_spec(&$$, buf, $1.begin, DS_NONE);
+       }
+       ;
+
+enumeration
+       : T_ENUM
+       {
+           imply_typedef("enum");
+           $$ = $1;
+       }
+       ;
+
+any_id
+       : T_IDENTIFIER
+       | T_TYPEDEF_NAME
+       ;
+
+declarator
+       : pointer direct_declarator
+       {
+           $$ = $2;
+           (void)sprintf(buf, "%s%s", $1.text, $$->text);
+           free($$->text);
+           $$->text = xstrdup(buf);
+           $$->begin = $1.begin;
+           $$->pointer = TRUE;
+       }
+       | direct_declarator
+       ;
+
+direct_declarator
+       : identifier_or_ref
+       {
+           $$ = new_declarator($1.text, $1.text, $1.begin);
+       }
+       | '(' declarator ')'
+       {
+           $$ = $2;
+           (void)sprintf(buf, "(%s)", $$->text);
+           free($$->text);
+           $$->text = xstrdup(buf);
+           $$->begin = $1.begin;
+       }
+       | direct_declarator T_BRACKETS
+       {
+           $$ = $1;
+           (void)sprintf(buf, "%s%s", $$->text, $2.text);
+           free($$->text);
+           $$->text = xstrdup(buf);
+       }
+       | direct_declarator '(' parameter_type_list ')'
+       {
+           $$ = new_declarator("%s()", $1->name, $1->begin);
+           $$->params = $3;
+           $$->func_stack = $1;
+           $$->head = ($1->func_stack == NULL) ? $$ : $1->head;
+           $$->func_def = FUNC_ANSI;
+       }
+       | direct_declarator '(' opt_identifier_list ')'
+       {
+           $$ = new_declarator("%s()", $1->name, $1->begin);
+           $$->params = $3;
+           $$->func_stack = $1;
+           $$->head = ($1->func_stack == NULL) ? $$ : $1->head;
+           $$->func_def = FUNC_TRADITIONAL;
+       }
+       ;
+
+pointer
+       : '*' opt_type_qualifiers
+       {
+           (void)sprintf($$.text, "*%s", $2.text);
+           $$.begin = $1.begin;
+       }
+       | '*' opt_type_qualifiers pointer
+       {
+           (void)sprintf($$.text, "*%s%s", $2.text, $3.text);
+           $$.begin = $1.begin;
+       }
+       ;
+
+opt_type_qualifiers
+       : /* empty */
+       {
+           strcpy($$.text, "");
+           $$.begin = 0L;
+       }
+       | type_qualifier_list
+       ;
+
+type_qualifier_list
+       : type_qualifier
+       {
+           (void)sprintf($$.text, "%s ", $1.text);
+           $$.begin = $1.begin;
+           free($1.text);
+       }
+       | type_qualifier_list type_qualifier
+       {
+           (void)sprintf($$.text, "%s%s ", $1.text, $2.text);
+           $$.begin = $1.begin;
+           free($2.text);
+       }
+       ;
+
+parameter_type_list
+       : parameter_list
+       | parameter_list ',' T_ELLIPSIS
+       {
+           add_ident_list(&$$, &$1, "...");
+       }
+       ;
+
+parameter_list
+       : parameter_declaration
+       {
+           new_param_list(&$$, $1);
+       }
+       | parameter_list ',' parameter_declaration
+       {
+           add_param_list(&$$, &$1, $3);
+       }
+       ;
+
+parameter_declaration
+       : decl_specifiers declarator
+       {
+           check_untagged(&$1);
+           $$ = new_parameter(&$1, $2);
+       }
+       | decl_specifiers abs_declarator
+       {
+           check_untagged(&$1);
+           $$ = new_parameter(&$1, $2);
+       }
+       | decl_specifiers
+       {
+           check_untagged(&$1);
+           $$ = new_parameter(&$1, (Declarator *)0);
+       }
+       ;
+
+opt_identifier_list
+       : /* empty */
+       {
+           new_ident_list(&$$);
+       }
+       | identifier_list
+       ;
+
+identifier_list
+       : T_IDENTIFIER
+       {
+           new_ident_list(&$$);
+           add_ident_list(&$$, &$$, $1.text);
+       }
+       | identifier_list ',' T_IDENTIFIER
+       {
+           add_ident_list(&$$, &$1, $3.text);
+       }
+       ;
+
+identifier_or_ref
+       : T_IDENTIFIER
+       {
+           $$ = $1;
+       }
+       | '&' T_IDENTIFIER
+       {
+#if OPT_LINTLIBRARY
+           if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
+               $$ = $2;
+           } else
+#endif
+               (void)sprintf($$.text, "&%s", $2.text);
+           $$.begin = $1.begin;
+       }
+       ;
+
+abs_declarator
+       : pointer
+       {
+           $$ = new_declarator($1.text, "", $1.begin);
+       }
+       | pointer direct_abs_declarator
+       {
+           $$ = $2;
+           (void)sprintf(buf, "%s%s", $1.text, $$->text);
+           free($$->text);
+           $$->text = xstrdup(buf);
+           $$->begin = $1.begin;
+       }
+       | direct_abs_declarator
+       ;
+
+direct_abs_declarator
+       : '(' abs_declarator ')'
+       {
+           $$ = $2;
+           (void)sprintf(buf, "(%s)", $$->text);
+           free($$->text);
+           $$->text = xstrdup(buf);
+           $$->begin = $1.begin;
+       }
+       | direct_abs_declarator T_BRACKETS
+       {
+           $$ = $1;
+           (void)sprintf(buf, "%s%s", $$->text, $2.text);
+           free($$->text);
+           $$->text = xstrdup(buf);
+       }
+       | T_BRACKETS
+       {
+           $$ = new_declarator($1.text, "", $1.begin);
+       }
+       | direct_abs_declarator '(' parameter_type_list ')'
+       {
+           $$ = new_declarator("%s()", "", $1->begin);
+           $$->params = $3;
+           $$->func_stack = $1;
+           $$->head = ($1->func_stack == NULL) ? $$ : $1->head;
+           $$->func_def = FUNC_ANSI;
+       }
+       | direct_abs_declarator '(' ')'
+       {
+           $$ = new_declarator("%s()", "", $1->begin);
+           $$->func_stack = $1;
+           $$->head = ($1->func_stack == NULL) ? $$ : $1->head;
+           $$->func_def = FUNC_ANSI;
+       }
+       | '(' parameter_type_list ')'
+       {
+           Declarator *d;
+           
+           d = new_declarator("", "", $1.begin);
+           $$ = new_declarator("%s()", "", $1.begin);
+           $$->params = $2;
+           $$->func_stack = d;
+           $$->head = $$;
+           $$->func_def = FUNC_ANSI;
+       }
+       | '(' ')'
+       {
+           Declarator *d;
+           
+           d = new_declarator("", "", $1.begin);
+           $$ = new_declarator("%s()", "", $1.begin);
+           $$->func_stack = d;
+           $$->head = $$;
+           $$->func_def = FUNC_ANSI;
+       }
+       ;
+
+%%
+
+#if defined(__EMX__) || defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(vms)
+# ifdef USE_flex
+#  include "lexyy.c"
+# else
+#  include "lex_yy.c"
+# endif
+#else
+# include "lex.yy.c"
+#endif
+
+static void
+yaccError (msg)
+char *msg;
+{
+    func_params = NULL;
+    put_error();               /* tell what line we're on, and what file */
+    fprintf(stderr, "%s at token '%s'\n", msg, yytext);
+}
+
+/* Initialize the table of type qualifier keywords recognized by the lexical
+ * analyzer.
+ */
+void
+init_parser ()
+{
+    static char *keywords[] = {
+       "const", "volatile", "interrupt",
+#ifdef vms
+       "noshare", "readonly",
+#endif
+#if defined(MSDOS) || defined(OS2)
+       "cdecl", "far", "huge", "near", "pascal",
+       "_cdecl", "_export", "_far", "_fastcall", "_fortran", "_huge",
+       "_interrupt", "_loadds", "_near", "_pascal", "_saveregs", "_segment",
+       "_cs", "_ds", "_es", "_ss", "_seg",
+       "__cdecl", "__export", "__far", "__fastcall", "__fortran", "__huge",
+       "__inline", "__interrupt", "__loadds", "__near", "__pascal",
+       "__saveregs", "__segment", "__stdcall", "__syscall",
+#ifdef OS2
+       "__far16",
+#endif
+#else
+       "__const__",    "__const",
+       "__volatile__", "__volatile",
+       "__inline__",   "__inline",
+#endif
+    };
+    int i;
+
+    /* Initialize type qualifier table. */
+    type_qualifiers = new_symbol_table();
+    for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
+       new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
+    }
+}
+
+/* Process the C source file.  Write function prototypes to the standard
+ * output.  Convert function definitions and write the converted source
+ * code to a temporary file.
+ */
+void
+process_file (infile, name)
+FILE *infile;
+char *name;
+{
+    char *s;
+
+    if (strlen(name) > 2) {
+       s = name + strlen(name) - 2;
+       if (*s == '.') {
+           ++s;
+           if (*s == 'l' || *s == 'y')
+               BEGIN LEXYACC;
+#if defined(MSDOS) || defined(OS2)
+           if (*s == 'L' || *s == 'Y')
+               BEGIN LEXYACC;
+#endif
+       }
+    }
+
+    included_files = new_symbol_table();
+    typedef_names = new_symbol_table();
+    define_names = new_symbol_table();
+    inc_depth = -1;
+    curly = 0;
+    ly_count = 0;
+    func_params = NULL;
+    yyin = infile;
+    include_file(strcpy(base_file, name), func_style != FUNC_NONE);
+    if (file_comments) {
+#if OPT_LINTLIBRARY
+       if (lintLibrary()) {
+           put_blankline(stdout);
+           begin_tracking();
+       }
+#endif
+       put_string(stdout, "/* ");
+       put_string(stdout, cur_file_name());
+       put_string(stdout, " */\n");
+    }
+    yyparse();
+    free_symbol_table(define_names);
+    free_symbol_table(typedef_names);
+    free_symbol_table(included_files);
+}
+
+#ifdef NO_LEAKS
+void
+free_parser()
+{
+    free_symbol_table (type_qualifiers);
+#ifdef FLEX_SCANNER
+    if (yy_current_buffer != 0)
+       yy_delete_buffer(yy_current_buffer);
+#endif
+}
+#endif
diff --git a/cproto-4.6/install.sh b/cproto-4.6/install.sh
new file mode 100755 (executable)
index 0000000..676c9f7
--- /dev/null
@@ -0,0 +1,239 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+#
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+tranformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+       -c) instcmd="$cpprog"
+           shift
+           continue;;
+
+       -d) dir_arg=true
+           shift
+           continue;;
+
+       -m) chmodcmd="$chmodprog $2"
+           shift
+           shift
+           continue;;
+
+       -o) chowncmd="$chownprog $2"
+           shift
+           shift
+           continue;;
+
+       -g) chgrpcmd="$chgrpprog $2"
+           shift
+           shift
+           continue;;
+
+       -s) stripcmd="$stripprog"
+           shift
+           continue;;
+
+       -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+           shift
+           continue;;
+
+       -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+           shift
+           continue;;
+
+       *)  if [ x"$src" = x ]
+           then
+               src=$1
+           else
+               # this colon is to work around a 386BSD /bin/sh bug
+               :
+               dst=$1
+           fi
+           shift
+           continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+       echo "install:  no input file specified"
+       exit 1
+else
+       true
+fi
+
+if [ x"$dir_arg" != x ]; then
+       dst=$src
+       src=""
+       
+       if [ -d $dst ]; then
+               instcmd=:
+       else
+               instcmd=mkdir
+       fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
+
+       if [ -f $src -o -d $src ]
+       then
+               true
+       else
+               echo "install:  $src does not exist"
+               exit 1
+       fi
+       
+       if [ x"$dst" = x ]
+       then
+               echo "install:  no destination specified"
+               exit 1
+       else
+               true
+       fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+       if [ -d $dst ]
+       then
+               dst="$dst"/`basename $src`
+       else
+               true
+       fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='   
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+       pathcomp="${pathcomp}${1}"
+       shift
+
+       if [ ! -d "${pathcomp}" ] ;
+        then
+               $mkdirprog "${pathcomp}"
+       else
+               true
+       fi
+
+       pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+       $doit $instcmd $dst &&
+
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+       if [ x"$transformarg" = x ] 
+       then
+               dstfile=`basename $dst`
+       else
+               dstfile=`basename $dst $transformbasename | 
+                       sed $transformarg`$transformbasename
+       fi
+
+# don't allow the sed command to completely eliminate the filename
+
+       if [ x"$dstfile" = x ] 
+       then
+               dstfile=`basename $dst`
+       else
+               true
+       fi
+
+# Make a temp file name in the proper directory.
+
+       dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+       $doit $instcmd $src $dsttmp &&
+
+       trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+       $doit $rmcmd -f $dstdir/$dstfile &&
+       $doit $mvcmd $dsttmp $dstdir/$dstfile 
+
+fi &&
+
+
+exit 0
+
diff --git a/cproto-4.6/lex.l b/cproto-4.6/lex.l
new file mode 100644 (file)
index 0000000..aca67c2
--- /dev/null
@@ -0,0 +1,985 @@
+%{
+/* $Id: lex.l,v 4.5 1996/04/13 04:29:18 cthuang Exp $
+ *
+ * Lexical analyzer for C function prototype generator
+ *
+ *     This is designed to parse lexically at the top level (e.g., of extern
+ *     objects such as procedures).  The corresponding yacc-grammar expects
+ *     that curly-braces (for function bodies) are recognized as a single
+ *     token, BRACES.  Similarly, square-brackets and their contents are
+ *     passed back as BRACKETS.
+ *
+ *     Assignments at the top level are data-initialization statements.
+ *     These are returned as INITIALIZER.
+ *
+ *     The logic here recognizes tokens inside curly-braces, but does not
+ *     pass them back to the grammar.
+ *
+ * Apollo extensions:
+ *     "&" is ignored when creating lint-libraries, because we ignore
+ *     expressions of all kinds.  Note that function-prototypes may use "&" to
+ *     denote reference-parameters.  By ignoring that as well, we make the
+ *     output compatible with lint (kludge).
+ *
+ *     Similarly, ignore "std_$call", since it is not compatible with lint.
+ *
+ *     CPP_INLINE handles a special case of the Apollo CC 6.7 compiler that
+ *     uses inline attribute declarations, e.g.
+ *
+ *             int     foo #attribute[aligned(1)];
+ *
+ *     In CC 6.8 this behavior is hidden by a macro.
+ *
+ * VAX/VMS extensions:
+ *     Treat the keywords 'globalref', etc., as 'extern'.
+ *
+ *     The keywords 'noshare' and 'readonly' are type-qualifiers.
+ *
+ * GCC extensions:
+ *     The keywords '__attribute__', '__inline', '__inline__', '__signed',
+ *     '__signed__'.
+ */
+
+#define        result(nn)      count(); if (!brackets && unnested()) return(nn)
+
+#define        is_IDENTIFIER       save_text_offset();\
+                           return type_of_name(yytext);
+
+#if !OPT_LINTLIBRARY
+#define gcc_attribute   absorb_special /* otherwise, we don't care */
+#endif
+
+#ifdef apollo
+#define        apollo_keyword
+#define        apollo_special  absorb_special()
+#else
+#define        apollo_keyword  is_IDENTIFIER
+#define        apollo_special  is_IDENTIFIER
+#endif
+
+#ifdef vms
+#define        vms_extern      save_text_offset(); return(T_EXTERN);
+#define        vms_keyword     save_text_offset();
+#else  /* unix */
+#define        vms_extern      is_IDENTIFIER
+#define        vms_keyword     is_IDENTIFIER
+#endif /* vms/unix */
+
+char * varargs_str;            /* save printflike/scanflike text */
+int    varargs_num;            /* code to save "VARARGS" */
+int    debug_trace;            /* true if we trace token-level stuff */
+char   base_file[BUFSIZ];      /* top-level file name */
+
+static int save_cpp;   /* true if cpp-text within curly braces */
+static int in_cpp;     /* true while we are within cpp-text */
+static int curly;      /* number of curly brace nesting levels */
+static int ly_count;   /* number of occurances of %% */
+
+#ifdef FLEX_SCANNER
+/* flex scanner state */
+static YY_BUFFER_STATE buffer_stack[MAX_INC_DEPTH];
+#endif
+
+static int inc_depth;                          /* include nesting level */
+static IncludeStack inc_stack[MAX_INC_DEPTH];  /* stack of included files */
+static SymbolTable *included_files;            /* files already included */
+
+static int  type_of_name      ARGS((char *name));
+static void startCpp          ARGS((int level));
+static void finishCpp         ARGS((void));
+#if defined(apollo) || !OPT_LINTLIBRARY
+static void absorb_special    ARGS((void));
+#endif
+#if OPT_LINTLIBRARY
+static void gcc_attribute     ARGS((void));
+#endif
+static void update_line_num   ARGS((void));
+static void save_text         ARGS((void));
+static void save_text_offset  ARGS((void));
+static void get_quoted        ARGS((void));
+static void get_comment       ARGS((void));
+static void get_cpp_directive ARGS((char *dest, unsigned n));
+static void do_include        ARGS((char *f));
+static void include_file      ARGS((char *name, int convert));
+static void put_file          ARGS((FILE *outf));
+static void put_quoted        ARGS((int c));
+
+#if OPT_LINTLIBRARY
+static int decipher_comment   ARGS((char *keyword, int len));
+#endif
+
+#ifdef yywrap
+#undef yywrap
+#endif
+int yywrap ARGS((void));
+%}
+
+WS             [ \t]
+LETTER         [A-Za-z$_]
+DIGIT          [0-9]
+ID             {LETTER}({LETTER}|{DIGIT})*
+QUOTE          [\"\']
+
+%s CPP1 INIT1 INIT2 CURLY LEXYACC ASM CPP_INLINE
+%%
+
+\n                     { save_text(); cur_file->line_num++;
+                           cur_declarator = NULL; }
+
+"/*"                   { save_text(); get_comment(); }
+"//".*$                save_text();
+
+<INITIAL>"&"           { save_text(); return '&'; /* C++ ref-variable? */ }
+
+<LEXYACC>^"%%"         { save_text(); if (++ly_count >= 2) BEGIN INITIAL; }
+<LEXYACC>^"%{"         { save_text(); BEGIN INITIAL; }
+<LEXYACC>{QUOTE}       get_quoted();
+<LEXYACC>.             save_text();
+<INITIAL>^"%}"         { save_text(); BEGIN LEXYACC; }
+
+<INITIAL>#{WS}*        { save_text(); startCpp(0); }
+<INITIAL>"??="{WS}*    { save_text(); startCpp(0); }
+
+<CPP1>attribute                { BEGIN CPP_INLINE; /* apollo */}
+<CPP1>options          { BEGIN CPP_INLINE; /* apollo */}
+<CPP_INLINE>[^;]*      finishCpp();
+
+<CPP1>define{WS}+{ID}  {
+                           char name[MAX_TEXT_SIZE], value[MAX_TEXT_SIZE];
+
+                           save_text();
+                           sscanf(yytext, "define %s", name);
+                           get_cpp_directive(buf, sizeof(buf));
+                           sscanf(buf, "%s", value);
+                           new_symbol(define_names, name, value, DS_NONE);
+                       }
+
+<CPP1>include{WS}*     {
+                           save_text();
+                           get_cpp_directive(buf, sizeof(buf));
+                           if (buf[0] != '"' && buf[0] != '<') {
+                               Symbol *sym = find_symbol(define_names, buf);
+                               if (sym != NULL && sym->value != NULL) {
+                                   strcpy(buf, sym->value);
+                               } else {
+                                   buf[0] = '\0';
+                               }
+                           }
+                           if (buf[0] != '\0')
+                               do_include(buf);
+                       }
+
+<CPP1>line{WS}+[0-9]+{WS}+\".*$  {
+                           save_text();
+                           sscanf(yytext, "line %d \"%[^\"]\"",
+                            &cur_file->line_num, cur_file->file_name);
+                           cur_file->line_num--;
+                           track_in();
+                           finishCpp();
+                       }
+<CPP1>[0-9]+{WS}+\".*$  {
+                           save_text();
+                           sscanf(yytext, "%d \"%[^\"]\"", &cur_file->line_num,
+                            cur_file->file_name);
+                           cur_file->line_num--;
+                           track_in();
+                           finishCpp();
+                       }
+<CPP1>[0-9]+.*$        {
+                           save_text();
+                           sscanf(yytext, "%d ", &cur_file->line_num);
+                           cur_file->line_num--;
+                           track_in();
+                           finishCpp();
+                       }
+
+<CPP1>.                { save_text(); get_cpp_directive(NULL, 0); }
+
+<INITIAL>"("           { save_text_offset(); return '('; }
+<INITIAL>")"           {
+                           save_text();
+                           if (cur_file->convert)
+                               cur_file->begin_comment =
+                                ftell(cur_file->tmp_file);
+                           return ')';
+                       }
+<INITIAL>"*"           { save_text_offset(); return '*'; }
+<INITIAL>[,;]          {
+                           save_text();
+                           if (cur_file->convert)
+                               cur_file->begin_comment =
+                                ftell(cur_file->tmp_file);
+                           return yytext[0];
+                       }
+<INITIAL>"..."         { save_text(); return T_ELLIPSIS; }
+<INITIAL>\"            {
+                           get_quoted();
+                           return T_STRING_LITERAL;
+                       }
+
+<INITIAL>asm           { save_text(); BEGIN ASM; return T_ASM; }
+<ASM>"("               save_text();
+<ASM>")"               { save_text(); BEGIN INITIAL; return T_ASMARG; }
+<ASM>{QUOTE}           get_quoted();
+<ASM>.                         save_text();
+
+<INITIAL>__?based[^(]*\([^)]*\)        { save_text_offset(); return T_TYPE_QUALIFIER; }
+
+<INITIAL>auto          { save_text_offset(); return T_AUTO; }
+<INITIAL>extern        { save_text_offset(); return T_EXTERN; }
+<INITIAL>register      { save_text_offset(); return T_REGISTER; }
+<INITIAL>static        { save_text_offset(); return T_STATIC; }
+<INITIAL>typedef       { save_text_offset(); return T_TYPEDEF; }
+<INITIAL>inline        { save_text_offset(); return T_INLINE; }
+<INITIAL>char          { save_text_offset(); return T_CHAR; }
+<INITIAL>double        { save_text_offset(); return T_DOUBLE; }
+<INITIAL>float         { save_text_offset(); return T_FLOAT; }
+<INITIAL>int           { save_text_offset(); return T_INT; }
+<INITIAL>void          { save_text_offset(); return T_VOID; }
+<INITIAL>long          { save_text_offset(); return T_LONG; }
+<INITIAL>short         { save_text_offset(); return T_SHORT; }
+<INITIAL>signed        { save_text_offset(); return T_SIGNED; }
+<INITIAL>unsigned      { save_text_offset(); return T_UNSIGNED; }
+<INITIAL>enum          { save_text_offset(); return T_ENUM; }
+<INITIAL>struct        { save_text_offset(); return T_STRUCT; }
+<INITIAL>union         { save_text_offset(); return T_UNION; }
+<INITIAL>va_dcl                { save_text_offset(); return T_VA_DCL; }
+
+<INITIAL>__signed      { save_text_offset(); return T_SIGNED; }
+<INITIAL>__signed__    { save_text_offset(); return T_SIGNED; }
+<INITIAL>__inline      { save_text_offset(); return T_INLINE; }
+<INITIAL>__inline__    { save_text_offset(); return T_INLINE; }
+<INITIAL>__attribute__ { gcc_attribute(); }
+
+<INITIAL>globalvalue   { vms_extern; }
+<INITIAL>globalref     { vms_extern; }
+<INITIAL>globaldef     { vms_extern; }
+
+<INITIAL>"std_$call"   { apollo_keyword; }
+<INITIAL>"__attribute" { apollo_special; }
+
+<INITIAL>{ID}          { is_IDENTIFIER }
+
+<INITIAL>\[[^\]]*\]    {
+                           /* This can't handle the case where a comment
+                            * containing a ] appears between the brackets.
+                            */
+                           save_text_offset();
+                           update_line_num();
+                           return T_BRACKETS;
+                       }
+<INITIAL>"??("[^?]*"??)"       {
+                           save_text_offset();
+                           update_line_num();
+                           return T_BRACKETS;
+                       }
+
+<INITIAL>"="           { save_text(); BEGIN INIT1; return '='; }
+<INIT1>"{"             { save_text(); curly = 1; BEGIN INIT2; }
+<INIT1>[,;]            {
+                           unput(yytext[yyleng-1]);
+                           BEGIN INITIAL;
+                           return T_INITIALIZER;
+                       }
+<INIT1>{QUOTE}         get_quoted();
+<INIT1>.               save_text();
+
+<INIT2>"{"             { save_text(); ++curly; }
+<INIT2>"}"             {
+                           save_text();
+                           if (--curly == 0) {
+                               BEGIN INITIAL;
+                               return T_INITIALIZER;
+                           }
+                       }
+<INIT2>{QUOTE}         get_quoted();
+<INIT2>.               save_text();
+
+<INITIAL>"{"           {
+                           save_text();
+                           curly = 1;
+                           return_val =
+                           returned_at = FALSE;
+                           BEGIN CURLY;
+                           return T_LBRACE;
+                       }
+<CURLY>"{"             { save_text(); ++curly; }
+<CURLY>"}"             {
+                           save_text();
+                           if (--curly == 0) {
+                               BEGIN INITIAL;
+                               return T_MATCHRBRACE;
+                           }
+                       }
+<CURLY>{QUOTE}         get_quoted();
+<CURLY>"return"                { save_text(); returned_at = TRUE; }
+<CURLY>";"             { save_text(); returned_at = FALSE; }
+<CURLY>#{WS}*          { save_text(); startCpp(1); }
+<CURLY>"??="{WS}*      { save_text(); startCpp(1); }
+<CURLY>.               { save_text(); return_val |= returned_at; }
+
+[ \r\t\f]+             save_text();
+.                      {
+                           save_text();
+                           put_error();
+                           fprintf(stderr, "bad character '%c'\n", yytext[0]);
+                       }
+%%
+
+static void
+startCpp (level)
+int level;
+{
+    save_cpp = level;
+    in_cpp = TRUE;
+    BEGIN CPP1;
+}
+
+static void
+finishCpp()
+{
+    in_cpp = FALSE;
+    if (save_cpp)
+       BEGIN CURLY;
+    else
+       BEGIN INITIAL;
+}
+
+/*
+ * Skip over embedded __attribute/__attribute_ syntax.
+ */
+#if defined(apollo) || !OPT_LINTLIBRARY
+static void
+absorb_special ()
+{
+    int        c;
+    int        nest    = 0;
+    while ((c = input()) > 0) {
+       if (c == '(')
+           nest++;
+       else if (c == ')') {
+           if (--nest <= 0)
+               break;
+       }
+    }
+}
+#endif
+
+#if OPT_LINTLIBRARY
+/*
+ * This recognizes some of the special attribute macros defined by gcc:
+ *     noreturn
+ *     format(printf,n,m)
+ *     format(scanf,n,m)
+ * and uses that information to construct equivalent lint-library text.
+ * (It's a distinct piece of code from the 'absorb_special()' function to
+ * avoid spurious matches with non-gcc compilers).
+ */
+static void
+gcc_attribute ()
+{
+    int        c, num1, num2;
+    int        nest = 0;
+    int        len = 0;
+    char bfr[BUFSIZ];
+
+    while ((c = input()) > 0) {
+       if (len < sizeof(bfr)-1 && !isspace(c))
+           bfr[len++] = c;
+       if (c == '(')
+           nest++;
+       else if (c == ')') {
+           if (--nest <= 0)
+               break;
+       }
+    }
+    bfr[len] = '\0';
+    if (!strcmp(bfr, "((noreturn))")) {
+       exitlike_func = TRUE;
+    } else if (sscanf(bfr, "((format(printf,%d,%d)))", &num1, &num2) == 2) {
+       (void)sprintf(bfr, "PRINTFLIKE%d", varargs_num = num1);
+       varargs_str = xstrdup(bfr);
+    } else if (sscanf(bfr, "((format(scanf,%d,%d)))", &num1, &num2) == 2) {
+       (void)sprintf(bfr, "SCANFLIKE%d", varargs_num = num1);
+       varargs_str = xstrdup(bfr);
+    }
+}
+#endif
+
+/* Decode the current token according to the type-of-name
+ */
+static int
+type_of_name (name)
+char *name;
+{
+    if (find_symbol(type_qualifiers, name) != NULL)
+       return T_TYPE_QUALIFIER;
+    else if (find_symbol(typedef_names, name) != NULL)
+       return T_TYPEDEF_NAME;
+    else if (find_symbol(define_names, name) != NULL)
+       return T_DEFINE_NAME;
+    else
+       return T_IDENTIFIER;
+}
+
+boolean
+is_typedef_name (name)
+char *name;
+{
+    return (find_symbol(typedef_names, name) != NULL);
+}
+
+/* If the matched text contains any new line characters, then update the
+ * current line number.
+ */
+static void
+update_line_num ()
+{
+    char *p = yytext;
+    while (*p != '\0') {
+       if (*p++ == '\n')
+           cur_file->line_num++;
+    }
+}
+
+/* Save the matched text in the temporary file.
+ */
+static void
+save_text ()
+{
+#if OPT_LINTLIBRARY
+    if (!in_cpp)
+       copy_typedef(yytext);
+#endif 
+    if (cur_file->convert) {
+       fputs(yytext, cur_file->tmp_file);
+    }
+}
+
+/* Record the current position in the temporary file and write the matched text
+ * to the file.
+ */
+static void
+save_text_offset ()
+{
+    (void)strcpy(yylval.text.text, yytext);
+#if OPT_LINTLIBRARY
+    copy_typedef(yytext);
+#endif
+    if (cur_file->convert) {
+       yylval.text.begin = ftell(cur_file->tmp_file);
+       fputs(yytext, cur_file->tmp_file);
+    } else
+       yylval.text.begin = 0;
+}
+
+#if OPT_LINTLIBRARY
+/* Decipher comments that are useful for lint (and making lint-libraries)
+ */
+static struct {
+    int        varText;
+    int        varargs;
+    int        externs;
+    int        preproz;
+} cmtVal;
+
+static int
+decipher_comment (keyword, len)
+char *keyword;
+int len;
+{
+    if (len != 0) {
+       int value;
+       keyword[len] = '\0';
+
+       /* these are recognized by some lint-programs */
+       if (!strcmp(keyword, "VARARGS")) {
+           cmtVal.varargs = -1;
+       } else if (sscanf(keyword, "VARARGS%d", &value) == 1) {
+           cmtVal.varargs = value;
+       } else if (!strcmp(keyword, "PRINTFLIKE")) {
+           cmtVal.varargs = 1;
+           cmtVal.varText = TRUE;
+       } else if (sscanf(keyword, "PRINTFLIKE%d", &value) == 1) {
+           cmtVal.varargs = value;
+           cmtVal.varText = TRUE;
+       } else if (!strcmp(keyword, "SCANFLIKE")) {
+           cmtVal.varargs = 2;
+           cmtVal.varText = TRUE;
+       } else if (sscanf(keyword, "SCANFLIKE%d", &value) == 1) {
+           cmtVal.varargs = value;
+           cmtVal.varText = TRUE;
+       /* these are extensions added to simplify library-generation */
+       } else if (!strcmp(keyword, "LINT_EXTERN")) {
+           cmtVal.externs = MAX_INC_DEPTH;
+       } else if (sscanf(keyword, "LINT_EXTERN%d", &value) == 1) {
+           cmtVal.externs = value;
+       } else if (!strcmp(keyword, "LINT_PREPRO")) {
+           cmtVal.preproz = -1;        /* the whole comment */
+       } else if (sscanf(keyword, "LINT_PREPRO%d", &value) == 1) {
+           cmtVal.preproz = value;
+       } else if (!strcmp(keyword, "LINT_SHADOWED")) {
+           lint_shadowed = TRUE;
+       }
+    }
+    return 0;
+}
+#endif
+
+static void
+put_quoted (c)
+int c;
+{
+    /* Modifying 'yytext[]' doesn't work well with FLEX, which simply
+     * maintains 'yytext' as a pointer into its input buffer.  LEX copies
+     * characters into the 'yytext[]' array.
+     */
+#if defined(FLEX_SCANNER) || !defined(YYLMAX)
+    if (c != 0) {
+       static char     temp[2];
+       temp[0] = c;
+       /* save_text */
+# if OPT_LINTLIBRARY
+       if (!in_cpp)
+           copy_typedef(temp);
+# endif        
+       if (cur_file->convert) {
+           fputs(temp, cur_file->tmp_file);
+       }
+       /* update_line_num */
+       if (c == '\n')
+           cur_file->line_num++;
+    }
+
+#else  /* this works fine on LEX (e.g., on SunOS 4.x) */
+
+    if ((c == 0) || (yyleng+1 >= YYLMAX)) {
+       save_text();
+       update_line_num();
+       yyleng = 0;
+    }
+    if (c != 0) {
+       yytext[yyleng++] = c;
+       yytext[yyleng] = 0;
+    }
+#endif /* LEX/FLEX */
+}
+
+/*
+ * Scan past the characters in a backslash sequence
+ */
+/* Scan past quoted string.  Note that some strings may overflow 'yytext[]', so
+ * we don't try to eat them in the lexical rules.
+ */
+static void
+get_quoted ()
+{
+    int        delim = *yytext;
+    int        c;
+
+#if defined(FLEX_SCANNER) || !defined(YYLMAX)
+    put_quoted(delim);
+#endif
+    while ((c = input()) != 0) {
+       if (c == '\\') {
+           put_quoted(c);
+           if ((c = input()) == 0)
+               break;
+           put_quoted(c);
+       } else {
+           put_quoted(c);
+           if (c == delim)
+               break;
+           if (c == '\n') {    /* recover from unbalanced */
+               put_error();
+               fprintf(stderr, "unbalanced quote character '%c'\n", delim);
+               break;
+           }
+       }
+    }
+    put_quoted(0);
+}
+
+/* Scan to end of comment.
+ */
+static void
+get_comment ()
+{
+    int c, lastc = '\0';
+
+#if OPT_LINTLIBRARY
+    int len = 0;
+    char keyword[BUFSIZ];
+
+    keyword[len] = '\0';
+    cmtVal.varText = 0;
+    cmtVal.varargs = 0;
+    cmtVal.externs = -1;
+    cmtVal.preproz = 0;
+#endif
+
+    while ((c = input()) != 0) {
+       if (cur_file->convert)
+           fputc(c, cur_file->tmp_file);
+
+#if OPT_LINTLIBRARY
+       if (!(isalnum(c) || c == '_' || c == '$')) {
+           int flag = cmtVal.preproz;
+           len = decipher_comment(keyword, len);
+           if (flag != cmtVal.preproz)
+               lastc = '\0';
+       } else if (len+1 < sizeof(keyword)) {
+           keyword[len++] = c;
+       }
+#endif
+
+       switch (c) {
+       case '\n':
+           cur_file->line_num++;
+#if OPT_LINTLIBRARY
+           if (cmtVal.preproz != 0 && lastc != '\0')
+               fputc(lastc, stdout); 
+           if (cmtVal.preproz > 0)     /* if negative, we pass everything */
+               cmtVal.preproz -= 1;
+#endif
+           break;
+       case '/':
+           if (lastc == '*') {
+               if (cur_file->convert) {
+                   if (func_params && cur_declarator) {
+                       cur_declarator->begin_comment = cur_file->begin_comment;
+                       cur_file->begin_comment = ftell(cur_file->tmp_file);
+                       cur_declarator->end_comment = cur_file->begin_comment;
+                       cur_declarator = NULL;
+                   } else {
+                       cur_file->end_comment = ftell(cur_file->tmp_file);
+                   }
+               }
+#if OPT_LINTLIBRARY
+               (void)decipher_comment(keyword, len);
+               if (cmtVal.varargs != 0) {
+                   if ((varargs_num = cmtVal.varargs) != 0
+                    && cmtVal.varText != 0) {
+                       if (varargs_str != 0)
+                           free(varargs_str);
+                       varargs_str = xstrdup(keyword);
+                   }
+               }
+               if (cmtVal.externs != -1)
+                   extern_in = cmtVal.externs;
+               if (cmtVal.preproz != 0)
+                   fputc('\n', stdout); 
+#endif
+               return;
+           }
+           /* FALLTHRU */
+       default:
+#if OPT_LINTLIBRARY
+           if (cmtVal.preproz != 0 && lastc != '\0')
+               fputc(lastc, stdout); 
+#endif
+           break;
+       }
+       lastc = c;
+    }
+}
+
+/* Scan rest of preprocessor directive.  If <dest> is not NULL, then store
+ * the text in the buffer pointed to by <dest> having size <n>.
+ */
+static void
+get_cpp_directive (dest, n)
+char *dest;            /* buffer to store directive text */
+unsigned n;            /* size of buffer to store directive text */
+{
+    char c, lastc[4];
+    
+    lastc[0] = lastc[1] = lastc[2] = lastc[3] = '\0';
+    if (dest != NULL)
+       *dest = '\0';
+
+    while ((c = input()) != 0) {
+       if (cur_file->convert)
+           fputc(c, cur_file->tmp_file);
+
+       switch (c) {
+       case '\n':
+           cur_file->line_num++;
+           if (lastc[2] != '\\' && strcmp(lastc, "?\?/") != 0) {
+               finishCpp();
+               return;
+           }
+           break;
+       case '*':
+           if (lastc[2] == '/')
+               get_comment();
+           break;
+       }
+       lastc[0] = lastc[1];
+       lastc[1] = lastc[2];
+       lastc[2] = c;
+
+       if (dest != NULL && n > 1) {
+           *dest++ = c;
+           *dest = '\0';
+           --n;
+       }
+    }
+}
+
+/* Return a pointer to the current file name.
+ */
+char *
+cur_file_name ()
+{
+    return cur_file->file_name;
+}
+
+/* Return the current line number.
+ */
+unsigned
+cur_line_num ()
+{
+    return cur_file->line_num;
+}
+
+/* Return the current temporary output file.
+ */
+FILE *
+cur_tmp_file ()
+{
+    return cur_file->tmp_file;
+}
+
+/* Set the modify flag for the current file.
+ */
+void
+cur_file_changed ()
+{
+    cur_file->changed = TRUE;
+}
+
+/* Return the temporary file offset of beginning of the current comment.
+ */
+long
+cur_begin_comment ()
+{
+    return cur_file->begin_comment;
+}
+
+/* Return the text of the current lexical token.
+ */
+char *
+cur_text ()
+{
+    return yytext;
+}
+
+#if !HAVE_TMPFILE
+/*
+ * tmpfile() - return a FILE* for a temporary file that will be
+ * removed automatically when the program exits.
+ * 
+ * Not all systems have the ANSI tmpfile() function yet...
+ *
+ * DaviD W. Sanderson (dws@cs.wisc.edu)
+ */
+FILE *
+tmpfile ()
+{
+    char name[MAX_TEXT_SIZE];
+    char *tmpdir;
+    FILE *f;
+
+    if ((tmpdir = getenv("TMPDIR")) == (char *)0)
+    {
+       tmpdir = "/tmp";
+    }
+    sprintf(name, "%s/TfXXXXXX", tmpdir);
+    mktemp(name);
+
+    if ((f = fopen(name, "w+")) == (FILE *)0)
+    {
+       return (FILE *)0;
+    }
+
+    if (unlink(name) == -1)
+    {
+       fclose(f);
+       return (FILE *)0;
+    }
+
+    return f;
+}
+#endif /* !HAVE_TMPFILE */
+
+/* Push a file onto the include stack. The stream yyin must already
+ * point to the file.
+ */
+static void
+include_file (name, convert)
+char *name;            /* file name */
+int convert;           /* if TRUE, convert function definitions */
+{
+    ++inc_depth;
+    cur_file = inc_stack + inc_depth;
+    cur_file->file = yyin;
+    cur_file->base_name = xstrdup(name);
+    cur_file->file_name = strcpy(xmalloc(MAX_TEXT_SIZE), name);
+    cur_file->line_num = 1;
+    cur_file->convert = convert;
+    cur_file->changed = FALSE;
+
+#ifdef FLEX_SCANNER
+    buffer_stack[inc_depth] = yy_create_buffer(yyin, YY_BUF_SIZE);
+    yy_switch_to_buffer(buffer_stack[inc_depth]);
+#endif
+
+    if (convert) {
+       cur_file->begin_comment = cur_file->end_comment = 0;
+       cur_file->tmp_file = tmpfile();
+       if (cur_file->tmp_file == NULL) {
+           fprintf(stderr, "%s: cannot create temporary file\n", progname);
+           cur_file->convert = FALSE;
+       }
+    }
+}
+
+#define BLOCK_SIZE 2048
+
+/* Copy converted C source from the temporary file to the output stream.
+ */
+static void
+put_file (outf)
+FILE *outf;
+{
+    char block[BLOCK_SIZE];
+    long filesize;
+    unsigned nread, count;
+
+    filesize = ftell(cur_file->tmp_file);
+    fseek(cur_file->tmp_file, 0L, 0);
+    while (filesize > 0) {
+       count = (filesize < BLOCK_SIZE) ? (unsigned)filesize : BLOCK_SIZE;
+       nread = fread(block, sizeof(char), count, cur_file->tmp_file);
+       if (nread == 0)
+           break;
+       fwrite(block, sizeof(char), nread, outf);
+       filesize -= nread;
+    }
+}
+
+/* Remove the top of the include stack.
+ */
+void
+pop_file (closed)
+int closed;
+{
+    FILE *outf;
+
+    if (!closed && (yyin != stdin))
+       fclose(yyin);
+
+    if (cur_file->convert) {
+       if (yyin == stdin) {
+           put_file(stdout);
+       } else if (cur_file->changed) {
+           if ((outf = fopen(cur_file->base_name, "w")) != NULL) {
+               put_file(outf);
+               fclose(outf);
+           } else {
+               fprintf(stderr, "%s: cannot create file %s\n", progname,
+                cur_file->base_name);
+           }
+       }
+
+       fclose(cur_file->tmp_file);
+    }
+    free(cur_file->base_name);
+    free(cur_file->file_name);
+
+#ifdef FLEX_SCANNER
+    yy_delete_buffer(YY_CURRENT_BUFFER);
+#endif
+
+    if (--inc_depth >= 0) {
+       cur_file = inc_stack + inc_depth;
+       yyin = cur_file->file;
+
+#ifdef FLEX_SCANNER
+       yy_switch_to_buffer(buffer_stack[inc_depth]);
+#endif
+    }
+}
+
+/* Process include directive.
+ */
+static void
+do_include (file_spec)
+char *file_spec;       /* path surrounded by "" or <> */
+{
+    int stdinc;        /* 1 = path surrounded by <> */
+    char file[MAX_TEXT_SIZE], path[MAX_TEXT_SIZE];
+    char match, *s;
+    int i;
+    unsigned n;
+    FILE *fp;
+
+    if (inc_depth >= MAX_INC_DEPTH-1) {
+       put_error();
+       fprintf(stderr, "includes too deeply nested\n");
+       return;
+    }
+
+    if (file_spec[0] == '"') {
+       match = '"';
+       stdinc = 0;
+    } else if (file_spec[0] == '<') {
+       match = '>';
+       stdinc = 1;
+    } else {
+       return;
+    }
+    s = strchr(file_spec+1, match);
+    n = (s != NULL) ? (unsigned)(s - file_spec - 1) : 0;
+    strncpy(file, file_spec+1, (size_t)n);
+    file[n] = '\0';
+
+    /* Do nothing if the file was already included. */
+    sprintf(path, stdinc ? "<%s>" : "\"%s\"", file);
+    if (find_symbol(included_files, path) != NULL)
+       return;
+    new_symbol(included_files, path, NULL, DS_NONE);
+
+    for (i = stdinc != 0; i < num_inc_dir; ++i) {
+       if (strlen(inc_dir[i]) == 0) {
+           strcpy(path, file);
+       } else {
+           sprintf(path, "%s/%s", inc_dir[i], file);
+       }
+       if ((fp = fopen(path, "r")) != NULL) {
+           yyin = fp;
+           include_file(path, func_style != FUNC_NONE && !stdinc);
+           return;
+       }
+    }
+
+    if (!quiet) {
+       put_error();
+       fprintf(stderr, "cannot read file %s\n", file_spec);
+    }
+}
+
+/* When the end of the current input file is reached, pop a
+ * nested include file.
+ */
+int
+yywrap ()
+{
+    if (inc_depth > 0) {
+       pop_file(FALSE);
+       return 0;
+    } else {
+       return 1;
+    }
+}
diff --git a/cproto-4.6/lex_yy.c b/cproto-4.6/lex_yy.c
new file mode 100644 (file)
index 0000000..16cd5e8
--- /dev/null
@@ -0,0 +1,3048 @@
+/* A lexical scanner generated by flex */
+
+/* Scanner skeleton version:
+ * /master/usr.bin/lex/skel.c,v 1.2 1996/05/30 12:31:07 bostic Exp
+ */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else  /* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif /* __STDC__ */
+#endif /* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+
+extern int yyleng;
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator).  This
+ * avoids problems with code like:
+ *
+ *     if ( condition_holds )
+ *             yyless( 5 );
+ *     else
+ *             do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the yyless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define yyless(n) \
+       do \
+               { \
+               /* Undo effects of setting up yytext. */ \
+               *yy_cp = yy_hold_char; \
+               YY_RESTORE_YY_MORE_OFFSET \
+               yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+               YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+               } \
+       while ( 0 )
+
+#define unput(c) yyunput( c, yytext_ptr )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int yy_size_t;
+
+
+struct yy_buffer_state
+       {
+       FILE *yy_input_file;
+
+       char *yy_ch_buf;                /* input buffer */
+       char *yy_buf_pos;               /* current position in input buffer */
+
+       /* Size of input buffer in bytes, not including room for EOB
+        * characters.
+        */
+       yy_size_t yy_buf_size;
+
+       /* Number of characters read into yy_ch_buf, not including EOB
+        * characters.
+        */
+       int yy_n_chars;
+
+       /* Whether we "own" the buffer - i.e., we know we created it,
+        * and can realloc() it to grow it, and should free() it to
+        * delete it.
+        */
+       int yy_is_our_buffer;
+
+       /* Whether this is an "interactive" input source; if so, and
+        * if we're using stdio for input, then we want to use getc()
+        * instead of fread(), to make sure we stop fetching input after
+        * each newline.
+        */
+       int yy_is_interactive;
+
+       /* Whether we're considered to be at the beginning of a line.
+        * If so, '^' rules will be active on the next match, otherwise
+        * not.
+        */
+       int yy_at_bol;
+
+       /* Whether to try to fill the input buffer when we reach the
+        * end of it.
+        */
+       int yy_fill_buffer;
+
+       int yy_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+       /* When an EOF's been seen but there's still some text to process
+        * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+        * shouldn't try reading from the input source any more.  We might
+        * still have a bunch of tokens to match, though, because of
+        * possible backing-up.
+        *
+        * When we actually see the EOF, we change the status to "new"
+        * (via yyrestart()), so that the user can continue scanning by
+        * just pointing yyin at a new input file.
+        */
+#define YY_BUFFER_EOF_PENDING 2
+       };
+
+static YY_BUFFER_STATE yy_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER yy_current_buffer
+
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+
+static int yy_n_chars;         /* number of characters read into yy_ch_buf */
+
+
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1;                /* whether we need to initialize */
+static int yy_start = 0;       /* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin.  A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart YY_PROTO(( FILE *input_file ));
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void yy_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+
+static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void yy_flex_free YY_PROTO(( void * ));
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+       { \
+       if ( ! yy_current_buffer ) \
+               yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+       yy_current_buffer->yy_is_interactive = is_interactive; \
+       }
+
+#define yy_set_bol(at_bol) \
+       { \
+       if ( ! yy_current_buffer ) \
+               yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+       yy_current_buffer->yy_at_bol = at_bol; \
+       }
+
+#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+
+typedef unsigned char YY_CHAR;
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+typedef int yy_state_type;
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state YY_PROTO(( void ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
+static int yy_get_next_buffer YY_PROTO(( void ));
+static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+       yytext_ptr = yy_bp; \
+       yyleng = (int) (yy_cp - yy_bp); \
+       yy_hold_char = *yy_cp; \
+       *yy_cp = '\0'; \
+       yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 85
+#define YY_END_OF_BUFFER 86
+static yyconst short int yy_accept[323] =
+    {   0,
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,   14,   14,   86,   84,   83,    1,
+       26,   10,   62,    4,   21,   22,   23,   24,   84,   84,
+       65,   84,   84,   62,   62,   62,   62,   62,   62,   62,
+       62,   62,   62,   62,   62,   62,   62,   74,   84,   20,
+       20,   20,   20,   20,   20,   20,   20,   20,   69,   69,
+       68,   67,   69,   66,   73,   73,   72,   73,   70,   71,
+       82,   82,   77,   80,   82,   79,   82,   82,   75,   76,
+        8,    8,    7,    8,    8,   31,   31,   30,   28,   29,
+       31,   14,   14,    1,   14,   83,   10,   62,    0,    2,
+
+        0,    0,    0,   63,   62,   62,   62,   62,   62,   62,
+       62,   62,   62,   62,   62,   62,   62,   62,   62,   62,
+       62,   62,   62,   62,    9,    0,    0,   19,    0,    0,
+        0,    0,    0,    0,   80,    0,    0,    5,    6,   14,
+       14,    2,   14,   25,    0,    3,    0,   11,   62,   62,
+       62,   62,   27,   62,   62,   62,   62,   62,   62,   62,
+       62,   42,   62,   62,   62,   62,   62,   62,   62,   62,
+       62,   62,   62,   62,    0,    0,    0,    0,    0,    0,
+       81,    0,   14,    3,    0,    0,   11,   62,   62,   62,
+       62,   33,   39,   62,   48,   62,   62,   62,   62,   44,
+
+       62,   62,   62,   62,   62,   62,   62,   62,   62,   62,
+       43,    0,   18,    0,    0,    0,    0,    0,   81,    0,
+        0,   62,   62,   62,   62,   62,   62,   41,   62,   62,
+       62,   45,   62,   62,   62,   62,   62,   50,   62,   62,
+        0,    0,    0,    0,    0,    0,   64,   62,   62,   62,
+       62,   40,   34,   62,   38,   62,   46,   36,   62,   49,
+       62,   62,   51,    0,    0,    0,    0,    0,   78,   62,
+       62,   62,    0,   62,    0,   62,   62,   62,   62,   62,
+       37,   62,    0,    0,   16,    0,   13,   62,   54,   52,
+        0,   32,   62,   62,   62,   35,   62,   47,    0,   15,
+
+       16,    0,   62,   62,   62,   59,   58,   62,   60,   12,
+       15,    0,   17,   62,   55,   53,   62,   61,   57,   62,
+       56,    0
+    } ;
+
+static yyconst int yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        1,    4,    4,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    2,    1,    5,    6,    7,    8,    9,   10,   11,
+       12,   13,    1,   14,    1,   15,   16,   17,   17,   17,
+       17,   17,   17,   17,   17,   17,   17,    1,   18,    1,
+       19,    1,   20,    1,   21,   21,   21,   21,   21,   21,
+       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
+       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
+       22,    1,   23,    1,   24,    1,   25,   26,   27,   28,
+
+       29,   30,   31,   32,   33,   21,   21,   34,   35,   36,
+       37,   38,   21,   39,   40,   41,   42,   43,   21,   44,
+       45,   21,   46,    1,   47,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static yyconst int yy_meta[48] =
+    {   0,
+        1,    2,    1,    1,    1,    1,    3,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    4,    5,    1,    1,
+        3,    1,    1,    3,    3,    3,    3,    3,    3,    3,
+        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
+        3,    3,    3,    3,    3,    1,    1
+    } ;
+
+static yyconst short int yy_base[343] =
+    {   0,
+        0,  562,   46,   82,  118,  163,  208,  254,  300,  346,
+       49,   65,  392,  407,   74,   85,  569,  571,   53,  571,
+      571,  566,    0,  571,  571,  571,  571,  571,  552,   45,
+      571,  546,  542,   40,   51,  532,  526,   58,  528,  527,
+      386,  384,  391,   63,  371,  379,   35,  571,  367,  571,
+      104,   84,  109,  372,  378,  370,  372,  363,  571,  123,
+      571,  571,  101,  571,  571,  127,  571,  117,  571,  571,
+      571,  133,  571,  398,  125,  571,  379,  369,  571,  571,
+      571,  138,  571,  130,  101,  571,  146,  571,  571,  571,
+      136,    0,  149,    0,  141,  154,  389,    0,  375,  571,
+
+      386,   94,  365,  571,  136,  362,  351,  343,  358,  340,
+      339,  339,  342,  341,  129,  341,  345,  338,  343,  146,
+      335,  142,  348,  338,  571,  367,  181,  571,  142,  328,
+      338,  340,  329,  322,  359,  341,  318,  571,  571,    0,
+      176,    0,  121,  571,  355,  571,  337,  353,  313,  317,
+      312,  304,    0,  306,  303,  315,  305,  309,  312,  310,
+      302,    0,  303,  300,  293,  295,  289,  305,  286,  298,
+      289,  292,  296,  295,  319,  282,  286,  283,  286,  281,
+      311,  270,  169,    0,  291,  289,  306,  266,  265,  267,
+      268,    0,    0,  262,    0,  256,  253,  268,  256,    0,
+
+      251,  249,  260,  255,  280,  259,  257,  248,  252,  255,
+        0,  278,  571,  247,  243,  236,  275,  239,  273,  235,
+      261,  233,  238,  233,  240,  238,  230,    0,  231,  234,
+      221,    0,  233,  233,  226,  211,  222,    0,  214,  215,
+      222,  218,  218,  186,  209,  208,  571,  210,  206,  212,
+      423,    0,    0,  161,    0,  211,    0,    0,  214,    0,
+      208,  208,    0,  194,  233,  205,  188,  193,  571,  206,
+      202,  202,  218,    0,  216,  198,  197,  200,  184,  188,
+        0,  193,  179,  217,  215,  189,  571,  174,  191,  190,
+      196,  571,  177,  176,  168,    0,  167,    0,  170,    0,
+
+      196,  194,  155,  171,  169,    0,    0,  150,    0,  571,
+        0,  157,  571,  126,    0,    0,   89,   58,    0,   32,
+        0,  571,  470,  475,  480,  485,  490,  495,  500,  503,
+      507,  512,  517,  521,  526,  531,  536,  541,  546,  550,
+      551,  555
+    } ;
+
+static yyconst short int yy_def[343] =
+    {   0,
+      322,    1,  323,  323,  324,  324,  325,  325,  326,  326,
+      327,  327,  328,  328,  329,  329,  322,  322,  322,  322,
+      322,  322,  330,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  331,  330,  330,  330,  330,  330,  330,  330,
+      330,  330,  330,  330,  330,  330,  330,  322,  322,  322,
+      322,  322,  332,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  333,  333,  333,  333,  322,  322,  330,  322,  322,
+
+      334,  322,  331,  322,  330,  330,  330,  330,  330,  330,
+      330,  330,  330,  330,  330,  330,  330,  330,  330,  330,
+      330,  330,  330,  330,  322,  332,  332,  322,  332,  322,
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  333,
+      333,  333,  335,  322,  334,  322,  336,  322,  330,  330,
+      330,  330,  330,  330,  330,  330,  330,  330,  330,  330,
+      330,  330,  330,  330,  330,  330,  330,  330,  330,  330,
+      330,  330,  330,  330,  337,  322,  322,  322,  322,  322,
+      322,  322,  335,  333,  336,  322,  322,  330,  330,  330,
+      330,  330,  330,  330,  330,  330,  330,  330,  330,  330,
+
+      330,  330,  330,  330,  330,  330,  330,  330,  330,  330,
+      330,  337,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  330,  330,  330,  330,  330,  330,  330,  330,  330,
+      330,  330,  330,  330,  330,  330,  330,  330,  330,  330,
+      322,  322,  322,  322,  322,  322,  322,  330,  330,  330,
+      322,  330,  330,  330,  330,  330,  330,  330,  330,  330,
+      330,  330,  330,  322,  322,  322,  322,  322,  322,  330,
+      330,  330,  338,  251,  339,  330,  330,  330,  330,  330,
+      330,  330,  322,  340,  322,  322,  322,  330,  330,  330,
+      339,  322,  330,  330,  330,  330,  330,  330,  322,  341,
+
+      322,  342,  330,  330,  330,  330,  330,  330,  330,  322,
+      341,  342,  322,  330,  330,  330,  330,  330,  330,  330,
+      330,    0,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  322
+    } ;
+
+static yyconst short int yy_nxt[619] =
+    {   0,
+       18,   19,   20,   19,   21,   22,   23,   18,   24,   18,
+       25,   26,   27,   28,   29,   30,   18,   28,   31,   32,
+       23,   33,   18,   34,   35,   23,   36,   37,   38,   39,
+       40,   23,   41,   42,   23,   23,   23,   23,   43,   44,
+       45,   46,   47,   23,   23,   48,   18,   51,   20,   51,
+       82,   20,   82,   83,   96,  321,   96,  100,   83,  123,
+      101,   52,   53,  105,   84,  106,   82,   20,   82,   83,
+       54,  124,   85,   55,   83,   93,   94,   93,   56,   57,
+       84,  320,   58,   51,   20,   51,   93,   94,   93,   95,
+      107,   18,  108,  111,  118,  119,  100,   52,   53,  101,
+
+       95,  112,   18,  120,  147,   96,   54,   96,  138,   55,
+      127,  128,  148,  100,   56,   57,  101,  319,   58,   60,
+       20,   60,   61,  184,   96,  129,   96,   61,   96,  100,
+       96,   62,  101,   63,   96,   62,   96,  100,  145,   96,
+      101,   96,  100,  127,  128,  101,  139,   96,  100,   96,
+      141,  101,  141,  142,  318,   96,  143,   96,  129,  313,
+      149,  106,  161,   64,   60,   20,   60,   61,  150,  162,
+      167,  184,   61,  168,  171,  151,   62,  141,   63,  141,
+       62,  172,  127,  128,  169,  175,  145,  244,  276,  286,
+      286,  317,  316,  302,  315,  314,  313,  301,  310,  277,
+
+      309,  308,  267,  278,  267,  307,  306,  292,   64,   66,
+       20,   66,   67,  305,  304,  303,  301,   67,  284,  299,
+      298,  297,  296,   68,  295,  294,  293,  292,  275,  290,
+      289,  288,  287,  285,  284,  283,  282,  281,  280,  279,
+      272,  271,  270,  269,  268,  266,  265,  264,  263,  262,
+      261,  260,  259,   69,   70,   66,   20,   66,   67,  258,
+      257,  256,  255,   67,  254,  253,  252,  251,  250,   68,
+      249,  248,  247,  246,  219,  245,  244,  243,  242,  241,
+      213,  240,  239,  238,  237,  236,  235,  234,  233,  232,
+      231,  230,  229,  228,  227,  226,  225,  224,  223,   69,
+
+       70,   72,   20,   72,   73,   74,  222,  187,  221,   73,
+      186,  220,  219,  218,  217,   75,  216,   76,  215,   77,
+      214,  213,  211,  210,  209,  208,  207,  206,  205,  204,
+      203,  202,  201,  200,  199,  198,  197,  196,   78,  195,
+      194,  193,  192,  191,  190,   79,   80,   72,   20,   72,
+       73,   74,  189,  188,  187,   73,  186,  146,  182,  181,
+      135,   75,  180,   76,  179,   77,  178,  177,  176,  128,
+      174,  173,  170,  166,  165,  164,  163,  160,  159,  158,
+      157,  156,  155,  154,   78,  153,  152,  104,  146,  144,
+       97,   79,   80,   87,   20,   87,   88,  137,  136,  135,
+
+      134,   88,   89,   90,  133,  132,  131,   91,   87,   20,
+       87,   88,  130,  125,  122,  121,   88,   89,   90,  117,
+      116,  115,   91,  273,  273,  273,  273,  273,  273,  274,
+      273,  273,  273,  275,  273,  273,  273,  273,  273,  274,
+      273,  273,  273,  274,  273,  273,  274,  274,  274,  274,
+      274,  274,  274,  274,  274,  274,  274,  274,  274,  274,
+      274,  274,  274,  274,  274,  274,  274,  274,  273,  273,
+       50,   50,   50,   50,   50,   59,   59,   59,   59,   59,
+       65,   65,   65,   65,   65,   71,   71,   71,   71,   71,
+       81,   81,   81,   81,   81,   86,   86,   86,   86,   86,
+
+       92,   92,   92,   92,   92,   98,   98,  103,  103,  103,
+      103,  103,  126,  126,  126,  126,  126,  140,  140,  140,
+      140,  145,  145,  145,  145,  145,  183,  183,  183,  183,
+      183,  185,  185,  185,  185,  185,  212,  212,  212,  212,
+      212,  273,  273,  273,  273,  273,  291,  291,  291,  291,
+      291,  300,  300,  311,  311,  312,  312,  312,  312,  312,
+      114,  113,  110,  109,  104,  102,   99,   97,  322,   49,
+       17,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  322,  322,  322,  322,  322,  322
+    } ;
+
+static yyconst short int yy_chk[619] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    3,    3,    3,
+       11,   11,   11,   11,   19,  320,   19,   30,   11,   47,
+       30,    3,    3,   34,   11,   34,   12,   12,   12,   12,
+        3,   47,   12,    3,   12,   15,   15,   15,    3,    3,
+       12,  318,    3,    4,    4,    4,   16,   16,   16,   15,
+       35,   15,   35,   38,   44,   44,   52,    4,    4,   52,
+
+       16,   38,   16,   44,  102,   51,    4,   51,   85,    4,
+       53,   53,  102,   63,    4,    4,   63,  317,    4,    5,
+        5,    5,    5,  143,   60,   53,   60,    5,   66,   68,
+       66,    5,   68,    5,   72,    5,   72,   75,  143,   82,
+       75,   82,   84,  129,  129,   84,   85,   87,   91,   87,
+       93,   91,   93,   95,  314,   96,   95,   96,  129,  312,
+      105,  105,  115,    5,    6,    6,    6,    6,  105,  115,
+      120,  183,    6,  120,  122,  105,    6,  141,    6,  141,
+        6,  122,  127,  127,  120,  127,  183,  244,  254,  267,
+      286,  308,  305,  286,  304,  303,  302,  301,  299,  254,
+
+      297,  295,  244,  254,  267,  294,  293,  291,    6,    7,
+        7,    7,    7,  290,  289,  288,  285,    7,  284,  283,
+      282,  280,  279,    7,  278,  277,  276,  275,  273,  272,
+      271,  270,  268,  266,  265,  264,  262,  261,  259,  256,
+      250,  249,  248,  246,  245,  243,  242,  241,  240,  239,
+      237,  236,  235,    7,    7,    8,    8,    8,    8,  234,
+      233,  231,  230,    8,  229,  227,  226,  225,  224,    8,
+      223,  222,  221,  220,  219,  218,  217,  216,  215,  214,
+      212,  210,  209,  208,  207,  206,  205,  204,  203,  202,
+      201,  199,  198,  197,  196,  194,  191,  190,  189,    8,
+
+        8,    9,    9,    9,    9,    9,  188,  187,  186,    9,
+      185,  182,  181,  180,  179,    9,  178,    9,  177,    9,
+      176,  175,  174,  173,  172,  171,  170,  169,  168,  167,
+      166,  165,  164,  163,  161,  160,  159,  158,    9,  157,
+      156,  155,  154,  152,  151,    9,    9,   10,   10,   10,
+       10,   10,  150,  149,  148,   10,  147,  145,  137,  136,
+      135,   10,  134,   10,  133,   10,  132,  131,  130,  126,
+      124,  123,  121,  119,  118,  117,  116,  114,  113,  112,
+      111,  110,  109,  108,   10,  107,  106,  103,  101,   99,
+       97,   10,   10,   13,   13,   13,   13,   78,   77,   74,
+
+       58,   13,   13,   13,   57,   56,   55,   13,   14,   14,
+       14,   14,   54,   49,   46,   45,   14,   14,   14,   43,
+       42,   41,   14,  251,  251,  251,  251,  251,  251,  251,
+      251,  251,  251,  251,  251,  251,  251,  251,  251,  251,
+      251,  251,  251,  251,  251,  251,  251,  251,  251,  251,
+      251,  251,  251,  251,  251,  251,  251,  251,  251,  251,
+      251,  251,  251,  251,  251,  251,  251,  251,  251,  251,
+      323,  323,  323,  323,  323,  324,  324,  324,  324,  324,
+      325,  325,  325,  325,  325,  326,  326,  326,  326,  326,
+      327,  327,  327,  327,  327,  328,  328,  328,  328,  328,
+
+      329,  329,  329,  329,  329,  330,  330,  331,  331,  331,
+      331,  331,  332,  332,  332,  332,  332,  333,  333,  333,
+      333,  334,  334,  334,  334,  334,  335,  335,  335,  335,
+      335,  336,  336,  336,  336,  336,  337,  337,  337,  337,
+      337,  338,  338,  338,  338,  338,  339,  339,  339,  339,
+      339,  340,  340,  341,  341,  342,  342,  342,  342,  342,
+       40,   39,   37,   36,   33,   32,   29,   22,   17,    2,
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+
+      322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
+      322,  322,  322,  322,  322,  322,  322,  322
+    } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *yytext;
+#line 1 "lex.l"
+#define INITIAL 0
+#line 2 "lex.l"
+/* $Id: lex_yy.c,v 4.5 1996/04/13 04:29:18 cthuang Exp $
+ *
+ * Lexical analyzer for C function prototype generator
+ *
+ *     This is designed to parse lexically at the top level (e.g., of extern
+ *     objects such as procedures).  The corresponding yacc-grammar expects
+ *     that curly-braces (for function bodies) are recognized as a single
+ *     token, BRACES.  Similarly, square-brackets and their contents are
+ *     passed back as BRACKETS.
+ *
+ *     Assignments at the top level are data-initialization statements.
+ *     These are returned as INITIALIZER.
+ *
+ *     The logic here recognizes tokens inside curly-braces, but does not
+ *     pass them back to the grammar.
+ *
+ * Apollo extensions:
+ *     "&" is ignored when creating lint-libraries, because we ignore
+ *     expressions of all kinds.  Note that function-prototypes may use "&" to
+ *     denote reference-parameters.  By ignoring that as well, we make the
+ *     output compatible with lint (kludge).
+ *
+ *     Similarly, ignore "std_$call", since it is not compatible with lint.
+ *
+ *     CPP_INLINE handles a special case of the Apollo CC 6.7 compiler that
+ *     uses inline attribute declarations, e.g.
+ *
+ *             int     foo #attribute[aligned(1)];
+ *
+ *     In CC 6.8 this behavior is hidden by a macro.
+ *
+ * VAX/VMS extensions:
+ *     Treat the keywords 'globalref', etc., as 'extern'.
+ *
+ *     The keywords 'noshare' and 'readonly' are type-qualifiers.
+ *
+ * GCC extensions:
+ *     The keywords '__attribute__', '__inline', '__inline__', '__signed',
+ *     '__signed__'.
+ */
+
+#define        result(nn)      count(); if (!brackets && unnested()) return(nn)
+
+#define        is_IDENTIFIER       save_text_offset();\
+                           return type_of_name(yytext);
+
+#if !OPT_LINTLIBRARY
+#define gcc_attribute   absorb_special /* otherwise, we don't care */
+#endif
+
+#ifdef apollo
+#define        apollo_keyword
+#define        apollo_special  absorb_special()
+#else
+#define        apollo_keyword  is_IDENTIFIER
+#define        apollo_special  is_IDENTIFIER
+#endif
+
+#ifdef vms
+#define        vms_extern      save_text_offset(); return(T_EXTERN);
+#define        vms_keyword     save_text_offset();
+#else  /* unix */
+#define        vms_extern      is_IDENTIFIER
+#define        vms_keyword     is_IDENTIFIER
+#endif /* vms/unix */
+
+char * varargs_str;            /* save printflike/scanflike text */
+int    varargs_num;            /* code to save "VARARGS" */
+int    debug_trace;            /* true if we trace token-level stuff */
+char   base_file[BUFSIZ];      /* top-level file name */
+
+static int save_cpp;   /* true if cpp-text within curly braces */
+static int in_cpp;     /* true while we are within cpp-text */
+static int curly;      /* number of curly brace nesting levels */
+static int ly_count;   /* number of occurances of %% */
+
+#ifdef FLEX_SCANNER
+/* flex scanner state */
+static YY_BUFFER_STATE buffer_stack[MAX_INC_DEPTH];
+#endif
+
+static int inc_depth;                          /* include nesting level */
+static IncludeStack inc_stack[MAX_INC_DEPTH];  /* stack of included files */
+static SymbolTable *included_files;            /* files already included */
+
+static int  type_of_name      ARGS((char *name));
+static void startCpp          ARGS((int level));
+static void finishCpp         ARGS((void));
+#if defined(apollo) || !OPT_LINTLIBRARY
+static void absorb_special    ARGS((void));
+#endif
+#if OPT_LINTLIBRARY
+static void gcc_attribute     ARGS((void));
+#endif
+static void update_line_num   ARGS((void));
+static void save_text         ARGS((void));
+static void save_text_offset  ARGS((void));
+static void get_quoted        ARGS((void));
+static void get_comment       ARGS((void));
+static void get_cpp_directive ARGS((char *dest, unsigned n));
+static void do_include        ARGS((char *f));
+static void include_file      ARGS((char *name, int convert));
+static void put_file          ARGS((FILE *outf));
+static void put_quoted        ARGS((int c));
+
+#if OPT_LINTLIBRARY
+static int decipher_comment   ARGS((char *keyword, int len));
+#endif
+
+#ifdef yywrap
+#undef yywrap
+#endif
+int yywrap ARGS((void));
+#define CPP1 1
+#define INIT1 2
+#define INIT2 3
+#define CURLY 4
+#define LEXYACC 5
+#define ASM 6
+#define CPP_INLINE 7
+
+#line 732 "lex.yy.c"
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap YY_PROTO(( void ));
+#else
+extern int yywrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int yyinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int yy_start_stack_ptr = 0;
+static int yy_start_stack_depth = 0;
+static int *yy_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void yy_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines.  This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+       if ( yy_current_buffer->yy_is_interactive ) \
+               { \
+               int c = '*', n; \
+               for ( n = 0; n < max_size && \
+                            (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+                       buf[n] = (char) c; \
+               if ( c == '\n' ) \
+                       buf[n++] = (char) c; \
+               if ( c == EOF && ferror( yyin ) ) \
+                       YY_FATAL_ERROR( "input in flex scanner failed" ); \
+               result = n; \
+               } \
+       else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
+                 && ferror( yyin ) ) \
+               YY_FATAL_ERROR( "input in flex scanner failed" );
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int yylex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+       if ( yyleng > 0 ) \
+               yy_current_buffer->yy_at_bol = \
+                               (yytext[yyleng - 1] == '\n'); \
+       YY_USER_ACTION
+
+YY_DECL
+       {
+       register yy_state_type yy_current_state;
+       register char *yy_cp, *yy_bp;
+       register int yy_act;
+
+#line 124 "lex.l"
+
+
+#line 889 "lex.yy.c"
+
+       if ( yy_init )
+               {
+               yy_init = 0;
+
+#ifdef YY_USER_INIT
+               YY_USER_INIT;
+#endif
+
+               if ( ! yy_start )
+                       yy_start = 1;   /* first start state */
+
+               if ( ! yyin )
+                       yyin = stdin;
+
+               if ( ! yyout )
+                       yyout = stdout;
+
+               if ( ! yy_current_buffer )
+                       yy_current_buffer =
+                               yy_create_buffer( yyin, YY_BUF_SIZE );
+
+               yy_load_buffer_state();
+               }
+
+       while ( 1 )             /* loops until end-of-file is reached */
+               {
+               yy_cp = yy_c_buf_p;
+
+               /* Support of yytext. */
+               *yy_cp = yy_hold_char;
+
+               /* yy_bp points to the position in yy_ch_buf of the start of
+                * the current run.
+                */
+               yy_bp = yy_cp;
+
+               yy_current_state = yy_start;
+               yy_current_state += YY_AT_BOL();
+yy_match:
+               do
+                       {
+                       register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+                       if ( yy_accept[yy_current_state] )
+                               {
+                               yy_last_accepting_state = yy_current_state;
+                               yy_last_accepting_cpos = yy_cp;
+                               }
+                       while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+                               {
+                               yy_current_state = (int) yy_def[yy_current_state];
+                               if ( yy_current_state >= 323 )
+                                       yy_c = yy_meta[(unsigned int) yy_c];
+                               }
+                       yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+                       ++yy_cp;
+                       }
+               while ( yy_base[yy_current_state] != 571 );
+
+yy_find_action:
+               yy_act = yy_accept[yy_current_state];
+               if ( yy_act == 0 )
+                       { /* have to back up */
+                       yy_cp = yy_last_accepting_cpos;
+                       yy_current_state = yy_last_accepting_state;
+                       yy_act = yy_accept[yy_current_state];
+                       }
+
+               YY_DO_BEFORE_ACTION;
+
+
+do_action:     /* This label is used only to access EOF actions. */
+
+
+               switch ( yy_act )
+       { /* beginning of action switch */
+                       case 0: /* must back up */
+                       /* undo the effects of YY_DO_BEFORE_ACTION */
+                       *yy_cp = yy_hold_char;
+                       yy_cp = yy_last_accepting_cpos;
+                       yy_current_state = yy_last_accepting_state;
+                       goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 126 "lex.l"
+{ save_text(); cur_file->line_num++;
+                           cur_declarator = NULL; }
+       YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 129 "lex.l"
+{ save_text(); get_comment(); }
+       YY_BREAK
+case 3:
+*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
+yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 130 "lex.l"
+save_text();
+       YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 132 "lex.l"
+{ save_text(); return '&'; /* C++ ref-variable? */ }
+       YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 134 "lex.l"
+{ save_text(); if (++ly_count >= 2) BEGIN INITIAL; }
+       YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 135 "lex.l"
+{ save_text(); BEGIN INITIAL; }
+       YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 136 "lex.l"
+get_quoted();
+       YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 137 "lex.l"
+save_text();
+       YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 138 "lex.l"
+{ save_text(); BEGIN LEXYACC; }
+       YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 140 "lex.l"
+{ save_text(); startCpp(0); }
+       YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 141 "lex.l"
+{ save_text(); startCpp(0); }
+       YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 143 "lex.l"
+{ BEGIN CPP_INLINE; /* apollo */}
+       YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 144 "lex.l"
+{ BEGIN CPP_INLINE; /* apollo */}
+       YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 145 "lex.l"
+finishCpp();
+       YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 147 "lex.l"
+{
+                           char name[MAX_TEXT_SIZE], value[MAX_TEXT_SIZE];
+
+                           save_text();
+                           sscanf(yytext, "define %s", name);
+                           get_cpp_directive(buf, sizeof(buf));
+                           sscanf(buf, "%s", value);
+                           new_symbol(define_names, name, value, DS_NONE);
+                       }
+       YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 157 "lex.l"
+{
+                           save_text();
+                           get_cpp_directive(buf, sizeof(buf));
+                           if (buf[0] != '"' && buf[0] != '<') {
+                               Symbol *sym = find_symbol(define_names, buf);
+                               if (sym != NULL && sym->value != NULL) {
+                                   strcpy(buf, sym->value);
+                               } else {
+                                   buf[0] = '\0';
+                               }
+                           }
+                           if (buf[0] != '\0')
+                               do_include(buf);
+                       }
+       YY_BREAK
+case 17:
+*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
+yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 172 "lex.l"
+{
+                           save_text();
+                           sscanf(yytext, "line %d \"%[^\"]\"",
+                            &cur_file->line_num, cur_file->file_name);
+                           cur_file->line_num--;
+                           track_in();
+                           finishCpp();
+                       }
+       YY_BREAK
+case 18:
+*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
+yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 180 "lex.l"
+{
+                           save_text();
+                           sscanf(yytext, "%d \"%[^\"]\"", &cur_file->line_num,
+                            cur_file->file_name);
+                           cur_file->line_num--;
+                           track_in();
+                           finishCpp();
+                       }
+       YY_BREAK
+case 19:
+*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
+yy_c_buf_p = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 188 "lex.l"
+{
+                           save_text();
+                           sscanf(yytext, "%d ", &cur_file->line_num);
+                           cur_file->line_num--;
+                           track_in();
+                           finishCpp();
+                       }
+       YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 196 "lex.l"
+{ save_text(); get_cpp_directive(NULL, 0); }
+       YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 198 "lex.l"
+{ save_text_offset(); return '('; }
+       YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 199 "lex.l"
+{
+                           save_text();
+                           if (cur_file->convert)
+                               cur_file->begin_comment =
+                                ftell(cur_file->tmp_file);
+                           return ')';
+                       }
+       YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 206 "lex.l"
+{ save_text_offset(); return '*'; }
+       YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 207 "lex.l"
+{
+                           save_text();
+                           if (cur_file->convert)
+                               cur_file->begin_comment =
+                                ftell(cur_file->tmp_file);
+                           return yytext[0];
+                       }
+       YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 214 "lex.l"
+{ save_text(); return T_ELLIPSIS; }
+       YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 215 "lex.l"
+{
+                           get_quoted();
+                           return T_STRING_LITERAL;
+                       }
+       YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 220 "lex.l"
+{ save_text(); BEGIN ASM; return T_ASM; }
+       YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 221 "lex.l"
+save_text();
+       YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 222 "lex.l"
+{ save_text(); BEGIN INITIAL; return T_ASMARG; }
+       YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 223 "lex.l"
+get_quoted();
+       YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 224 "lex.l"
+save_text();
+       YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 226 "lex.l"
+{ save_text_offset(); return T_TYPE_QUALIFIER; }
+       YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 228 "lex.l"
+{ save_text_offset(); return T_AUTO; }
+       YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 229 "lex.l"
+{ save_text_offset(); return T_EXTERN; }
+       YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 230 "lex.l"
+{ save_text_offset(); return T_REGISTER; }
+       YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 231 "lex.l"
+{ save_text_offset(); return T_STATIC; }
+       YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 232 "lex.l"
+{ save_text_offset(); return T_TYPEDEF; }
+       YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 233 "lex.l"
+{ save_text_offset(); return T_INLINE; }
+       YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 234 "lex.l"
+{ save_text_offset(); return T_CHAR; }
+       YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 235 "lex.l"
+{ save_text_offset(); return T_DOUBLE; }
+       YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 236 "lex.l"
+{ save_text_offset(); return T_FLOAT; }
+       YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 237 "lex.l"
+{ save_text_offset(); return T_INT; }
+       YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 238 "lex.l"
+{ save_text_offset(); return T_VOID; }
+       YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 239 "lex.l"
+{ save_text_offset(); return T_LONG; }
+       YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 240 "lex.l"
+{ save_text_offset(); return T_SHORT; }
+       YY_BREAK
+case 46:
+YY_RULE_SETUP
+#line 241 "lex.l"
+{ save_text_offset(); return T_SIGNED; }
+       YY_BREAK
+case 47:
+YY_RULE_SETUP
+#line 242 "lex.l"
+{ save_text_offset(); return T_UNSIGNED; }
+       YY_BREAK
+case 48:
+YY_RULE_SETUP
+#line 243 "lex.l"
+{ save_text_offset(); return T_ENUM; }
+       YY_BREAK
+case 49:
+YY_RULE_SETUP
+#line 244 "lex.l"
+{ save_text_offset(); return T_STRUCT; }
+       YY_BREAK
+case 50:
+YY_RULE_SETUP
+#line 245 "lex.l"
+{ save_text_offset(); return T_UNION; }
+       YY_BREAK
+case 51:
+YY_RULE_SETUP
+#line 246 "lex.l"
+{ save_text_offset(); return T_VA_DCL; }
+       YY_BREAK
+case 52:
+YY_RULE_SETUP
+#line 248 "lex.l"
+{ save_text_offset(); return T_SIGNED; }
+       YY_BREAK
+case 53:
+YY_RULE_SETUP
+#line 249 "lex.l"
+{ save_text_offset(); return T_SIGNED; }
+       YY_BREAK
+case 54:
+YY_RULE_SETUP
+#line 250 "lex.l"
+{ save_text_offset(); return T_INLINE; }
+       YY_BREAK
+case 55:
+YY_RULE_SETUP
+#line 251 "lex.l"
+{ save_text_offset(); return T_INLINE; }
+       YY_BREAK
+case 56:
+YY_RULE_SETUP
+#line 252 "lex.l"
+{ gcc_attribute(); }
+       YY_BREAK
+case 57:
+YY_RULE_SETUP
+#line 254 "lex.l"
+{ vms_extern; }
+       YY_BREAK
+case 58:
+YY_RULE_SETUP
+#line 255 "lex.l"
+{ vms_extern; }
+       YY_BREAK
+case 59:
+YY_RULE_SETUP
+#line 256 "lex.l"
+{ vms_extern; }
+       YY_BREAK
+case 60:
+YY_RULE_SETUP
+#line 258 "lex.l"
+{ apollo_keyword; }
+       YY_BREAK
+case 61:
+YY_RULE_SETUP
+#line 259 "lex.l"
+{ apollo_special; }
+       YY_BREAK
+case 62:
+YY_RULE_SETUP
+#line 261 "lex.l"
+{ is_IDENTIFIER }
+       YY_BREAK
+case 63:
+YY_RULE_SETUP
+#line 263 "lex.l"
+{
+                           /* This can't handle the case where a comment
+                            * containing a ] appears between the brackets.
+                            */
+                           save_text_offset();
+                           update_line_num();
+                           return T_BRACKETS;
+                       }
+       YY_BREAK
+case 64:
+YY_RULE_SETUP
+#line 271 "lex.l"
+{
+                           save_text_offset();
+                           update_line_num();
+                           return T_BRACKETS;
+                       }
+       YY_BREAK
+case 65:
+YY_RULE_SETUP
+#line 277 "lex.l"
+{ save_text(); BEGIN INIT1; return '='; }
+       YY_BREAK
+case 66:
+YY_RULE_SETUP
+#line 278 "lex.l"
+{ save_text(); curly = 1; BEGIN INIT2; }
+       YY_BREAK
+case 67:
+YY_RULE_SETUP
+#line 279 "lex.l"
+{
+                           unput(yytext[yyleng-1]);
+                           BEGIN INITIAL;
+                           return T_INITIALIZER;
+                       }
+       YY_BREAK
+case 68:
+YY_RULE_SETUP
+#line 284 "lex.l"
+get_quoted();
+       YY_BREAK
+case 69:
+YY_RULE_SETUP
+#line 285 "lex.l"
+save_text();
+       YY_BREAK
+case 70:
+YY_RULE_SETUP
+#line 287 "lex.l"
+{ save_text(); ++curly; }
+       YY_BREAK
+case 71:
+YY_RULE_SETUP
+#line 288 "lex.l"
+{
+                           save_text();
+                           if (--curly == 0) {
+                               BEGIN INITIAL;
+                               return T_INITIALIZER;
+                           }
+                       }
+       YY_BREAK
+case 72:
+YY_RULE_SETUP
+#line 295 "lex.l"
+get_quoted();
+       YY_BREAK
+case 73:
+YY_RULE_SETUP
+#line 296 "lex.l"
+save_text();
+       YY_BREAK
+case 74:
+YY_RULE_SETUP
+#line 298 "lex.l"
+{
+                           save_text();
+                           curly = 1;
+                           return_val =
+                           returned_at = FALSE;
+                           BEGIN CURLY;
+                           return T_LBRACE;
+                       }
+       YY_BREAK
+case 75:
+YY_RULE_SETUP
+#line 306 "lex.l"
+{ save_text(); ++curly; }
+       YY_BREAK
+case 76:
+YY_RULE_SETUP
+#line 307 "lex.l"
+{
+                           save_text();
+                           if (--curly == 0) {
+                               BEGIN INITIAL;
+                               return T_MATCHRBRACE;
+                           }
+                       }
+       YY_BREAK
+case 77:
+YY_RULE_SETUP
+#line 314 "lex.l"
+get_quoted();
+       YY_BREAK
+case 78:
+YY_RULE_SETUP
+#line 315 "lex.l"
+{ save_text(); returned_at = TRUE; }
+       YY_BREAK
+case 79:
+YY_RULE_SETUP
+#line 316 "lex.l"
+{ save_text(); returned_at = FALSE; }
+       YY_BREAK
+case 80:
+YY_RULE_SETUP
+#line 317 "lex.l"
+{ save_text(); startCpp(1); }
+       YY_BREAK
+case 81:
+YY_RULE_SETUP
+#line 318 "lex.l"
+{ save_text(); startCpp(1); }
+       YY_BREAK
+case 82:
+YY_RULE_SETUP
+#line 319 "lex.l"
+{ save_text(); return_val |= returned_at; }
+       YY_BREAK
+case 83:
+YY_RULE_SETUP
+#line 321 "lex.l"
+save_text();
+       YY_BREAK
+case 84:
+YY_RULE_SETUP
+#line 322 "lex.l"
+{
+                           save_text();
+                           put_error();
+                           fprintf(stderr, "bad character '%c'\n", yytext[0]);
+                       }
+       YY_BREAK
+case 85:
+YY_RULE_SETUP
+#line 327 "lex.l"
+ECHO;
+       YY_BREAK
+#line 1505 "lex.yy.c"
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(CPP1):
+case YY_STATE_EOF(INIT1):
+case YY_STATE_EOF(INIT2):
+case YY_STATE_EOF(CURLY):
+case YY_STATE_EOF(LEXYACC):
+case YY_STATE_EOF(ASM):
+case YY_STATE_EOF(CPP_INLINE):
+       yyterminate();
+
+       case YY_END_OF_BUFFER:
+               {
+               /* Amount of text matched not including the EOB char. */
+               int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+
+               /* Undo the effects of YY_DO_BEFORE_ACTION. */
+               *yy_cp = yy_hold_char;
+               YY_RESTORE_YY_MORE_OFFSET
+
+               if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+                       {
+                       /* We're scanning a new file or input source.  It's
+                        * possible that this happened because the user
+                        * just pointed yyin at a new source and called
+                        * yylex().  If so, then we have to assure
+                        * consistency between yy_current_buffer and our
+                        * globals.  Here is the right place to do so, because
+                        * this is the first action (other than possibly a
+                        * back-up) that will match for the new input source.
+                        */
+                       yy_n_chars = yy_current_buffer->yy_n_chars;
+                       yy_current_buffer->yy_input_file = yyin;
+                       yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+                       }
+
+               /* Note that here we test for yy_c_buf_p "<=" to the position
+                * of the first EOB in the buffer, since yy_c_buf_p will
+                * already have been incremented past the NUL character
+                * (since all states make transitions on EOB to the
+                * end-of-buffer state).  Contrast this with the test
+                * in input().
+                */
+               if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+                       { /* This was really a NUL. */
+                       yy_state_type yy_next_state;
+
+                       yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+
+                       yy_current_state = yy_get_previous_state();
+
+                       /* Okay, we're now positioned to make the NUL
+                        * transition.  We couldn't have
+                        * yy_get_previous_state() go ahead and do it
+                        * for us because it doesn't know how to deal
+                        * with the possibility of jamming (and we don't
+                        * want to build jamming into it because then it
+                        * will run more slowly).
+                        */
+
+                       yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+                       yy_bp = yytext_ptr + YY_MORE_ADJ;
+
+                       if ( yy_next_state )
+                               {
+                               /* Consume the NUL. */
+                               yy_cp = ++yy_c_buf_p;
+                               yy_current_state = yy_next_state;
+                               goto yy_match;
+                               }
+
+                       else
+                               {
+                               yy_cp = yy_c_buf_p;
+                               goto yy_find_action;
+                               }
+                       }
+
+               else switch ( yy_get_next_buffer() )
+                       {
+                       case EOB_ACT_END_OF_FILE:
+                               {
+                               yy_did_buffer_switch_on_eof = 0;
+
+                               if ( yywrap() )
+                                       {
+                                       /* Note: because we've taken care in
+                                        * yy_get_next_buffer() to have set up
+                                        * yytext, we can now set up
+                                        * yy_c_buf_p so that if some total
+                                        * hoser (like flex itself) wants to
+                                        * call the scanner after we return the
+                                        * YY_NULL, it'll still work - another
+                                        * YY_NULL will get returned.
+                                        */
+                                       yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+
+                                       yy_act = YY_STATE_EOF(YY_START);
+                                       goto do_action;
+                                       }
+
+                               else
+                                       {
+                                       if ( ! yy_did_buffer_switch_on_eof )
+                                               YY_NEW_FILE;
+                                       }
+                               break;
+                               }
+
+                       case EOB_ACT_CONTINUE_SCAN:
+                               yy_c_buf_p =
+                                       yytext_ptr + yy_amount_of_matched_text;
+
+                               yy_current_state = yy_get_previous_state();
+
+                               yy_cp = yy_c_buf_p;
+                               yy_bp = yytext_ptr + YY_MORE_ADJ;
+                               goto yy_match;
+
+                       case EOB_ACT_LAST_MATCH:
+                               yy_c_buf_p =
+                               &yy_current_buffer->yy_ch_buf[yy_n_chars];
+
+                               yy_current_state = yy_get_previous_state();
+
+                               yy_cp = yy_c_buf_p;
+                               yy_bp = yytext_ptr + YY_MORE_ADJ;
+                               goto yy_find_action;
+                       }
+               break;
+               }
+
+       default:
+               YY_FATAL_ERROR(
+                       "fatal flex scanner internal error--no action found" );
+       } /* end of action switch */
+               } /* end of scanning one token */
+       } /* end of yylex */
+
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *     EOB_ACT_LAST_MATCH -
+ *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *     EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int yy_get_next_buffer()
+       {
+       register char *dest = yy_current_buffer->yy_ch_buf;
+       register char *source = yytext_ptr;
+       register int number_to_move, i;
+       int ret_val;
+
+       if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+               YY_FATAL_ERROR(
+               "fatal flex scanner internal error--end of buffer missed" );
+
+       if ( yy_current_buffer->yy_fill_buffer == 0 )
+               { /* Don't try to fill the buffer, so this is an EOF. */
+               if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+                       {
+                       /* We matched a single character, the EOB, so
+                        * treat this as a final EOF.
+                        */
+                       return EOB_ACT_END_OF_FILE;
+                       }
+
+               else
+                       {
+                       /* We matched some text prior to the EOB, first
+                        * process it.
+                        */
+                       return EOB_ACT_LAST_MATCH;
+                       }
+               }
+
+       /* Try to read more data. */
+
+       /* First move last chars to start of buffer. */
+       number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+
+       for ( i = 0; i < number_to_move; ++i )
+               *(dest++) = *(source++);
+
+       if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+               /* don't do the read, it's not guaranteed to return an EOF,
+                * just force an EOF
+                */
+               yy_n_chars = 0;
+
+       else
+               {
+               int num_to_read =
+                       yy_current_buffer->yy_buf_size - number_to_move - 1;
+
+               while ( num_to_read <= 0 )
+                       { /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+                       YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+                       /* just a shorter name for the current buffer */
+                       YY_BUFFER_STATE b = yy_current_buffer;
+
+                       int yy_c_buf_p_offset =
+                               (int) (yy_c_buf_p - b->yy_ch_buf);
+
+                       if ( b->yy_is_our_buffer )
+                               {
+                               int new_size = b->yy_buf_size * 2;
+
+                               if ( new_size <= 0 )
+                                       b->yy_buf_size += b->yy_buf_size / 8;
+                               else
+                                       b->yy_buf_size *= 2;
+
+                               b->yy_ch_buf = (char *)
+                                       /* Include room in for 2 EOB chars. */
+                                       yy_flex_realloc( (void *) b->yy_ch_buf,
+                                                        b->yy_buf_size + 2 );
+                               }
+                       else
+                               /* Can't grow it, we don't own it. */
+                               b->yy_ch_buf = 0;
+
+                       if ( ! b->yy_ch_buf )
+                               YY_FATAL_ERROR(
+                               "fatal error - scanner input buffer overflow" );
+
+                       yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+                       num_to_read = yy_current_buffer->yy_buf_size -
+                                               number_to_move - 1;
+#endif
+                       }
+
+               if ( num_to_read > YY_READ_BUF_SIZE )
+                       num_to_read = YY_READ_BUF_SIZE;
+
+               /* Read in more data. */
+               YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+                       yy_n_chars, num_to_read );
+               }
+
+       if ( yy_n_chars == 0 )
+               {
+               if ( number_to_move == YY_MORE_ADJ )
+                       {
+                       ret_val = EOB_ACT_END_OF_FILE;
+                       yyrestart( yyin );
+                       }
+
+               else
+                       {
+                       ret_val = EOB_ACT_LAST_MATCH;
+                       yy_current_buffer->yy_buffer_status =
+                               YY_BUFFER_EOF_PENDING;
+                       }
+               }
+
+       else
+               ret_val = EOB_ACT_CONTINUE_SCAN;
+
+       yy_n_chars += number_to_move;
+       yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+       yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+       yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+
+       return ret_val;
+       }
+
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+static yy_state_type yy_get_previous_state()
+       {
+       register yy_state_type yy_current_state;
+       register char *yy_cp;
+
+       yy_current_state = yy_start;
+       yy_current_state += YY_AT_BOL();
+
+       for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+               {
+               register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+               if ( yy_accept[yy_current_state] )
+                       {
+                       yy_last_accepting_state = yy_current_state;
+                       yy_last_accepting_cpos = yy_cp;
+                       }
+               while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+                       {
+                       yy_current_state = (int) yy_def[yy_current_state];
+                       if ( yy_current_state >= 323 )
+                               yy_c = yy_meta[(unsigned int) yy_c];
+                       }
+               yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+               }
+
+       return yy_current_state;
+       }
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *     next_state = yy_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+#else
+static yy_state_type yy_try_NUL_trans( yy_current_state )
+yy_state_type yy_current_state;
+#endif
+       {
+       register int yy_is_jam;
+       register char *yy_cp = yy_c_buf_p;
+
+       register YY_CHAR yy_c = 1;
+       if ( yy_accept[yy_current_state] )
+               {
+               yy_last_accepting_state = yy_current_state;
+               yy_last_accepting_cpos = yy_cp;
+               }
+       while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+               {
+               yy_current_state = (int) yy_def[yy_current_state];
+               if ( yy_current_state >= 323 )
+                       yy_c = yy_meta[(unsigned int) yy_c];
+               }
+       yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+       yy_is_jam = (yy_current_state == 322);
+
+       return yy_is_jam ? 0 : yy_current_state;
+       }
+
+
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void yyunput( int c, register char *yy_bp )
+#else
+static void yyunput( c, yy_bp )
+int c;
+register char *yy_bp;
+#endif
+       {
+       register char *yy_cp = yy_c_buf_p;
+
+       /* undo effects of setting up yytext */
+       *yy_cp = yy_hold_char;
+
+       if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+               { /* need to shift things up to make room */
+               /* +2 for EOB chars. */
+               register int number_to_move = yy_n_chars + 2;
+               register char *dest = &yy_current_buffer->yy_ch_buf[
+                                       yy_current_buffer->yy_buf_size + 2];
+               register char *source =
+                               &yy_current_buffer->yy_ch_buf[number_to_move];
+
+               while ( source > yy_current_buffer->yy_ch_buf )
+                       *--dest = *--source;
+
+               yy_cp += (int) (dest - source);
+               yy_bp += (int) (dest - source);
+               yy_n_chars = yy_current_buffer->yy_buf_size;
+
+               if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+                       YY_FATAL_ERROR( "flex scanner push-back overflow" );
+               }
+
+       *--yy_cp = (char) c;
+
+
+       yytext_ptr = yy_bp;
+       yy_hold_char = *yy_cp;
+       yy_c_buf_p = yy_cp;
+       }
+#endif /* ifndef YY_NO_UNPUT */
+
+
+#ifdef __cplusplus
+static int yyinput()
+#else
+static int input()
+#endif
+       {
+       int c;
+
+       *yy_c_buf_p = yy_hold_char;
+
+       if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+               {
+               /* yy_c_buf_p now points to the character we want to return.
+                * If this occurs *before* the EOB characters, then it's a
+                * valid NUL; if not, then we've hit the end of the buffer.
+                */
+               if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+                       /* This was really a NUL. */
+                       *yy_c_buf_p = '\0';
+
+               else
+                       { /* need more input */
+                       int offset = yy_c_buf_p - yytext_ptr;
+                       ++yy_c_buf_p;
+
+                       switch ( yy_get_next_buffer() )
+                               {
+                               case EOB_ACT_END_OF_FILE:
+                                       {
+                                       if ( yywrap() )
+                                               {
+                                               yy_c_buf_p = yytext_ptr + offset;
+                                               return EOF;
+                                               }
+
+                                       if ( ! yy_did_buffer_switch_on_eof )
+                                               YY_NEW_FILE;
+#ifdef __cplusplus
+                                       return yyinput();
+#else
+                                       return input();
+#endif
+                                       }
+
+                               case EOB_ACT_CONTINUE_SCAN:
+                                       yy_c_buf_p = yytext_ptr + offset;
+                                       break;
+
+                               case EOB_ACT_LAST_MATCH:
+#ifdef __cplusplus
+                                       YY_FATAL_ERROR(
+                                       "unexpected last match in yyinput()" );
+#else
+                                       YY_FATAL_ERROR(
+                                       "unexpected last match in input()" );
+#endif
+                               }
+                       }
+               }
+
+       c = *(unsigned char *) yy_c_buf_p;      /* cast for 8-bit char's */
+       *yy_c_buf_p = '\0';     /* preserve yytext */
+       yy_hold_char = *++yy_c_buf_p;
+
+       yy_current_buffer->yy_at_bol = (c == '\n');
+
+       return c;
+       }
+
+
+#ifdef YY_USE_PROTOS
+void yyrestart( FILE *input_file )
+#else
+void yyrestart( input_file )
+FILE *input_file;
+#endif
+       {
+       if ( ! yy_current_buffer )
+               yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+
+       yy_init_buffer( yy_current_buffer, input_file );
+       yy_load_buffer_state();
+       }
+
+
+#ifdef YY_USE_PROTOS
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void yy_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+       {
+       if ( yy_current_buffer == new_buffer )
+               return;
+
+       if ( yy_current_buffer )
+               {
+               /* Flush out information for old buffer. */
+               *yy_c_buf_p = yy_hold_char;
+               yy_current_buffer->yy_buf_pos = yy_c_buf_p;
+               yy_current_buffer->yy_n_chars = yy_n_chars;
+               }
+
+       yy_current_buffer = new_buffer;
+       yy_load_buffer_state();
+
+       /* We don't actually know whether we did this switch during
+        * EOF (yywrap()) processing, but the only time this flag
+        * is looked at is after yywrap() is called, so it's safe
+        * to go ahead and always set it.
+        */
+       yy_did_buffer_switch_on_eof = 1;
+       }
+
+
+#ifdef YY_USE_PROTOS
+void yy_load_buffer_state( void )
+#else
+void yy_load_buffer_state()
+#endif
+       {
+       yy_n_chars = yy_current_buffer->yy_n_chars;
+       yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
+       yyin = yy_current_buffer->yy_input_file;
+       yy_hold_char = *yy_c_buf_p;
+       }
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE yy_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+       {
+       YY_BUFFER_STATE b;
+
+       b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+       if ( ! b )
+               YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+       b->yy_buf_size = size;
+
+       /* yy_ch_buf has to be 2 characters longer than the size given because
+        * we need to put in 2 end-of-buffer characters.
+        */
+       b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+       if ( ! b->yy_ch_buf )
+               YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+       b->yy_is_our_buffer = 1;
+
+       yy_init_buffer( b, file );
+
+       return b;
+       }
+
+
+#ifdef YY_USE_PROTOS
+void yy_delete_buffer( YY_BUFFER_STATE b )
+#else
+void yy_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+       {
+       if ( ! b )
+               return;
+
+       if ( b == yy_current_buffer )
+               yy_current_buffer = (YY_BUFFER_STATE) 0;
+
+       if ( b->yy_is_our_buffer )
+               yy_flex_free( (void *) b->yy_ch_buf );
+
+       yy_flex_free( (void *) b );
+       }
+
+
+#ifndef YY_ALWAYS_INTERACTIVE
+#ifndef YY_NEVER_INTERACTIVE
+extern int isatty YY_PROTO(( int ));
+#endif
+#endif
+
+#ifdef YY_USE_PROTOS
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void yy_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+       {
+       yy_flush_buffer( b );
+
+       b->yy_input_file = file;
+       b->yy_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+       b->yy_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+       b->yy_is_interactive = 0;
+#else
+       b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+       }
+
+
+#ifdef YY_USE_PROTOS
+void yy_flush_buffer( YY_BUFFER_STATE b )
+#else
+void yy_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+       {
+       b->yy_n_chars = 0;
+
+       /* We always need two end-of-buffer characters.  The first causes
+        * a transition to the end-of-buffer state.  The second causes
+        * a jam in that state.
+        */
+       b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+       b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+       b->yy_buf_pos = &b->yy_ch_buf[0];
+
+       b->yy_at_bol = 1;
+       b->yy_buffer_status = YY_BUFFER_NEW;
+
+       if ( b == yy_current_buffer )
+               yy_load_buffer_state();
+       }
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+#else
+YY_BUFFER_STATE yy_scan_buffer( base, size )
+char *base;
+yy_size_t size;
+#endif
+       {
+       YY_BUFFER_STATE b;
+
+       if ( size < 2 ||
+            base[size-2] != YY_END_OF_BUFFER_CHAR ||
+            base[size-1] != YY_END_OF_BUFFER_CHAR )
+               /* They forgot to leave room for the EOB's. */
+               return 0;
+
+       b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+       if ( ! b )
+               YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+       b->yy_buf_size = size - 2;      /* "- 2" to take care of EOB's */
+       b->yy_buf_pos = b->yy_ch_buf = base;
+       b->yy_is_our_buffer = 0;
+       b->yy_input_file = 0;
+       b->yy_n_chars = b->yy_buf_size;
+       b->yy_is_interactive = 0;
+       b->yy_at_bol = 1;
+       b->yy_fill_buffer = 0;
+       b->yy_buffer_status = YY_BUFFER_NEW;
+
+       yy_switch_to_buffer( b );
+
+       return b;
+       }
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_string( yyconst char *str )
+#else
+YY_BUFFER_STATE yy_scan_string( str )
+yyconst char *str;
+#endif
+       {
+       int len;
+       for ( len = 0; str[len]; ++len )
+               ;
+
+       return yy_scan_bytes( str, len );
+       }
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+#else
+YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+yyconst char *bytes;
+int len;
+#endif
+       {
+       YY_BUFFER_STATE b;
+       char *buf;
+       yy_size_t n;
+       int i;
+
+       /* Get memory for full buffer, including space for trailing EOB's. */
+       n = len + 2;
+       buf = (char *) yy_flex_alloc( n );
+       if ( ! buf )
+               YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+       for ( i = 0; i < len; ++i )
+               buf[i] = bytes[i];
+
+       buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+       b = yy_scan_buffer( buf, n );
+       if ( ! b )
+               YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+       /* It's okay to grow etc. this buffer, and we should throw it
+        * away when we're done.
+        */
+       b->yy_is_our_buffer = 1;
+
+       return b;
+       }
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void yy_push_state( int new_state )
+#else
+static void yy_push_state( new_state )
+int new_state;
+#endif
+       {
+       if ( yy_start_stack_ptr >= yy_start_stack_depth )
+               {
+               yy_size_t new_size;
+
+               yy_start_stack_depth += YY_START_STACK_INCR;
+               new_size = yy_start_stack_depth * sizeof( int );
+
+               if ( ! yy_start_stack )
+                       yy_start_stack = (int *) yy_flex_alloc( new_size );
+
+               else
+                       yy_start_stack = (int *) yy_flex_realloc(
+                                       (void *) yy_start_stack, new_size );
+
+               if ( ! yy_start_stack )
+                       YY_FATAL_ERROR(
+                       "out of memory expanding start-condition stack" );
+               }
+
+       yy_start_stack[yy_start_stack_ptr++] = YY_START;
+
+       BEGIN(new_state);
+       }
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state()
+       {
+       if ( --yy_start_stack_ptr < 0 )
+               YY_FATAL_ERROR( "start-condition stack underflow" );
+
+       BEGIN(yy_start_stack[yy_start_stack_ptr]);
+       }
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state()
+       {
+       return yy_start_stack[yy_start_stack_ptr - 1];
+       }
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void yy_fatal_error( yyconst char msg[] )
+#else
+static void yy_fatal_error( msg )
+char msg[];
+#endif
+       {
+       (void) fprintf( stderr, "%s\n", msg );
+       exit( YY_EXIT_FAILURE );
+       }
+
+
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+       do \
+               { \
+               /* Undo effects of setting up yytext. */ \
+               yytext[yyleng] = yy_hold_char; \
+               yy_c_buf_p = yytext + n; \
+               yy_hold_char = *yy_c_buf_p; \
+               *yy_c_buf_p = '\0'; \
+               yyleng = n; \
+               } \
+       while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef yytext_ptr
+#ifdef YY_USE_PROTOS
+static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
+#else
+static void yy_flex_strncpy( s1, s2, n )
+char *s1;
+yyconst char *s2;
+int n;
+#endif
+       {
+       register int i;
+       for ( i = 0; i < n; ++i )
+               s1[i] = s2[i];
+       }
+#endif
+
+#ifdef YY_NEED_STRLEN
+#ifdef YY_USE_PROTOS
+static int yy_flex_strlen( yyconst char *s )
+#else
+static int yy_flex_strlen( s )
+yyconst char *s;
+#endif
+       {
+       register int n;
+       for ( n = 0; s[n]; ++n )
+               ;
+
+       return n;
+       }
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_alloc( yy_size_t size )
+#else
+static void *yy_flex_alloc( size )
+yy_size_t size;
+#endif
+       {
+       return (void *) malloc( size );
+       }
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_realloc( void *ptr, yy_size_t size )
+#else
+static void *yy_flex_realloc( ptr, size )
+void *ptr;
+yy_size_t size;
+#endif
+       {
+       /* The cast to (char *) in the following accommodates both
+        * implementations that use char* generic pointers, and those
+        * that use void* generic pointers.  It works with the latter
+        * because both ANSI C and C++ allow castless assignment from
+        * any pointer type to void*, and deal with argument conversions
+        * as though doing an assignment.
+        */
+       return (void *) realloc( (char *) ptr, size );
+       }
+
+#ifdef YY_USE_PROTOS
+static void yy_flex_free( void *ptr )
+#else
+static void yy_flex_free( ptr )
+void *ptr;
+#endif
+       {
+       free( ptr );
+       }
+
+#if YY_MAIN
+int main()
+       {
+       yylex();
+       return 0;
+       }
+#endif
+#line 327 "lex.l"
+
+
+static void
+startCpp (level)
+int level;
+{
+    save_cpp = level;
+    in_cpp = TRUE;
+    BEGIN CPP1;
+}
+
+static void
+finishCpp()
+{
+    in_cpp = FALSE;
+    if (save_cpp)
+       BEGIN CURLY;
+    else
+       BEGIN INITIAL;
+}
+
+/*
+ * Skip over embedded __attribute/__attribute_ syntax.
+ */
+#if defined(apollo) || !OPT_LINTLIBRARY
+static void
+absorb_special ()
+{
+    int        c;
+    int        nest    = 0;
+    while ((c = input()) > 0) {
+       if (c == '(')
+           nest++;
+       else if (c == ')') {
+           if (--nest <= 0)
+               break;
+       }
+    }
+}
+#endif
+
+#if OPT_LINTLIBRARY
+/*
+ * This recognizes some of the special attribute macros defined by gcc:
+ *     noreturn
+ *     format(printf,n,m)
+ *     format(scanf,n,m)
+ * and uses that information to construct equivalent lint-library text.
+ * (It's a distinct piece of code from the 'absorb_special()' function to
+ * avoid spurious matches with non-gcc compilers).
+ */
+static void
+gcc_attribute ()
+{
+    int        c, num1, num2;
+    int        nest = 0;
+    int        len = 0;
+    char bfr[BUFSIZ];
+
+    while ((c = input()) > 0) {
+       if (len < sizeof(bfr)-1 && !isspace(c))
+           bfr[len++] = c;
+       if (c == '(')
+           nest++;
+       else if (c == ')') {
+           if (--nest <= 0)
+               break;
+       }
+    }
+    bfr[len] = '\0';
+    if (!strcmp(bfr, "((noreturn))")) {
+       exitlike_func = TRUE;
+    } else if (sscanf(bfr, "((format(printf,%d,%d)))", &num1, &num2) == 2) {
+       (void)sprintf(bfr, "PRINTFLIKE%d", varargs_num = num1);
+       varargs_str = xstrdup(bfr);
+    } else if (sscanf(bfr, "((format(scanf,%d,%d)))", &num1, &num2) == 2) {
+       (void)sprintf(bfr, "SCANFLIKE%d", varargs_num = num1);
+       varargs_str = xstrdup(bfr);
+    }
+}
+#endif
+
+/* Decode the current token according to the type-of-name
+ */
+static int
+type_of_name (name)
+char *name;
+{
+    if (find_symbol(type_qualifiers, name) != NULL)
+       return T_TYPE_QUALIFIER;
+    else if (find_symbol(typedef_names, name) != NULL)
+       return T_TYPEDEF_NAME;
+    else if (find_symbol(define_names, name) != NULL)
+       return T_DEFINE_NAME;
+    else
+       return T_IDENTIFIER;
+}
+
+boolean
+is_typedef_name (name)
+char *name;
+{
+    return (find_symbol(typedef_names, name) != NULL);
+}
+
+/* If the matched text contains any new line characters, then update the
+ * current line number.
+ */
+static void
+update_line_num ()
+{
+    char *p = yytext;
+    while (*p != '\0') {
+       if (*p++ == '\n')
+           cur_file->line_num++;
+    }
+}
+
+/* Save the matched text in the temporary file.
+ */
+static void
+save_text ()
+{
+#if OPT_LINTLIBRARY
+    if (!in_cpp)
+       copy_typedef(yytext);
+#endif 
+    if (cur_file->convert) {
+       fputs(yytext, cur_file->tmp_file);
+    }
+}
+
+/* Record the current position in the temporary file and write the matched text
+ * to the file.
+ */
+static void
+save_text_offset ()
+{
+    (void)strcpy(yylval.text.text, yytext);
+#if OPT_LINTLIBRARY
+    copy_typedef(yytext);
+#endif
+    if (cur_file->convert) {
+       yylval.text.begin = ftell(cur_file->tmp_file);
+       fputs(yytext, cur_file->tmp_file);
+    } else
+       yylval.text.begin = 0;
+}
+
+#if OPT_LINTLIBRARY
+/* Decipher comments that are useful for lint (and making lint-libraries)
+ */
+static struct {
+    int        varText;
+    int        varargs;
+    int        externs;
+    int        preproz;
+} cmtVal;
+
+static int
+decipher_comment (keyword, len)
+char *keyword;
+int len;
+{
+    if (len != 0) {
+       int value;
+       keyword[len] = '\0';
+
+       /* these are recognized by some lint-programs */
+       if (!strcmp(keyword, "VARARGS")) {
+           cmtVal.varargs = -1;
+       } else if (sscanf(keyword, "VARARGS%d", &value) == 1) {
+           cmtVal.varargs = value;
+       } else if (!strcmp(keyword, "PRINTFLIKE")) {
+           cmtVal.varargs = 1;
+           cmtVal.varText = TRUE;
+       } else if (sscanf(keyword, "PRINTFLIKE%d", &value) == 1) {
+           cmtVal.varargs = value;
+           cmtVal.varText = TRUE;
+       } else if (!strcmp(keyword, "SCANFLIKE")) {
+           cmtVal.varargs = 2;
+           cmtVal.varText = TRUE;
+       } else if (sscanf(keyword, "SCANFLIKE%d", &value) == 1) {
+           cmtVal.varargs = value;
+           cmtVal.varText = TRUE;
+       /* these are extensions added to simplify library-generation */
+       } else if (!strcmp(keyword, "LINT_EXTERN")) {
+           cmtVal.externs = MAX_INC_DEPTH;
+       } else if (sscanf(keyword, "LINT_EXTERN%d", &value) == 1) {
+           cmtVal.externs = value;
+       } else if (!strcmp(keyword, "LINT_PREPRO")) {
+           cmtVal.preproz = -1;        /* the whole comment */
+       } else if (sscanf(keyword, "LINT_PREPRO%d", &value) == 1) {
+           cmtVal.preproz = value;
+       } else if (!strcmp(keyword, "LINT_SHADOWED")) {
+           lint_shadowed = TRUE;
+       }
+    }
+    return 0;
+}
+#endif
+
+static void
+put_quoted (c)
+int c;
+{
+    /* Modifying 'yytext[]' doesn't work well with FLEX, which simply
+     * maintains 'yytext' as a pointer into its input buffer.  LEX copies
+     * characters into the 'yytext[]' array.
+     */
+#if defined(FLEX_SCANNER) || !defined(YYLMAX)
+    if (c != 0) {
+       static char     temp[2];
+       temp[0] = c;
+       /* save_text */
+# if OPT_LINTLIBRARY
+       if (!in_cpp)
+           copy_typedef(temp);
+# endif        
+       if (cur_file->convert) {
+           fputs(temp, cur_file->tmp_file);
+       }
+       /* update_line_num */
+       if (c == '\n')
+           cur_file->line_num++;
+    }
+
+#else  /* this works fine on LEX (e.g., on SunOS 4.x) */
+
+    if ((c == 0) || (yyleng+1 >= YYLMAX)) {
+       save_text();
+       update_line_num();
+       yyleng = 0;
+    }
+    if (c != 0) {
+       yytext[yyleng++] = c;
+       yytext[yyleng] = 0;
+    }
+#endif /* LEX/FLEX */
+}
+
+/*
+ * Scan past the characters in a backslash sequence
+ */
+/* Scan past quoted string.  Note that some strings may overflow 'yytext[]', so
+ * we don't try to eat them in the lexical rules.
+ */
+static void
+get_quoted ()
+{
+    int        delim = *yytext;
+    int        c;
+
+#if defined(FLEX_SCANNER) || !defined(YYLMAX)
+    put_quoted(delim);
+#endif
+    while ((c = input()) != 0) {
+       if (c == '\\') {
+           put_quoted(c);
+           if ((c = input()) == 0)
+               break;
+           put_quoted(c);
+       } else {
+           put_quoted(c);
+           if (c == delim)
+               break;
+           if (c == '\n') {    /* recover from unbalanced */
+               put_error();
+               fprintf(stderr, "unbalanced quote character '%c'\n", delim);
+               break;
+           }
+       }
+    }
+    put_quoted(0);
+}
+
+/* Scan to end of comment.
+ */
+static void
+get_comment ()
+{
+    int c, lastc = '\0';
+
+#if OPT_LINTLIBRARY
+    int len = 0;
+    char keyword[BUFSIZ];
+
+    keyword[len] = '\0';
+    cmtVal.varText = 0;
+    cmtVal.varargs = 0;
+    cmtVal.externs = -1;
+    cmtVal.preproz = 0;
+#endif
+
+    while ((c = input()) != 0) {
+       if (cur_file->convert)
+           fputc(c, cur_file->tmp_file);
+
+#if OPT_LINTLIBRARY
+       if (!(isalnum(c) || c == '_' || c == '$')) {
+           int flag = cmtVal.preproz;
+           len = decipher_comment(keyword, len);
+           if (flag != cmtVal.preproz)
+               lastc = '\0';
+       } else if (len+1 < sizeof(keyword)) {
+           keyword[len++] = c;
+       }
+#endif
+
+       switch (c) {
+       case '\n':
+           cur_file->line_num++;
+#if OPT_LINTLIBRARY
+           if (cmtVal.preproz != 0 && lastc != '\0')
+               fputc(lastc, stdout); 
+           if (cmtVal.preproz > 0)     /* if negative, we pass everything */
+               cmtVal.preproz -= 1;
+#endif
+           break;
+       case '/':
+           if (lastc == '*') {
+               if (cur_file->convert) {
+                   if (func_params && cur_declarator) {
+                       cur_declarator->begin_comment = cur_file->begin_comment;
+                       cur_file->begin_comment = ftell(cur_file->tmp_file);
+                       cur_declarator->end_comment = cur_file->begin_comment;
+                       cur_declarator = NULL;
+                   } else {
+                       cur_file->end_comment = ftell(cur_file->tmp_file);
+                   }
+               }
+#if OPT_LINTLIBRARY
+               (void)decipher_comment(keyword, len);
+               if (cmtVal.varargs != 0) {
+                   if ((varargs_num = cmtVal.varargs) != 0
+                    && cmtVal.varText != 0) {
+                       if (varargs_str != 0)
+                           free(varargs_str);
+                       varargs_str = xstrdup(keyword);
+                   }
+               }
+               if (cmtVal.externs != -1)
+                   extern_in = cmtVal.externs;
+               if (cmtVal.preproz != 0)
+                   fputc('\n', stdout); 
+#endif
+               return;
+           }
+           /* FALLTHRU */
+       default:
+#if OPT_LINTLIBRARY
+           if (cmtVal.preproz != 0 && lastc != '\0')
+               fputc(lastc, stdout); 
+#endif
+           break;
+       }
+       lastc = c;
+    }
+}
+
+/* Scan rest of preprocessor directive.  If <dest> is not NULL, then store
+ * the text in the buffer pointed to by <dest> having size <n>.
+ */
+static void
+get_cpp_directive (dest, n)
+char *dest;            /* buffer to store directive text */
+unsigned n;            /* size of buffer to store directive text */
+{
+    char c, lastc[4];
+    
+    lastc[0] = lastc[1] = lastc[2] = lastc[3] = '\0';
+    if (dest != NULL)
+       *dest = '\0';
+
+    while ((c = input()) != 0) {
+       if (cur_file->convert)
+           fputc(c, cur_file->tmp_file);
+
+       switch (c) {
+       case '\n':
+           cur_file->line_num++;
+           if (lastc[2] != '\\' && strcmp(lastc, "?\?/") != 0) {
+               finishCpp();
+               return;
+           }
+           break;
+       case '*':
+           if (lastc[2] == '/')
+               get_comment();
+           break;
+       }
+       lastc[0] = lastc[1];
+       lastc[1] = lastc[2];
+       lastc[2] = c;
+
+       if (dest != NULL && n > 1) {
+           *dest++ = c;
+           *dest = '\0';
+           --n;
+       }
+    }
+}
+
+/* Return a pointer to the current file name.
+ */
+char *
+cur_file_name ()
+{
+    return cur_file->file_name;
+}
+
+/* Return the current line number.
+ */
+unsigned
+cur_line_num ()
+{
+    return cur_file->line_num;
+}
+
+/* Return the current temporary output file.
+ */
+FILE *
+cur_tmp_file ()
+{
+    return cur_file->tmp_file;
+}
+
+/* Set the modify flag for the current file.
+ */
+void
+cur_file_changed ()
+{
+    cur_file->changed = TRUE;
+}
+
+/* Return the temporary file offset of beginning of the current comment.
+ */
+long
+cur_begin_comment ()
+{
+    return cur_file->begin_comment;
+}
+
+/* Return the text of the current lexical token.
+ */
+char *
+cur_text ()
+{
+    return yytext;
+}
+
+#if !HAVE_TMPFILE
+/*
+ * tmpfile() - return a FILE* for a temporary file that will be
+ * removed automatically when the program exits.
+ * 
+ * Not all systems have the ANSI tmpfile() function yet...
+ *
+ * DaviD W. Sanderson (dws@cs.wisc.edu)
+ */
+FILE *
+tmpfile ()
+{
+    char name[MAX_TEXT_SIZE];
+    char *tmpdir;
+    FILE *f;
+
+    if ((tmpdir = getenv("TMPDIR")) == (char *)0)
+    {
+       tmpdir = "/tmp";
+    }
+    sprintf(name, "%s/TfXXXXXX", tmpdir);
+    mktemp(name);
+
+    if ((f = fopen(name, "w+")) == (FILE *)0)
+    {
+       return (FILE *)0;
+    }
+
+    if (unlink(name) == -1)
+    {
+       fclose(f);
+       return (FILE *)0;
+    }
+
+    return f;
+}
+#endif /* !HAVE_TMPFILE */
+
+/* Push a file onto the include stack. The stream yyin must already
+ * point to the file.
+ */
+static void
+include_file (name, convert)
+char *name;            /* file name */
+int convert;           /* if TRUE, convert function definitions */
+{
+    ++inc_depth;
+    cur_file = inc_stack + inc_depth;
+    cur_file->file = yyin;
+    cur_file->base_name = xstrdup(name);
+    cur_file->file_name = strcpy(xmalloc(MAX_TEXT_SIZE), name);
+    cur_file->line_num = 1;
+    cur_file->convert = convert;
+    cur_file->changed = FALSE;
+
+#ifdef FLEX_SCANNER
+    buffer_stack[inc_depth] = yy_create_buffer(yyin, YY_BUF_SIZE);
+    yy_switch_to_buffer(buffer_stack[inc_depth]);
+#endif
+
+    if (convert) {
+       cur_file->begin_comment = cur_file->end_comment = 0;
+       cur_file->tmp_file = tmpfile();
+       if (cur_file->tmp_file == NULL) {
+           fprintf(stderr, "%s: cannot create temporary file\n", progname);
+           cur_file->convert = FALSE;
+       }
+    }
+}
+
+#define BLOCK_SIZE 2048
+
+/* Copy converted C source from the temporary file to the output stream.
+ */
+static void
+put_file (outf)
+FILE *outf;
+{
+    char block[BLOCK_SIZE];
+    long filesize;
+    unsigned nread, count;
+
+    filesize = ftell(cur_file->tmp_file);
+    fseek(cur_file->tmp_file, 0L, 0);
+    while (filesize > 0) {
+       count = (filesize < BLOCK_SIZE) ? (unsigned)filesize : BLOCK_SIZE;
+       nread = fread(block, sizeof(char), count, cur_file->tmp_file);
+       if (nread == 0)
+           break;
+       fwrite(block, sizeof(char), nread, outf);
+       filesize -= nread;
+    }
+}
+
+/* Remove the top of the include stack.
+ */
+void
+pop_file (closed)
+int closed;
+{
+    FILE *outf;
+
+    if (!closed && (yyin != stdin))
+       fclose(yyin);
+
+    if (cur_file->convert) {
+       if (yyin == stdin) {
+           put_file(stdout);
+       } else if (cur_file->changed) {
+           if ((outf = fopen(cur_file->base_name, "w")) != NULL) {
+               put_file(outf);
+               fclose(outf);
+           } else {
+               fprintf(stderr, "%s: cannot create file %s\n", progname,
+                cur_file->base_name);
+           }
+       }
+
+       fclose(cur_file->tmp_file);
+    }
+    free(cur_file->base_name);
+    free(cur_file->file_name);
+
+#ifdef FLEX_SCANNER
+    yy_delete_buffer(YY_CURRENT_BUFFER);
+#endif
+
+    if (--inc_depth >= 0) {
+       cur_file = inc_stack + inc_depth;
+       yyin = cur_file->file;
+
+#ifdef FLEX_SCANNER
+       yy_switch_to_buffer(buffer_stack[inc_depth]);
+#endif
+    }
+}
+
+/* Process include directive.
+ */
+static void
+do_include (file_spec)
+char *file_spec;       /* path surrounded by "" or <> */
+{
+    int stdinc;        /* 1 = path surrounded by <> */
+    char file[MAX_TEXT_SIZE], path[MAX_TEXT_SIZE];
+    char match, *s;
+    int i;
+    unsigned n;
+    FILE *fp;
+
+    if (inc_depth >= MAX_INC_DEPTH-1) {
+       put_error();
+       fprintf(stderr, "includes too deeply nested\n");
+       return;
+    }
+
+    if (file_spec[0] == '"') {
+       match = '"';
+       stdinc = 0;
+    } else if (file_spec[0] == '<') {
+       match = '>';
+       stdinc = 1;
+    } else {
+       return;
+    }
+    s = strchr(file_spec+1, match);
+    n = (s != NULL) ? (unsigned)(s - file_spec - 1) : 0;
+    strncpy(file, file_spec+1, (size_t)n);
+    file[n] = '\0';
+
+    /* Do nothing if the file was already included. */
+    sprintf(path, stdinc ? "<%s>" : "\"%s\"", file);
+    if (find_symbol(included_files, path) != NULL)
+       return;
+    new_symbol(included_files, path, NULL, DS_NONE);
+
+    for (i = stdinc != 0; i < num_inc_dir; ++i) {
+       if (strlen(inc_dir[i]) == 0) {
+           strcpy(path, file);
+       } else {
+           sprintf(path, "%s/%s", inc_dir[i], file);
+       }
+       if ((fp = fopen(path, "r")) != NULL) {
+           yyin = fp;
+           include_file(path, func_style != FUNC_NONE && !stdinc);
+           return;
+       }
+    }
+
+    if (!quiet) {
+       put_error();
+       fprintf(stderr, "cannot read file %s\n", file_spec);
+    }
+}
+
+/* When the end of the current input file is reached, pop a
+ * nested include file.
+ */
+int
+yywrap ()
+{
+    if (inc_depth > 0) {
+       pop_file(FALSE);
+       return 0;
+    } else {
+       return 1;
+    }
+}
diff --git a/cproto-4.6/lintlibs.c b/cproto-4.6/lintlibs.c
new file mode 100644 (file)
index 0000000..1d9c210
--- /dev/null
@@ -0,0 +1,649 @@
+/* $Id: lintlibs.c,v 4.4 1998/01/19 00:49:21 cthuang Exp $
+ *
+ * C prototype/lint-library generator
+ * These routines implement the semantic actions for lint libraries executed by
+ * the yacc parser.
+ */
+#include <stdio.h>
+#include <ctype.h>
+#include "cproto.h"
+#include "semantic.h"
+#include "symbol.h"
+
+#if OPT_LINTLIBRARY
+
+       int     in_include;
+
+static SymbolTable *include_list;
+static SymbolTable *declared_list;
+
+static char    *strip_name      ARGS((char *s));
+static void    free_inc_stack   ARGS((int n));
+static void    make_inc_stack   ARGS((int n, char *path));
+static int     already_included ARGS((char *path));
+static void    add2implied_buf  ARGS((char *s, int append));
+static int     c_suffix         ARGS((char *path));
+
+static int     in_typedef;
+static int     blank_lines;    /* used to filter blank lines from typedefs */
+
+static int     implied_cnt;    /* state-count associated with implied_buf */
+static char    *implied_buf;
+
+static char    quote_l = '"',
+               quote_r = '"';
+
+/*
+ * Output a string to standard output, keeping track of the trailing newlines
+ * to make it simple to format with blank lines.
+ */
+void
+put_string(outf, s)
+FILE   *outf;
+char   *s;
+{
+       if (*s != '\0') {
+               fputs(s, outf);
+               if (outf == stdout) {   /* ensure we aren't doing temp-file! */
+                       while (*s != '\0') {
+                               if (*s++ == '\n')
+                                       blank_lines++;
+                               else
+                                       blank_lines = 0;
+                       }
+               }
+       }
+}
+
+/*
+ * Output a single character
+ */
+void
+put_char(outf, c)
+FILE   *outf;
+int    c;
+{
+       static  char    s[] = "?";
+       s[0] = c;
+       put_string(outf, s);
+}
+
+/*
+ * Write a newline, taking care not to make a blank line
+ */
+void
+put_newline(outf)
+FILE   *outf;
+{
+       while (!blank_lines)
+               put_string(outf, "\n");
+}
+
+/*
+ * Make a blank line (limited to 2 successive newlines)
+ */
+void
+put_blankline(outf)
+FILE   *outf;
+{
+       while (blank_lines < 2)
+               put_string(outf, "\n");
+}
+
+/*
+ * Put a token, padded by a tab if it is short enough
+ */
+void
+put_padded(outf, s)
+FILE   *outf;
+char   *s;
+{
+       put_string(outf, s);
+       put_char(outf, (lintLibrary() && strlen(s) < 8) ? '\t' : ' ');
+}
+
+/*
+ * Format lint-library so that we put a blank line before each item that may
+ * take up multiple lines:
+ *     0) functions
+ *     1) typedefs (explicit and implied)
+ * as well as when transitioning to
+ *     2) variable declarations
+ *
+ * If the "-T" option is set, we skip a blank line around typedefs.
+ */
+void
+fmt_library(code)
+int    code;
+{
+       if (lintLibrary() || types_out) {
+               static  int     save;
+
+               if (!lintLibrary() && code == 0)
+                       code = 3;
+               if (code <= 1 || code != save)
+                       put_blankline(stdout);
+               save = code;
+       }
+}
+
+/*
+ * conversion for names so test-diffs are less
+ * (patch: should use relpath)
+ */
+#ifdef vms
+static char    *strip_name(s)
+       char    *s;
+       {
+               static  char    stripped[BUFSIZ];
+               auto    int     len = strlen(getwd(stripped));
+               if (strlen(s) > len
+               && !strncmp(s, stripped, len))
+                       s += len;
+               return (vms2name(stripped, s));
+       }
+#else
+static char    *strip_name(s)
+       char    *s;
+       {
+               static  char    GccLeaf[] = "/gcc-lib/";
+               static  char    IncLeaf[] = "/include/";
+               char *t;
+               register int    n;
+               register size_t len;
+               int standard = FALSE;
+
+               for (n = 1; n < num_inc_dir; n++) {
+                       len = strlen(inc_dir[n]);
+                       if (!strncmp(inc_dir[n], s, len)
+                        && is_path_sep(s[len])) {
+                               standard = TRUE;
+                               s += len + 1;
+                               quote_l = '<';
+                               quote_r = '>';
+                               break;
+                       }
+               }
+               if (!standard) {
+                       quote_l =
+                       quote_r = '"';
+                       if (*s == '.' && is_path_sep(s[1]))
+                               s += 2;
+                       else if ((t = strstr(s, GccLeaf)) != 0
+                            &&  (t = strstr(t, IncLeaf)) != 0) {
+                               s = t+sizeof(IncLeaf)-1;
+                               quote_l = '<';
+                               quote_r = '>';
+                       }
+               }
+               return s;
+       }
+#endif
+#define        CUR_FILE        strip_name(cur_file_name())
+
+static int     base_level;
+static char    *inc_stack[MAX_INC_DEPTH];
+
+#ifdef DEBUG
+static
+dump_stack(tag)
+char   *tag;
+{
+       register int    j;
+       printf("/* stack%s:%s", tag, cur_file_name());
+       for (j = 0; j <= in_include; j++)
+               printf("\n\t%d%s:%s", j,
+                       j == base_level ? "*" : "",
+                       inc_stack[j] ? inc_stack[j] : "?");
+       printf(" */\n");
+}
+#endif /* DEBUG */
+
+static
+void   free_inc_stack(n)
+       int     n;
+{
+       if (inc_stack[n] != 0) {
+               free(inc_stack[n]);
+               inc_stack[n] = 0;
+       }
+}
+
+static
+void   make_inc_stack(n, s)
+       int     n;
+       char    *s;
+{
+       free_inc_stack(n);
+       inc_stack[n] = xstrdup(s);
+}
+
+/*
+ * Keep track of include-files so that we only include each once.
+ */
+static
+int    already_included (path)
+       char    *path;
+{
+       if (!include_list)
+               include_list = new_symbol_table();
+       if (find_symbol(include_list, path) != NULL)
+               return TRUE;
+       new_symbol(include_list, path, NULL, DS_NONE);
+       return FALSE;
+}
+
+/*
+ * Keep track of variables that may have been implicitly declared via
+ * include-files so that we declare them only once in the lint library
+ * output.
+ */
+int    already_declared (name)
+       char    *name;
+{
+       if (declared_list == 0)
+               declared_list = new_symbol_table ();
+       if (find_symbol (declared_list, name) == 0) {
+               (void)new_symbol (declared_list, name, 0, 0);
+               return FALSE;
+       }
+       return TRUE;
+}
+
+/*
+ * Initialize state for 'track_in()'
+ */
+static int     InitTracking;
+void   begin_tracking()
+{
+       InitTracking = FALSE;
+}
+
+static int     c_suffix(path)
+       char    *path;
+{
+       char    *last = path + strlen(path);
+#ifdef vms
+       char    *vers = strrchr(path, ';');
+       if (vers != 0)
+               last = vers;
+#endif
+       return ((last - path) > 2 && !strcmp(last-2, ".c"));
+}
+
+/*
+ * For lint-library, we want to keep track of what file we are in so that we
+ * can generate appropriate comments and include-statements.
+ *
+ * The main program 'cproto' is invoked with 'cpp' once for each C-file,
+ * relying on it to spit out "#" comments which identify the name and line
+ * number of each processed file.  After the first '#' comment, all others
+ * refer to included files.
+ */
+void   track_in()
+{
+       static  char    old_file[MAX_TEXT_SIZE];        /* from last call */
+       auto    boolean show = lintLibrary();
+
+       if (!show && !debug_trace)
+               return;
+
+#ifdef DEBUG
+       printf("/* track_in: in_include=%d line_num=%d base_file=%s */\n",
+               in_include, cur_line_num(), base_file);
+       dump_stack("-before");
+#endif /* DEBUG */
+
+       if (cur_line_num() == 0) {      /* begin new (nested?) file */
+               if (!InitTracking) {
+                       InitTracking = TRUE;
+                       /* yacc may omit first cpp-line! */
+                       in_include =
+                       base_level = (strcmp(cur_file_name(), base_file) != 0);
+                       make_inc_stack(0, base_file);
+               } else if (!strcmp(cur_file_name(), base_file)) {
+                       flush_varargs();
+                       in_include = 0; /* reset level */
+               } else {
+                       make_inc_stack(in_include, old_file);
+                       if (in_include++ == 0) {
+                               char    *s = CUR_FILE;
+                               if (show && !already_included(s)) {
+                                       fmt_library(4);
+                                       put_string (stdout, "#include ");
+                                       put_char   (stdout, quote_l);
+                                       put_string (stdout, s);
+                                       put_char   (stdout, quote_r);
+                                       put_newline(stdout);
+                               }
+                               if (debug_trace)
+                                       fprintf(stderr, "++ %s\n", cur_file_name());
+                       }
+                       make_inc_stack(in_include, cur_file_name());
+               }
+               (void)strcpy(old_file, cur_file_name());
+       } else if (!strcmp(cur_file_name(), base_file)) {
+               in_include = 0; /* kludgy bison! */
+               (void)strcpy(old_file, cur_file_name());
+       } else if (strcmp(old_file, cur_file_name())) { /* continue/unnest ? */
+               int n, found;
+               char *s = cur_file_name();
+#ifdef DEBUG
+               char temp[80];
+#endif
+
+               flush_varargs();
+               for (n = in_include, found = FALSE; n >= 0; n--) {
+                       if (!strcmp(inc_stack[n], s)) {
+                               found = TRUE;
+                               in_include--;
+                               break;
+                       }
+               }
+               if (!found) {
+                       /*
+                        * There's two kinds of broken programs that can cause
+                        * us to lose sync at this point:  (1) programs such as
+                        * yacc that don't reference the grammar file, instead
+                        * referencing the generated file, and (2) broken
+                        * preprocessors (such as on OSF/1) that neglect to
+                        * report line #1 on headers that are rejected due to
+                        * prior inclusion.
+                        *
+                        * If the source file's extension is ".h", we'll assume
+                        * the latter case (i.e., just report it).  The former
+                        * case requires that we reset the stack.
+                        */
+#ifdef DEBUG
+                       sprintf(temp, "/* lost sync @%d: ", cur_line_num()+1);
+                       put_blankline(stdout);
+                       put_string(stdout, temp);
+                       put_string(stdout, s);
+                       put_string(stdout, " */\n");
+#endif
+                       if (in_include == 1 && c_suffix(s)) {
+                               /* yacc did it again! */
+                               in_include = 0;
+                               make_inc_stack(in_include, strcpy(base_file, s));
+#ifdef DEBUG
+                               put_string(stdout, "/* processed ");
+                               put_string(stdout, s);
+                               put_string(stdout, " */\n");
+#endif
+                       }
+               }
+               (void)strcpy(old_file, inc_stack[in_include]);
+       }
+#ifdef DEBUG
+       dump_stack("-after");
+#endif /* DEBUG */
+}
+
+/*
+ * Copy/append to 'implied_buf[]'
+ */
+static
+void   add2implied_buf(s,append)
+       char    *s;
+       int     append;
+{
+       static  unsigned
+                       implied_len,    /* current strlen(implied_buf) */
+                       implied_max;    /* maximum size of implied_buf */
+
+       if (!append)
+               implied_len = 0;
+       implied_len += strlen(s);
+
+       if (implied_buf == 0)
+               *(implied_buf = malloc(implied_max = BUFSIZ)) = '\0';
+       if (implied_max < implied_len + 2)
+               implied_buf = realloc(implied_buf, implied_max += implied_len+2);
+       if (!append)
+               *implied_buf = '\0';
+       (void)strcat(implied_buf, s);
+}
+
+/*
+ * If the "-t" option is set (or if we are generating a lint-library), we
+ * intercept tokens which are part of a typedef, copying them to the output.
+ *
+ * The 'imply_typedef()' entrypoint is called from the grammar for the special
+ * cases of struct/union/enum when we expect to be getting curly-braces which
+ * define the structure.  If no curly-braces are found by the end of the
+ * rule, we can discard the buffer.
+ */
+int    want_typedef()
+{
+       if (lintLibrary()) {
+               if (in_include == 0)
+                       return (TRUE);
+       } else if (types_out) {
+               return (TRUE);
+       }
+       return (FALSE);
+}
+
+void   begin_typedef()
+{
+       if (want_typedef()) {
+               in_typedef = TRUE;
+               fmt_library(1);
+               copy_typedef("typedef");
+       }
+}
+
+void   copy_typedef(s)
+       char    *s;
+{
+       if (!strcmp(s, "/*")
+        || *s == '#')
+               ;       /* ignore */
+       else if (in_typedef) {
+               if (*s == '\n')
+                       put_newline(stdout);
+               else
+                       put_string(stdout, s);
+       } else if (implied_cnt > 0) {   /* "KEY ID {" ? */
+               add2implied_buf(s,TRUE);
+               if (!isspace(*s))
+                       implied_cnt--;
+               if ((implied_cnt == 2 || implied_cnt == 1)
+               &&  !strcmp(s, "{")) {
+                       implied_cnt = 9999;
+               }
+       }
+}
+
+void   end_typedef()
+{
+       copy_typedef("\n");
+       in_typedef = FALSE;
+       (void)implied_typedef();
+}
+
+void   imply_typedef(s)
+       char    *s;
+{
+       if (!in_typedef && want_typedef()) {
+               add2implied_buf(s,FALSE);
+               implied_cnt = 3;
+       }
+}
+
+char * implied_typedef()
+{
+       if (implied_cnt > 0) {
+               implied_cnt = 0;
+               return (implied_buf);
+       }
+       return (0);
+}
+
+/*
+ * Indent lint-library stuff to make it readable
+ */
+void   indent(outf)
+       FILE    *outf;
+{
+       put_string(outf, "\n\t\t");
+}
+
+/* Test for the special case of an ellipsis-parameter when trying to make a
+ * lint-library
+ */
+int    lint_ellipsis(p)
+       Parameter       *p;
+{
+       return (   knrLintLibrary()
+               && (!strcmp(p->declarator->name, ELLIPSIS)));
+}
+
+/*
+ * Reset the data used for "VARARGS" comment.  Actually, reset almost any
+ * special attribute that's attached to a function, so we don't accidentally
+ * propagate it to the next function (or data) to be output.
+ */
+void   flush_varargs()
+{
+       exitlike_func = FALSE;
+
+       varargs_num = 0;
+       if (varargs_str != 0) {
+               free(varargs_str);
+               varargs_str = 0;
+       }
+}
+
+/* If either we received a "VARARGS" comment in the lexical scanner, or if the
+ * parameter list contains an ellipsis, generate a corresponding "VARARGS"
+ * comment for lint-library output.
+ */
+void   ellipsis_varargs(d)
+       Declarator      *d;
+{
+       int             count;
+       Parameter       *p;
+
+       fmt_library(0);
+       for (p = d->params.first, count = 0; p != 0; p = p->next, count++)
+               if (lint_ellipsis(p)) {
+                       varargs_num = count;
+                       break;
+               }
+       if (varargs_num != 0) {
+               put_string(stdout, "\t/* VARARGS");
+               if (varargs_num > 0) {
+                       printf("%d", varargs_num);
+                       if (varargs_str != 0) {
+                               put_char(stdout, ' ');
+                               put_string(stdout, varargs_str);
+                       }
+               }
+               flush_varargs();
+               put_string(stdout, " */\n");
+       }
+}
+
+/* (Attempt to) create a parameter name for lint-library applications in which
+ * we are starting from a function prototype which has no explicit parameter
+ * name.
+ */
+char * supply_parm(count)
+       int     count;
+{
+       static  char    temp[80];
+       (void)sprintf(temp, "p%d", count);
+       while (is_typedef_name(temp) && (strlen(temp) < sizeof(temp)-1))
+               (void)strcat(temp, "_");
+       return (temp);
+}
+
+/*
+ * (Attempt to) distinguish between declarators for functions and for
+ * function pointers.
+ */
+int    is_actual_func (d)
+       Declarator *d;
+{
+       if (lintLibrary() && (d->func_def != FUNC_NONE)) {
+               if (d->func_stack->text[0] == PAREN_L) {
+                       if (strstr(d->func_stack->text, "()") != 0)
+                               return TRUE;
+               } else {
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
+/*
+ * Output the body (or terminating semicolon) of a procedure
+ */
+void   put_body(outf, decl_spec, declarator)
+       FILE            *outf;
+       DeclSpec        *decl_spec;     /* declaration specifier */
+       Declarator      *declarator;
+{
+    register char      *spec_text;
+
+    if (is_actual_func(declarator)) {
+       strcut(decl_spec->text, "static");
+       strcut(decl_spec->text, "extern");
+       indent(outf);
+       put_char(outf, CURL_L);
+       if (!*(spec_text = decl_spec->text))
+               spec_text = "void";
+       if (exitlike_func) {
+           put_string(outf, " for(;;); /* no return */ ");
+       } else if (!strcmp(spec_text, "void")
+        && declarator->text[0] != '*'
+        && declarator->func_stack->func_def == FUNC_NONE) {
+           put_string(outf, " /* void */ ");
+       } else {
+           put_string(outf, " return(*(");
+           if (declarator->func_stack->func_def == FUNC_NONE) {
+               put_string(outf, spec_text);
+               put_char(outf, ' ');
+               if (declarator->pointer) {
+                       char *s = declarator->text;
+                       while (*s++ == '*')
+                               put_char(outf, '*');
+               }
+               put_char(outf, '*');
+           } else {
+               put_string(outf, spec_text);
+               put_string(outf, "(*)()");
+           }
+           put_string(outf, ")0); ");
+       }
+       put_char(outf, CURL_R);
+    } else {
+       /* SVR4 lint complains if we declare const data w/o some initializer.
+        */
+       if (strkey(decl_spec->text, "const") != NULL
+        || strkey(declarator->text, "const") != NULL)
+           put_string(outf, " = {0}");
+       put_string(outf, ";");
+    }
+    put_newline(outf);
+    exitlike_func = FALSE;
+}
+
+#ifdef NO_LEAKS
+void
+free_lintlibs()
+{
+    register int n;
+    if (implied_buf != 0)
+       free(implied_buf);
+    for (n = 0; n < MAX_INC_DEPTH; n++)
+       free_inc_stack(n);
+    if (include_list != 0)
+       free_symbol_table(include_list);
+    if (declared_list != 0)
+       free_symbol_table(declared_list);
+}
+#endif
+
+#endif /* OPT_LINTLIBRARY */
diff --git a/cproto-4.6/mkdirs.sh b/cproto-4.6/mkdirs.sh
new file mode 100755 (executable)
index 0000000..91f6d04
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Last modified: 1994-03-25
+# Public domain
+
+errstatus=0
+
+for file in ${1+"$@"} ; do 
+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+   shift
+
+   pathcomp=
+   for d in ${1+"$@"} ; do
+     pathcomp="$pathcomp$d"
+     case "$pathcomp" in
+       -* ) pathcomp=./$pathcomp ;;
+     esac
+
+     if test ! -d "$pathcomp"; then
+        echo "mkdir $pathcomp" 1>&2
+        mkdir "$pathcomp" || errstatus=$?
+     fi
+
+     pathcomp="$pathcomp/"
+   done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
diff --git a/cproto-4.6/msdos/README b/cproto-4.6/msdos/README
new file mode 100644 (file)
index 0000000..a5b15a4
--- /dev/null
@@ -0,0 +1,5 @@
+The files in this directory are used to build on MS-DOS.
+
+turboc.mak     makefile for Turbo C/C++ 3.0 for MS-DOS
+borland.mak    makefile for Borland C for MS-DOS
+micrsoft.mak   makefile for Microsoft C
diff --git a/cproto-4.6/msdos/borland.mak b/cproto-4.6/msdos/borland.mak
new file mode 100644 (file)
index 0000000..426799e
--- /dev/null
@@ -0,0 +1,63 @@
+# $Id: borland.mak,v 4.1 1998/01/20 00:19:17 cthuang Exp $
+#
+# Borland C++ makefile for C prototype generator
+
+# Define MSDOS for MS-DOS compatibility.
+# Define TURBO_CPP to pipe the input through the Turbo C preprocessor.
+DEFINES = -DMSDOS -DTURBO_CPP
+
+LEX = lex
+YACC = yacc
+CC = bcc
+CFLAGS = -mc $(DEFINES) -w-pin -w-pro
+LIBS = \bc\lib\wildargs.obj
+
+DIST1 = README CHANGES cproto.man
+DIST2 = cproto.1 borland.mak micrsoft.mak makefile.in lex.l grammar.y
+DIST3 = system.h cproto.h patchlev.h semantic.h symbol.h
+DIST4 = cproto.c popen.c lintlibs.c semantic.c strkey.c strstr.c symbol.c
+
+OBJECTS = cproto.obj lintlibs.obj getopt.obj popen.obj semantic.obj strkey.obj strstr.obj symbol.obj y_tab.obj
+
+all: cproto.exe
+
+cproto.exe: $(OBJECTS)
+       $(CC) $(CFLAGS) -e$*.exe $(OBJECTS) $(LIBS)
+
+y_tab.obj: y_tab.c lex_yy.c system.h cproto.h symbol.h semantic.h
+       $(CC) $(CFLAGS) -c $*.c
+
+y_tab.c: grammar.y
+       $(YACC) grammar.y
+
+lex_yy.c: lex.l
+       $(LEX) lex.l
+
+cproto.man: cproto.1
+       cawf -man $*.1 | bsfilt - >$*.man
+
+clean:
+       erase *.obj
+       erase *.bak
+       erase *.log
+       erase lex_yy.c
+       erase y_tab.c
+       erase cproto.exe
+
+ci:
+       ci -u3 $(DIST2) $(DIST3)
+       ci -u3 $(DIST4)
+
+shar:
+       shar $(DIST1) $(DIST2) >cproto.sh1
+       shar $(DIST3) $(DIST4) >cproto.sh2
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
+
+cproto.obj: system.h cproto.h symbol.h
+lintlibs.obj: system.h cproto.h symbol.h semantic.h
+popen.obj: system.h cproto.h
+semantic.obj: system.h cproto.h symbol.h semantic.h
+strkey.obj: cproto.h system.h
+strstr.obj: system.h
+symbol.obj: system.h cproto.h symbol.h
diff --git a/cproto-4.6/msdos/micrsoft.lnk b/cproto-4.6/msdos/micrsoft.lnk
new file mode 100644 (file)
index 0000000..58c496e
--- /dev/null
@@ -0,0 +1,12 @@
+CPROTO.OBJ + 
+LINTLIBS.OBJ + 
+GETOPT.OBJ + 
+SEMANTIC.OBJ + 
+STRKEY.OBJ + 
+SYMBOL.OBJ + 
+YTAB.OBJ  +
+POPEN.OBJ 
+cproto.exe 
+cproto.map
+d:\msc60ax\lib\llibce.lib
+;
diff --git a/cproto-4.6/msdos/micrsoft.mak b/cproto-4.6/msdos/micrsoft.mak
new file mode 100644 (file)
index 0000000..0ec336f
--- /dev/null
@@ -0,0 +1,82 @@
+# $Id: micrsoft.mak,v 4.1 1998/01/20 00:19:18 cthuang Exp $
+#
+# Microsoft C makefile for C prototype generator
+# tested with:
+#      nmake 1.11.
+#      cl 6.00ax.
+
+# Define MSDOS for MS-DOS compatibility.
+# Define TURBO_CPP to pipe the input through the Turbo C preprocessor.
+DEFINES = -DMSDOS -DSTDC_HEADERS
+
+MSC_TOP = d:\msc60ax
+
+# names from MKS tools (ran out of memory in lex; used unix output)
+Y_TAB = ytab
+LEX_YY = lex_yy
+
+LEX = lex
+YACC = yacc
+CC = cl
+LINK = link
+CFLAGS = -EM -AL $(DEFINES)
+LIBS = $(MSC_TOP)\lib\setargv.obj
+LDFLAGS = /F 1000
+
+DIST1 = README CHANGES cproto.man
+DIST2 = cproto.1 borland.mak micrsoft.mak makefile.in lex.l grammar.y
+DIST3 = system.h cproto.h patchlev.h semantic.h symbol.h
+DIST4 = cproto.c lintlibs.c popen.c semantic.c strkey.c strstr.c symbol.c
+
+OBJECTS = cproto.obj lintlibs.obj getopt.obj semantic.obj strkey.obj symbol.obj $(Y_TAB).obj popen.obj
+
+all: cproto.exe
+
+cproto.exe: $(OBJECTS) micrsoft.lnk
+       $(LINK) @micrsoft.lnk
+
+micrsoft.lnk:
+       for %%i in ( *.obj ) do echo %%i + >>$@
+       echo >>$@
+       echo cproto.exe >>$@
+       echo >>$@
+       echo $(LIBS); >>$@
+
+$(Y_TAB).obj: $(Y_TAB).c $(LEX_YY).c system.h cproto.h symbol.h semantic.h
+       $(CC) $(CFLAGS) -c $*.c
+
+$(Y_TAB).c: grammar.y
+       $(YACC) grammar.y
+
+$(LEX_YY).c: lex.l
+       $(LEX) lex.l
+
+cproto.man: cproto.1
+       cawf -man $*.1 | bsfilt - >$*.man
+
+clean:
+       erase *.obj
+       erase *.bak
+       erase *.log
+       erase $(LEX_YY).c
+       erase $(Y_TAB).c
+       erase micrsoft.lnk
+       erase cproto.exe
+
+ci:
+       ci -u3 $(DIST2) $(DIST3)
+       ci -u3 $(DIST4)
+
+shar:
+       shar $(DIST1) $(DIST2) >cproto.sh1
+       shar $(DIST3) $(DIST4) >cproto.sh2
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
+
+cproto.obj: system.h cproto.h
+lintlibs.obj: system.h cproto.h symbol.h semantic.h
+popen.obj: system.h cproto.h
+semantic.obj: system.h cproto.h symbol.h semantic.h
+strkey.obj: cproto.h system.h
+strstr.obj: system.h
+symbol.obj: system.h cproto.h symbol.h
diff --git a/cproto-4.6/msdos/turboc.mak b/cproto-4.6/msdos/turboc.mak
new file mode 100644 (file)
index 0000000..3bd2ffd
--- /dev/null
@@ -0,0 +1,157 @@
+# $Id: turboc.mak,v 4.2 1998/01/24 01:42:11 cthuang Exp $
+#
+# Turbo C/C++ makefile for C prototype generator
+# (adapted from PRJ2MAK output)
+.AUTODEPEND 
+
+# Define MSDOS for MS-DOS compatibility.
+# Define TURBO_CPP to pipe the input through the Turbo C preprocessor.
+DEFINES = MSDOS;TURBO_CPP
+
+# There's no standard for the names produced by lex clones on MSDOS:
+#      FLEX produces LEXYY.C
+#      MKS LEX produces LEX_YY.C (I think)
+#LEX = lex
+#LEX_OUT=lex_yy
+LEX = flex
+LEX_OUT=lexyy
+
+#YACC = yacc
+YACC = byacc
+#YACC = bison -o y_tab.c
+
+#              *Translator Definitions*
+CC = tcc +cproto.cfg
+MODEL = l
+TLIB = tlib
+TLINK = tlink
+LIBPATH = C:\TC\LIB
+LIBS = $(LIBPATH)\wildargs.obj
+INCLUDEPATH = .;\tc\include
+
+DOC_FILES = \
+       README \
+       CHANGES \
+       cproto.man \
+       cproto.1
+
+MAK_FILES = \
+       makefile.in configure.in \
+       turboc.mak \
+       borland.mak \
+       micrsoft.mak
+
+DIST2 = lex.l grammar.y
+DIST3 = system.h cproto.h patchlev.h semantic.h symbol.h
+DIST4 = cproto.c popen.c lintlibs.c semantic.c strkey.c strstr.c symbol.c
+
+OBJECTS = \
+       cproto.obj \
+       lintlibs.obj \
+       getopt.obj \
+       popen.obj \
+       semantic.obj \
+       strkey.obj \
+       strstr.obj \
+       symbol.obj \
+       y_tab.obj
+
+all: cproto.exe
+
+y_tab.obj : cproto.cfg \
+       y_tab.c $(LEX_OUT).c system.h cproto.h symbol.h semantic.h
+       $(CC) -w-rch -c {$*.c }
+
+y_tab.c : grammar.y
+       $(YACC) grammar.y
+
+$(LEX_OUT).c: lex.l
+       $(LEX) lex.l
+
+cproto.man: cproto.1
+       cawf -man $*.1 | bsfilt - >$*.man
+
+clean:
+       erase *.$$$
+       erase cproto.cfg
+       erase *.out
+       erase *.obj
+       erase *.bak
+       erase *.log
+       erase $(LEX_OUT).c
+       erase y_tab.c
+       erase cproto.exe
+
+#              *Implicit Rules*
+.c.obj:
+       $(CC) -c {$< }
+
+.cpp.obj:
+       $(CC) -c {$< }
+
+#              *Explicit Rules*
+cproto.exe: cproto.cfg $(OBJECTS)
+       $(TLINK) /v/x/c/L$(LIBPATH) @&&|
+c0$(MODEL).obj+
+cproto.obj +
+lintlibs.obj +
+getopt.obj +
+popen.obj +
+semantic.obj +
+strkey.obj +
+strstr.obj +
+symbol.obj +
+y_tab.obj +
+$(LIBS)
+cproto
+               # no map file
+emu.lib+
+math$(MODEL).lib+
+c$(MODEL).lib
+|
+
+#              *Compiler Configuration File*
+cproto.cfg: turboc.mak
+       copy &&|
+-m$(MODEL)
+-v
+-vi-
+-w-ret
+-w-nci
+-w-inl
+-wpin
+-wamb
+-wamp
+-w-par
+-wasm
+-wcln
+-w-cpt
+-wdef
+-w-dup
+-w-pia
+-wsig
+-wnod
+-w-ill
+-w-sus
+-wstv
+-wucp
+-wuse
+-w-ext
+-w-ias
+-w-ibc
+-w-pre
+-w-nst
+-I$(INCLUDEPATH)
+-L$(LIBPATH)
+-D$(DEFINES);STDC_HEADERS=1;USE_$(LEX);YY_USE_PROTOS
+| cproto.cfg
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.
+
+cproto.obj : cproto.cfg system.h cproto.h symbol.h
+lintlibs.obj : cproto.cfg system.h cproto.h symbol.h semantic.h
+popen.obj : cproto.cfg system.h cproto.h
+semantic.obj : cproto.cfg system.h cproto.h symbol.h semantic.h
+strkey.obj : cproto.cfg cproto.h system.h
+strstr.obj : cproto.cfg system.h
+symbol.obj : cproto.cfg system.h cproto.h symbol.h
diff --git a/cproto-4.6/os2/README b/cproto-4.6/os2/README
new file mode 100644 (file)
index 0000000..fdfc5ed
--- /dev/null
@@ -0,0 +1,5 @@
+The files in this directory are used to build and test on OS/2.
+
+watcom.mak     makefile for Watcom C/C++
+
+run_test.cmd   REXX script to run the regression tests
diff --git a/cproto-4.6/os2/run_test.cmd b/cproto-4.6/os2/run_test.cmd
new file mode 100644 (file)
index 0000000..49559e1
--- /dev/null
@@ -0,0 +1,27 @@
+/* REXX script to run cproto tests. */
+/* $Id: run_test.cmd,v 4.2 1998/01/22 19:49:38 cthuang Exp $ */
+"@echo off"
+
+testDir = "..\testing"
+casesFile = testDir||"\run_test.txt"
+sourceFile = testDir||"\syntax.c"
+logFile = "run_test.out"
+
+echo "Test log" ">" logFile
+
+linein(casesFile,1,0);
+do while lines(casesFile) > 0
+    parse value linein(casesFile) with caseID '=' platforms '=' options
+    if left(caseID, 4) = "CASE" & pos("os2", platforms) > 0 then do
+       say caseID
+
+       baseName = "case"||substr(caseID, 6, 2)
+        inputFile = baseName||".c"
+       outputFile = baseName||".out"
+       refFile = testDir||"\"||baseName||".ref"
+
+       copy sourceFile inputFile ">nul"
+       cproto options inputFile ">" outputFile
+       echo n "|" comp outputFile refFile ">>" logFile
+    end
+end
diff --git a/cproto-4.6/os2/watcom.mak b/cproto-4.6/os2/watcom.mak
new file mode 100644 (file)
index 0000000..905a626
--- /dev/null
@@ -0,0 +1,53 @@
+# $Id: watcom.mak,v 4.3 1998/01/22 19:49:39 cthuang Exp $
+#
+# Watcom makefile for C prototype generator
+# To use this file, do
+#
+#      wmake /u /f watcom.mak
+
+PROGRAM = cproto
+DEFINES =
+INCLUDES = -I.. -I..\porting
+
+LEX = lex
+YACC = yacc
+CC = wcl386
+CFLAGS = $(DEFINES) $(INCLUDES)
+LIBS =
+
+.c: ..
+
+.c.obj: .AUTODEPEND
+       $(CC) $(CFLAGS) /c $<
+
+O = .obj
+OBJECTS = \
+       cproto$(O) \
+       getopt$(O) \
+       lintlibs$(O) \
+       semantic$(O) \
+       strkey$(O) \
+       symbol$(O) \
+       y_tab$(O)
+
+all: $(PROGRAM).exe
+
+$(PROGRAM).exe: $(OBJECTS)
+       $(CC) $(CFLAGS) /fe=$@ $(OBJECTS) $(LIBS)
+
+getopt$(O): ..\porting\getopt.c
+       $(CC) $(CFLAGS) /c ..\porting\getopt.c
+
+cproto.man: cproto.1
+       cawf -man $*.1 | bsfilt - >$*.man
+
+clean:
+       -del $(PROGRAM).exe
+       -del *$(O)
+       -del *.err
+       -del *.log
+       -del *.out
+       -del case*.c
+
+test:
+       run_test
diff --git a/cproto-4.6/porting/README b/cproto-4.6/porting/README
new file mode 100644 (file)
index 0000000..761db33
--- /dev/null
@@ -0,0 +1,8 @@
+The files in this directory are needed to build on non-UNIX platforms.
+
+getopt.c       This is a free implementation of the getopt function for
+getopt.h       systems that don't already have it (such as MS-DOS and VMS).
+               Some systems that support auto-configuration may need these
+               files.  You'll have to edit the makefile in that case.
+popen.c                fakes a pipe open/close by writing to a temporary file.
diff --git a/cproto-4.6/porting/getopt.c b/cproto-4.6/porting/getopt.c
new file mode 100644 (file)
index 0000000..290da93
--- /dev/null
@@ -0,0 +1,87 @@
+/* ::[[ @(#) getopt.c 1.5 89/03/11 05:40:23 ]]:: */
+#ifndef LINT
+static char sccsid[]="::[[ @(#) getopt.c 1.5 89/03/11 05:40:23 ]]::";
+#endif
+
+/*
+ * Here's something you've all been waiting for:  the AT&T public domain
+ * source for getopt(3).  It is the code which was given out at the 1985
+ * UNIFORUM conference in Dallas.  I obtained it by electronic mail
+ * directly from AT&T.  The people there assure me that it is indeed
+ * in the public domain.
+ *
+ * There is no manual page.  That is because the one they gave out at
+ * UNIFORUM was slightly different from the current System V Release 2
+ * manual page.  The difference apparently involved a note about the
+ * famous rules 5 and 6, recommending using white space between an option
+ * and its first argument, and not grouping options that have arguments.
+ * Getopt itself is currently lenient about both of these things White
+ * space is allowed, but not mandatory, and the last option in a group can
+ * have an argument.  That particular version of the man page evidently
+ * has no official existence, and my source at AT&T did not send a copy.
+ * The current SVR2 man page reflects the actual behavor of this getopt.
+ * However, I am not about to post a copy of anything licensed by AT&T.
+ */
+
+#ifdef ANSIPROTO
+int strcmp (char *, char *);
+char *strchr (char *, char);
+#endif
+
+#include <stdio.h>
+
+#define ERR(szz,czz) if(opterr){fprintf(stderr,"%s%s%c\n",argv[0],szz,czz);}
+
+extern int strcmp();
+extern char *strchr();
+
+int   opterr = 1;
+int   optind = 1;
+int   optopt;
+char  *optarg;
+
+int
+getopt(argc, argv, opts)
+int   argc;
+char  **argv, *opts;
+{
+   static int sp = 1;
+   register int c;
+   register char *cp;
+
+   if(sp == 1)
+      if(optind >= argc ||
+         argv[optind][0] != '-' || argv[optind][1] == '\0')
+         return(EOF);
+      else if(strcmp(argv[optind], "--") == 0) {
+         optind++;
+         return(EOF);
+      }
+   optopt = c = argv[optind][sp];
+   if(c == ':' || (cp=strchr(opts, c)) == NULL) {
+      ERR(": illegal option -- ", c);
+      if(argv[optind][++sp] == '\0') {
+         optind++;
+         sp = 1;
+      }
+      return('?');
+   }
+   if(*++cp == ':') {
+      if(argv[optind][sp+1] != '\0')
+         optarg = &argv[optind++][sp+1];
+      else if(++optind >= argc) {
+         ERR(": option requires an argument -- ", c);
+         sp = 1;
+         return('?');
+      } else
+         optarg = argv[optind++];
+      sp = 1;
+   } else {
+      if(argv[optind][++sp] == '\0') {
+         sp = 1;
+         optind++;
+      }
+      optarg = NULL;
+   }
+   return(c);
+}
diff --git a/cproto-4.6/porting/getopt.h b/cproto-4.6/porting/getopt.h
new file mode 100644 (file)
index 0000000..12c5d37
--- /dev/null
@@ -0,0 +1,8 @@
+extern char *optarg;
+extern int optind, opterr;
+
+#if defined(__STDC__)
+int getopt (int argc, char **argv, const char *options);
+#else
+int getopt ();
+#endif
diff --git a/cproto-4.6/porting/popen.c b/cproto-4.6/porting/popen.c
new file mode 100644 (file)
index 0000000..300e73b
--- /dev/null
@@ -0,0 +1,81 @@
+/* $Id: popen.c,v 4.2 1998/01/08 00:03:28 cthuang Exp $
+ *
+ * Imitate a UNIX pipe in MS-DOS.
+ */
+#ifdef MSDOS
+#include <stdio.h>
+#include <stdlib.h>
+#include <process.h>
+#include <io.h>
+#include "cproto.h"
+
+static char pipe_name[FILENAME_MAX];   /* name of the temporary file */
+
+/* Open a pipe for reading.
+ */
+FILE *
+popen (cmd, type)
+char *cmd, *type;
+{
+    char *tmpdir, *argv[30], **arg, *cmdline, *s, opt[FILENAME_MAX];
+    int ostdout, status;
+
+    /* Set temporary file name. */
+    if ((tmpdir = getenv("TMP")) == NULL) {
+       pipe_name[0] = '\0';
+    } else {
+       strcpy(pipe_name, tmpdir);
+       trim_path_sep(pipe_name);
+       strcat(pipe_name, "/");
+    }
+    strcat(pipe_name, tmpnam(NULL));
+
+    /* Split the command into an argument array. */
+    cmdline = xstrdup(cmd);
+    arg = argv;
+    s = strtok(cmdline, " ");
+    *arg++ = s;
+#ifdef TURBO_CPP
+    sprintf(opt, "-o%s", pipe_name);
+    *arg++ = opt;
+#endif
+    while ((s = strtok(NULL, " ")) != NULL) {
+       *arg++ = s;
+    }
+    *arg = NULL;
+    /* Redirect the program's stdout. */
+    ostdout = dup(fileno(stdout));
+#ifdef TURBO_CPP
+    freopen("nul", "w", stdout);
+#else
+    freopen(pipe_name, "w", stdout);
+#endif
+    /* Run the program. */
+    status = spawnvp(P_WAIT, argv[0], argv);
+    /* Restore stdout. */
+    dup2(ostdout, fileno(stdout));
+    free(cmdline);
+
+    if (status != 0)
+       return NULL;
+    /* Open the intermediate file and return the stream. */
+    return fopen(pipe_name, type) ;
+}
+/* Close the pipe.
+ */
+int
+pclose (f)
+FILE *f;
+{
+    int status;
+    status = fclose(f);
+    unlink(pipe_name);
+    return status;
+}
+#endif /* MSDOS */
diff --git a/cproto-4.6/semantic.c b/cproto-4.6/semantic.c
new file mode 100644 (file)
index 0000000..aefa0b2
--- /dev/null
@@ -0,0 +1,1225 @@
+/* $Id: semantic.c,v 4.5 1998/01/19 00:49:26 cthuang Exp $
+ *
+ * Semantic actions executed by the parser of the
+ * C function prototype generator.
+ */
+#include <stdio.h>
+#include "cproto.h"
+#include "semantic.h"
+
+#if OPT_LINTLIBRARY
+static int             put_parameter           ARGS((FILE *outf, Parameter *p, int name_only, int count, int commented));
+#define        putParameter(fp,p,f,n,c)                put_parameter(fp, p, f, n, c)
+#else
+static int             put_parameter           ARGS((FILE *outf, Parameter *p, int commented));
+#define        putParameter(fp,p,f,n,c)                put_parameter(fp, p, c)
+#endif
+
+static char *          concat_string           ARGS((char *a, char *b));
+#if OPT_LINTLIBRARY
+static char *          glue_strings            ARGS((char *a, char *b));
+#endif
+static boolean         is_void_parameter       ARGS((Parameter *p));
+static Parameter *     search_parameter_list   ARGS((ParameterList *params, char *name));
+static void            put_param_list          ARGS((FILE *outf, Declarator *declarator, int commented));
+static void            put_parameters          ARGS((FILE *outf, Declarator *declarator, int commented));
+static void            put_func_declarator     ARGS((FILE *outf, Declarator *declarator, int commented));
+static void            put_declarator          ARGS((FILE *outf, Declarator *declarator, int commented));
+static void            put_decl_spec           ARGS((FILE *outf, DeclSpec *decl_spec));
+#if OPT_LINTLIBRARY
+static void            put_llib_params         ARGS((Declarator *d, int c));
+#endif
+static int             uses_varargs            ARGS((Declarator *declarator));
+static void            check_void_param        ARGS((Declarator *declarator));
+static void            set_param_decl_spec     ARGS((Declarator *declarator));
+static void            put_param_decl          ARGS((Declarator *declarator, int commented));
+
+/* Head function declarator in a prototype or function definition */
+static Declarator *func_declarator;
+
+/* Role of the function declarator
+ * FUNC_PROTO if it is the declarator in a function prototype.
+ * FUNC_DEF if it is the declarator in a function definition.
+ */
+static int where;
+
+/* Output format to use */
+static int format;
+
+/* Function-parameter level, used to simplify logic that comments/suppresses
+ * function parameters in the output.
+ */
+static int nestedParams;
+
+/* Initialize a new declaration specifier part.
+ */
+void
+new_decl_spec (decl_spec, text, offset, flags)
+DeclSpec *decl_spec;
+char *text;
+long offset;
+int flags;
+{
+#if OPT_LINTLIBRARY
+    if (lintLibrary()) {
+       if (!strcmp(text, "register"))
+           text = "";
+    }
+#endif
+    decl_spec->text = xstrdup(text);
+    decl_spec->begin = offset;
+    decl_spec->flags = flags;
+}
+
+/* Free storage used by a declaration specifier part.
+ */
+void
+free_decl_spec (decl_spec)
+DeclSpec *decl_spec;
+{
+    free(decl_spec->text);
+}
+
+/* Create a new string by joining two strings with a space between them.
+ * Return a pointer to the resultant string.
+ * If out of memory, output an error message and exit.
+ */
+static char *
+concat_string (a, b)
+char *a, *b;
+{
+    char *result;
+
+    result = xmalloc(strlen(a) + strlen(b) + 2);
+    strcpy(result, a);
+    strcat(result, " ");
+    strcat(result, b);
+    return result;
+}
+
+#if OPT_LINTLIBRARY
+static char *
+glue_strings (a, b)    /* concatenate w/o embedded blank */
+char *a, *b;
+{
+    char *result;
+
+    result = xmalloc(strlen(a) + strlen(b) + 2);
+    strcpy(result, a);
+    strcat(result, b);
+    return result;
+}
+#endif
+
+/* Append two declaration specifier parts together.
+ */
+void
+join_decl_specs (result, a, b)
+DeclSpec *result, *a, *b;
+{
+    result->text = concat_string(a->text, b->text);
+    result->flags = a->flags | b->flags;
+    result->begin = a->begin;
+}
+
+/* Output an error message if the declaration specifier is an untagged
+ * struct, union or enum.
+ */
+void
+check_untagged (decl_spec)
+DeclSpec *decl_spec;
+{
+    if (strstr(decl_spec->text, "struct {}") != NULL) {
+       put_error();
+       fputs("untagged struct declaration\n", stderr);
+    } else if (strstr(decl_spec->text, "union {}") != NULL) {
+       put_error();
+       fputs("untagged union declaration\n", stderr);
+    } else if (strstr(decl_spec->text, "enum {}") != NULL) {
+       put_error();
+       fputs("untagged enum declaration\n", stderr);
+    }
+}
+
+/* Allocate and initialize a declarator.
+ */
+Declarator *
+new_declarator (text, name, offset)
+char *text, *name;
+long offset;
+{
+    Declarator *d;
+
+    d = NEW(Declarator);
+    d->text = xstrdup(text);
+    d->name = xstrdup(name);
+    d->begin = offset;
+    d->begin_comment = d->end_comment = 0;
+    d->func_def = FUNC_NONE;
+    new_ident_list(&d->params);
+    d->head = d;
+    d->func_stack = NULL;
+    d->pointer = FALSE;
+    return d;
+}
+
+/* Free storage used by a declarator.
+ */
+void
+free_declarator (d)
+Declarator *d;
+{
+    free(d->text);
+    free(d->name);
+    free_param_list(&d->params);
+    if (d->func_stack != NULL)
+       free_declarator(d->func_stack);
+    free(d);
+}
+
+/* Initialize a declarator list and add the given declarator to it.
+ */
+void
+new_decl_list (decl_list, declarator)
+DeclaratorList *decl_list;
+Declarator *declarator;
+{
+    decl_list->first = decl_list->last = declarator;
+    declarator->next = NULL;
+}
+
+/* Free storage used by the declarators in the declarator list.
+ */
+void
+free_decl_list (decl_list)
+DeclaratorList *decl_list;
+{
+    Declarator *d, *next;
+
+    d = decl_list->first;
+    while (d != NULL) {
+       next = d->next;
+       free_declarator(d);
+       d = next;
+    }
+}
+
+/* Add the declarator to the declarator list.
+ */
+void
+add_decl_list (to, from, declarator)
+DeclaratorList *to, *from;
+Declarator *declarator;
+{
+    to->first = from->first;
+    from->last->next = declarator;
+    to->last = declarator;
+    to->last->next = NULL;
+}
+
+/* Create a new parameter structure.
+ */
+Parameter *
+new_parameter (decl_spec, declarator)
+DeclSpec *decl_spec;
+Declarator *declarator;
+{
+    Parameter *param;
+    param = NEW(Parameter);
+
+    if (decl_spec == NULL) {
+       new_decl_spec(&param->decl_spec, "", 0L, DS_NONE);
+    } else {
+       param->decl_spec = *decl_spec;
+    }
+
+    if (declarator == NULL) {
+       declarator = new_declarator("", "", 0L);
+    }
+    param->declarator = declarator;
+
+    param->comment = NULL;
+    return param;
+}
+
+/* Free the storage used by the parameter.
+ */
+void
+free_parameter (param)
+Parameter *param;
+{
+    free_decl_spec(&param->decl_spec);
+    free_declarator(param->declarator);
+    if (param->comment != NULL)
+       free(param->comment);
+    free(param);
+}
+
+/* Return TRUE if the parameter is void.
+ */
+static boolean
+is_void_parameter (p)
+Parameter *p;
+{
+    return p == NULL || (strcmp(p->decl_spec.text, "void") == 0 &&
+     p->declarator->text[0] == '\0');
+}
+
+/* Initialize a list of function parameters.
+ */
+void
+new_param_list (param_list, param)
+ParameterList *param_list;
+Parameter *param;
+{
+    param_list->first = param_list->last = param;
+    param->next = NULL;
+
+    param_list->begin_comment = param_list->end_comment = 0;
+    param_list->comment = NULL;
+}
+
+/* Free storage used by the elements in the function parameter list.
+ */
+void
+free_param_list (param_list)
+ParameterList *param_list;
+{
+    Parameter *p, *next;
+
+    p = param_list->first;
+    while (p != NULL) {
+       next = p->next;
+       free_parameter(p);
+       p = next;
+    }
+
+    if (param_list->comment != NULL)
+       free(param_list->comment);
+}
+
+/* Add the parameter to the function parameter list.
+ */
+void
+add_param_list (to, from, param)
+ParameterList *to, *from;
+Parameter *param;
+{
+    to->first = from->first;
+    from->last->next = param;
+    to->last = param;
+    param->next = NULL;
+}
+
+/* Initialize an empty list of function parameter names.
+ */
+void
+new_ident_list (param_list)
+ParameterList *param_list;
+{
+    param_list->first = param_list->last = NULL;
+    param_list->begin_comment = param_list->end_comment = 0;
+    param_list->comment = NULL;
+}
+
+/* Add an item to the list of function parameter declarations but set only
+ * the parameter name field.
+ */
+void
+add_ident_list (to, from, name)
+ParameterList *to, *from;
+char *name;
+{
+    Parameter *p;
+    Declarator *declarator;
+
+    declarator = new_declarator(name, name, 0L);
+    p = new_parameter((DeclSpec *)0, declarator);
+
+    to->first = from->first;
+    if (to->first == NULL) {
+       to->first = p;
+    } else {
+       from->last->next = p;
+    }
+    to->last = p;
+    p->next = NULL;
+}
+
+/* Search the list of parameters for a matching parameter name.
+ * Return a pointer to the matching parameter or NULL if not found.
+ */
+static Parameter *
+search_parameter_list (params, name)
+ParameterList *params;
+char *name;
+{
+    Parameter *p;
+
+    for (p = params->first; p != NULL; p = p->next) {
+       if (strcmp(p->declarator->name, name) == 0)
+           return p;
+    }
+    return (Parameter *)NULL;
+}
+
+/* For each name in the declarator list <declarators>, set the declaration
+ * specifier part of the parameter in <params> having the same name.
+ * This is also where we promote formal parameters.  Parameters of type
+ * "char", "unsigned char", "short", or "unsigned short" are promoted to
+ * "int".  Parameters of type "float" are promoted to "double".
+ */
+void
+set_param_types (params, decl_spec, declarators)
+ParameterList *params;
+DeclSpec *decl_spec;
+DeclaratorList *declarators;
+{
+    Declarator *d;
+    Parameter *p;
+    char *decl_spec_text;
+
+    for (d = declarators->first; d != NULL; d = d->next) {
+       /* Search the parameter list for a matching name. */
+       if ((p = search_parameter_list(params, d->name)) == NULL) {
+           put_error();
+           fprintf(stderr, "declared argument \"%s\" is missing\n", d->name);
+       } else {
+           decl_spec_text = decl_spec->text;
+           if (promote_param && strcmp(d->text, d->name) == 0) {
+               if (decl_spec->flags & (DS_CHAR | DS_SHORT))
+                   decl_spec_text = "int";
+               else if (decl_spec->flags & DS_FLOAT)
+                   decl_spec_text = "double";
+           }
+           free(p->decl_spec.text);
+           p->decl_spec.text = xstrdup(decl_spec_text);
+
+           free_declarator(p->declarator);
+           p->declarator = d;
+       }
+    }
+}
+
+/* Output a function parameter.
+ */
+static int
+put_parameter (outf, p,
+#if OPT_LINTLIBRARY
+       name_only, count,
+#endif
+       commented)
+FILE *outf;
+Parameter *p;
+#if OPT_LINTLIBRARY
+int    name_only;      /* nonzero if we only show the parameter name */
+int    count;          /* index in parameter list if we haven't names */
+#endif
+int    commented;      /* comment-delimiters already from higher level */
+{
+    char       *s;
+    char       gap = ' ';
+
+#if OPT_LINTLIBRARY
+    if (name_only) {
+       s = p->declarator->name;
+       if (lintLibrary()) {
+           while (*s == '*')
+               s++;
+           if (*s == '\0' && !is_void_parameter(p))
+               s = supply_parm(count);
+       }
+       put_string(outf, s);    /* ... remainder of p->declarator.name */
+       return (TRUE);
+    }
+#endif
+
+    s = p->decl_spec.text;
+#if OPT_LINTLIBRARY
+    if (lintLibrary()) {
+       if (is_void_parameter(p))
+           return (FALSE);
+       indent(outf);
+       if (knrLintLibrary() && !*s)
+           s = "int";
+       if (strlen(s) < 8)
+           gap = '\t';
+    }
+#endif
+
+    put_string(outf, s);
+
+#if OPT_LINTLIBRARY
+    if (lintLibrary()) {
+       char *t, *u;
+       s = p->declarator->text;
+       while (*s == '*')
+           s++;
+       if (*s == '\0') {
+           u = p->declarator->text;
+           p->declarator->text = glue_strings(u, supply_parm(count));
+           free(u);
+       } else if (p->declarator->name[0] == '\0') {
+           if ((t = strstr(s, "%s")) != 0) {
+               int parenthesized = FALSE;
+               Declarator *q;
+
+               free(p->declarator->name);
+               p->declarator->name = xstrdup(supply_parm(count));
+
+               for (q = p->declarator; q != 0; q = q->func_stack) {
+                   if (q->func_def == FUNC_NONE) {
+                       if (!strcmp(q->text, "(*)")) {
+                           char temp[20];
+                           sprintf(temp, "(*%s)", p->declarator->name);
+                           free(q->text);
+                           q->text = xstrdup(temp);
+                           parenthesized = TRUE;
+                       } else {
+                           free(q->text);
+                           q->text = xstrdup(p->declarator->name);
+                       }
+                       break;
+                   }
+               }
+               if (!parenthesized) {
+                   if ((u = strchr(t, PAREN_L)) != 0) { /* e.g., "*%s()" */
+                       t = p->declarator->text;
+                       u = xmalloc(strlen(t) + 3);
+                       (void)sprintf(u, "(%s)", t);
+                       p->declarator->text = u;
+                       free(t);
+                   }
+               }
+           } else {    /* e.g., s is "[20]" for "char [20]" parameter */
+                       /* ...or something like "* const *" */
+               while (*s != '\0' && *s != SQUARE_L)
+                       s++;
+               u = xstrdup(s);                 /* the "[20]" */
+               *s = '\0';
+               if (s != p->declarator->text) {
+                       s = glue_strings(p->declarator->text, supply_parm(count));
+               } else {
+                       s = xstrdup(supply_parm(count));
+               }
+               p->declarator->text = glue_strings(s, u);
+               free(u);
+               free(s);
+           }
+       }
+    }
+#endif
+
+    if (p->declarator->text[0] != '\0') {
+       if (strcmp(p->declarator->text, ELLIPSIS) == 0) {
+           put_string(outf, ELLIPSIS);
+       } else {
+           if (proto_style != PROTO_ABSTRACT || proto_comments
+            || where != FUNC_PROTO
+            || strcmp(p->declarator->text, p->declarator->name) != 0)
+               put_char(outf, gap);
+           put_declarator(outf, p->declarator, commented);
+       }
+    }
+    return (TRUE);
+}
+
+/* Output a parameter list.
+ */
+static void
+put_param_list (outf, declarator, commented)
+FILE *outf;
+Declarator *declarator;
+int commented;
+{
+#if OPT_LINTLIBRARY
+    int count = 0;
+#endif
+    Parameter *p;
+    int f;
+    int hide_it = (where == FUNC_PROTO) && (proto_style == PROTO_TRADITIONAL);
+    int do_cmt = proto_comments && hide_it;
+
+    p = declarator->params.first;
+    if (hide_it && !do_cmt) {
+       ;
+    } else if (is_void_parameter(p)) {
+       if (do_cmt) {
+           if (!commented)
+               put_string(outf, COMMENT_BEGIN);
+           put_string(outf, "void");
+           if (!commented)
+               put_string(outf, COMMENT_END);
+       } else if (!hide_it)
+#if OPT_LINTLIBRARY
+       if (!knrLintLibrary())
+#endif
+           put_string(outf, "void");
+    } else {
+       f = (declarator == func_declarator) ? format : FMT_OTHER;
+
+#if OPT_LINTLIBRARY
+       if (where == FUNC_PROTO
+        && knrLintLibrary()
+        && (func_declarator != declarator)) {
+           do_cmt = TRUE;      /* patch: shouldn't have gotten here at all */
+       }
+#endif
+       if (where == FUNC_DEF && declarator->params.comment != NULL)
+           put_string(outf, declarator->params.comment);
+       else if (do_cmt && !commented)
+           put_string(outf, COMMENT_BEGIN);
+
+       put_string(outf, fmt[f].first_param_prefix);
+       (void)putParameter(outf, p, knrLintLibrary(), ++count, commented);
+
+       while (p->next != NULL) {
+#if OPT_LINTLIBRARY
+           if (lint_ellipsis(p->next))
+               break;
+#endif
+           put_char(outf, ',');
+           if (where == FUNC_DEF && p->comment != NULL)
+               put_string(outf, p->comment);
+
+           p = p->next;
+           put_string(outf, fmt[f].middle_param_prefix);
+           (void)putParameter(outf, p, knrLintLibrary(), ++count, commented);
+       }
+       if (where == FUNC_DEF && p->comment != NULL)
+           put_string(outf, p->comment);
+       else if (do_cmt && !commented)
+           put_string(outf, COMMENT_END);
+
+       put_string(outf, fmt[f].last_param_suffix);
+    }
+}
+
+/* Output function parameters.
+ */
+static void
+put_parameters (outf, declarator, commented)
+FILE *outf;
+Declarator *declarator;
+int commented;
+{
+    Parameter *p;
+
+    nestedParams++;
+    if (where == FUNC_DEF && func_style == FUNC_TRADITIONAL) {
+
+       /* Output parameter name list for traditional function definition. */
+       p = declarator->params.first;
+
+       /* Output parameter name list only for head function declarator. */
+       if (!is_void_parameter(p) && declarator == func_declarator) {
+           put_string(outf, fmt[format].first_param_prefix);
+           put_string(outf, p->declarator->name);
+           p = p->next;
+           while (p != NULL && strcmp(p->declarator->text, ELLIPSIS) != 0) {
+               put_char(outf, ',');
+               put_string(outf, fmt[format].middle_param_prefix);
+               put_string(outf, p->declarator->name);
+               p = p->next;
+           }
+           put_string(outf, fmt[format].last_param_suffix);
+       }
+    } else {
+
+       /* Output parameter type list. */
+       if (where == FUNC_PROTO && proto_style == PROTO_TRADITIONAL &&
+        declarator == func_declarator) {
+           if (proto_comments) {
+               put_string(outf, COMMENT_BEGIN);
+               put_param_list(outf, declarator, TRUE);
+               put_string(outf, COMMENT_END);
+           }
+       } else if (func_style != FUNC_NONE || proto_style != PROTO_NONE) {
+#if OPT_LINTLIBRARY
+           if (!knrLintLibrary() || nestedParams <= 1)
+#endif
+               put_param_list(outf, declarator, commented);
+       }
+    }
+    nestedParams--;
+}
+
+/* Output a function declarator.
+ */
+static void
+put_func_declarator (outf, declarator, commented)
+FILE *outf;
+Declarator *declarator;
+int commented;
+{
+    char *s, *t, *decl_text;
+    int f;
+    int saveNest = nestedParams;
+
+    /* Output declarator text before function declarator place holder. */
+    if ((s = strstr(declarator->text, "%s")) == NULL)
+       return;
+    *s = '\0';
+    put_string(outf, declarator->text);
+
+    /* Substitute place holder with function declarator. */
+    if (declarator->func_stack->func_def == FUNC_NONE) {
+
+       decl_text = declarator->func_stack->text;
+       if (declarator->name[0] == '\0') {
+           put_string(outf, decl_text);
+       } else {
+           int star;
+
+           /* Output the declarator text before the declarator name. */
+           if ((t = strstr(decl_text, declarator->name)) == NULL)
+               return;
+           *t = '\0';
+           star = ((t != decl_text) && (t[-1] == '*'));
+           put_string(outf, decl_text);
+           *t = declarator->name[0];
+
+           /* Output the declarator prefix before the name. */
+           f = (declarator == func_declarator) ? format : FMT_OTHER;
+           if (strcmp(fmt[f].declarator_prefix, " ") != 0)
+               put_string(outf, fmt[f].declarator_prefix);
+
+           /* Output the declarator name. */
+           if (where == FUNC_PROTO && proto_style == PROTO_ABSTRACT &&
+            declarator != func_declarator) {
+               if (proto_comments) {
+                   if (star) put_char(outf, ' ');
+                   put_string(outf, COMMENT_BEGIN);
+                   put_string(outf, declarator->name);
+                   put_string(outf, COMMENT_END);
+               }
+           } else {
+               put_string(outf, declarator->name);
+           }
+
+           /* Output the remaining declarator text. */
+           put_string(outf, t + strlen(declarator->name));
+
+           /* Output the declarator suffix. */
+           put_string(outf, fmt[f].declarator_suffix);
+       }
+    } else {
+       put_func_declarator(outf, declarator->func_stack, commented);
+       nestedParams = 2; /* e.g., "void (*signal(p1, p2))()" */
+    }
+    *s = '%';
+    s += 2;
+
+    /* Output declarator text up to but before parameters place holder. */
+    if ((t = strstr(s, "()")) == NULL)
+       return;
+    *t = '\0';
+    put_string(outf, s);
+
+    if (where == FUNC_PROTO
+     && (func_declarator == declarator
+      || func_declarator == declarator->head)
+     && proto_macro) {
+       fprintf(outf, " %s(", macro_name);
+    }
+
+    /* Substitute place holder with function parameters. */
+    put_char(outf, *t++ = PAREN_L);
+    put_parameters(outf, declarator, commented);
+    put_string(outf, t);
+
+    if (where == FUNC_PROTO
+     && (func_declarator == declarator
+      || func_declarator == declarator->head)
+     && proto_macro) {
+       put_char(outf, PAREN_R);
+    }
+    nestedParams = saveNest;
+}
+
+/* Output a declarator.
+ */
+static void
+put_declarator (outf, declarator, commented)
+FILE *outf;
+Declarator *declarator;
+int commented;
+{
+    char *s;
+
+    if (declarator->func_def == FUNC_NONE) {
+       if (where == FUNC_PROTO && proto_style == PROTO_ABSTRACT &&
+        declarator->name[0] != '\0') {
+           if ((s = strstr(declarator->text, declarator->name)) == NULL)
+               return;
+           *s = '\0';
+           if (proto_comments) {
+               fprintf(outf, "%s%s%s%s%s", declarator->text,
+                COMMENT_BEGIN, declarator->name, COMMENT_END,
+                s + strlen(declarator->name));
+           } else {
+               fprintf(outf, "%s%s", declarator->text,
+                s + strlen(declarator->name));
+           }
+           *s = declarator->name[0];
+       } else {
+           put_string(outf, declarator->text);
+       }
+    } else {
+       put_func_declarator(outf, declarator, commented);
+    }
+}
+
+/* Output a declaration specifier for an external declaration.
+ */
+static void
+put_decl_spec (outf, decl_spec)
+FILE *outf;
+DeclSpec *decl_spec;
+{
+    /* An "extern func()" is legal, but we want to be explicit for lint libs */
+#if OPT_LINTLIBRARY
+    if (decl_spec->text[0] == '\0') {
+       free(decl_spec->text);
+       decl_spec->text = xstrdup("int");
+    }
+#endif
+    if (extern_out && !(decl_spec->flags & DS_STATIC) &&
+     strkey(decl_spec->text, "extern") == NULL)
+       put_padded(outf, "extern");
+    put_padded(outf, decl_spec->text);
+}
+
+/* Output the list of parameters in K&R style, for lint-library
+ */
+#if OPT_LINTLIBRARY
+static void
+put_llib_params(declarator, commented)
+Declarator *declarator;
+int commented;
+{
+       Parameter *p;
+       int     count = 0;
+
+       nestedParams++;
+       p = (declarator->func_stack->func_def != FUNC_NONE)
+               ? declarator->func_stack->params.first
+               : declarator->params.first;
+
+       while (p != 0) {
+               if (lint_ellipsis(p))
+                       break;
+               if (putParameter(stdout, p, FALSE, ++count, commented))
+                       putchar(';');
+               p = p->next;
+       }
+       nestedParams--;
+}
+#endif
+
+/* Generate variable declarations.
+ */
+void
+gen_declarations (decl_spec, decl_list)
+DeclSpec *decl_spec;           /* declaration specifier */
+DeclaratorList *decl_list;     /* list of declared variables */
+{
+    Declarator *d;
+    int        commented = FALSE;
+    int        saveNest = nestedParams;
+
+#if OPT_LINTLIBRARY
+    boolean    defines = (strchr(decl_spec->text, CURL_L) != 0);
+    int                is_func;
+
+    /* special treatment for -l, -T options */
+    if ((!variables_out && types_out && defines) || (decl_list == 0)) {
+       strcut(decl_spec->text, "static");
+       strcut(decl_spec->text, "extern");
+       fmt_library((decl_list == 0) ? 1 : 2);
+       if (decl_spec->text[0] != '\0') {
+           put_string(stdout, decl_spec->text);
+           put_string(stdout, ";\n");
+       }
+       return;
+    }
+#endif
+
+    if (!variables_out || (decl_spec->flags & (DS_EXTERN|DS_JUNK))) {
+#if OPT_LINTLIBRARY
+       if (in_include >= extern_in)    /* -x option not set? */
+#endif
+           return;
+#if OPT_LINTLIBRARY
+       strcut(decl_spec->text, "extern");
+#endif
+    }
+    if (scope_out == SCOPE_EXTERN && (decl_spec->flags & DS_STATIC))
+       return;
+    if (scope_out == SCOPE_STATIC && !(decl_spec->flags & DS_STATIC))
+       return;
+
+    check_untagged(decl_spec);
+    func_declarator = NULL;
+    where = FUNC_OTHER;
+    format = FMT_OTHER;
+    nestedParams = 0;
+
+    for (d = decl_list->first; d != NULL; d = d->next) {
+       if (d->func_def == FUNC_NONE
+        || d->head->func_stack->pointer
+#if OPT_LINTLIBRARY
+        || (in_include < extern_in)
+#endif
+          ) {
+#if OPT_LINTLIBRARY
+           if (already_declared(d->name)) {
+               flush_varargs();
+               continue;
+           }
+
+           /*
+            * Try to distinguish function declarations from function pointer
+            * declarations, so that we don't unintentionally emit lint-library
+            * arguments for function pointers.
+            */
+           is_func = is_actual_func(d);
+
+           if (is_func) {
+               ellipsis_varargs(d);
+           } else {
+               nestedParams = 2;       /* disable params altogether */
+               if (types_out)
+                   fmt_library(2);
+           }
+           if (lint_shadowed && lintLibrary())
+               printf("#undef %s\n", d->name);
+#endif
+           put_string(stdout, fmt[FMT_PROTO].decl_spec_prefix);
+           put_decl_spec(stdout, decl_spec);
+           put_declarator(stdout, d, commented);
+#if OPT_LINTLIBRARY
+           if (knrLintLibrary() && is_func)
+               put_llib_params(d, commented);
+#endif
+           put_body(stdout, decl_spec, d);
+           nestedParams = saveNest;
+       }
+#if OPT_LINTLIBRARY
+       flush_varargs();
+#endif
+    }
+    exitlike_func = FALSE;
+}
+
+/* Return TRUE if the function uses varargs.
+ */
+static int
+uses_varargs (declarator)
+Declarator *declarator;
+{
+    Parameter *p;
+
+    return (p = declarator->params.first) != NULL
+       && (p->next == NULL)
+       && (!strcmp(p->declarator->name, "va_alist"));
+}
+
+/* If the parameter list is empty, then replace it with "void".
+ */
+static void
+check_void_param (declarator)
+Declarator *declarator;
+{
+    DeclSpec decl_spec;
+    Parameter *p;
+
+    if (declarator->params.first == NULL) {
+       new_decl_spec(&decl_spec, "void", 0L, DS_NONE);
+       p = new_parameter(&decl_spec, (Declarator *)0);
+       new_param_list(&declarator->params, p);
+    }
+}
+
+/* If a parameter name appears in the parameter list of a traditional style
+ * function definition but is not declared in the parameter declarations,
+ * then assign it the default type "int".
+ */
+static void
+set_param_decl_spec (declarator)
+Declarator *declarator;
+{
+    Parameter *p;
+
+    for (p = declarator->params.first; p != NULL; p = p->next) {
+       if (p->decl_spec.text[0] == '\0' &&
+        strcmp(p->declarator->text, ELLIPSIS) != 0) {
+           free(p->decl_spec.text);
+           p->decl_spec.text = xstrdup("int");
+       }
+    }
+}
+
+/* Generate a function prototype.
+ */
+void
+gen_prototype (decl_spec, declarator)
+DeclSpec *decl_spec;
+Declarator *declarator;
+{
+    Parameter *p;
+    int        commented = FALSE;
+
+    if (proto_style == PROTO_NONE || (decl_spec->flags & DS_JUNK))
+       return;
+    if (scope_out == SCOPE_EXTERN && (decl_spec->flags & DS_STATIC))
+       return;
+    if (scope_out == SCOPE_STATIC && !(decl_spec->flags & DS_STATIC))
+       return;
+
+    /*
+     * Trim pathological keywords (which are legal, but unnecessary) from the
+     * function and its parameters.
+     */
+    strcut(decl_spec->text, "extern");
+    for (p = declarator->params.first; p != NULL; p = p->next) {
+       strcut(p->decl_spec.text, "extern");
+       strcut(p->decl_spec.text, "auto");
+    }
+
+#if OPT_LINTLIBRARY
+    if (lintLibrary())
+       ellipsis_varargs(declarator);
+    else if (types_out)
+       fmt_library(0);
+#endif
+
+    func_declarator = declarator->head;
+    if (uses_varargs(func_declarator)) {
+       /* Generate a prototype for a function that uses varargs by replacing
+        * the "va_alist" parameter with an empty parameter list.
+        */
+       free_param_list(&func_declarator->params);
+       func_declarator->params.first = NULL;
+    }
+
+    check_void_param(func_declarator);
+    set_param_decl_spec(func_declarator);
+
+    where = FUNC_PROTO;
+    format = FMT_PROTO;
+    nestedParams = 0;
+
+#if OPT_LINTLIBRARY
+    if (lint_shadowed && lintLibrary())
+       printf("#undef %s\n", declarator->name);
+#endif
+    put_string(stdout, fmt[format].decl_spec_prefix);
+    put_decl_spec(stdout, decl_spec);
+    put_func_declarator(stdout, declarator, commented);
+#if OPT_LINTLIBRARY
+    if (knrLintLibrary())
+       put_llib_params(declarator, commented);
+#endif
+    put_body(stdout, decl_spec, declarator);
+}
+
+/* Generate a declarator for a function pointer declarator or prototype.
+ */
+void
+gen_func_declarator (declarator)
+Declarator *declarator;
+{
+    /* Go to the beginning of the function declarator in the temporary
+     * file and overwrite it with the converted declarator.
+     */
+    fseek(cur_tmp_file(), declarator->begin, 0);
+    func_declarator = NULL;
+
+    where = FUNC_DEF;
+    format = FMT_FUNC;
+    nestedParams = 0;
+
+    put_func_declarator(cur_tmp_file(), declarator, FALSE);
+    cur_file_changed();
+}
+
+/* Output parameter declarations for old style function definition.
+ */
+static void
+put_param_decl (declarator, commented)
+Declarator *declarator;
+int commented;
+{
+#if OPT_LINTLIBRARY
+    int count = 0;
+#endif
+    Parameter *p;
+
+    p = declarator->params.first;
+    if (!is_void_parameter(p)) {
+       fputc('\n', cur_tmp_file());
+       (void)putParameter(cur_tmp_file(), p, knrLintLibrary(), ++count, commented);
+       fputc(';', cur_tmp_file());
+       if (p->comment != 0)
+           fputs(p->comment, cur_tmp_file());
+       p = p->next;
+       while (p != NULL && strcmp(p->declarator->text, ELLIPSIS) != 0) {
+           fputc('\n', cur_tmp_file());
+           (void)putParameter(cur_tmp_file(), p, knrLintLibrary(), ++count, commented);
+           fputc(';', cur_tmp_file());
+           if (p->comment != 0)
+               fputs(p->comment, cur_tmp_file());
+           p = p->next;
+       }
+    }
+}
+
+/* Generate a function definition head.
+ */
+void
+gen_func_definition (decl_spec, declarator)
+DeclSpec *decl_spec;
+Declarator *declarator;
+{
+    Parameter *p;
+    ParameterList *params;
+    char *comment = 0;
+    int n;
+    unsigned comment_len;
+    long diff;
+
+    /* Do nothing if the function is already defined in the desired style
+     * or if the function uses varargs.
+     */
+    func_declarator = declarator->head;
+    if (func_declarator->func_def == func_style ||
+       uses_varargs(func_declarator))
+       return;
+
+    /* Save the text between the function head and the function body.
+     * Read the temporary file from after the last ) or ; to the
+     * end of the file.
+     */
+    if ((diff = (ftell(cur_tmp_file()) - cur_begin_comment())) > 0) {
+       comment_len = (unsigned)diff;
+       *(comment = xmalloc(comment_len)) = '\0';
+       fseek(cur_tmp_file(), cur_begin_comment(), 0);
+       fread(comment, sizeof(char), comment_len, cur_tmp_file());
+    } else {
+       comment_len = 0;
+    }
+
+    format = FMT_FUNC;
+    nestedParams = 0;
+
+    if (func_declarator->func_def == FUNC_TRADITIONAL
+     || func_declarator->func_def == FUNC_BOTH) {
+       /* Save the text before the parameter declarations. */
+       params = &func_declarator->params;
+       n = (int)(params->end_comment - params->begin_comment);
+       if (n > 0) {
+           *(params->comment = xmalloc((unsigned)(n+1))) = '\0';
+           fseek(cur_tmp_file(), params->begin_comment, 0);
+           fread(params->comment, sizeof(char), (size_t)n, cur_tmp_file());
+           params->comment[n] = '\0';
+           format = FMT_FUNC_COMMENT;
+       }
+
+       /* Get the parameter comments. */
+       for (p = func_declarator->params.first; p != NULL; p = p->next) {
+           n = (int)(p->declarator->end_comment - p->declarator->begin_comment);
+           if (n > 0) {
+               *(p->comment = xmalloc((unsigned)n+1)) = '\0';
+               fseek(cur_tmp_file(), p->declarator->begin_comment, 0);
+               fread(p->comment, sizeof(char), (size_t)n, cur_tmp_file());
+               p->comment[n] = '\0';
+               format = FMT_FUNC_COMMENT;
+           }
+       }
+    }
+
+    check_void_param(func_declarator);
+    set_param_decl_spec(func_declarator);
+
+    /* Go to the beginning of the function head in the temporary file
+     * and overwrite it with the converted function head.
+     */
+    where = FUNC_DEF;
+    fseek(cur_tmp_file(), decl_spec->begin, 0);
+
+    if (func_style == FUNC_BOTH) {
+       char *cur_func;
+       unsigned func_len;
+
+       /* Save the current function definition head. */
+       if ((diff = (cur_begin_comment() - decl_spec->begin)) > 0) {
+           func_len = (unsigned)diff;
+           cur_func = xmalloc(func_len);
+           fread(cur_func, sizeof(char), func_len, cur_tmp_file());
+       } else {
+           cur_func = 0;
+           func_len = 0;
+       }
+
+       fseek(cur_tmp_file(), decl_spec->begin, 0);
+       fprintf(cur_tmp_file(), "%s\n\n", func_directive);
+
+       /* Output new style function definition head. */
+       if (func_declarator->func_def == FUNC_ANSI) {
+           if (cur_func != 0)
+               fwrite(cur_func, sizeof(char), func_len, cur_tmp_file());
+       } else {
+           fputs(fmt[format].decl_spec_prefix, cur_tmp_file());
+           fputs(decl_spec->text, cur_tmp_file());
+           fputc(' ', cur_tmp_file());
+
+           func_style = FUNC_ANSI;
+           put_func_declarator(cur_tmp_file(), declarator, FALSE);
+       }
+       fputs("\n#else\n\n", cur_tmp_file());
+
+       /* Output old style function definition head. */
+       if (func_declarator->func_def == FUNC_TRADITIONAL
+        || func_declarator->func_def == FUNC_BOTH) {
+           if (cur_func != 0)
+               fwrite(cur_func, sizeof(char), func_len, cur_tmp_file());
+       } else {
+           fputs(fmt[format].decl_spec_prefix, cur_tmp_file());
+           fputs(decl_spec->text, cur_tmp_file());
+           fputc(' ', cur_tmp_file());
+
+           format = FMT_FUNC;
+           func_style = FUNC_TRADITIONAL;
+           put_func_declarator(cur_tmp_file(), declarator, FALSE);
+           put_param_decl(func_declarator, FALSE);
+       }
+
+       fputs("\n#endif", cur_tmp_file());
+       if (*comment != '\n')
+           fputc('\n', cur_tmp_file());
+       func_style = FUNC_BOTH;
+
+       if (cur_func != 0)
+           free(cur_func);
+
+    } else {
+       /* Output declarator specifiers. */
+       fputs(fmt[format].decl_spec_prefix, cur_tmp_file());
+       fputs(decl_spec->text, cur_tmp_file());
+       fputc(' ', cur_tmp_file());
+
+       /* Output function declarator. */
+       put_func_declarator(cur_tmp_file(), declarator, FALSE);
+       if (func_style == FUNC_TRADITIONAL)
+           put_param_decl(func_declarator, FALSE);
+    }
+
+    /* Output text between function head and body. */
+    if (comment != 0) {
+       fwrite(comment, sizeof(char), comment_len, cur_tmp_file());
+       free(comment);
+    }
+
+    cur_file_changed();
+}
diff --git a/cproto-4.6/semantic.h b/cproto-4.6/semantic.h
new file mode 100644 (file)
index 0000000..28c416b
--- /dev/null
@@ -0,0 +1,47 @@
+/* $Id: semantic.h,v 4.1 1994/10/12 14:12:48 cthuang Exp $
+ *
+ * Declarations of semantic action routines
+ */
+
+extern void new_decl_spec ARGS((
+    DeclSpec *decl_spec, char *text, long offset, int flags));
+extern void free_decl_spec ARGS((
+    DeclSpec *decl_spec));
+extern void join_decl_specs ARGS((
+    DeclSpec *result, DeclSpec *a, DeclSpec *b));
+extern void check_untagged ARGS((
+    DeclSpec *decl_spec));
+extern Declarator *new_declarator ARGS((
+    char *text, char *name, long offset));
+extern void free_declarator ARGS((
+    Declarator *d));
+extern void new_decl_list ARGS((
+    DeclaratorList *decl_list, Declarator *declarator));
+extern void free_decl_list ARGS((
+    DeclaratorList *decl_list));
+extern void add_decl_list ARGS((
+    DeclaratorList *to, DeclaratorList *from, Declarator *declarator));
+extern Parameter *new_parameter ARGS((
+    DeclSpec *decl_spec, Declarator *declarator));
+extern void free_parameter ARGS((
+    Parameter *param));
+extern void new_param_list ARGS((
+    ParameterList *param_list, Parameter *param));
+extern void free_param_list ARGS((
+    ParameterList *param_list));
+extern void add_param_list ARGS((
+    ParameterList *to, ParameterList *from, Parameter *param));
+extern void new_ident_list ARGS((
+    ParameterList *param_list));
+extern void add_ident_list ARGS((
+    ParameterList *to, ParameterList *from, char *name));
+extern void set_param_types ARGS((
+    ParameterList *params, DeclSpec *decl_spec, DeclaratorList *declarators));
+extern void gen_declarations ARGS((
+    DeclSpec *decl_spec, DeclaratorList *decl_list));
+extern void gen_prototype ARGS((
+    DeclSpec *decl_spec, Declarator *declarator));
+extern void gen_func_declarator ARGS((
+    Declarator *declarator));
+extern void gen_func_definition ARGS((
+    DeclSpec *decl_spec, Declarator *declarator));
diff --git a/cproto-4.6/strkey.c b/cproto-4.6/strkey.c
new file mode 100644 (file)
index 0000000..82a5511
--- /dev/null
@@ -0,0 +1,56 @@
+/* $Id: strkey.c,v 4.2 1998/01/19 00:49:28 cthuang Exp $
+ *
+ * Some string handling routines
+ */
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include "cproto.h"
+
+#define        LETTER(c) (isalnum(c) || (c == '_') || (c == '$'))
+
+/*
+ * Return a pointer to the first occurence of the given keyword in the string
+ * or NULL if not found.  Unlike 'strstr()', which verifies that the match is
+ * against an identifier-token.
+ */
+char *
+strkey (src, key)
+char *src, *key;
+{
+    if (src != 0 && key != 0) {
+       register char *s  = src, *d;
+       register size_t len = strlen(key);
+
+       while (*s) {
+           if (!LETTER(*s)) {
+               s++;
+           } else {
+               for (d = s; LETTER(*d); d++)
+                   ;
+               if ((d - s) == len && !strncmp(s, key, len))
+                   return s;
+               s = d;
+           }
+       }
+    }
+    return NULL;
+}
+
+/*
+ * Delete a specified keyword from a string if it appears there
+ */
+void
+strcut (src, key)
+char *src, *key;
+{
+    register char *s, *d;
+
+    if ((s = strkey(src, key)) != '\0') {
+       d = s + strlen(key);
+       while (*d != '\0' && !LETTER(*d))
+           d++;
+       while ((*s++ = *d++) != '\0')
+           ;
+    }
+}
diff --git a/cproto-4.6/strstr.c b/cproto-4.6/strstr.c
new file mode 100644 (file)
index 0000000..8c67d65
--- /dev/null
@@ -0,0 +1,32 @@
+/* $Id: strstr.c,v 4.1 1994/10/12 14:12:48 cthuang Exp $
+ *
+ * Simple implementation of the ANSI strstr() function
+ */
+#include <stdio.h>
+
+#include "cproto.h"
+
+/* Search for a substring within the given string.
+ * Return a pointer to the first occurence within the string,
+ * or NULL if not found.
+ */
+#if !HAVE_STRSTR
+char *
+strstr (src, key)
+char *src, *key;
+{
+    char *s;
+    int keylen;
+
+    if ((keylen = strlen(key)) == 0)
+       return src;
+
+    s = strchr(src, *key);
+    while (s != NULL) {
+       if (strncmp(s, key, keylen) == 0)
+           return s;
+       s = strchr(s+1, *key);
+    }
+    return NULL;
+}
+#endif
diff --git a/cproto-4.6/symbol.c b/cproto-4.6/symbol.c
new file mode 100644 (file)
index 0000000..25e18b7
--- /dev/null
@@ -0,0 +1,125 @@
+/* $Id: symbol.c,v 4.3 1998/01/19 00:49:30 cthuang Exp $
+ *
+ * Implements a symbol table abstract data type.
+ */
+#include <stdio.h>
+#include "cproto.h"
+#include "symbol.h"
+
+static unsigned hash ARGS((char *name));
+static Symbol *search_symbol_list ARGS((Symbol *list, char *name));
+
+/* Create a symbol table.
+ * Return a pointer to the symbol table or NULL if an error occurs.
+ */
+SymbolTable *
+new_symbol_table ()
+{
+    SymbolTable *symtab;
+    int i;
+
+    if ((symtab = NEW(SymbolTable)) != NULL) {
+       for (i = 0; i < SYM_MAX_HASH; ++i)
+           symtab->bucket[i] = NULL;
+    }
+    return symtab;
+}
+
+
+/* Free the memory allocated to the symbol table.
+ */
+void
+free_symbol_table (symtab)
+SymbolTable *symtab;
+{
+    int i;
+    Symbol *sym, *next;
+
+    for (i = 0; i < SYM_MAX_HASH; ++i) {
+       sym = symtab->bucket[i];
+       while (sym != NULL) {
+           next = sym->next;
+           if (sym->name  != 0) free(sym->name);
+           if (sym->value != 0) free(sym->value);
+           free(sym);
+           sym = next;
+       }
+    }
+    free(symtab);
+}
+
+
+/* This is a simple hash function mapping a symbol name to a hash bucket. */
+
+static unsigned
+hash (name)
+char *name;
+{
+    char *s;
+    unsigned h;
+
+    h = 0;
+    s = name;
+    while (*s != '\0')
+       h = (h << 1) ^ *s++;
+    return h % SYM_MAX_HASH;
+}
+
+
+/* Search the list of symbols <list> for the symbol <name>.
+ * Return a pointer to the symbol or NULL if not found.
+ */
+static Symbol *
+search_symbol_list (list, name)
+Symbol *list;
+char *name;
+{
+    Symbol *sym;
+
+    for (sym = list; sym != NULL; sym = sym->next) {
+       if (strcmp(sym->name, name) == 0)
+           return sym;
+    }
+    return NULL;
+}
+
+
+/* Look for symbol <name> in symbol table <symtab>.
+ * Return a pointer to the symbol or NULL if not found.
+ */
+Symbol *
+find_symbol (symtab, name)
+SymbolTable *symtab;
+char *name;
+{
+    return search_symbol_list(symtab->bucket[hash(name)], name);
+}
+
+
+/* If the symbol <name> does not already exist in symbol table <symtab>,
+ * then add the symbol to the symbol table.
+ * Return a pointer to the symbol.
+ */
+Symbol *
+new_symbol (symtab, name, value, flags)
+SymbolTable *symtab;   /* symbol table */
+char *name;            /* symbol name */
+char *value;           /* symbol value */
+int flags;             /* symbol attributes */
+{
+    Symbol *sym;
+    int i;
+
+    if ((sym = find_symbol(symtab, name)) == NULL) {
+       sym = NEW(Symbol);
+       sym->name = xstrdup(name);
+       i = hash(name);
+       sym->next = symtab->bucket[i];
+       symtab->bucket[i] = sym;
+    } else {
+       free(sym->value);
+    }
+    sym->value = (value != NULL) ? xstrdup(value) : NULL;
+    sym->flags = flags;
+    return sym;
+}
diff --git a/cproto-4.6/symbol.h b/cproto-4.6/symbol.h
new file mode 100644 (file)
index 0000000..eb0fa77
--- /dev/null
@@ -0,0 +1,32 @@
+/* $Id: symbol.h,v 4.1 1994/10/12 14:12:48 cthuang Exp $
+ *
+ * A symbol table is a collection of string identifiers stored in a
+ * hash table.
+ */
+#ifndef SYMBOL_H
+#define SYMBOL_H
+
+typedef struct symbol {
+    struct symbol *next;       /* next symbol in list */
+    char *name;                /* name of symbol */
+    char *value;               /* value of symbol (for defines) */
+    short flags;               /* symbol attributes */
+} Symbol;
+
+/* The hash table length should be a prime number. */
+#define SYM_MAX_HASH 251
+
+typedef struct symbol_table {
+    Symbol *bucket[SYM_MAX_HASH];      /* hash buckets */
+} SymbolTable;
+
+extern SymbolTable *new_symbol_table   /* Create symbol table */
+       ARGS((void));
+extern void free_symbol_table          /* Destroy symbol table */
+       ARGS((SymbolTable *s));
+extern Symbol *find_symbol             /* Lookup symbol name */
+       ARGS((SymbolTable *s, char *n));
+extern Symbol *new_symbol              /* Define new symbol */
+       ARGS((SymbolTable *s, char *n, char *v, int f));
+
+#endif
diff --git a/cproto-4.6/system.h b/cproto-4.6/system.h
new file mode 100644 (file)
index 0000000..9c1aa85
--- /dev/null
@@ -0,0 +1,209 @@
+/* $Id: system.h,v 4.7 1998/01/24 01:42:09 cthuang Exp $
+ *
+ * cproto configuration and system dependencies
+ */
+#ifndef        SYSTEM_H
+#define        SYSTEM_H
+#if !defined(TRUE) || (TRUE != 1)
+#undef  TRUE
+#define        TRUE    (1)
+#endif
+
+#if !defined(FALSE) || (FALSE != 0)
+#undef  FALSE
+#define        FALSE   (0)
+#endif
+
+/* Watcom C++ predefines __DOS__ when the target platform is MS-DOS */
+/* Borland C++ for MS-DOS predefines __MSDOS__ */
+#if defined(__DOS__) || defined(__MSDOS__)
+#ifndef MSDOS
+#define MSDOS
+#endif
+#endif
+
+/* Watcom C++ predefines __OS2__ when the target platform is OS/2 */
+#ifdef __OS2__
+#ifndef OS2
+#define OS2
+#endif
+#endif
+
+/* Watcom C++ predefines __NT__ when the target platform is Windows NT */
+#ifdef __NT__
+#ifndef WIN32
+#define WIN32
+#endif
+#endif
+
+/* don't use continuation-lines -- breaks on VAXC */
+#if defined(__STDC__) || defined(__GNUC__) || defined(__WATCOMC__) || defined(vms)
+#define ARGS(p) p
+#else
+#define ARGS(p) ()
+#endif
+
+/* Turbo C preprocessor */
+#ifdef __TURBOC__
+#define YY_READ_BUF_SIZE 256   /* patch */
+#define HAVE_TMPFILE 1
+#define HAVE_GETOPT_H 1        /* use the one from porting-directory */
+#include <io.h>                /* declares 'read()' for flex */
+#endif
+
+#ifdef TURBO_CPP
+#define CPP "cpp -P-"
+#endif
+
+/* EMX C preprocessor */
+#ifdef __EMX__
+#ifndef CPP
+#define CPP "cpp"
+#endif
+#endif
+
+/* Watcom C preprocessor */
+#ifdef __WATCOMC__
+#ifndef CPP
+#define CPP "wcl386 /p"
+#endif
+#define HAVE_POPEN_PROTOTYPE 1
+#define popen _popen
+#define pclose _pclose
+#define HAVE_TMPFILE 1
+#endif
+
+/* Microsoft C preprocessor */
+#ifdef M_I86
+#ifndef CPP
+#define CPP "cl /E /nologo"
+#endif
+#define HAVE_TMPFILE 1
+#endif
+
+/* Vax C */
+#ifdef vms
+#ifndef CPP
+#define CPP "cc /preprocess_only=%s"
+#endif
+#define unlink remove
+#define HAVE_TMPFILE 1
+#define HAVE_GETOPT_H 1
+#define USE_flex 1
+#endif
+
+/* Set configuration parameters for systems on which we cannot run autoconf.
+ * (Assumes Posix unless overridden).
+ */
+#ifndef HAVE_STDLIB_H
+#define HAVE_STDLIB_H 1
+#endif
+
+#ifndef HAVE_STRING_H
+#define HAVE_STRING_H 1
+#endif
+
+#ifndef HAVE_STRSTR
+#define HAVE_STRSTR 1
+#endif
+
+#ifndef HAVE_GETOPT_H
+#define HAVE_GETOPT_H 0
+#endif 
+
+/* Default C preprocessor on UNIX systems */
+#ifndef MSDOS
+#ifndef CPP
+#define CPP "/lib/cpp"
+#endif
+#endif
+
+/* maximum include file nesting */
+#ifndef MAX_INC_DEPTH
+#define MAX_INC_DEPTH 15
+#endif
+
+/* maximum number of include directories */
+#ifndef MAX_INC_DIR
+#define MAX_INC_DIR 15
+#endif
+
+/* maximum text buffer size */
+#ifndef MAX_TEXT_SIZE
+#define MAX_TEXT_SIZE 256
+#endif
+
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#else
+extern char *malloc  ARGS((size_t n));
+extern char *realloc ARGS((char *p, size_t n));
+#endif
+
+/* Declare argument for exit() function */
+#ifdef vms
+#include <stsdef.h>
+#define        EXIT_SUCCESS    (STS$M_INHIB_MSG | STS$K_SUCCESS)
+#define        EXIT_FAILURE    (STS$M_INHIB_MSG | STS$K_ERROR)
+#else
+#ifndef EXIT_SUCCESS
+#define        EXIT_SUCCESS    (0)
+#endif
+#ifndef EXIT_FAILURE
+#define        EXIT_FAILURE    (1)
+#endif
+#endif /* vms */
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if STDC_HEADERS || HAVE_STRING_H
+#  include <string.h>
+/* An ANSI string.h and pre-ANSI memory.h might conflict.  */
+#  if !STDC_HEADERS && HAVE_MEMORY_H
+#    include <memory.h>
+#  endif /* not STDC_HEADERS and HAVE_MEMORY_H */
+#else /* not STDC_HEADERS and not HAVE_STRING_H */
+#  include <strings.h>
+#  define strchr index
+#  define strrchr rindex
+/* memory.h and strings.h conflict on some systems.  */
+#endif /* not STDC_HEADERS and not HAVE_STRING_H */
+
+extern char *getenv  ARGS((const char *v));
+extern char *strstr  ARGS((const char *s, const char *p));
+
+/*
+ * The DOALLOC symbol controls whether we compile in the simple memory tests
+ * in 'trace.c' (use dbmalloc for more rigorous testing).
+ */
+#ifdef DOALLOC
+#include <trace.h>
+#endif /* DOALLOC */
+
+/*
+ * Lint libraries are useful only on systems that are likely to have lint.
+ * The OPT_LINTLIBRARY symbol controls whether we compile in the lint library
+ * support.
+ */
+#ifndef OPT_LINTLIBRARY
+# if HAVE_PROG_LINT || defined(unix)
+#  define OPT_LINTLIBRARY 1
+# endif
+#endif
+
+#if BISON_HAS_YYTNAME || YACC_HAS_YYTOKS || YACC_HAS_YYTOKS_2 || YACC_HAS_YYNAME
+# define YYDEBUG 1
+#endif
+
+#if HAVE_LIBDMALLOC
+#include <dmalloc.h>   /* Gray Watson's library */
+#endif
+
+#if HAVE_LIBDBMALLOC
+#include <dbmalloc.h>  /* Conor Cahill's library */
+#endif
+
+#endif /* SYSTEM_H */
diff --git a/cproto-4.6/testing/README b/cproto-4.6/testing/README
new file mode 100644 (file)
index 0000000..cc9ca05
--- /dev/null
@@ -0,0 +1,60 @@
+$Id: README,v 4.3 1995/01/06 23:42:14 tom Exp $
+
+CPROTO/TESTING
+
+There's several types of files in this directory, distinguished by their
+suffixes.
+
+       makefile
+               a UNIX makefile used to coordinate files and to invoke the
+               UNIX master test script 'run_test.sh'.
+
+       case*.bat
+               MSDOS scripts automatically generated to run test cases.
+
+       test_dos.bat
+               The master MSDOS test script.
+
+       syntax.c
+               The test data (contains some intentional errors, and all of
+               the interesting tests that can be made portable across all
+               platforms).
+
+       apollo.c
+       linux.c
+       solaris.c
+       turboc.c
+               These are lint library templates, used for exercising cproto.
+               They include as many of the system's include files as possible,
+               in an attempt to find lexical/grammar problems with cproto.
+
+       run_test.com
+               The VMS master test script.
+
+       case*.dcl
+               UNIX+VMS scripts automatically generated to run test cases.
+               (They don't have a ".com" suffix because that would create
+               problems on MSDOS).
+
+       descrip.mms
+               The VMS equivalent of 'makefile'.
+
+       case*.ref
+               Reference files obtained by running the test scripts.
+
+       make_bat.sh
+               The script that generates case*.bat
+
+       make_dcl.sh
+               The script that generates case*.dcl
+
+       run_test.sh
+               The master UNIX test script
+
+       testunix.sh
+               The UNIX test script that actually does all of the work
+
+       run_test.txt
+               The test list, from which the case*.dcl, case*.bat files
+               are generated.
+
diff --git a/cproto-4.6/testing/apollo.c b/cproto-4.6/testing/apollo.c
new file mode 100644 (file)
index 0000000..e01bf02
--- /dev/null
@@ -0,0 +1,117 @@
+#define        const
+/* LINT_PREPRO6
+#undef COMPLETE_SR10_2
+#ifdef __STDC__
+#ident Standard LLIB
+#else
+#ident Traditional LLIB
+#endif
+*/
+
+/* LINT_EXTERN */
+#include       <apollo/base.h>
+
+/*             <apollo/a.out.h>        */
+#include       <apollo/aclm.h>
+/*             <apollo/aouthdr.h>      */
+/*             <apollo/builtins.h>     */
+/*             <apollo/cache.h>        */
+
+#include       <apollo/cal.h>
+
+/*             <apollo/ctm.h>          (see below) */
+/*             <apollo/dialog.h>       (separate) */
+/*             <apollo/dsee.h>         (separate) */
+
+#ifdef COMPLETE_SR10_2
+#include       <apollo/dst.h>
+#include       <apollo/ec2.h>
+#include       <apollo/errlog.h>
+#endif
+
+#include       <apollo/error.h>
+#include       <apollo/ev.h>
+
+/*             <apollo/fault.h>        */
+/*             <apollo/filehdr.h>      */
+
+#ifdef COMPLETE_SR10_2
+#include       <apollo/fontn.h>
+#include       <apollo/fpp.h>
+#include       <apollo/fpp1.h>
+#include       <apollo/gmf.h>
+#endif
+
+/*             <apollo/gmr.h>          (missing?) */
+/*             <apollo/gpr.h>          (lint can't eat prototype-in!) */
+/*             <apollo/gsr.h>          (missing?) */
+/*             <apollo/gsr_types.h>    */
+
+#ifdef COMPLETE_SR10_2
+#include       <apollo/io_traits.h>
+#endif
+#include       <apollo/ios.h>
+#ifdef COMPLETE_SR10_2
+#include       <apollo/ios_dir.h>
+#include       <apollo/ios_dir_trait.h>
+#include       <apollo/ipc.h>
+/*             <apollo/kbd.h>          */
+/*             <apollo/linenum.h>      */
+#include       <apollo/loader.h>
+#include       <apollo/mbx.h>
+/*             <apollo/mir.h>          */
+#include       <apollo/ms.h>
+#include       <apollo/mts.h>
+#include       <apollo/mutex.h>
+#endif
+
+#include       <apollo/name.h>
+/*             <apollo/nlist.h>        */
+
+#ifdef COMPLETE_SR10_2
+#include       <apollo/org.h>
+#include       <apollo/osinfo.h>
+#endif
+
+#include       <apollo/pad.h>
+
+#ifdef COMPLETE_SR10_2
+#include       <apollo/pbufs.h>
+#include       <apollo/pfm.h>
+#include       <apollo/pgm.h>
+#include       <apollo/pm.h>
+#include       <apollo/ppfm.h>
+#include       <apollo/prf.h>
+#include       <apollo/proc1.h>
+#include       <apollo/proc2.h>
+/*             <apollo/reloc.h>        */
+#include       <apollo/rws.h>
+/*             <apollo/scndata.h>      */
+/*             <apollo/scnhdr.h>       */
+#include       <apollo/sfcb.h>
+#include       <apollo/sio.h>
+#include       <apollo/sio_hw.h>
+#include       <apollo/sio_trait.h>
+#include       <apollo/smdu.h>
+#include       <apollo/sri.h>
+/*             <apollo/storclass.h>    */
+#include       <apollo/symbol.h>
+/*             <apollo/syms.h>         */
+#include       <apollo/task.h>
+#include       <apollo/time.h>
+#include       <apollo/tml.h>
+#include       <apollo/tone.h>
+#include       <apollo/tpad.h>
+#endif
+
+/* patch:#include      <apollo/trait.h> */
+#include       <apollo/tty.h>
+#include       <apollo/type_uids.h>
+
+#ifdef COMPLETE_SR10_2
+/*             <apollo/unwind.h>       */
+#include       <apollo/vec.h>
+#include       <apollo/vfmt.h>
+
+#include       <apollo/ctm.h>
+#endif
diff --git a/cproto-4.6/testing/case01.ref b/cproto-4.6/testing/case01.ref
new file mode 100644 (file)
index 0000000..be41f63
--- /dev/null
@@ -0,0 +1,29 @@
+/* case01.c */
+int dots_0(int p1);
+int dots_1(int p1, ...);
+int dots_3(int p1, char p2, ...);
+_FIRST *func1(void);
+_FIRST *func2(_FIRST *p1, int p2[], float p);
+int *(func_func)(void);
+int main(register argc, char **argv);
+int veryfunny(char *a, long b, long c);
+int program(string argv[], struct alpha y, int zz, int z1, int z2, int z3);
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(void_junk void_int);
+void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1);
+void (*sigdisp2(int sig, void (*func)(int sig)))(int sig2);
+int (*K_R_INT_ptr(long *p1, int p2))(void);
+void (*K_R_VOID_ptr(long *p1, int p2))(void);
+int *K_R_int_ptr(long *p1, int p2);
+void *K_R_void_ptr(long *p1, int p2);
+int K_R_int_val(long *p1, int p2);
+int K_R_int_val2(long *p1, int p2);
+void K_R_void_val(long *p1, int p2);
+int K_R_void_val2(long *p1, int p2);
diff --git a/cproto-4.6/testing/case02.ref b/cproto-4.6/testing/case02.ref
new file mode 100644 (file)
index 0000000..3db95d7
--- /dev/null
@@ -0,0 +1 @@
+/* case02.c */
diff --git a/cproto-4.6/testing/case03.ref b/cproto-4.6/testing/case03.ref
new file mode 100644 (file)
index 0000000..87e9ac5
--- /dev/null
@@ -0,0 +1,29 @@
+/* case03.c */
+int dots_0(/*int p1*/);
+int dots_1(/*int p1, ...*/);
+int dots_3(/*int p1, char p2, ...*/);
+_FIRST *func1(/*void*/);
+_FIRST *func2(/*_FIRST *p1, int p2[], float p*/);
+int *(func_func)(/*void*/);
+int main(/*register argc, char **argv*/);
+int veryfunny(/*char *a, long b, long c*/);
+int program(/*string argv[], struct alpha y, int zz, int z1, int z2, int z3*/);
+int junk0(/*void*/);
+int junk1(/*void*/);
+int junk2(/*void*/);
+int junk3(/*void*/);
+BONG *junk4(/*void*/);
+extern_junk *foo(/*void*/);
+void_junk *foo2a(/*void*/);
+void_junk *foo2(/*void*/);
+void_junk *foo_void(/*void_junk void_int*/);
+void (*Sigdisp(/*int sig, void (*func)(int sig)*/))(/*int sig1*/);
+void (*sigdisp2(/*int sig, void (*func)(int sig)*/))(/*int sig2*/);
+int (*K_R_INT_ptr(/*long *p1, int p2*/))(/*void*/);
+void (*K_R_VOID_ptr(/*long *p1, int p2*/))(/*void*/);
+int *K_R_int_ptr(/*long *p1, int p2*/);
+void *K_R_void_ptr(/*long *p1, int p2*/);
+int K_R_int_val(/*long *p1, int p2*/);
+int K_R_int_val2(/*long *p1, int p2*/);
+void K_R_void_val(/*long *p1, int p2*/);
+int K_R_void_val2(/*long *p1, int p2*/);
diff --git a/cproto-4.6/testing/case04.ref b/cproto-4.6/testing/case04.ref
new file mode 100644 (file)
index 0000000..6f206c9
--- /dev/null
@@ -0,0 +1,29 @@
+/* case04.c */
+int dots_0(int /*p1*/);
+int dots_1(int /*p1*/, ...);
+int dots_3(int /*p1*/, char /*p2*/, ...);
+_FIRST *func1(void);
+_FIRST *func2(_FIRST */*p1*/, int /*p2*/[], float /*p*/);
+int *(func_func)(void);
+int main(register /*argc*/, char **/*argv*/);
+int veryfunny(char */*a*/, long /*b*/, long /*c*/);
+int program(string /*argv*/[], struct alpha /*y*/, int /*zz*/, int /*z1*/, int /*z2*/, int /*z3*/);
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(void_junk /*void_int*/);
+void (*Sigdisp(int /*sig*/, void (* /*func*/)(int /*sig*/)))(int /*sig1*/);
+void (*sigdisp2(int /*sig*/, void (* /*func*/)(int /*sig*/)))(int /*sig2*/);
+int (*K_R_INT_ptr(long */*p1*/, int /*p2*/))(void);
+void (*K_R_VOID_ptr(long */*p1*/, int /*p2*/))(void);
+int *K_R_int_ptr(long */*p1*/, int /*p2*/);
+void *K_R_void_ptr(long */*p1*/, int /*p2*/);
+int K_R_int_val(long */*p1*/, int /*p2*/);
+int K_R_int_val2(long */*p1*/, int /*p2*/);
+void K_R_void_val(long */*p1*/, int /*p2*/);
+int K_R_void_val2(long */*p1*/, int /*p2*/);
diff --git a/cproto-4.6/testing/case05.ref b/cproto-4.6/testing/case05.ref
new file mode 100644 (file)
index 0000000..06b6b25
--- /dev/null
@@ -0,0 +1,29 @@
+/* case05.c */
+int dots_0(int p1);
+int dots_1(int p1, ...);
+int dots_3(int p1, char p2, ...);
+_FIRST *func1(void);
+_FIRST *func2(_FIRST *p1, int p2[], float p);
+int *(func_func)(void);
+int main(register argc, char **argv);
+int veryfunny(char *a, long b, long c);
+int program(string argv[], struct alpha y, int zz, int z1, int z2, int z3);
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(void_junk void_int);
+void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1);
+void (*sigdisp2(int sig, void (*func)(int sig)))(int sig2);
+int (*K_R_INT_ptr(long *p1, int p2))(void);
+void (*K_R_VOID_ptr(long *p1, int p2))(void);
+int *K_R_int_ptr(long *p1, int p2);
+void *K_R_void_ptr(long *p1, int p2);
+int K_R_int_val(long *p1, int p2);
+int K_R_int_val2(long *p1, int p2);
+void K_R_void_val(long *p1, int p2);
+int K_R_void_val2(long *p1, int p2);
diff --git a/cproto-4.6/testing/case06.ref b/cproto-4.6/testing/case06.ref
new file mode 100644 (file)
index 0000000..9368dbb
--- /dev/null
@@ -0,0 +1,53 @@
+/* case06.c */
+char x6;
+short x7;
+int x8;
+long x9;
+float x10;
+double x11;
+signed x12;
+unsigned x13;
+x4t x17;
+const x18 = {0};
+volatile x19;
+_FIRST first;
+_FIRST last;
+_FIRST first_last[];
+struct _second _SECOND;
+int i[];
+float f[];
+int array[][10][20];
+int dots_0(int p1);
+int dots_1(int p1, ...);
+int dots_3(int p1, char p2, ...);
+_FIRST *func1(void);
+_FIRST *func2(_FIRST *p1, int p2[], float p);
+int *(func_func)(void);
+bool a1;
+struct zip2 z2;
+struct {} z3;
+enum zap1 what;
+enum zap2 what2;
+enum {} what3;
+int main(register argc, char **argv);
+int veryfunny(char *a, long b, long c);
+int program(string argv[], struct alpha y, int zz, int z1, int z2, int z3);
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(void_junk void_int);
+void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1);
+void (*sigdisp2(int sig, void (*func)(int sig)))(int sig2);
+int (*K_R_INT_ptr(long *p1, int p2))(void);
+void (*K_R_VOID_ptr(long *p1, int p2))(void);
+int *K_R_int_ptr(long *p1, int p2);
+void *K_R_void_ptr(long *p1, int p2);
+int K_R_int_val(long *p1, int p2);
+int K_R_int_val2(long *p1, int p2);
+void K_R_void_val(long *p1, int p2);
+int K_R_void_val2(long *p1, int p2);
diff --git a/cproto-4.6/testing/case07.ref b/cproto-4.6/testing/case07.ref
new file mode 100644 (file)
index 0000000..6730e43
--- /dev/null
@@ -0,0 +1,53 @@
+/* case07.c */
+extern char x6;
+extern short x7;
+extern int x8;
+extern long x9;
+extern float x10;
+extern double x11;
+extern signed x12;
+extern unsigned x13;
+extern x4t x17;
+extern const x18 = {0};
+extern volatile x19;
+extern _FIRST first;
+extern _FIRST last;
+extern _FIRST first_last[];
+extern struct _second _SECOND;
+extern int i[];
+extern float f[];
+extern int array[][10][20];
+extern int dots_0(int p1);
+extern int dots_1(int p1, ...);
+extern int dots_3(int p1, char p2, ...);
+extern _FIRST *func1(void);
+extern _FIRST *func2(_FIRST *p1, int p2[], float p);
+extern int *(func_func)(void);
+extern bool a1;
+extern struct zip2 z2;
+extern struct {} z3;
+extern enum zap1 what;
+extern enum zap2 what2;
+extern enum {} what3;
+extern int main(register argc, char **argv);
+extern int veryfunny(char *a, long b, long c);
+extern int program(string argv[], struct alpha y, int zz, int z1, int z2, int z3);
+extern int junk0(void);
+extern int junk1(void);
+extern int junk2(void);
+extern int junk3(void);
+extern BONG *junk4(void);
+extern extern_junk *foo(void);
+extern void_junk *foo2a(void);
+extern void_junk *foo2(void);
+extern void_junk *foo_void(void_junk void_int);
+extern void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1);
+extern void (*sigdisp2(int sig, void (*func)(int sig)))(int sig2);
+extern int (*K_R_INT_ptr(long *p1, int p2))(void);
+extern void (*K_R_VOID_ptr(long *p1, int p2))(void);
+extern int *K_R_int_ptr(long *p1, int p2);
+extern void *K_R_void_ptr(long *p1, int p2);
+extern int K_R_int_val(long *p1, int p2);
+extern int K_R_int_val2(long *p1, int p2);
+extern void K_R_void_val(long *p1, int p2);
+extern int K_R_void_val2(long *p1, int p2);
diff --git a/cproto-4.6/testing/case08.ref b/cproto-4.6/testing/case08.ref
new file mode 100644 (file)
index 0000000..e77ea07
--- /dev/null
@@ -0,0 +1,61 @@
+#if __STDC__ || defined(__cplusplus)
+#define P_(s) s
+#else
+#define P_(s) ()
+#endif
+
+/* case08.c */
+extern char x6;
+extern short x7;
+extern int x8;
+extern long x9;
+extern float x10;
+extern double x11;
+extern signed x12;
+extern unsigned x13;
+extern x4t x17;
+extern const x18 = {0};
+extern volatile x19;
+extern _FIRST first;
+extern _FIRST last;
+extern _FIRST first_last[];
+extern struct _second _SECOND;
+extern int i[];
+extern float f[];
+extern int array[][10][20];
+extern int dots_0 P_((int p1));
+extern int dots_1 P_((int p1, ...));
+extern int dots_3 P_((int p1, char p2, ...));
+extern _FIRST *func1 P_((void));
+extern _FIRST *func2 P_((_FIRST *p1, int p2[], float p));
+extern int *(func_func) P_((void));
+extern bool a1;
+extern struct zip2 z2;
+extern struct {} z3;
+extern enum zap1 what;
+extern enum zap2 what2;
+extern enum {} what3;
+extern int main P_((register argc, char **argv));
+extern int veryfunny P_((char *a, long b, long c));
+extern int program P_((string argv[], struct alpha y, int zz, int z1, int z2, int z3));
+extern int junk0 P_((void));
+extern int junk1 P_((void));
+extern int junk2 P_((void));
+extern int junk3 P_((void));
+extern BONG *junk4 P_((void));
+extern extern_junk *foo P_((void));
+extern void_junk *foo2a P_((void));
+extern void_junk *foo2 P_((void));
+extern void_junk *foo_void P_((void_junk void_int));
+extern void (*Sigdisp P_((int sig, void (*func)(int sig)))) P_((int sig1));
+extern void (*sigdisp2 P_((int sig, void (*func)(int sig)))) P_((int sig2));
+extern int (*K_R_INT_ptr P_((long *p1, int p2))) P_((void));
+extern void (*K_R_VOID_ptr P_((long *p1, int p2))) P_((void));
+extern int *K_R_int_ptr P_((long *p1, int p2));
+extern void *K_R_void_ptr P_((long *p1, int p2));
+extern int K_R_int_val P_((long *p1, int p2));
+extern int K_R_int_val2 P_((long *p1, int p2));
+extern void K_R_void_val P_((long *p1, int p2));
+extern int K_R_void_val2 P_((long *p1, int p2));
+
+#undef P_
diff --git a/cproto-4.6/testing/case09.ref b/cproto-4.6/testing/case09.ref
new file mode 100644 (file)
index 0000000..0a3adea
--- /dev/null
@@ -0,0 +1,112 @@
+/* case09.c */
+char x6;
+short x7;
+int x8;
+long x9;
+float x10;
+double x11;
+signed x12;
+unsigned x13;
+x4t x17;
+const x18 = {0};
+volatile x19;
+_FIRST first;
+_FIRST last;
+_FIRST first_last[];
+struct _second _SECOND;
+int i[];
+float f[];
+int array[][10][20];
+int dots_0(
+       int p1
+       );
+int dots_1(
+       int p1,
+       ...
+       );
+int dots_3(
+       int p1,
+       char p2,
+       ...
+       );
+_FIRST *func1(void);
+_FIRST *func2(
+       _FIRST *p1,
+       int p2[],
+       float p
+       );
+int *(func_func)(void);
+bool a1;
+struct zip2 z2;
+struct {} z3;
+enum zap1 what;
+enum zap2 what2;
+enum {} what3;
+int main(
+       register argc,
+       char **argv
+       );
+int veryfunny(
+       char *a,
+       long b,
+       long c
+       );
+int program(
+       string argv[],
+       struct alpha y,
+       int zz,
+       int z1,
+       int z2,
+       int z3
+       );
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(
+       void_junk void_int
+       );
+void (*Sigdisp(
+       int sig,
+       void (*func)(int sig)
+       ))(int sig1);
+void (*sigdisp2(
+       int sig,
+       void (*func)(int sig)
+       ))(int sig2);
+int (*K_R_INT_ptr(
+       long *p1,
+       int p2
+       ))(void);
+void (*K_R_VOID_ptr(
+       long *p1,
+       int p2
+       ))(void);
+int *K_R_int_ptr(
+       long *p1,
+       int p2
+       );
+void *K_R_void_ptr(
+       long *p1,
+       int p2
+       );
+int K_R_int_val(
+       long *p1,
+       int p2
+       );
+int K_R_int_val2(
+       long *p1,
+       int p2
+       );
+void K_R_void_val(
+       long *p1,
+       int p2
+       );
+int K_R_void_val2(
+       long *p1,
+       int p2
+       );
diff --git a/cproto-4.6/testing/case10.ref b/cproto-4.6/testing/case10.ref
new file mode 100644 (file)
index 0000000..ed0b0ed
--- /dev/null
@@ -0,0 +1,88 @@
+/* case10.c */
+
+typedef        int     x4t;
+
+struct x14;
+
+union x15;
+
+enum x16;
+
+x4t;
+
+typedef        struct  _first  {
+       int             a:5;
+       struct  {
+               int     a,b;
+       } b_struct;
+       char            b:16, b1:1;      
+       long            c:16, c1;
+       short           d:16, d1:8, d2;
+       unsigned        e:16;
+       float           f;
+       double          g;
+       struct  _first  *link;
+       }       _FIRST;
+
+struct _second {
+               enum    {true, false} bool;
+               enum    {wrong=1, right=3} values;
+       };
+
+int dots_0(int p1);
+int dots_1(int p1, ...);
+int dots_3(int p1, char p2, ...);
+_FIRST *func1(void);
+_FIRST *func2(_FIRST *p1, int p2[], float p);
+int *(func_func)(void);
+
+typedef        int     bool;
+
+struct ZIP1    { int x1, y1; };
+
+struct zip2    { int x2, y2; };
+struct         { int x3, y3; };
+
+struct ZIP4    { int x4, y4; };
+
+struct zip5    { int x5, y5; };
+struct zip6    { int x6, y6; };
+struct         { int x7, y7; };
+struct         { int x8, y8; };
+enum   zap1    { a,b,c,d };
+enum           {a9,b9,c9,d9};
+
+typedef        struct  bong    {
+       int     (*func)();
+       } BONG;
+
+typedef        char    *string;
+
+int main(register argc, char **argv);
+int veryfunny(char *a, long b, long c);
+int program(string argv[], struct      alpha { int x,z; } y, int zz, int z1, int z2, int z3);
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+
+typedef        int     extern_junk;
+
+extern_junk *foo(void);
+
+typedef        int     void_junk;
+
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(void_junk void_int);
+void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1);
+void (*sigdisp2(int sig, void (*func)(int sig)))(int sig2);
+int (*K_R_INT_ptr(long *p1, int p2))(void);
+void (*K_R_VOID_ptr(long *p1, int p2))(void);
+int *K_R_int_ptr(long *p1, int p2);
+void *K_R_void_ptr(long *p1, int p2);
+int K_R_int_val(long *p1, int p2);
+int K_R_int_val2(long *p1, int p2);
+void K_R_void_val(long *p1, int p2);
+int K_R_void_val2(long *p1, int p2);
diff --git a/cproto-4.6/testing/case11.ref b/cproto-4.6/testing/case11.ref
new file mode 100644 (file)
index 0000000..4274d6e
--- /dev/null
@@ -0,0 +1,202 @@
+/* LINTLIBRARY */
+
+/* case11.c */
+
+typedef        int     x4t;
+
+char   x6;
+short  x7;
+int    x8;
+long   x9;
+float  x10;
+double x11;
+signed x12;
+unsigned x13;
+
+struct x14;
+
+union x15;
+
+enum x16;
+
+x4t;
+
+x4t    x17;
+const  x18 = {0};
+volatile x19;
+
+typedef        struct  _first  {
+       int             a:5;
+       struct  {
+               int     a,b;
+       } b_struct;
+       char            b:16, b1:1;     
+       long            c:16, c1;
+       short           d:16, d1:8, d2;
+       unsigned        e:16;
+       float           f;
+       double          g;
+       struct  _first  *link;
+       }       _FIRST;
+
+_FIRST first;
+_FIRST last;
+_FIRST first_last[];
+struct _second {
+               enum    {true, false} bool;
+               enum    {wrong=1, right=3} values;
+       } _SECOND;
+int    i[];
+float  f[];
+int    array[][10][20];
+
+int    dots_0(p1)
+               int     p1;
+               { return(*(int *)0); }
+
+       /* VARARGS1 */
+int    dots_1(p1)
+               int     p1;
+               { return(*(int *)0); }
+
+       /* VARARGS2 */
+int    dots_3(p1, p2)
+               int     p1;
+               char    p2;
+               { return(*(int *)0); }
+
+_FIRST *func1()
+               { return(*(_FIRST **)0); }
+
+_FIRST *func2(p1, p2, p)
+               _FIRST  *p1;
+               int     p2[];
+               float   p;
+               { return(*(_FIRST **)0); }
+
+int    *(func_func)();
+
+typedef        int     bool;
+
+bool   a1;
+
+struct ZIP1    { int x1, y1; };
+
+struct zip2    { int x2, y2; } z2;
+struct         { int x3, y3; } z3;
+
+struct ZIP4    { int x4, y4; };
+
+enum   zap1    { a,b,c,d } what;
+enum zap2 what2;
+enum           {a9,b9,c9,d9} what3;
+
+typedef        struct  bong    {
+       int     (*func)();
+       } BONG;
+
+typedef        char    *string;
+
+void   main(argc, argv)
+               int     argc;
+               char    **argv;
+               { /* void */ }
+
+       /* VARARGS */
+int    veryfunny(a, b, c)
+               char    *a;
+               long    b;
+               long    c;
+               { return(*(int *)0); }
+
+       /* VARARGS3 */
+int    program(argv, y, zz, z1, z2, z3)
+               string  argv[];
+               struct  alpha { int x,z; } y;
+               int     zz;
+               int     z1;
+               int     z2;
+               int     z3;
+               { return(*(int *)0); }
+
+void   junk0()
+               { /* void */ }
+
+int    junk1()
+               { return(*(int *)0); }
+
+void   junk2()
+               { /* void */ }
+
+int    junk3()
+               { return(*(int *)0); }
+
+BONG   *junk4()
+               { return(*(BONG **)0); }
+
+typedef        int     extern_junk;
+
+extern_junk *foo()
+               { return(*(extern_junk **)0); }
+
+typedef        int     void_junk;
+
+void_junk *foo2a()
+               { return(*(void_junk **)0); }
+
+void_junk *foo2()
+               { return(*(void_junk **)0); }
+
+void_junk *foo_void(void_int)
+               void_junk void_int;
+               { return(*(void_junk **)0); }
+
+void   (*Sigdisp(sig, func))()
+               int     sig;
+               void    (*func)();
+               { return(*(void(*)())0); }
+
+void   (*sigdisp2(sig, func))()
+               int     sig;
+               void    (*func)();
+               { return(*(void(*)())0); }
+
+int    (*K_R_INT_ptr(p1, p2))()
+               long    *p1;
+               int     p2;
+               { return(*(int(*)())0); }
+
+void   (*K_R_VOID_ptr(p1, p2))()
+               long    *p1;
+               int     p2;
+               { return(*(void(*)())0); }
+
+int    *K_R_int_ptr(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int **)0); }
+
+void   *K_R_void_ptr(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(void **)0); }
+
+int    K_R_int_val(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int *)0); }
+
+int    K_R_int_val2(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int *)0); }
+
+void   K_R_void_val(p1, p2)
+               long    *p1;
+               int     p2;
+               { /* void */ }
+
+void   K_R_void_val2(p1, p2)
+               long    *p1;
+               int     p2;
+               { /* void */ }
diff --git a/cproto-4.6/testing/case12.ref b/cproto-4.6/testing/case12.ref
new file mode 100644 (file)
index 0000000..ff2b75c
--- /dev/null
@@ -0,0 +1,30 @@
+/* case12.c */
+int dots_0(int p1);
+int dots_1(int p1, ...);
+int dots_3(int p1, char p2, ...);
+_FIRST *func1(void);
+_FIRST *func2(_FIRST *p1, int p2[], float p);
+int *(func_func)(void);
+int main(register argc, char **argv);
+int veryfunny(char *a, long b, long c);
+int program(string argv[], struct alpha y, int zz, int z1, int z2, int z3);
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(void_junk void_int);
+static void_junk *foo_void2(void);
+void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1);
+void (*sigdisp2(int sig, void (*func)(int sig)))(int sig2);
+int (*K_R_INT_ptr(long *p1, int p2))(void);
+void (*K_R_VOID_ptr(long *p1, int p2))(void);
+int *K_R_int_ptr(long *p1, int p2);
+void *K_R_void_ptr(long *p1, int p2);
+int K_R_int_val(long *p1, int p2);
+int K_R_int_val2(long *p1, int p2);
+void K_R_void_val(long *p1, int p2);
+int K_R_void_val2(long *p1, int p2);
diff --git a/cproto-4.6/testing/case13.ref b/cproto-4.6/testing/case13.ref
new file mode 100644 (file)
index 0000000..80247a6
--- /dev/null
@@ -0,0 +1,215 @@
+/* LINTLIBRARY */
+
+/* case13.c */
+
+static x2;
+
+typedef        int     x4t;
+
+char   x6;
+short  x7;
+int    x8;
+long   x9;
+float  x10;
+double x11;
+signed x12;
+unsigned x13;
+
+struct x14;
+
+union x15;
+
+enum x16;
+
+x4t;
+
+x4t    x17;
+const  x18 = {0};
+volatile x19;
+
+typedef        struct  _first  {
+       int             a:5;
+       struct  {
+               int     a,b;
+       } b_struct;
+       char            b:16, b1:1;     
+       long            c:16, c1;
+       short           d:16, d1:8, d2;
+       unsigned        e:16;
+       float           f;
+       double          g;
+       struct  _first  *link;
+       }       _FIRST;
+
+_FIRST first;
+_FIRST last;
+_FIRST first_last[];
+struct _second {
+               enum    {true, false} bool;
+               enum    {wrong=1, right=3} values;
+       } _SECOND;
+int    i[];
+float  f[];
+int    array[][10][20];
+
+int    dots_0(p1)
+               int     p1;
+               { return(*(int *)0); }
+
+       /* VARARGS1 */
+int    dots_1(p1)
+               int     p1;
+               { return(*(int *)0); }
+
+       /* VARARGS2 */
+int    dots_3(p1, p2)
+               int     p1;
+               char    p2;
+               { return(*(int *)0); }
+
+_FIRST *func1()
+               { return(*(_FIRST **)0); }
+
+_FIRST *func2(p1, p2, p)
+               _FIRST  *p1;
+               int     p2[];
+               float   p;
+               { return(*(_FIRST **)0); }
+
+int    *(func_func)();
+
+typedef        int     bool;
+
+bool   a1;
+static bool a2;
+
+struct ZIP1    { int x1, y1; };
+
+struct zip2    { int x2, y2; } z2;
+struct         { int x3, y3; } z3;
+
+struct ZIP4    { int x4, y4; };
+
+static struct  zip5    { int x5, y5; } z5;
+static struct  zip6    { int x6, y6; } z6;
+static struct  zip6    { int x6, y6; } w6;
+static struct          { int x7, y7; } z7;
+static struct          { int x8, y8; } z8;
+static struct          { int x8, y8; } w8;
+enum   zap1    { a,b,c,d } what;
+enum zap2 what2;
+enum           {a9,b9,c9,d9} what3;
+static char *zap;
+
+typedef        struct  bong    {
+       int     (*func)();
+       } BONG;
+
+typedef        char    *string;
+
+void   main(argc, argv)
+               int     argc;
+               char    **argv;
+               { /* void */ }
+
+       /* VARARGS */
+int    veryfunny(a, b, c)
+               char    *a;
+               long    b;
+               long    c;
+               { return(*(int *)0); }
+
+       /* VARARGS3 */
+int    program(argv, y, zz, z1, z2, z3)
+               string  argv[];
+               struct  alpha { int x,z; } y;
+               int     zz;
+               int     z1;
+               int     z2;
+               int     z3;
+               { return(*(int *)0); }
+
+void   junk0()
+               { /* void */ }
+
+int    junk1()
+               { return(*(int *)0); }
+
+void   junk2()
+               { /* void */ }
+
+int    junk3()
+               { return(*(int *)0); }
+
+BONG   *junk4()
+               { return(*(BONG **)0); }
+
+typedef        int     extern_junk;
+
+extern_junk *foo()
+               { return(*(extern_junk **)0); }
+
+typedef        int     void_junk;
+
+void_junk *foo2a()
+               { return(*(void_junk **)0); }
+
+void_junk *foo2()
+               { return(*(void_junk **)0); }
+
+void_junk *foo_void(void_int)
+               void_junk void_int;
+               { return(*(void_junk **)0); }
+
+static void_junk *foo_void2()
+               { return(*(void_junk **)0); }
+
+void   (*Sigdisp(sig, func))()
+               int     sig;
+               void    (*func)();
+               { return(*(void(*)())0); }
+
+void   (*sigdisp2(sig, func))()
+               int     sig;
+               void    (*func)();
+               { return(*(void(*)())0); }
+
+int    (*K_R_INT_ptr(p1, p2))()
+               long    *p1;
+               int     p2;
+               { return(*(int(*)())0); }
+
+void   (*K_R_VOID_ptr(p1, p2))()
+               long    *p1;
+               int     p2;
+               { return(*(void(*)())0); }
+
+int    *K_R_int_ptr(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int **)0); }
+
+void   *K_R_void_ptr(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(void **)0); }
+
+int    K_R_int_val(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int *)0); }
+
+int    K_R_int_val2(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int *)0); }
+
+void   K_R_void_val(p1, p2)
+               long    *p1;
+               int     p2;
+               { /* void */ }
+
+void   K_R_void_val2(p1, p2)
+               long    *p1;
+               int     p2;
+               { /* void */ }
diff --git a/cproto-4.6/testing/case14.ref b/cproto-4.6/testing/case14.ref
new file mode 100644 (file)
index 0000000..dd3f8bb
--- /dev/null
@@ -0,0 +1,314 @@
+/* LINTLIBRARY */
+
+/* case14.c */
+
+int    x3;
+
+typedef        int     x4t;
+
+char   x6;
+short  x7;
+int    x8;
+long   x9;
+float  x10;
+double x11;
+signed x12;
+unsigned x13;
+
+struct x14;
+
+union x15;
+
+enum x16;
+
+x4t;
+
+x4t    x17;
+const  x18 = {0};
+volatile x19;
+
+typedef        struct  _first  {
+       int             a:5;
+       struct  {
+               int     a,b;
+       } b_struct;
+       char            b:16, b1:1;     
+       long            c:16, c1;
+       short           d:16, d1:8, d2;
+       unsigned        e:16;
+       float           f;
+       double          g;
+       struct  _first  *link;
+       }       _FIRST;
+
+_FIRST first;
+_FIRST last;
+_FIRST first_last[];
+struct _second {
+               enum    {true, false} bool;
+               enum    {wrong=1, right=3} values;
+       } _SECOND;
+int    i[];
+float  f[];
+int    array[][10][20];
+
+int    dots_0(p1)
+               int     p1;
+               { return(*(int *)0); }
+
+       /* VARARGS1 */
+int    dots_1(p1)
+               int     p1;
+               { return(*(int *)0); }
+
+       /* VARARGS2 */
+int    dots_3(p1, p2)
+               int     p1;
+               char    p2;
+               { return(*(int *)0); }
+
+int    dots_4(p1, p2, p3)
+               int     p1;
+               char    p2;
+               char    *p3;
+               { return(*(int *)0); }
+
+       /* VARARGS3 */
+char   *dots_5(p1, p2, p3)
+               int     p1;
+               char    p2;
+               char    *p3;
+               { return(*(char **)0); }
+
+_FIRST *xdots_0(p1)
+               int     p1;
+               { return(*(_FIRST **)0); }
+
+       /* VARARGS1 */
+char   *xdots_1(p1)
+               int     p1;
+               { return(*(char **)0); }
+
+       /* VARARGS2 */
+int    xdots_3(p1, p2)
+               int     p1;
+               char    p2;
+               { return(*(int *)0); }
+
+_FIRST *func1()
+               { return(*(_FIRST **)0); }
+
+_FIRST *func2(p1, p2, p)
+               _FIRST  *p1;
+               int     p2[];
+               float   p;
+               { return(*(_FIRST **)0); }
+
+int    *(func_func)();
+
+float  efunc0(p1, p2, p3)
+               int     p1;
+               int     p2;
+               int     p3;
+               { return(*(float *)0); }
+
+_FIRST efunc1(p1, p2, p3)
+               int     p1;
+               float   p2;
+               long    p3;
+               { return(*(_FIRST *)0); }
+
+typedef        int     bool;
+
+bool   a1;
+bool   a3;
+
+struct ZIP1    { int x1, y1; };
+
+struct zip2    { int x2, y2; } z2;
+struct         { int x3, y3; } z3;
+
+struct ZIP4    { int x4, y4; };
+
+enum   zap1    { a,b,c,d } what;
+enum zap2 what2;
+enum           {a9,b9,c9,d9} what3;
+
+typedef        struct  bong    {
+       int     (*func)();
+       } BONG;
+
+typedef        char    *string;
+
+int    junk;
+
+void   main(argc, argv)
+               int     argc;
+               char    **argv;
+               { /* void */ }
+
+       /* VARARGS */
+int    veryfunny(a, b, c)
+               char    *a;
+               long    b;
+               long    c;
+               { return(*(int *)0); }
+
+       /* VARARGS3 */
+int    program(argv, y, zz, z1, z2, z3)
+               string  argv[];
+               struct  alpha { int x,z; } y;
+               int     zz;
+               int     z1;
+               int     z2;
+               int     z3;
+               { return(*(int *)0); }
+
+void   junk0()
+               { /* void */ }
+
+int    junk1()
+               { return(*(int *)0); }
+
+void   junk2()
+               { /* void */ }
+
+int    junk3()
+               { return(*(int *)0); }
+
+BONG   *junk4()
+               { return(*(BONG **)0); }
+
+typedef        int     extern_junk;
+
+extern_junk *foo()
+               { return(*(extern_junk **)0); }
+
+typedef        int     void_junk;
+
+void_junk *foo2a()
+               { return(*(void_junk **)0); }
+
+void_junk *foo2a()
+               { return(*(void_junk **)0); }
+
+void_junk *foo2()
+               { return(*(void_junk **)0); }
+
+void_junk *foo_void(void_int)
+               void_junk void_int;
+               { return(*(void_junk **)0); }
+
+void   (*sigdisp(sig, func))()
+               int     sig;
+               void    (*func)();
+               { return(*(void(*)())0); }
+
+void   (*Sigdisp(sig, func))()
+               int     sig;
+               void    (*func)();
+               { return(*(void(*)())0); }
+
+void   (*sigdisp2(sig, func))()
+               int     sig;
+               void    (*func)();
+               { return(*(void(*)())0); }
+
+int    (*K_R_INT_ptr(p1, p2))()
+               long    *p1;
+               int     p2;
+               { return(*(int(*)())0); }
+
+int    (*STD_INT_ptr(p1, p2))()
+               long    *p1;
+               int     p2;
+               { return(*(int(*)())0); }
+
+void   (*K_R_VOID_ptr(p1, p2))()
+               long    *p1;
+               int     p2;
+               { return(*(void(*)())0); }
+
+void   (*STD_VOID_ptr(p1, p2))()
+               long    *p1;
+               int     p2;
+               { return(*(void(*)())0); }
+
+int    *K_R_int_ptr(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int **)0); }
+
+int    **STD_int2_ptr(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int ***)0); }
+
+int    *STD_int_ptr(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int **)0); }
+
+void   *K_R_void_ptr(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(void **)0); }
+
+void   *STD_void_ptr(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(void **)0); }
+
+int    K_R_int_val(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int *)0); }
+
+int    K_R_int_val2(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int *)0); }
+
+int    STD_int_val(p1, p2)
+               long    *p1;
+               int     p2;
+               { return(*(int *)0); }
+
+void   K_R_void_val(p1, p2)
+               long    *p1;
+               int     p2;
+               { /* void */ }
+
+void   K_R_void_val2(p1, p2)
+               long    *p1;
+               int     p2;
+               { /* void */ }
+
+void   STD_void_val(p1, p2)
+               long    *p1;
+               int     p2;
+               { /* void */ }
+
+int    (*XSetAfterFunction(p1, p2))()
+               long    *p1;
+               int     (*p2)();
+               { return(*(int(*)())0); }
+
+int    XQueryKeymap(p1, p2)
+               long    *p1;
+               char    p2[32];
+               { return(*(int *)0); }
+
+int    Another(p1, p2)
+               long    *p1;
+               int     (*p2)();
+               { return(*(int *)0); }
+
+int    GenFunc(p1, p2)
+               int     *p1;
+               int     (*p2());
+               { return(*(int *)0); }
+
+void   *(*__glob_opendir_hook)();
+const char *(*__glob_readdir_hook)() = {0};
+void   (*__glob_closedir_hook)();
diff --git a/cproto-4.6/testing/case15.ref b/cproto-4.6/testing/case15.ref
new file mode 100644 (file)
index 0000000..b5556fd
--- /dev/null
@@ -0,0 +1,1233 @@
+/* LINTLIBRARY */
+
+/* apollo.c */
+#undef COMPLETE_SR10_2
+#ifdef __STDC__
+#ident Standard LLIB
+#else
+#ident Traditional LLIB
+
+#include <apollo/base.h>
+
+short  pm_$errout;
+uid_$t uid_$nil;
+
+void   lib_$init_set(set, size)
+               void    *set;
+               short   size;
+               { /* void */ }
+
+void   lib_$add_to_set(set, size, element)
+               void    *set;
+               short   size;
+               short   element;
+               { /* void */ }
+
+void   lib_$clr_from_set(set, size, element)
+               void    *set;
+               short   size;
+               short   element;
+               { /* void */ }
+
+boolean        lib_$member_of_set(set, size, element)
+               void    *set;
+               short   size;
+               short   element;
+               { return(*(boolean *)0); }
+
+#include <apollo/aclm.h>
+
+void   aclm_$up()
+               { /* void */ }
+
+void   aclm_$down()
+               { /* void */ }
+
+#include <apollo/cal.h>
+
+void   cal_$decode_ascii_time(string, string_length, hour, minute, second, status)
+               char    *string;
+               short   string_length;
+               short   *hour;
+               short   *minute;
+               short   *second;
+               status_$t *status;
+               { /* void */ }
+
+void   cal_$decode_ascii_date(string, string_length, year, month, day, status)
+               char    *string;
+               short   string_length;
+               short   *year;
+               short   *month;
+               short   *day;
+               status_$t *status;
+               { /* void */ }
+
+void   cal_$decode_ascii_tzdif(string, string_length, tz_dif, tz_name, status)
+               char    *string;
+               short   string_length;
+               short   *tz_dif;
+               cal_$tz_name_t tz_name;
+               status_$t *status;
+               { /* void */ }
+
+void   cal_$decode_time(clock, decoded_clock)
+               time_$clock_t clock;
+               cal_$timedate_rec_t *decoded_clock;
+               { /* void */ }
+
+void   cal_$encode_time(decoded_clock, clock)
+               cal_$timedate_rec_t decoded_clock;
+               time_$clock_t *clock;
+               { /* void */ }
+
+void   cal_$decode_local_time(decoded_clock)
+               cal_$timedate_rec_t *decoded_clock;
+               { /* void */ }
+
+cal_$weekday_t cal_$weekday(year, month, day)
+               short   year;
+               short   month;
+               short   day;
+               { return(*(cal_$weekday_t *)0); }
+
+void   cal_$apply_local_offset(clock)
+               time_$clock_t *clock;
+               { /* void */ }
+
+void   cal_$remove_local_offset(clock)
+               time_$clock_t *clock;
+               { /* void */ }
+
+void   cal_$get_local_time(clock)
+               time_$clock_t *clock;
+               { /* void */ }
+
+void   cal_$write_timezone(timezone_info, status)
+               cal_$timezone_rec_t timezone_info;
+               status_$t *status;
+               { /* void */ }
+
+void   cal_$sec_to_clock(seconds, clock)
+               unsigned long seconds;
+               time_$clock_t *clock;
+               { /* void */ }
+
+unsigned long cal_$clock_to_sec(clock)
+               time_$clock_t clock;
+               { return(*(unsigned long *)0); }
+
+void   cal_$get_info(timezone_info)
+               cal_$timezone_rec_t *timezone_info;
+               { /* void */ }
+
+void   cal_$float_clock(clock, float_seconds)
+               time_$clock_t clock;
+               double  *float_seconds;
+               { /* void */ }
+
+void   cal_$add_clock(clock1, clock2)
+               time_$clock_t *clock1;
+               time_$clock_t clock2;
+               { /* void */ }
+
+boolean        cal_$sub_clock(clock1, clock2)
+               time_$clock_t *clock1;
+               time_$clock_t clock2;
+               { return(*(boolean *)0); }
+
+short  cal_$cmp_clock(clock1, clock2)
+               time_$clock_t clock1;
+               time_$clock_t clock2;
+               { return(*(short *)0); }
+
+#include <apollo/error.h>
+
+void   error_$find_text(status, sub_np, sub_nl, mod_np, mod_nl, err_p, err_l)
+               status_$t status;
+               char    **sub_np;
+               short   *sub_nl;
+               char    **mod_np;
+               short   *mod_nl;
+               char    **err_p;
+               short   *err_l;
+               { /* void */ }
+
+void   error_$get_text(status, sub_n, sub_nl, mod_n, mod_nl, err_t, err_l)
+               status_$t status;
+               error_$string_t sub_n;
+               short   *sub_nl;
+               error_$string_t mod_n;
+               short   *mod_nl;
+               error_$string_t err_t;
+               short   *err_l;
+               { /* void */ }
+
+void   error_$print(status)
+               status_$t status;
+               { /* void */ }
+
+void   error_$print_name(status, name, namelen)
+               status_$t status;
+               char    *name;
+               pinteger namelen;
+               { /* void */ }
+
+       /* VARARGS6 */
+void   error_$print_format(status, strm, prechr, command, commlen, str)
+               status_$t status;
+               stream_$id_t strm;
+               char    prechr;
+               error_$string_t command;
+               short   commlen;
+               char    *str;
+               { /* void */ }
+
+void   error_$init_std_format(strm, prechr, command, commlen)
+               stream_$id_t strm;
+               char    prechr;
+               char    *command;
+               short   commlen;
+               { /* void */ }
+
+       /* VARARGS2 */
+void   error_$std_format(status, str)
+               status_$t status;
+               char    *str;
+               { /* void */ }
+
+boolean        error_$fail(status)
+               status_$t status;
+               { return(*(boolean *)0); }
+
+short  error_$subsys(status)
+               status_$t status;
+               { return(*(short *)0); }
+
+short  error_$module(status)
+               status_$t status;
+               { return(*(short *)0); }
+
+short  error_$code(status)
+               status_$t status;
+               { return(*(short *)0); }
+
+#include <apollo/ev.h>
+
+boolean        ev_$set_var(name, namelen, value, valuelen)
+               char    *name;
+               short   namelen;
+               char    *value;
+               short   valuelen;
+               { return(*(boolean *)0); }
+
+boolean        ev_$get_var(name, namelen, value_ptr, valuelen)
+               char    *name;
+               short   namelen;
+               char    **value_ptr;
+               short   *valuelen;
+               { return(*(boolean *)0); }
+
+boolean        ev_$exist_var(name, namelen)
+               char    *name;
+               short   namelen;
+               { return(*(boolean *)0); }
+
+boolean        ev_$delete_var(name, namelen)
+               char    *name;
+               short   namelen;
+               { return(*(boolean *)0); }
+
+boolean        ev_$read_var_entry(ix, name_ptr, namelen, value_ptr, valuelen)
+               short   *ix;
+               char    **name_ptr;
+               short   *namelen;
+               char    **value_ptr;
+               short   *valuelen;
+               { return(*(boolean *)0); }
+
+#include <apollo/ios.h>
+
+xoid_$t        xoid_$nil;
+
+ios_$id_t ios_$open(n, l, opts, st)
+               char    *n;
+               short   l;
+               ios_$open_options_t opts;
+               status_$t *st;
+               { return(*(ios_$id_t *)0); }
+
+void   ios_$create(name, name_len, type_uid, cmode, oopts, id, status)
+               char    *name;
+               short   name_len;
+               uid_$t  type_uid;
+               ios_$create_mode_t cmode;
+               ios_$open_options_t oopts;
+               ios_$id_t *id;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$close(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { /* void */ }
+
+void   ios_$get_ec(id, key, ecp, st)
+               ios_$id_t id;
+               ios_$ec_key_t key;
+               ec2_$ptr_t *ecp;
+               status_$t *st;
+               { /* void */ }
+
+void   ios_$delete(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { /* void */ }
+
+void   ios_$truncate(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { /* void */ }
+
+long   ios_$get(id, opt, b, l, st)
+               ios_$id_t id;
+               ios_$put_get_opts_t opt;
+               char    *b;
+               long    l;
+               status_$t *st;
+               { return(*(long *)0); }
+
+long   ios_$locate(id, opt, b, l, st)
+               ios_$id_t id;
+               ios_$put_get_opts_t opt;
+               char    **b;
+               long    l;
+               status_$t *st;
+               { return(*(long *)0); }
+
+void   ios_$put(id, opt, b, l, st)
+               ios_$id_t id;
+               ios_$put_get_opts_t opt;
+               char    *b;
+               long    l;
+               status_$t *st;
+               { /* void */ }
+
+long   ios_$putp(id, opt, b, l, st)
+               ios_$id_t id;
+               ios_$put_get_opts_t opt;
+               char    *b;
+               long    l;
+               status_$t *st;
+               { return(*(long *)0); }
+
+long   ios_$inq_rec_remainder(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { return(*(long *)0); }
+
+ios_$mgr_flag_set ios_$inq_mgr_flags(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { return(*(ios_$mgr_flag_set *)0); }
+
+ios_$obj_flag_set ios_$inq_obj_flags(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { return(*(ios_$obj_flag_set *)0); }
+
+void   ios_$set_obj_flag(id, f, on_off, st)
+               ios_$id_t id;
+               ios_$obj_flag_t f;
+               boolean on_off;
+               status_$t *st;
+               { /* void */ }
+
+ios_$conn_flag_set ios_$inq_conn_flags(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { return(*(ios_$conn_flag_set *)0); }
+
+void   ios_$set_conn_flag(id, f, on_off, st)
+               ios_$id_t id;
+               ios_$conn_flag_t f;
+               boolean on_off;
+               status_$t *st;
+               { /* void */ }
+
+void   ios_$seek(id, abs_rel, seek_type, key, st)
+               ios_$id_t id;
+               ios_$abs_rel_t abs_rel;
+               ios_$seek_type_t seek_type;
+               long    key;
+               status_$t *st;
+               { /* void */ }
+
+void   ios_$seek_full_key(id, key, status)
+               ios_$id_t id;
+               ios_$seek_key_t key;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$seek_short_key(id, key, status)
+               ios_$id_t id;
+               long    key;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$seek_to_bof(id, status)
+               ios_$id_t id;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$seek_to_eof(id, status)
+               ios_$id_t id;
+               status_$t *status;
+               { /* void */ }
+
+long   ios_$inq_short_key(id, pos_opt, status)
+               ios_$id_t id;
+               ios_$pos_opt_t pos_opt;
+               status_$t *status;
+               { return(*(long *)0); }
+
+void   ios_$inq_full_key(id, pos_opt, key, status)
+               ios_$id_t id;
+               ios_$pos_opt_t pos_opt;
+               ios_$seek_key_t *key;
+               status_$t *status;
+               { /* void */ }
+
+long   ios_$inq_rec_pos(id, pos_opt, st)
+               ios_$id_t id;
+               ios_$pos_opt_t pos_opt;
+               status_$t *st;
+               { return(*(long *)0); }
+
+long   ios_$inq_byte_pos(id, pos_opt, status)
+               ios_$id_t id;
+               ios_$pos_opt_t pos_opt;
+               status_$t *status;
+               { return(*(long *)0); }
+
+long   ios_$inq_cur_rec_len(id, status)
+               ios_$id_t id;
+               status_$t *status;
+               { return(*(long *)0); }
+
+ios_$rtype_t ios_$inq_rec_type(id, status)
+               ios_$id_t id;
+               status_$t *status;
+               { return(*(ios_$rtype_t *)0); }
+
+void   ios_$set_rec_type(id, rec_type, rec_len, status)
+               ios_$id_t id;
+               ios_$rtype_t rec_type;
+               long    rec_len;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$force_write_file(id, status)
+               ios_$id_t id;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$inq_file_attr(id, dtc, dtm, dtu, blks, status)
+               ios_$id_t id;
+               time_$clockh_t *dtc;
+               time_$clockh_t *dtm;
+               time_$clockh_t *dtu;
+               long    *blks;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$inq_path_name_lc(strid, ntype, max_nl, name, nl, status)
+               ios_$id_t strid;
+               ios_$name_type_t ntype;
+               short   max_nl;
+               char    *name;
+               short   *nl;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$change_path_name(strid, new_name, new_nl, status)
+               ios_$id_t strid;
+               char    *new_name;
+               short   new_nl;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$inq_type_uid(strid, type_uid, status)
+               ios_$id_t strid;
+               uid_$t  *type_uid;
+               status_$t *status;
+               { /* void */ }
+
+void   *ios_$get_handle(strid, type_uid, status)
+               ios_$id_t strid;
+               uid_$t  type_uid;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$set_locate_buffer_size(id, size, status)
+               ios_$id_t id;
+               short   size;
+               status_$t *status;
+               { /* void */ }
+
+ios_$id_t ios_$switch(strid1, strid2, status)
+               ios_$id_t strid1;
+               ios_$id_t strid2;
+               status_$t *status;
+               { return(*(ios_$id_t *)0); }
+
+ios_$id_t ios_$replicate(strid1, strid2, status)
+               ios_$id_t strid1;
+               ios_$id_t strid2;
+               status_$t *status;
+               { return(*(ios_$id_t *)0); }
+
+ios_$id_t ios_$dup(strid1, strid2, status)
+               ios_$id_t strid1;
+               ios_$id_t strid2;
+               status_$t *status;
+               { return(*(ios_$id_t *)0); }
+
+boolean        ios_$equal(strid1, strid2, status)
+               ios_$id_t strid1;
+               ios_$id_t strid2;
+               status_$t *status;
+               { return(*(boolean *)0); }
+
+void   ios_$set_dir(pname, plen, dir, status)
+               char    *pname;
+               pinteger plen;
+               ios_$dir_type_t dir;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$get_dir_lc(dir, max_plen, pname, plen, status)
+               ios_$dir_type_t dir;
+               short   max_plen;
+               char    *pname;
+               short   *plen;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$inq_path_name(strid, ntype, name, nl, status)
+               ios_$id_t strid;
+               ios_$name_type_t ntype;
+               char    *name;
+               short   *nl;
+               status_$t *status;
+               { /* void */ }
+
+void   ios_$get_dir(dir, pname, plen, status)
+               ios_$dir_type_t dir;
+               char    *pname;
+               short   *plen;
+               status_$t *status;
+               { /* void */ }
+
+#include <apollo/name.h>
+
+void   name_$get_wdir_lc(maxpathlen, pathname, name_length, status)
+               unsigned short maxpathlen;
+               char    *pathname;
+               unsigned short *name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$get_ndir_lc(maxpathlen, pathname, name_length, status)
+               unsigned short maxpathlen;
+               char    *pathname;
+               unsigned short *name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$create_file(filename, name_length, status)
+               char    *filename;
+               unsigned short name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$delete_file(filename, name_length, status)
+               char    *filename;
+               unsigned short name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$create_directory(directory_name, name_length, status)
+               char    *directory_name;
+               unsigned short name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$delete_directory(directory_name, name_length, status)
+               char    *directory_name;
+               unsigned short name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$read_dir_lc(dir_name, name_length, seek_to_bof, cursor, max_count, dirlistsize, dirlist, read_count, status)
+               char    *dir_name;
+               unsigned short name_length;
+               boolean *seek_to_bof;
+               name_$cursor_t *cursor;
+               unsigned short max_count;
+               unsigned long dirlistsize;
+               char    *dirlist;
+               unsigned short *read_count;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$add_link(linkname, name_length, link_text, text_length, status)
+               char    *linkname;
+               unsigned short name_length;
+               char    *link_text;
+               unsigned short text_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$read_link_lc(linkname, name_length, maxlinklen, link_text, text_length, status)
+               char    *linkname;
+               unsigned short name_length;
+               unsigned short maxlinklen;
+               char    *link_text;
+               unsigned short *text_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$drop_link(linkname, name_length, status)
+               char    *linkname;
+               unsigned short name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$extract_data_lc(dir_entry, entry_type, entry_length, max_entry_length, entry_name, status)
+               name_$canonical_dir_entry_t dir_entry;
+               short   *entry_type;
+               unsigned short *entry_length;
+               unsigned short max_entry_length;
+               char    *entry_name;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$get_path_lc(in_name, in_len, maxpnamelen, out_name, out_len, status)
+               char    *in_name;
+               unsigned short in_len;
+               unsigned short maxpnamelen;
+               char    *out_name;
+               unsigned short *out_len;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$cname(old_pathname, old_length, new_leaf, leaf_length, status)
+               char    *old_pathname;
+               unsigned short old_length;
+               char    *new_leaf;
+               unsigned short leaf_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$set_wdir(name, name_length, status)
+               char    *name;
+               unsigned short name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$get_wdir(name, name_length, status)
+               char    *name;
+               unsigned short *name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$get_wdir_cc(name, name_length, status)
+               char    *name;
+               unsigned short *name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$set_ndir(name, name_length, status)
+               char    *name;
+               unsigned short name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$get_ndir(name, name_length, status)
+               char    *name;
+               unsigned short *name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$get_ndir_cc(name, name_length, status)
+               char    *name;
+               unsigned short *name_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$read_dir(dir_name, name_length, dirlist, index, max_count, read_count, status)
+               char    *dir_name;
+               unsigned short name_length;
+               name_$dir_entry_t *dirlist;
+               unsigned short *index;
+               unsigned short max_count;
+               unsigned short *read_count;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$read_dir_cc(dir_name, name_length, dirlist, index, max_count, read_count, status)
+               char    *dir_name;
+               unsigned short name_length;
+               name_$dir_entry_t *dirlist;
+               unsigned short *index;
+               unsigned short max_count;
+               unsigned short *read_count;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$read_link(linkname, name_length, link_text, text_length, status)
+               char    *linkname;
+               unsigned short name_length;
+               char    *link_text;
+               unsigned short *text_length;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$extract_data(dir_entry, entry_type, entry_length, entry_name)
+               name_$dir_entry_t dir_entry;
+               unsigned short *entry_type;
+               unsigned short *entry_length;
+               char    *entry_name;
+               { /* void */ }
+
+void   name_$get_path(in_name, in_len, out_name, out_len, status)
+               char    *in_name;
+               unsigned short in_len;
+               char    *out_name;
+               unsigned short *out_len;
+               status_$t *status;
+               { /* void */ }
+
+void   name_$get_path_cc(in_name, in_len, out_name, out_len, status)
+               char    *in_name;
+               unsigned short in_len;
+               char    *out_name;
+               unsigned short *out_len;
+               status_$t *status;
+               { /* void */ }
+
+#include <apollo/pad.h>
+
+void   pad_$raw(sid, sts)
+               short   sid;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$cooked(sid, sts)
+               short   sid;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$create(n, l, ptype, rel_pad, side, options, size, rslt_stream, s)
+               char    *n;
+               unsigned short l;
+               pad_$type_t ptype;
+               stream_$id_t rel_pad;
+               pad_$side_t side;
+               pad_$cre_opt_t options;
+               short   size;
+               stream_$id_t *rslt_stream;
+               status_$t *s;
+               { /* void */ }
+
+void   pad_$create_window(n, l, ptype, unit, window, rslt_stream, s)
+               char    *n;
+               unsigned short l;
+               pad_$type_t ptype;
+               short   unit;
+               pad_$window_desc_t window;
+               stream_$id_t *rslt_stream;
+               status_$t *s;
+               { /* void */ }
+
+void   pad_$create_frame(sid, width, height, sts)
+               stream_$id_t sid;
+               short   width;
+               short   height;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$delete_frame(sid, sts)
+               stream_$id_t sid;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$clear_frame(sid, clr_key, sts)
+               stream_$id_t sid;
+               stream_$sk_t clr_key;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$close_frame(sid, sts)
+               stream_$id_t sid;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$move(sid, rel_abs, x, y, sts)
+               stream_$id_t sid;
+               pad_$rel_abs_t rel_abs;
+               short   x;
+               short   y;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$set_scale(sid, xs, ys, sts)
+               stream_$id_t sid;
+               short   xs;
+               short   ys;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$load_font(sid, fname, fnl, fontx, sts)
+               stream_$id_t sid;
+               char    *fname;
+               short   fnl;
+               short   *fontx;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$use_font(sid, fontx, sts)
+               stream_$id_t sid;
+               short   fontx;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$inq_font(sid, fwidth, fhite, fname, fnsize, fnlen, sts)
+               stream_$id_t sid;
+               short   *fwidth;
+               short   *fhite;
+               char    *fname;
+               short   fnsize;
+               short   *fnlen;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$inq_windows(sid, wlist, wlsize, wcnt, sts)
+               stream_$id_t sid;
+               pad_$window_desc_t *wlist;
+               short   wlsize;
+               short   *wcnt;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$inq_position(sid, y, x, sts)
+               stream_$id_t sid;
+               short   *y;
+               short   *x;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$set_tabs(sid, tsb, cnt, sts)
+               stream_$id_t sid;
+               short   *tsb;
+               short   cnt;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$cpr_enable(sid, cpr_type, sts)
+               stream_$id_t sid;
+               short   cpr_type;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$locate(sid, x, y, c, sts)
+               stream_$id_t sid;
+               short   *x;
+               short   *y;
+               char    *c;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$dm_cmd(sid, cmd, cmd_len, sts)
+               stream_$id_t sid;
+               char    *cmd;
+               short   cmd_len;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$def_pfk(sid, key_name, def, def_len, sts)
+               stream_$id_t sid;
+               char    *key_name;
+               char    *def;
+               short   def_len;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$edit_wait(sid, sts)
+               stream_$id_t sid;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$inq_disp_type(sid, dtype, unit, sts)
+               stream_$id_t sid;
+               pad_$display_type_t *dtype;
+               short   *unit;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$inq_view(sid, window_no, line, eof_lnum, x_offset, y_offset, sts)
+               stream_$id_t sid;
+               short   window_no;
+               long    *line;
+               long    *eof_lnum;
+               short   *x_offset;
+               short   *y_offset;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$set_view(sid, window_no, line, x_offset, y_offset, sts)
+               stream_$id_t sid;
+               short   window_no;
+               long    line;
+               short   x_offset;
+               short   y_offset;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$inq_kbd(sid, buf_size, kbd_suffix, len, sts)
+               stream_$id_t sid;
+               short   buf_size;
+               char    *kbd_suffix;
+               short   *len;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$pop_push_window(sid, window_no, pop_push, sts)
+               stream_$id_t sid;
+               short   window_no;
+               boolean pop_push;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$set_border(sid, window_no, border, sts)
+               stream_$id_t sid;
+               short   window_no;
+               boolean border;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$create_icon(n, l, ptype, unit, icon_pos, icon_font_char, window, rslt_stream, s)
+               char    *n;
+               unsigned short l;
+               pad_$type_t ptype;
+               short   unit;
+               pad_$position_t icon_pos;
+               char    icon_font_char;
+               pad_$window_desc_t *window;
+               stream_$id_t *rslt_stream;
+               status_$t *s;
+               { /* void */ }
+
+void   pad_$make_icon(sid, window_no, font_char, sts)
+               stream_$id_t sid;
+               short   window_no;
+               char    font_char;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$icon_wait(sid, window_no, icon_moved, icon_pos_if_moved, sts)
+               stream_$id_t sid;
+               short   window_no;
+               boolean *icon_moved;
+               pad_$position_t *icon_pos_if_moved;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$set_full_window(sid, window_no, window, sts)
+               stream_$id_t sid;
+               short   window_no;
+               pad_$window_desc_t *window;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$inq_full_window(sid, window_no, window, sts)
+               stream_$id_t sid;
+               short   window_no;
+               pad_$window_desc_t *window;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$set_icon_pos(sid, window_no, icon_pos, font_char, sts)
+               stream_$id_t sid;
+               short   window_no;
+               pad_$position_t icon_pos;
+               char    font_char;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$inq_icon(sid, window_no, icon_pos, font_char, sts)
+               stream_$id_t sid;
+               short   window_no;
+               pad_$position_t *icon_pos;
+               char    *font_char;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$make_invisible(sid, window_no, sts)
+               stream_$id_t sid;
+               short   window_no;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$select_window(sid, window_no, sts)
+               stream_$id_t sid;
+               short   window_no;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$set_auto_close(sid, window_no, auto_close, sts)
+               stream_$id_t sid;
+               short   window_no;
+               boolean auto_close;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$inq_icon_font(sid, window_no, font_name, fnbs, fnlen, sts)
+               stream_$id_t sid;
+               short   window_no;
+               char    *font_name;
+               short   fnbs;
+               short   *fnlen;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$set_icon_font(sid, window_no, font_name, fnlen, sts)
+               stream_$id_t sid;
+               short   window_no;
+               char    *font_name;
+               short   fnlen;
+               status_$t *sts;
+               { /* void */ }
+
+boolean        pad_$is_icon(sid, window_no, sts)
+               stream_$id_t sid;
+               short   window_no;
+               status_$t *sts;
+               { return(*(boolean *)0); }
+
+void   pad_$force_prompt(sid, sts)
+               stream_$id_t sid;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$isa(sid, sts)
+               stream_$id_t sid;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$isa_dm_pad(sid, sts)
+               stream_$id_t sid;
+               status_$t *sts;
+               { /* void */ }
+
+void   pad_$set_erase(sid, window_no, erase, sts)
+               stream_$id_t sid;
+               short   window_no;
+               boolean erase;
+               status_$t *sts;
+               { /* void */ }
+
+#include <apollo/tty.h>
+
+void   tty_$isa(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$inq_size(id, height, width, st)
+               ios_$id_t id;
+               pinteger *height;
+               pinteger *width;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$set_size(id, height, width, st)
+               ios_$id_t id;
+               pinteger height;
+               pinteger width;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$set_input_flag(id, flag, val, st)
+               ios_$id_t id;
+               tty_$input_flag_t flag;
+               boolean val;
+               status_$t *st;
+               { /* void */ }
+
+tty_$input_flag_set_t tty_$inq_input_flags(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { return(*(tty_$input_flag_set_t *)0); }
+
+void   tty_$set_output_flag(id, flag, val, st)
+               ios_$id_t id;
+               tty_$output_flag_t flag;
+               boolean val;
+               status_$t *st;
+               { /* void */ }
+
+tty_$output_flag_set_t tty_$inq_output_flags(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { return(*(tty_$output_flag_set_t *)0); }
+
+void   tty_$set_echo_flag(id, flag, val, st)
+               ios_$id_t id;
+               tty_$echo_flag_t flag;
+               boolean val;
+               status_$t *st;
+               { /* void */ }
+
+tty_$echo_flag_set_t tty_$inq_echo_flags(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { return(*(tty_$echo_flag_set_t *)0); }
+
+void   tty_$set_func_char(id, func, ch, st)
+               ios_$id_t id;
+               tty_$func_t func;
+               char    ch;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$inq_func_char(id, func, ch, st)
+               ios_$id_t id;
+               tty_$func_t func;
+               char    *ch;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$enable_func(id, func, val, st)
+               ios_$id_t id;
+               tty_$func_t func;
+               boolean val;
+               status_$t *st;
+               { /* void */ }
+
+tty_$func_set_t tty_$inq_func_enabled(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { return(*(tty_$func_set_t *)0); }
+
+void   tty_$set_process_group(id, uid, st)
+               ios_$id_t id;
+               uid_$t  uid;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$inq_process_group(id, uid, st)
+               ios_$id_t id;
+               uid_$t  *uid;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$set_input_break_mode(id, mode, st)
+               ios_$id_t id;
+               tty_$input_break_mode_t *mode;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$inq_input_break_mode(id, mode, st)
+               ios_$id_t id;
+               tty_$input_break_mode_t *mode;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$drain_output(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$discard_input(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$discard_output(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$simulate_input(id, ch, st)
+               ios_$id_t id;
+               char    ch;
+               status_$t *st;
+               { /* void */ }
+
+void   tty_$set_delay(id, delay, val, st)
+               ios_$id_t id;
+               tty_$delay_t delay;
+               pinteger val;
+               status_$t *st;
+               { /* void */ }
+
+pinteger tty_$inq_delay(id, delay, st)
+               ios_$id_t id;
+               tty_$delay_t delay;
+               status_$t *st;
+               { return(*(pinteger *)0); }
+
+void   tty_$set_unix_mode(id, mode, val, st)
+               ios_$id_t id;
+               tty_$unix_mode_t mode;
+               boolean val;
+               status_$t *st;
+               { /* void */ }
+
+tty_$unix_mode_set_t tty_$inq_unix_modes(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { return(*(tty_$unix_mode_set_t *)0); }
+
+void   tty_$set_raw(id, val, st)
+               ios_$id_t id;
+               boolean val;
+               status_$t *st;
+               { /* void */ }
+
+boolean        tty_$inq_raw(id, st)
+               ios_$id_t id;
+               status_$t *st;
+               { return(*(boolean *)0); }
+
+void   tty_$set_non_canon_break_mode(id, mode, st)
+               ios_$id_t id;
+               tty_$input_break_mode_t *mode;
+               status_$t *st;
+               { /* void */ }
+
+#include <apollo/type_uids.h>
+
+uid_$t case_hm_$uid;
+uid_$t cmpexe_$uid;
+uid_$t coff_$uid;
+uid_$t d3m_area_$uid;
+uid_$t d3m_sch_$uid;
+uid_$t directory_$uid;
+uid_$t dm_edit_$uid;
+uid_$t hdr_undef_$uid;
+uid_$t input_pad_$uid;
+uid_$t mbx_$uid;
+uid_$t mt_$uid;
+uid_$t nulldev_$uid;
+uid_$t object_file_$uid;
+uid_$t pad_$uid;
+uid_$t pty_$slave_uid;
+uid_$t pty_$uid;
+uid_$t records_$uid;
+uid_$t sio_$uid;
+uid_$t tcp_$uid;
+uid_$t uasc_$uid;
+uid_$t unstruct_$uid;
diff --git a/cproto-4.6/testing/case16.ref b/cproto-4.6/testing/case16.ref
new file mode 100644 (file)
index 0000000..1dc0659
--- /dev/null
@@ -0,0 +1,335 @@
+/* case16.c */
+int dots_0(int p1);
+int dots_1(int p1, ...);
+int dots_3(int P1, char P2, ...);
+_FIRST *func1(void);
+_FIRST *func2(_FIRST *P1 , int P2 [], float p);
+int *(func_func)(int p1, int p2, int p3);
+int main(register argc, char **argv);
+int veryfunny(char *a, long b, long c);
+int program(string argv[], struct alpha y, int zz, int z1, int z2, int z3);
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(void_junk void_int);
+void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1);
+void (*sigdisp2(int sig, void (*func)(int sig)))(int sig2);
+int (*K_R_INT_ptr(long *p1, int p2))(void);
+void (*K_R_VOID_ptr(long *p1, int p2))(void);
+int *K_R_int_ptr(long *p1, int p2);
+void *K_R_void_ptr(long *p1, int p2);
+int K_R_int_val(long *p1, int p2);
+int K_R_int_val2(long *p1, int p2);
+void K_R_void_val(long *p1, int p2);
+int K_R_void_val2(long *p1, int p2);
+... edited case16.c ...
+/*
+ * Define:
+ *     ERR_YACC        to force yacc error reporting
+ *     ERR_LEX         to force lex error reporting
+ *     ERR_CHECK       to force compiler error reporting
+ */
+               /* use one item from type-specifiers */
+#ifdef ERR_YACC
+auto           x;
+register       x1;
+#endif ERR_YACC
+static         x2;
+extern         x3;
+#ifdef ERR_CC
+typedef                x4;
+#endif
+typedef        int     x4t;
+#ifdef ERR_YACC
+void           x5;
+#endif ERR_YACC
+char           x6;
+short          x7;
+int            x8;
+long           x9;
+float          x10;
+double         x11;
+signed         x12;
+unsigned       x13;
+struct         x14;
+#ifdef ERR_CHECK
+struct         x14a {};
+struct         {};
+#endif ERR_CHECK
+union          x15;
+enum           x16;
+x4t;
+x4t            x17;
+const          x18;
+volatile       x19;
+#ifdef ERR_CHECK
+junk           x20;
+#endif ERR_CHECK
+
+typedef        struct  _first  {
+       int             a:5;
+       struct  {
+               int     a,b;
+       } b_struct;
+       char            b:16, b1:1;     /* comment with };};}; */
+       long            c:16, c1;
+       short           d:16, d1:8, d2;
+       unsigned        e:16;
+       float           f;
+       double          g;
+#ifdef ERR_CHECK
+       long    float   f2;
+       long    double  g2;
+#endif ERR_CHECK
+       struct  _first  *link;
+       }       _FIRST;
+
+_FIRST first, last={0}, first_last[] = {{0},{1},{2},{3,{4}}};
+
+struct _second {
+               enum    {true, false} bool;
+               enum    {wrong=1, right=3} values;
+       } _SECOND;
+
+int    i[] = {1,
+               '\002',
+               03,
+               0x4,
+               0X5,
+               0x6a,
+               0X7b,
+               0x8aBcD,
+               9l,
+               10l,
+               11L};
+float  f[] = {5,
+#ifdef ERR_CHECK
+               .5,
+               .5e,
+               .5e+,
+               5e-,
+               5e,
+#endif
+               5.5,
+               5e5,
+               5e0,
+               5e-1,
+               5e+5
+               };
+
+int    array[][10][20];
+
+       /*
+        * This grammar can accept some illegal stuff too, in particular it will
+        * permit some instances of parameter-names to be dropped.
+        */
+#ifdef ERR_CHECK
+#define        P1
+#define        P2
+#define        P3
+#else
+#define        P1      p1
+#define        P2      p2
+#define        P3      p3
+#endif
+
+       /* ellipsis is legal, except in K&R style declaration */
+
+       int 
+dots_0 (int p1)                { return(1); }
+
+       dots_1(int p1, ...)     { return(1); }
+
+#ifdef ERR_CHECK
+       dots_2(p1, ...)         { return(1); }
+#endif ERR_CHECK
+
+       dots_3(int P1,char P2, ...)     { return(1); }
+
+int    dots_4(int,char, char *);
+char * dots_5(int,char, char *, ...);
+
+extern _FIRST *xdots_0(p1);
+
+extern char *xdots_1(int p1, ...);
+
+#ifdef ERR_CHECK
+extern xdots_2(p1, ...);
+#endif ERR_CHECK
+
+extern xdots_3(int P1,char P2, ...);
+
+_FIRST *
+func1 (void) { }
+_FIRST *func2(_FIRST *P1,int P2[],float p) { }
+
+int *(
+func_func) (int p1, int p2, int p3)    { return(0); }
+
+extern float   efunc0(p1,p2,p3);
+extern _FIRST  efunc1(int p1, float p2,long P3);
+#ifdef ERR_CHECK
+extern _FIRST  efunc1(int p1, float p2,p3);
+#endif ERR_CHECK
+
+
+typedef        int     bool;
+
+bool   a1;
+static bool    a2;
+extern bool    a3;
+
+struct ZIP1    { int x1, y1; };
+struct zip2    { int x2, y2; } z2;
+struct         { int x3, y3; } z3;     /* not ANSI, but mostly accepted */
+
+static struct  ZIP4    { int x4, y4; };
+static struct  zip5    { int x5, y5; } z5;
+static struct  zip6    { int x6, y6; } z6, w6;
+static struct          { int x7, y7; } z7;
+static struct          { int x8, y8; } z8, w8;
+
+enum   zap1    { a,b,c,d }     what;
+enum   zap2                    what2;
+enum           {a9,b9,c9,d9}   what3;
+
+static char    *zap = "alphabet/\
+first/\
+last";
+typedef        struct  bong    {
+       int     (*func)();
+       } BONG;
+
+typedef        char    *string;
+
+#ifdef ERR_LEX
+string s = "aaa\0000\
+
+bbb";
+#endif ERR_LEX
+
+extern int     junk;
+
+int 
+main (register argc, extern char **argv)
+{
+}
+
+/*VARARGS*/
+/* some other comment */
+int 
+veryfunny (char *a, long b, long c)
+{
+       return 0;
+}
+
+/*VARARGS3*/
+int 
+program (
+    string argv[],     /* first argument */
+    struct alpha y,    /* second argument */
+    int zz,
+    int z1,
+    int z2,
+    int z3
+)
+{
+       return(0);
+}
+
+int 
+junk0 (void) { if(junk != 6) return; else junk++; }
+int 
+junk1 (void) { return (0); }
+int 
+junk2 (void) { }
+int 
+junk3 (void) { return 1; }
+
+BONG *
+junk4 (void) { }
+
+typedef        int     extern_junk;
+extern_junk *
+foo (void) { }
+
+typedef        int     void_junk;
+extern void_junk *
+foo2a (void) { }
+extern void_junk       *foo2a();
+void_junk *
+foo2 (void) { }
+void_junk      *foo_void(void_junk void_int) { }
+static void_junk *
+foo_void2 (void) { }
+
+extern void (*sigdisp(int sig, void (*func)(int sig)))(int sig);
+
+void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1)
+{ /* nothing */ }
+
+void (*
+sigdisp2 (
+    int sig,           /* the signal value */
+    void (*func)(int sig)      /* the function pointer */
+))(int sig2)
+{ /* nothing again! */ }
+
+int (*
+K_R_INT_ptr (long *p1, int p2))(void) { return (*(int(*)())0); }
+
+int (*STD_INT_ptr(long* , int))();
+
+void (*
+K_R_VOID_ptr (long *p1, int p2))(void) { return (*(void(*)())0); }
+
+void (*STD_VOID_ptr(long* , int))();
+
+int *
+K_R_int_ptr (long *p1, int p2) { return (*(int **)0); }
+
+int **STD_int2_ptr(long* , int);
+
+int *STD_int_ptr(long* , int);
+
+void *
+K_R_void_ptr (long *p1, int p2) { return (*(void **)0); }
+
+void *STD_void_ptr(long* , int);
+
+int 
+K_R_int_val (long *p1, int p2) { return (*(int *)0); }
+
+int 
+K_R_int_val2 (long *p1, int p2) { return (*(int *)0); }
+
+int STD_int_val(long*, int);
+
+void 
+K_R_void_val (long *p1, int p2) { /*void*/ }
+
+int 
+K_R_void_val2 (
+    long *p1,
+    int p2 { /*void*/
+) }
+
+void STD_void_val(long* , int);
+
+extern xdots_3(int P1,char P2, ...);
+
+extern int (*XSetAfterFunction(long* , int (*) ( long*)))();
+extern XQueryKeymap(long*, char [32]);
+extern Another(long*, int (*)());
+
+extern GenFunc(int *, int *());
+
+/* these are pointers, not actual functions */
+extern void * (*__glob_opendir_hook) (const char *__directory);
+extern const char *(*__glob_readdir_hook) (void * __stream);
+extern void (*__glob_closedir_hook) (void * __stream);
diff --git a/cproto-4.6/testing/case17.ref b/cproto-4.6/testing/case17.ref
new file mode 100644 (file)
index 0000000..ea619cb
--- /dev/null
@@ -0,0 +1,331 @@
+/* case17.c */
+int dots_0(int p1);
+int dots_1(int p1, ...);
+int dots_3(int P1, char P2, ...);
+_FIRST *func1(void);
+_FIRST *func2(_FIRST *P1 , int P2 [], float p);
+int *(func_func)(int p1, int p2, int p3);
+int main(register argc, char **argv);
+int veryfunny(char *a, long b, long c);
+int program(string argv[], struct alpha y, int zz, int z1, int z2, int z3);
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(void_junk void_int);
+void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1);
+void (*sigdisp2(int sig, void (*func)(int sig)))(int sig2);
+int (*K_R_INT_ptr(long *p1, int p2))(void);
+void (*K_R_VOID_ptr(long *p1, int p2))(void);
+int *K_R_int_ptr(long *p1, int p2);
+void *K_R_void_ptr(long *p1, int p2);
+int K_R_int_val(long *p1, int p2);
+int K_R_int_val2(long *p1, int p2);
+void K_R_void_val(long *p1, int p2);
+int K_R_void_val2(long *p1, int p2);
+... edited case17.c ...
+/*
+ * Define:
+ *     ERR_YACC        to force yacc error reporting
+ *     ERR_LEX         to force lex error reporting
+ *     ERR_CHECK       to force compiler error reporting
+ */
+               /* use one item from type-specifiers */
+#ifdef ERR_YACC
+auto           x;
+register       x1;
+#endif ERR_YACC
+static         x2;
+extern         x3;
+#ifdef ERR_CC
+typedef                x4;
+#endif
+typedef        int     x4t;
+#ifdef ERR_YACC
+void           x5;
+#endif ERR_YACC
+char           x6;
+short          x7;
+int            x8;
+long           x9;
+float          x10;
+double         x11;
+signed         x12;
+unsigned       x13;
+struct         x14;
+#ifdef ERR_CHECK
+struct         x14a {};
+struct         {};
+#endif ERR_CHECK
+union          x15;
+enum           x16;
+x4t;
+x4t            x17;
+const          x18;
+volatile       x19;
+#ifdef ERR_CHECK
+junk           x20;
+#endif ERR_CHECK
+
+typedef        struct  _first  {
+       int             a:5;
+       struct  {
+               int     a,b;
+       } b_struct;
+       char            b:16, b1:1;     /* comment with };};}; */
+       long            c:16, c1;
+       short           d:16, d1:8, d2;
+       unsigned        e:16;
+       float           f;
+       double          g;
+#ifdef ERR_CHECK
+       long    float   f2;
+       long    double  g2;
+#endif ERR_CHECK
+       struct  _first  *link;
+       }       _FIRST;
+
+_FIRST first, last={0}, first_last[] = {{0},{1},{2},{3,{4}}};
+
+struct _second {
+               enum    {true, false} bool;
+               enum    {wrong=1, right=3} values;
+       } _SECOND;
+
+int    i[] = {1,
+               '\002',
+               03,
+               0x4,
+               0X5,
+               0x6a,
+               0X7b,
+               0x8aBcD,
+               9l,
+               10l,
+               11L};
+float  f[] = {5,
+#ifdef ERR_CHECK
+               .5,
+               .5e,
+               .5e+,
+               5e-,
+               5e,
+#endif
+               5.5,
+               5e5,
+               5e0,
+               5e-1,
+               5e+5
+               };
+
+int    array[][10][20];
+
+       /*
+        * This grammar can accept some illegal stuff too, in particular it will
+        * permit some instances of parameter-names to be dropped.
+        */
+#ifdef ERR_CHECK
+#define        P1
+#define        P2
+#define        P3
+#else
+#define        P1      p1
+#define        P2      p2
+#define        P3      p3
+#endif
+
+       /* ellipsis is legal, except in K&R style declaration */
+
+       dots_0(p1)              { return(1); }
+
+       int 
+dots_1 (p1)
+int p1;        { return(1); }
+
+#ifdef ERR_CHECK
+       dots_2(p1, ...)         { return(1); }
+#endif ERR_CHECK
+
+       int 
+dots_3 (, )
+int P1;
+char P2;       { return(1); }
+
+int    dots_4();
+char *dots_5();
+
+extern _FIRST *xdots_0();
+
+extern char *xdots_1();
+
+#ifdef ERR_CHECK
+extern xdots_2(p1, ...);
+#endif ERR_CHECK
+
+extern xdots_3();
+
+_FIRST *func1() { }
+_FIRST *
+func2 (, , p)
+_FIRST *P1 ;
+int P2 [];
+float p; { }
+
+int    *(func_func)(
+#ifdef ERR_CHECK
+p1,p2,p3
+#endif ERR_CHECK
+)      { return(0); }
+
+extern float   efunc0();
+extern _FIRST  efunc1();
+#ifdef ERR_CHECK
+extern _FIRST  efunc1(int p1, float p2,p3);
+#endif ERR_CHECK
+
+
+typedef        int     bool;
+
+bool   a1;
+static bool    a2;
+extern bool    a3;
+
+struct ZIP1    { int x1, y1; };
+struct zip2    { int x2, y2; } z2;
+struct         { int x3, y3; } z3;     /* not ANSI, but mostly accepted */
+
+static struct  ZIP4    { int x4, y4; };
+static struct  zip5    { int x5, y5; } z5;
+static struct  zip6    { int x6, y6; } z6, w6;
+static struct          { int x7, y7; } z7;
+static struct          { int x8, y8; } z8, w8;
+
+enum   zap1    { a,b,c,d }     what;
+enum   zap2                    what2;
+enum           {a9,b9,c9,d9}   what3;
+
+static char    *zap = "alphabet/\
+first/\
+last";
+typedef        struct  bong    {
+       int     (*func)();
+       } BONG;
+
+typedef        char    *string;
+
+#ifdef ERR_LEX
+string s = "aaa\0000\
+
+bbb";
+#endif ERR_LEX
+
+extern int     junk;
+
+main(argc, argv)
+register argc;
+#ifdef ERR_CHECK
+extern
+#endif ERR_CHECK
+char   **argv;
+{
+}
+
+/*VARARGS*/
+/* some other comment */
+veryfunny(a,b,c)
+char *a;
+long b, c;
+{
+       return 0;
+}
+
+/*VARARGS3*/
+program(argv, y, zz, z1, z2, z3)
+string argv[]; /* first argument */
+struct alpha { int x,z; } y;   /* second argument */
+{
+       return(0);
+}
+
+junk0() { if(junk != 6) return; else junk++; }
+junk1() { return (0); }
+junk2() { }
+junk3() { return 1; }
+
+BONG   *junk4() { }
+
+typedef        int     extern_junk;
+extern_junk    *foo() { }
+
+typedef        int     void_junk;
+extern void_junk       *foo2a() { }
+extern void_junk       *foo2a();
+void_junk      *foo2() { }
+void_junk *
+foo_void (void_int)
+void_junk void_int; { }
+static void_junk       *foo_void2() { }
+
+extern void (*sigdisp())();
+
+void (*
+Sigdisp (sig, func))()
+int sig;
+void (*func)();
+{ /* nothing */ }
+
+void (*
+sigdisp2 (
+    sig,
+    func
+))()
+int sig;               /* the signal value */
+void (*func)();        /* the function pointer */
+{ /* nothing again! */ }
+
+int (*K_R_INT_ptr(p1, p2))() long *p1; int p2; { return (*(int(*)())0); }
+
+int (*STD_INT_ptr())();
+
+void (*K_R_VOID_ptr(p1,p2))() long *p1; int p2; { return (*(void(*)())0); }
+
+void (*STD_VOID_ptr())();
+
+int *K_R_int_ptr(p1,p2) long *p1; int p2; { return (*(int **)0); }
+
+int **STD_int2_ptr();
+
+int *STD_int_ptr();
+
+void *K_R_void_ptr(p1,p2) long *p1; int p2; { return (*(void **)0); }
+
+void *STD_void_ptr();
+
+int K_R_int_val(p1,p2) long *p1; int p2; { return (*(int *)0); }
+
+K_R_int_val2(p1,p2) long *p1; int p2; { return (*(int *)0); }
+
+int STD_int_val();
+
+void K_R_void_val(p1,p2) long *p1; int p2; { /*void*/ }
+
+K_R_void_val2(p1,p2) long *p1; int p2; { /*void*/ }
+
+void STD_void_val();
+
+extern xdots_3();
+
+extern int (*XSetAfterFunction())();
+extern XQueryKeymap();
+extern Another();
+
+extern GenFunc();
+
+/* these are pointers, not actual functions */
+extern void *(*__glob_opendir_hook)();
+extern const char *(*__glob_readdir_hook)();
+extern void (*__glob_closedir_hook)();
diff --git a/cproto-4.6/testing/case18.ref b/cproto-4.6/testing/case18.ref
new file mode 100644 (file)
index 0000000..4e41378
--- /dev/null
@@ -0,0 +1,29 @@
+/* case18.c */
+int dots_0();
+int dots_1();
+int dots_3();
+_FIRST *func1();
+_FIRST *func2();
+int *(func_func)();
+int main();
+int veryfunny();
+int program();
+int junk0();
+int junk1();
+int junk2();
+int junk3();
+BONG *junk4();
+extern_junk *foo();
+void_junk *foo2a();
+void_junk *foo2();
+void_junk *foo_void();
+void (*Sigdisp())();
+void (*sigdisp2())();
+int (*K_R_INT_ptr())();
+void (*K_R_VOID_ptr())();
+int *K_R_int_ptr();
+void *K_R_void_ptr();
+int K_R_int_val();
+int K_R_int_val2();
+void K_R_void_val();
+int K_R_void_val2();
diff --git a/cproto-4.6/testing/case19.ref b/cproto-4.6/testing/case19.ref
new file mode 100644 (file)
index 0000000..eddf982
--- /dev/null
@@ -0,0 +1,29 @@
+/* case19.c */
+int dots_0(int);
+int dots_1(int, ...);
+int dots_3(int, char, ...);
+_FIRST *func1(void);
+_FIRST *func2(_FIRST *, int [], float);
+int *(func_func)(void);
+int main(register, char **);
+int veryfunny(char *, long, long);
+int program(string [], struct alpha, int, int, int, int);
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(void_junk);
+void (*Sigdisp(int, void (*)(int)))(int);
+void (*sigdisp2(int, void (*)(int)))(int);
+int (*K_R_INT_ptr(long *, int))(void);
+void (*K_R_VOID_ptr(long *, int))(void);
+int *K_R_int_ptr(long *, int);
+void *K_R_void_ptr(long *, int);
+int K_R_int_val(long *, int);
+int K_R_int_val2(long *, int);
+void K_R_void_val(long *, int);
+int K_R_void_val2(long *, int);
diff --git a/cproto-4.6/testing/case20.ref b/cproto-4.6/testing/case20.ref
new file mode 100644 (file)
index 0000000..0e2b22a
--- /dev/null
@@ -0,0 +1,29 @@
+/* case20.c */
+int dots_0(int p1);
+int dots_1(int p1, ...);
+int dots_3(int p1, char p2, ...);
+_FIRST *func1(void);
+_FIRST *func2(_FIRST *p1, int p2[], float p);
+int *(func_func)(void);
+int main(register argc, char **argv);
+int veryfunny(char *a, long b, long c);
+int program(string argv[], struct alpha y, int zz, int z1, int z2, int z3);
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(void_junk void_int);
+void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1);
+void (*sigdisp2(int sig, void (*func)(int sig)))(int sig2);
+int (*K_R_INT_ptr(long *p1, int p2))(void);
+void (*K_R_VOID_ptr(long *p1, int p2))(void);
+int *K_R_int_ptr(long *p1, int p2);
+void *K_R_void_ptr(long *p1, int p2);
+int K_R_int_val(long *p1, int p2);
+int K_R_int_val2(long *p1, int p2);
+void K_R_void_val(long *p1, int p2);
+int K_R_void_val2(long *p1, int p2);
diff --git a/cproto-4.6/testing/case21.ref b/cproto-4.6/testing/case21.ref
new file mode 100644 (file)
index 0000000..feba30d
--- /dev/null
@@ -0,0 +1,112 @@
+/* case21.c */
+char x6;
+short x7;
+int x8;
+long x9;
+float x10;
+double x11;
+signed x12;
+unsigned x13;
+x4t x17;
+const x18 = {0};
+volatile x19;
+_FIRST first;
+_FIRST last;
+_FIRST first_last[];
+struct _second _SECOND;
+int i[];
+float f[];
+int array[][10][20];
+int dots_0(
+       int p1
+       );
+int dots_1(
+       int p1,
+       ...
+       );
+int dots_3(
+       int p1,
+       char p2,
+       ...
+       );
+_FIRST *func1(void);
+_FIRST *func2(
+       _FIRST *p1,
+       int p2[],
+       float p
+       );
+int *(func_func)(void);
+bool a1;
+struct zip2 z2;
+struct {} z3;
+enum zap1 what;
+enum zap2 what2;
+enum {} what3;
+int main(
+       register argc,
+       char **argv
+       );
+int veryfunny(
+       char *a,
+       long b,
+       long c
+       );
+int program(
+       string argv[],
+       struct alpha y,
+       int zz,
+       int z1,
+       int z2,
+       int z3
+       );
+int junk0(void);
+int junk1(void);
+int junk2(void);
+int junk3(void);
+BONG *junk4(void);
+extern_junk *foo(void);
+void_junk *foo2a(void);
+void_junk *foo2(void);
+void_junk *foo_void(
+       void_junk void_int
+       );
+void (*Sigdisp(
+       int sig,
+       void (*func)(int sig)
+       ))(int sig1);
+void (*sigdisp2(
+       int sig,
+       void (*func)(int sig)
+       ))(int sig2);
+int (*K_R_INT_ptr(
+       long *p1,
+       int p2
+       ))(void);
+void (*K_R_VOID_ptr(
+       long *p1,
+       int p2
+       ))(void);
+int *K_R_int_ptr(
+       long *p1,
+       int p2
+       );
+void *K_R_void_ptr(
+       long *p1,
+       int p2
+       );
+int K_R_int_val(
+       long *p1,
+       int p2
+       );
+int K_R_int_val2(
+       long *p1,
+       int p2
+       );
+void K_R_void_val(
+       long *p1,
+       int p2
+       );
+int K_R_void_val2(
+       long *p1,
+       int p2
+       );
diff --git a/cproto-4.6/testing/case22.ref b/cproto-4.6/testing/case22.ref
new file mode 100644 (file)
index 0000000..22de135
--- /dev/null
@@ -0,0 +1,258 @@
+/* LINTLIBRARY */
+
+/* case22.c */
+
+typedef        int     x4t;
+
+#undef x6
+char   x6;
+#undef x7
+short  x7;
+#undef x8
+int    x8;
+#undef x9
+long   x9;
+#undef x10
+float  x10;
+#undef x11
+double x11;
+#undef x12
+signed x12;
+#undef x13
+unsigned x13;
+
+struct x14;
+
+union x15;
+
+enum x16;
+
+x4t;
+
+#undef x17
+x4t    x17;
+#undef x18
+const  x18 = {0};
+#undef x19
+volatile x19;
+
+typedef        struct  _first  {
+       int             a:5;
+       struct  {
+               int     a,b;
+       } b_struct;
+       char            b:16, b1:1;     
+       long            c:16, c1;
+       short           d:16, d1:8, d2;
+       unsigned        e:16;
+       float           f;
+       double          g;
+       struct  _first  *link;
+       }       _FIRST;
+
+#undef first
+_FIRST first;
+#undef last
+_FIRST last;
+#undef first_last
+_FIRST first_last[];
+#undef _SECOND
+struct _second {
+               enum    {true, false} bool;
+               enum    {wrong=1, right=3} values;
+       } _SECOND;
+#undef i
+int    i[];
+#undef f
+float  f[];
+#undef array
+int    array[][10][20];
+
+#undef dots_0
+int    dots_0(
+               int     p1)
+               { return(*(int *)0); }
+
+#undef dots_1
+int    dots_1(
+               int     p1, 
+               ...)
+               { return(*(int *)0); }
+
+#undef dots_3
+int    dots_3(
+               int     p1, 
+               char    p2, 
+               ...)
+               { return(*(int *)0); }
+
+#undef func1
+_FIRST *func1(void)
+               { return(*(_FIRST **)0); }
+
+#undef func2
+_FIRST *func2(
+               _FIRST  *p1, 
+               int     p2[], 
+               float   p)
+               { return(*(_FIRST **)0); }
+
+#undef func_func
+int    *(func_func)(void);
+
+typedef        int     bool;
+
+#undef a1
+bool   a1;
+
+struct ZIP1    { int x1, y1; };
+
+#undef z2
+struct zip2    { int x2, y2; } z2;
+#undef z3
+struct         { int x3, y3; } z3;
+
+struct ZIP4    { int x4, y4; };
+
+#undef what
+enum   zap1    { a,b,c,d } what;
+#undef what2
+enum zap2 what2;
+#undef what3
+enum           {a9,b9,c9,d9} what3;
+
+typedef        struct  bong    {
+       int     (*func)();
+       } BONG;
+
+typedef        char    *string;
+
+#undef main
+void   main(
+               int     argc, 
+               char    **argv)
+               { /* void */ }
+
+       /* VARARGS */
+#undef veryfunny
+int    veryfunny(
+               char    *a, 
+               long    b, 
+               long    c)
+               { return(*(int *)0); }
+
+       /* VARARGS3 */
+#undef program
+int    program(
+               string  argv[], 
+               struct  alpha { int x,z; } y, 
+               int     zz, 
+               int     z1, 
+               int     z2, 
+               int     z3)
+               { return(*(int *)0); }
+
+#undef junk0
+void   junk0(void)
+               { /* void */ }
+
+#undef junk1
+int    junk1(void)
+               { return(*(int *)0); }
+
+#undef junk2
+void   junk2(void)
+               { /* void */ }
+
+#undef junk3
+int    junk3(void)
+               { return(*(int *)0); }
+
+#undef junk4
+BONG   *junk4(void)
+               { return(*(BONG **)0); }
+
+typedef        int     extern_junk;
+
+#undef foo
+extern_junk *foo(void)
+               { return(*(extern_junk **)0); }
+
+typedef        int     void_junk;
+
+#undef foo2a
+void_junk *foo2a(void)
+               { return(*(void_junk **)0); }
+
+#undef foo2
+void_junk *foo2(void)
+               { return(*(void_junk **)0); }
+
+#undef foo_void
+void_junk *foo_void(
+               void_junk void_int)
+               { return(*(void_junk **)0); }
+
+#undef Sigdisp
+void   (*Sigdisp(
+               int     sig, 
+               void    (*func)(
+               int     sig)))(
+               int     sig1)
+               { return(*(void(*)())0); }
+
+#undef sigdisp2
+void   (*sigdisp2(
+               int     sig, 
+               void    (*func)(
+               int     sig)))(
+               int     sig2)
+               { return(*(void(*)())0); }
+
+#undef K_R_INT_ptr
+int    (*K_R_INT_ptr(
+               long    *p1, 
+               int     p2))(void)
+               { return(*(int(*)())0); }
+
+#undef K_R_VOID_ptr
+void   (*K_R_VOID_ptr(
+               long    *p1, 
+               int     p2))(void)
+               { return(*(void(*)())0); }
+
+#undef K_R_int_ptr
+int    *K_R_int_ptr(
+               long    *p1, 
+               int     p2)
+               { return(*(int **)0); }
+
+#undef K_R_void_ptr
+void   *K_R_void_ptr(
+               long    *p1, 
+               int     p2)
+               { return(*(void **)0); }
+
+#undef K_R_int_val
+int    K_R_int_val(
+               long    *p1, 
+               int     p2)
+               { return(*(int *)0); }
+
+#undef K_R_int_val2
+int    K_R_int_val2(
+               long    *p1, 
+               int     p2)
+               { return(*(int *)0); }
+
+#undef K_R_void_val
+void   K_R_void_val(
+               long    *p1, 
+               int     p2)
+               { /* void */ }
+
+#undef K_R_void_val2
+void   K_R_void_val2(
+               long    *p1, 
+               int     p2)
+               { /* void */ }
diff --git a/cproto-4.6/testing/descrip.mms b/cproto-4.6/testing/descrip.mms
new file mode 100644 (file)
index 0000000..280701e
--- /dev/null
@@ -0,0 +1,52 @@
+# $Id: descrip.mms,v 4.1 1998/01/20 00:59:43 cthuang Exp $
+# VMS make-file for CPROTO test directory
+#
+
+####### (Development) ##########################################################
+
+####### (Command-line Options) #################################################
+
+####### (Standard Lists) #######################################################
+
+REF_FILES=\
+       case1.ref       case2.ref       case3.ref       case4.ref\
+       case5.ref       case6.ref       case7.ref       case8.ref\
+       case9.ref       case10.ref      case11.ref      case12.ref\
+       case13.ref      case14.ref      case15.ref\
+       case17.ref      case18.ref      case19.ref      case20.ref\
+       case21.ref
+
+COM_FILES=\
+       case1.dcl       case2.dcl       case3.dcl       case4.dcl\
+       case5.dcl       case6.dcl       case7.dcl       case8.dcl\
+       case9.dcl       case10.dcl      case11.dcl      case12.dcl\
+       case13.dcl      case14.dcl      case15.dcl\
+       case17.dcl      case18.dcl      case19.dcl      case20.dcl\
+       case21.dcl
+
+TESTDATA=\
+       syntax.c\
+       $(COM_FILES)\
+       $(REF_FILES)
+
+SCRIPTS        =\
+       run_tests.sh    run_tests.com
+
+SOURCES        = makefile descrip.mms $(SCRIPTS) $(TESTDATA)
+
+ALL    = $(SCRIPTS)
+
+####### (Standard Productions) #################################################
+all :  $(ALL) [-.bin]$(THIS).exe [-.bin]$(THIS)1.exe
+       @ write sys$output "Type ""mms run_tests""
+
+clean :
+       @- write sys$output "** made $@"
+clobber :      clean
+       @- write sys$output "** made $@"
+destroy :
+       @- remove -vf *.*;*
+run_tests :    $(SCRIPTS) $(TESTDATA)
+       @run_tests
+
+####### (Details of Productions) ###############################################
diff --git a/cproto-4.6/testing/linux.c b/cproto-4.6/testing/linux.c
new file mode 100644 (file)
index 0000000..1a37566
--- /dev/null
@@ -0,0 +1,87 @@
+/* $Id: linux.c,v 4.2 1998/01/08 00:03:30 cthuang Exp $ */
+/* LINT_EXTERN */
+/* LINT_SHADOWED */
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <a.out.h>
+#include <alloca.h>
+#include <ansidecl.h>
+#include <ar.h>
+#include <assert.h>
+#include <bstring.h>
+#include <bytesex.h>
+#include <confstr.h>
+#include <ctype.h>
+#include <curses.h>
+#include <dbm.h>
+/* #include <dbmalloc.h> */
+#include <dirent.h>
+#include <endian.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <features.h>
+#include <fnmatch.h>
+#include <fpu_control.h>
+#include <ftw.h>
+/* #include <gdbm.h> */
+#include <getopt.h>
+#include <glob.h>
+#include <gnu-stabs.h>
+#include <grp.h>
+#include <huge_val.h>
+#include <ieee754.h>
+#include <iolibio.h>
+/* #include <iostdio.h> */
+#include <jmp_buf.h>
+#include <libio.h>
+#include <limits.h>
+#include <locale.h>
+#include <localeinfo.h>
+#include <malloc.h>
+#include <math.h>
+#include <memory.h>
+#include <mntent.h>
+#include <nan.h>
+/* #include <ndbm.h> */
+#include <netdb.h>
+#include <nl_types.h>
+#include <nlist.h>
+#include <obstack.h>
+#include <paths.h>
+#include <posix1_lim.h>
+#include <posix2_lim.h>
+#include <posix_opt.h>
+#include <pwd.h>
+#include <regex.h>
+/* #include <regexp.h> */
+#include <linux/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+#include <setjmp.h>
+#include <shadow.h>
+/* #include <sharedlib.h> */
+#include <signal.h>
+#include <stab.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <syscall.h>
+#include <sysexits.h>
+#include <syslog.h>
+#include <tar.h>
+#include <termcap.h>
+#include <termio.h>
+#include <termios.h>
+#include <time.h>
+#include <ulimit.h>
+#include <unistd.h>
+#include <utime.h>
+#include <utmp.h>
+#include <values.h>
+#include <vga.h>
+#include <vgagl.h>
+#include <vgamouse.h>
+#include <waitflags.h>
+#include <waitstatus.h>
diff --git a/cproto-4.6/testing/make_bat.sh b/cproto-4.6/testing/make_bat.sh
new file mode 100755 (executable)
index 0000000..4f89052
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/sh
+# $Id: make_bat.sh,v 4.4 1998/02/01 13:47:53 cthuang Exp $
+#
+# This makes a special ".bat" file for testing CPROTO on MSDOS.
+# It won't work properly if /bin/echo tries to expand the backslash sequences.
+# (This is the case on SunOS 4.1.x).
+#
+# The MSDOS 'fc' program doesn't return an exit code for differing files.
+# We have to examine the output log...
+TMP=make$$
+rm -f $TMP
+trap "rm -f $TMP" 0 1 2 5 15
+if [ -f /bin/echo ]
+then
+       ECHO=/bin/echo
+else
+       ECHO=echo
+fi
+for i in $*
+do
+       i="`echo $i | sed -e 's/[A-Za-z_.]//g'`"
+       I="case$i"
+       if [ -n "$i" -a ! -f $I.bat ]
+       then
+               echo '** making '$I.bat
+               cat >$I.bat <<EOF
+@echo off
+echo Testing case $i
+echo Testing case $i >>run_test.out
+if exist $I.out erase $I.out
+if exist $I.dif erase $I.dif
+copy syntax.c $I.c
+EOF
+               grep 'CASE[     ]'$i run_test.txt >$TMP
+               OPTS=`sed -e 's/^.*=/CPROTO/' $TMP`
+               TEST=`sed -e 's/^.*=/CPROTO/' -e 's/-[at]//' $TMP`
+               sed     -e 's/^.*=/CPROTO/' $TMP | \
+               sed     -e 's/^/..\\/' \
+                       -e s/\$/\ -o$I.out\ -O$I.err\ $I.c/ \
+                       -e s/\"//g >>$I.bat
+               if [ ".$OPTS" !=  ".$TEST" ]
+               then
+               cat >>$I.bat <<EOF
+echo ... edited $I.c ... >>$I.out
+type $I.c >>$I.out
+EOF
+               fi
+               cat >>$I.bat <<EOF
+if not exist $I.ref goto saveit
+    fc/L/n/w $I.out $I.ref >>run_test.out
+    if exist $I.out erase $I.out
+    if exist $I.err erase $I.err
+    goto end
+:saveit
+    ren $I.out $I.ref
+:end
+    erase $I.c
+EOF
+       fi
+done
diff --git a/cproto-4.6/testing/make_dcl.sh b/cproto-4.6/testing/make_dcl.sh
new file mode 100755 (executable)
index 0000000..a3e51db
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+# $Id: make_dcl.sh,v 4.1 1998/01/20 00:59:45 cthuang Exp $
+#
+# This makes a special ".dcl" file that can be executed from either UNIX or
+# VMS.  We auto-generate the script (with this name) to avoid confusion on
+# MSDOS, which thinks ".com" files are even more special.
+#
+for i in $*
+do
+       i="`echo $i | sed -e 's/[A-Za-z_.]//g'`"
+       I="case$i"
+       if [ -n "$i" -a ! -f $I.dcl ]
+       then
+               echo '** making '$I.dcl
+               grep "CASE[     ]$i" run_test.txt | \
+                       sed -e 's/^.*=/$CPROTO /' \
+                               -e s/\$/\ -o$I.out\ $I.c/ >$I.dcl
+               chmod 755 $I.dcl
+       fi
+done
diff --git a/cproto-4.6/testing/makefile b/cproto-4.6/testing/makefile
new file mode 100644 (file)
index 0000000..88adb88
--- /dev/null
@@ -0,0 +1,47 @@
+# $Id: makefile,v 4.3 1998/01/08 00:03:33 cthuang Exp $
+# make-file for CPROTO test directory
+
+THIS   = cproto
+B      = ..
+
+####### (Standard Lists) #######################################################
+REF_FILES=\
+       case01.ref      case02.ref      case03.ref      case04.ref\
+       case05.ref      case06.ref      case07.ref      case08.ref\
+       case09.ref      case10.ref      case11.ref      case12.ref\
+       case13.ref      case14.ref      case15.ref      case16.ref\
+       case17.ref      case18.ref      case19.ref      case20.ref\
+       case21.ref
+
+TESTDATA=\
+       run_test.txt\
+       syntax.c\
+       $(COM_FILES)\
+       $(REF_FILES)
+
+SCRIPTS        =\
+       make_dcl.sh\
+       testunix.sh\
+       run_test.sh     run_test.com
+
+SOURCES        = makefile descrip.mms $(SCRIPTS) $(TESTDATA)
+
+####### (Standard Productions) #################################################
+all:   $(SOURCES) $B/$(THIS)
+       @echo 'Type "make run_test"'
+
+scripts : $(SOURCES)
+       make_bat.sh `fgrep dos run_test.txt |sed -e 's/=.*//'`
+       make_dcl.sh `fgrep unix run_test.txt |sed -e 's/=.*//'`
+
+clean:
+       - rm -f *.log *.out *.err *.tmp case*.c
+
+distclean: clean
+
+realclean: distclean
+       - rm -f *.dcl case*.bat
+
+run_test:      $(SOURCES)
+       date >>$@.out
+       sh -c '(./run_test.sh 2>&1)' |tee -a $@.out
diff --git a/cproto-4.6/testing/run_test.com b/cproto-4.6/testing/run_test.com
new file mode 100644 (file)
index 0000000..f87cdbb
--- /dev/null
@@ -0,0 +1,95 @@
+$! $Id: run_test.com,v 4.3 1998/01/08 00:03:35 cthuang Exp $
+$! Perform all regression-tests for CPROTO on VAX/VMS
+$
+$      verify  = F$VERIFY(0)
+$      path    := 'F$ENVIRONMENT("DEFAULT")
+$      path    := "''F$EXTRACT(0,F$LENGTH(path)-1,path)'.-]"
+$      CPROTO  :== "$''path'cproto.exe"
+$      CPROTO1 :== "$''path'cproto1.exe"
+$
+$      caselist=""
+$      open/read input_file run_test.txt
+$ read_loop:
+$      read/end=read_exit input_file sometext
+$      if f$locate("vms",sometext) .ne. f$length(sometext)
+$      then
+$              sometext = f$edit(sometext,"collapse,lowercase")
+$              sometext = f$extract(0, f$locate("=", sometext), sometext)
+$              caselist = "''caselist'/''sometext'"
+$      endif
+$      goto read_loop
+$ read_exit:
+$      close input_file
+$      caselist = "''caselist'/"
+$
+$
+$      if "''p1'" .eqs. ""
+$      then
+$              cases = "*"
+$      else
+$              cases = "''p1'"
+$      endif
+$
+$      old_name = ""
+$ test_loop:
+$      ref_name = F$SEARCH("''cases'.ref;",1)
+$      if ref_name .eqs. ""
+$      then
+$              verify = F$VERIFY(verify)
+$              exit
+$      endif
+$      if "''old_name'" .eqs. "''ref_name'" then exit
+$      old_name = ref_name
+$
+$      com_name = F$EXTRACT(0, F$LOCATE(".REF;", ref_name), ref_name)
+$      casename = F$PARSE(ref_name,,, "NAME", "SYNTAX_ONLY")
+$      casename = F$EDIT(casename,"LOWERCASE")
+$      case_num = F$EXTRACT(4, F$LENGTH(casename), casename)
+$
+$      write sys$output "** ",ref_name
+$      if f$locate("/''casename'/", caselist) .eq. f$length(caselist)
+$      then
+$              write sys$output "...skipped"
+$              goto test_loop
+$      endif
+$
+$      if F$SEARCH("''com_name'.dcl;", 2) .eqs. ""
+$      then
+$              write sys$output "?? no script for ", ref_name
+$      else
+$              if F$SEARCH("''com_name'.out") .nes. "" then delete 'com_name.out;*
+$              if F$SEARCH("''com_name'.err") .nes. "" then delete 'com_name.err;*
+$              if F$SEARCH("''casename'.c") .nes. "" then delete 'casename.c;*
+$              copy syntax.c  'casename.c;
+$              set noon
+$              define/user_mode sys$error 'casename.err
+$              @'com_name.dcl
+$              set on
+$              if F$SEARCH("''com_name'.out") .eqs. ""
+$              then
+$                      write sys$output "?? no output from test"
+$              else
+$                      if f$search("''casename'.c;-1") .nes. ""
+$                      then
+$                              diff/out='com_name 'casename.c
+$                              if $severity .ne. 1
+$                              then
+$                                      open/append output_file 'com_name.out
+$                                      write output_file "... edited ''casename'.c ..."
+$                                      close output_file
+$                                      append 'casename.c 'com_name.out
+$                              endif
+$                      endif
+$                      diff/out='com_name 'com_name.out 'ref_name
+$                      if $severity .ne. 1
+$                      then
+$                              write sys$output "?? test failed"
+$                              type 'com_name.dif
+$                      else
+$                              delete 'com_name.dif;*
+$                              if F$SEARCH("''com_name'.err") .nes. "" then delete 'com_name.err;*
+$                      endif
+$                      delete 'casename.c;*, 'com_name.out;*
+$              endif
+$      endif
+$      goto test_loop
diff --git a/cproto-4.6/testing/run_test.sh b/cproto-4.6/testing/run_test.sh
new file mode 100755 (executable)
index 0000000..5ea847b
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+# $Id: run_test.sh,v 4.3 1998/01/08 00:03:37 cthuang Exp $
+#
+# This test-script assumes that we can reproduce (except for minor whitespace)
+# the reference files listed in run_test.txt
+#
+echo '** '`date`
+for i in `grep 'CASE.*unix' run_test.txt | sed -e 's/^[^0-9]*//'  -e 's/[      ].*//'`
+do
+       ./testunix.sh $i
+done
diff --git a/cproto-4.6/testing/run_test.txt b/cproto-4.6/testing/run_test.txt
new file mode 100644 (file)
index 0000000..664a4a6
--- /dev/null
@@ -0,0 +1,23 @@
+$Id: run_test.txt,v 4.4 1998/01/22 19:49:42 cthuang Exp $
+CASE 01 = unix, vms, dos, os2 =
+CASE 02 = unix, vms, dos, os2 = -f0
+CASE 03 = unix, vms, dos, os2 = -c -f1
+CASE 04 = unix, vms, dos, os2 = -c -f2
+CASE 05 = unix, vms, dos, os2 = -c -f3
+CASE 06 = unix, vms, dos = -c -f3 -v
+CASE 07 = unix, vms, dos = -c -f3 -v -e
+CASE 08 = unix, vms, dos = -c -f3 -v -e -m
+CASE 09 = unix, vms, dos = -c -f3 -v -"Pint\sfunc(\n\ta,\n\tb\n\t)"
+CASE 10 = unix = -"T"
+CASE 11 = unix = -l
+CASE 12 = unix, vms, dos, os2 = -s
+CASE 13 = unix = -l -s
+CASE 14 = unix = -l -x
+CASE 15 = apollo = -D__STDC__ -D__attribute='#attributes' -l apollo.c
+CASE 16 = unix, vms, dos = -a
+CASE 17 = unix, vms, dos = -t
+CASE 18 = unix, vms, dos, os2 = -f1
+CASE 19 = unix, vms, dos, os2 = -f2
+CASE 20 = unix, vms, dos, os2 = -f3
+CASE 21 = unix, vms, dos = -f3 -v -"Pint\sfunc(\n\ta,\n\tb\n\t)"
+CASE 22 = unix = -l -a
diff --git a/cproto-4.6/testing/solaris.c b/cproto-4.6/testing/solaris.c
new file mode 100644 (file)
index 0000000..8fbe2c5
--- /dev/null
@@ -0,0 +1,138 @@
+/* $Id: solaris.c,v 4.1 1994/10/12 14:12:48 cthuang Exp $ */
+/*LINTLIBRARY*/
+/*LINT_EXTERN*/
+/*LINT_SHADOWED*/
+#include <sys/types.h>
+#include <netinet/in.h>
+/*LINT_PREPRO2
+#define MAXDNAME 10
+*/
+#define MAXDNAME 10
+
+#include <aio.h>
+#include <alloca.h>
+#include <ar.h>
+#include <archives.h>
+#include <assert.h>
+#include <cpio.h>
+#include <crypt.h>
+#include <ctype.h>
+#include <curses.h>
+#include <deflt.h>
+#include <devmgmt.h>
+/*#include <dial.h> -- true redef */
+#include <dirent.h>
+#include <dlfcn.h>
+#include <elf.h>
+#include <errno.h>
+#include <eti.h>
+#include <euc.h>
+#include <fatal.h>
+#include <fcntl.h>
+#include <float.h>
+#include <floatingpoint.h>
+#include <fmtmsg.h>
+#include <form.h>
+#include <ftw.h>
+#include <getwidth.h>
+#include <grp.h>
+#include <ieeefp.h>
+#include <kstat.h>
+#include <kvm.h>
+#include <langinfo.h>
+#include <lastlog.h>
+#include <libelf.h>
+#include <libgen.h>
+#include <libgenIO.h>
+#include <libintl.h>
+#include <libw.h>
+#include <limits.h>
+#include <linenum.h>
+#include <link.h>
+#include <listen.h>
+#include <locale.h>
+#include <macros.h>
+#include <maillock.h>
+#include <malloc.h>
+#include <math.h>
+#include <memory.h>
+#include <menu.h>
+#include <mon.h>
+#include <mp.h>
+#include <mqueue.h>
+#include <nan.h>
+#include <ndbm.h>
+#include <netconfig.h>
+#include <netdb.h>
+#include <netdir.h>
+#include <nl_types.h>
+#include <nlist.h>
+#include <nss_common.h>
+#include <nss_dbdefs.h>
+#include <nsswitch.h>
+#include <panel.h>
+#include <pkgdev.h>
+#include <pkginfo.h>
+#include <pkglocs.h>
+#include <pkgstrct.h>
+#include <pkgtrans.h>
+#include <poll.h>
+#include <prof.h>
+#include <pw.h>
+#include <pwd.h>
+/*#include <regexp.h>*/
+#include <regexpr.h>
+#include <resolv.h>
+#include <rje.h>
+#include <rmmount.h>
+#include <sac.h>
+#include <sched.h>
+#include <search.h>
+#include <semaphore.h>
+#include <setjmp.h>
+/*#include <sgtty.h> */
+#include <shadow.h>
+#include <siginfo.h>
+#include <signal.h>
+#include <std.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <storclass.h>
+#include <string.h>
+#include <stropts.h>
+#include <sum.h>
+#include <syms.h>
+#include <synch.h>
+#include <syslog.h>
+/* #include <table.h> conflict with search.h */
+#include <tar.h>
+/* #include <term.h> conflict with termcap.h */
+/*LINT_PREPRO2
+#undef PC
+*/
+#undef PC
+#include <termcap.h>
+#include <termio.h>
+#include <termios.h>
+#include <thread.h>
+#include <time.h>
+#include <tiuser.h>
+#include <tzfile.h>
+#include <ucontext.h>
+#include <ulimit.h>
+#include <unctrl.h>
+#include <unistd.h>
+#include <userdefs.h>
+#include <ustat.h>
+#include <utime.h>
+#include <utmp.h>
+#include <utmpx.h>
+#include <valtools.h>
+#include <values.h>
+/* #include <varargs.h> - gcc prefers to give its own include-pathname here */
+#include <volmgt.h>
+#include <wait.h>
+#include <wctype.h>
+#include <widec.h>
diff --git a/cproto-4.6/testing/syntax.c b/cproto-4.6/testing/syntax.c
new file mode 100644 (file)
index 0000000..7e142e8
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+ * Define:
+ *     ERR_YACC        to force yacc error reporting
+ *     ERR_LEX         to force lex error reporting
+ *     ERR_CHECK       to force compiler error reporting
+ */
+               /* use one item from type-specifiers */
+#ifdef ERR_YACC
+auto           x;
+register       x1;
+#endif ERR_YACC
+static         x2;
+extern         x3;
+#ifdef ERR_CC
+typedef                x4;
+#endif
+typedef        int     x4t;
+#ifdef ERR_YACC
+void           x5;
+#endif ERR_YACC
+char           x6;
+short          x7;
+int            x8;
+long           x9;
+float          x10;
+double         x11;
+signed         x12;
+unsigned       x13;
+struct         x14;
+#ifdef ERR_CHECK
+struct         x14a {};
+struct         {};
+#endif ERR_CHECK
+union          x15;
+enum           x16;
+x4t;
+x4t            x17;
+const          x18;
+volatile       x19;
+#ifdef ERR_CHECK
+junk           x20;
+#endif ERR_CHECK
+
+typedef        struct  _first  {
+       int             a:5;
+       struct  {
+               int     a,b;
+       } b_struct;
+       char            b:16, b1:1;     /* comment with };};}; */
+       long            c:16, c1;
+       short           d:16, d1:8, d2;
+       unsigned        e:16;
+       float           f;
+       double          g;
+#ifdef ERR_CHECK
+       long    float   f2;
+       long    double  g2;
+#endif ERR_CHECK
+       struct  _first  *link;
+       }       _FIRST;
+
+_FIRST first, last={0}, first_last[] = {{0},{1},{2},{3,{4}}};
+
+struct _second {
+               enum    {true, false} bool;
+               enum    {wrong=1, right=3} values;
+       } _SECOND;
+
+int    i[] = {1,
+               '\002',
+               03,
+               0x4,
+               0X5,
+               0x6a,
+               0X7b,
+               0x8aBcD,
+               9l,
+               10l,
+               11L};
+float  f[] = {5,
+#ifdef ERR_CHECK
+               .5,
+               .5e,
+               .5e+,
+               5e-,
+               5e,
+#endif
+               5.5,
+               5e5,
+               5e0,
+               5e-1,
+               5e+5
+               };
+
+int    array[][10][20];
+
+       /*
+        * This grammar can accept some illegal stuff too, in particular it will
+        * permit some instances of parameter-names to be dropped.
+        */
+#ifdef ERR_CHECK
+#define        P1
+#define        P2
+#define        P3
+#else
+#define        P1      p1
+#define        P2      p2
+#define        P3      p3
+#endif
+
+       /* ellipsis is legal, except in K&R style declaration */
+
+       dots_0(p1)              { return(1); }
+
+       dots_1(int p1, ...)     { return(1); }
+
+#ifdef ERR_CHECK
+       dots_2(p1, ...)         { return(1); }
+#endif ERR_CHECK
+
+       dots_3(int P1,char P2, ...)     { return(1); }
+
+int    dots_4(int,char, char *);
+char * dots_5(int,char, char *, ...);
+
+extern _FIRST *xdots_0(p1);
+
+extern char *xdots_1(int p1, ...);
+
+#ifdef ERR_CHECK
+extern xdots_2(p1, ...);
+#endif ERR_CHECK
+
+extern xdots_3(int P1,char P2, ...);
+
+_FIRST *func1() { }
+_FIRST *func2(_FIRST *P1,int P2[],float p) { }
+
+int    *(func_func)(
+#ifdef ERR_CHECK
+p1,p2,p3
+#endif ERR_CHECK
+)      { return(0); }
+
+extern float   efunc0(p1,p2,p3);
+extern _FIRST  efunc1(int p1, float p2,long P3);
+#ifdef ERR_CHECK
+extern _FIRST  efunc1(int p1, float p2,p3);
+#endif ERR_CHECK
+
+
+typedef        int     bool;
+
+bool   a1;
+static bool    a2;
+extern bool    a3;
+
+struct ZIP1    { int x1, y1; };
+struct zip2    { int x2, y2; } z2;
+struct         { int x3, y3; } z3;     /* not ANSI, but mostly accepted */
+
+static struct  ZIP4    { int x4, y4; };
+static struct  zip5    { int x5, y5; } z5;
+static struct  zip6    { int x6, y6; } z6, w6;
+static struct          { int x7, y7; } z7;
+static struct          { int x8, y8; } z8, w8;
+
+enum   zap1    { a,b,c,d }     what;
+enum   zap2                    what2;
+enum           {a9,b9,c9,d9}   what3;
+
+static char    *zap = "alphabet/\
+first/\
+last";
+typedef        struct  bong    {
+       int     (*func)();
+       } BONG;
+
+typedef        char    *string;
+
+#ifdef ERR_LEX
+string s = "aaa\0000\
+
+bbb";
+#endif ERR_LEX
+
+extern int     junk;
+
+main(argc, argv)
+register argc;
+#ifdef ERR_CHECK
+extern
+#endif ERR_CHECK
+char   **argv;
+{
+}
+
+/*VARARGS*/
+/* some other comment */
+veryfunny(a,b,c)
+char *a;
+long b, c;
+{
+       return 0;
+}
+
+/*VARARGS3*/
+program(argv, y, zz, z1, z2, z3)
+string argv[]; /* first argument */
+struct alpha { int x,z; } y;   /* second argument */
+{
+       return(0);
+}
+
+junk0() { if(junk != 6) return; else junk++; }
+junk1() { return (0); }
+junk2() { }
+junk3() { return 1; }
+
+BONG   *junk4() { }
+
+typedef        int     extern_junk;
+extern_junk    *foo() { }
+
+typedef        int     void_junk;
+extern void_junk       *foo2a() { }
+extern void_junk       *foo2a();
+void_junk      *foo2() { }
+void_junk      *foo_void(void_junk void_int) { }
+static void_junk       *foo_void2() { }
+
+extern void (*sigdisp(int sig, void (*func)(int sig)))(int sig);
+
+void (*Sigdisp(int sig, void (*func)(int sig)))(int sig1)
+{ /* nothing */ }
+
+void (*sigdisp2(sig, func))(int sig2)
+       int sig;                /* the signal value */
+       void (*func)(int sig);  /* the function pointer */
+{ /* nothing again! */ }
+
+int (*K_R_INT_ptr(p1, p2))() long *p1; int p2; { return (*(int(*)())0); }
+
+int (*STD_INT_ptr(long* , int))();
+
+void (*K_R_VOID_ptr(p1,p2))() long *p1; int p2; { return (*(void(*)())0); }
+
+void (*STD_VOID_ptr(long* , int))();
+
+int *K_R_int_ptr(p1,p2) long *p1; int p2; { return (*(int **)0); }
+
+int **STD_int2_ptr(long* , int);
+
+int *STD_int_ptr(long* , int);
+
+void *K_R_void_ptr(p1,p2) long *p1; int p2; { return (*(void **)0); }
+
+void *STD_void_ptr(long* , int);
+
+int K_R_int_val(p1,p2) long *p1; int p2; { return (*(int *)0); }
+
+K_R_int_val2(p1,p2) long *p1; int p2; { return (*(int *)0); }
+
+int STD_int_val(long*, int);
+
+void K_R_void_val(p1,p2) long *p1; int p2; { /*void*/ }
+
+K_R_void_val2(p1,p2) long *p1; int p2; { /*void*/ }
+
+void STD_void_val(long* , int);
+
+extern xdots_3(int P1,char P2, ...);
+
+extern int (*XSetAfterFunction(long* , int (*) ( long*)))();
+extern XQueryKeymap(long*, char [32]);
+extern Another(long*, int (*)());
+
+extern GenFunc(int *, int *());
+
+/* these are pointers, not actual functions */
+extern void * (*__glob_opendir_hook) (const char *__directory);
+extern const char *(*__glob_readdir_hook) (void * __stream);
+extern void (*__glob_closedir_hook) (void * __stream);
diff --git a/cproto-4.6/testing/test_dos.bat b/cproto-4.6/testing/test_dos.bat
new file mode 100644 (file)
index 0000000..cd19225
--- /dev/null
@@ -0,0 +1,4 @@
+@echo off
+rem $Id: test_dos.bat,v 4.1 1998/01/08 00:19:27 cthuang Exp $
+erase run_test.out
+for %%n in ( case*.bat ) do call %%n
diff --git a/cproto-4.6/testing/testunix.sh b/cproto-4.6/testing/testunix.sh
new file mode 100755 (executable)
index 0000000..037bba8
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+# $Id: testunix.sh,v 4.1 1998/01/20 00:59:47 cthuang Exp $
+#
+# Test one or more given cases by number, creating the VMS test script
+# as a side-effect.
+#
+CPROTO=../cproto
+for i in $*
+do
+       echo '** Case '$i
+       I="case$i"
+       ./make_dcl.sh $i
+
+       rm -f $I.c $I.out $I.err $I.tmp
+       cp syntax.c $I.c
+       chmod +w $I.c
+
+       . ./$I.dcl 2>$I.err
+
+       if [ -f $I.ref ]
+       then
+               # When we select either the -a or -t options, CPROTO will edit
+               # the input file.  It also writes to the standard output the
+               # prototypes that it is extracting.  Since there's only one
+               # reference for each test, I simply concatenate the edited file
+               # after the test output, for use as a combined reference.
+               if ( cmp -s $I.c syntax.c )
+               then
+                       rm -f $I.c
+               else
+                       echo '... edited '$I.c' ...' >>$I.out
+                       cat $I.c >>$I.out
+                       rm -f $I.c
+               fi
+
+               if [ -f $I.out ]
+               then
+                       diff -b -c $I.ref $I.out |fgrep -v 'No diff' >$I.tmp
+                       if [ -s $I.tmp ]
+                       then
+                               cat $I.err
+                               cat $I.tmp
+                       else
+                               echo '... ok'
+                               rm -f $I.out $I.tmp $I.err
+                       fi
+               else
+                       echo '? no output '$I
+               fi
+       else
+               echo '...saving reference for '$i
+               mv $I.out $I.ref
+               rm -f $I.err
+       fi
+done
diff --git a/cproto-4.6/testing/turboc.c b/cproto-4.6/testing/turboc.c
new file mode 100644 (file)
index 0000000..1ec23c6
--- /dev/null
@@ -0,0 +1,53 @@
+/*LINT_EXTERN*/
+#include <sys/stat.h>
+#include <sys/timeb.h>
+#include <sys/types.h>
+
+#include <alloc.h>
+#include <assert.h>
+/* C++ only #include <bcd.h> */
+#include <bios.h>
+/* C++ only #include <complex.h> */
+#include <conio.h>
+/* C++ only #include <constrea.h> */
+#include <ctype.h>
+#include <dir.h>
+#include <direct.h>
+#include <dirent.h>
+#include <dos.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <float.h>
+/* C++ only #include <fstream.h> */
+/* C++ only #include <generic.h> */
+#include <graphics.h>
+#include <io.h>
+/* C++ only #include <iomanip.h> */
+/* C++ only #include <iostream.h> */
+#include <limits.h>
+#include <locale.h>
+#include <locking.h>
+#include <malloc.h>
+#include <math.h>
+#include <mem.h>
+#include <memory.h>
+/* C++ only #include <new.h> */
+#include <process.h>
+#include <search.h>
+#include <setjmp.h>
+#include <share.h>
+#include <signal.h>
+#include <stat.h>
+/* ? #include <stdarg.h> */
+#include <stddef.h>
+#include <stdio.h>
+/* C++ only #include <stdiostr.h> */
+#include <stdlib.h>
+#include <string.h>
+/* C++ only #include <strstrea.h> */
+#include <time.h>
+#include <timeb.h>
+#include <types.h>
+#include <utime.h>
+#include <values.h>
+/* ? #include <varargs.h> */
diff --git a/cproto-4.6/trace.c b/cproto-4.6/trace.c
new file mode 100644 (file)
index 0000000..589c6df
--- /dev/null
@@ -0,0 +1,318 @@
+/* $Id: trace.c,v 4.2 1998/01/19 00:49:33 cthuang Exp $
+ *
+ * Simple malloc debugging (for finding leaks)
+ *
+ * This is a cut-down version of a module I wrote originally for 'vile', it
+ * requires an ANSI compiler.  Its main purpose is to allow tracing problems in
+ * a repeatable test, including malloc/free bugs -- dickey@clark.net
+ */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <trace.h>     /* interface of this module */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+#define        BEFORE  0       /* padding "before" allocated area */
+#define AFTER   0      /* padding "after" allocated area */
+
+#include <stdarg.h>
+
+#if    DOALLOC
+#undef malloc
+#undef realloc
+#undef free
+#endif /* DOALLOC */
+
+void
+Trace(char *format, ...)
+{
+       static  FILE    *fp;
+       va_list ap;
+
+       if (!fp)
+               fp = fopen("Trace.out", "w");
+       if (!fp)
+               abort();
+
+       va_start(ap,format);
+       if (format != 0) {
+               vfprintf(fp, format, ap);
+               va_end(ap);
+               (void)fflush(fp);
+       } else {
+               (void)fclose(fp);
+               (void)fflush(stdout);
+               (void)fflush(stderr);
+       }
+}
+
+#define        SECS(tv)        (tv.tv_sec + (tv.tv_usec / 1.0e6))
+
+void
+Elapsed(char *msg)
+{
+#if HAVE_GETTIMEOFDAY
+       static  struct  timeval         tv0, tv1;
+       static  struct  timezone        tz0, tz1;
+       static  int     init;
+       if (!init++)
+               gettimeofday(&tv0, &tz0);
+       gettimeofday(&tv1, &tz1);
+       Trace("%10.6f %s\n", SECS(tv1) - SECS(tv0), msg);
+       tv0 = tv1;
+#endif
+}
+
+#ifdef apollo
+static
+int contains(char *ref, char *tst)
+{
+       size_t  len     = strlen(ref);
+       while (*tst) {
+               if (!strncmp(ref,tst++,len))
+                       return TRUE;
+       }
+       return FALSE;
+}
+#endif /* apollo */
+
+void
+WalkBack(void)
+{
+#ifdef apollo
+       static  char    *first  = "\"WalkBack\"",
+                       *last   = "\"unix_$main\"";
+       auto    FILE    *pp;
+       auto    char    bfr[BUFSIZ];
+       auto    int     ok      = FALSE;
+       static  int     count;
+
+       Trace("%s %d\n", first, ++count);
+       sprintf(bfr, "/com/tb %d", getpid());
+       if (!(pp = popen(bfr, "r")))
+               perror(bfr);
+
+       while (fgets(bfr, sizeof(bfr), pp)) {
+               if (ok && contains(last, bfr))
+                       break;
+               else if (contains(first, bfr))
+                       ok = TRUE;
+               else if (ok)
+                       Trace("%s", bfr);
+       }
+       (void)fclose(pp);
+#endif /* apollo */
+}
+
+static long    count_alloc,
+               count_freed;
+
+void
+fail_alloc(char *msg, char *ptr)
+{
+       Trace("%s: %p\n", msg, ptr);
+       Trace("allocs %ld, frees %ld\n", count_alloc, count_freed);
+       WalkBack();
+#if NO_LEAKS
+       show_alloc();
+#endif
+       Trace((char *)0);
+       abort();
+}
+
+#if    DOALLOC
+#undef malloc
+#undef realloc
+#undef free
+
+typedef        struct  {
+       long    size;   /* ...its size */
+       char    *text;  /* the actual segment */
+       int     note;   /* ...last value of 'count_alloc' */
+       } AREA;
+
+static AREA    area[DOALLOC];
+
+static long    maxAllocated,   /* maximum # of bytes allocated */
+               nowAllocated,   /* current # of bytes allocated */
+               nowPending,     /* current end of 'area[]' table */
+               maxPending;     /* maximum # of segments allocated */
+
+static
+int FindArea(char *ptr)
+{
+       register int j;
+       for (j = 0; j < DOALLOC; j++)
+               if (area[j].text == ptr) {
+                       if (j >= nowPending) {
+                               nowPending = j+1;
+                               if (nowPending > maxPending)
+                                       maxPending = nowPending;
+                       }
+                       return j;
+               }
+       return -1;
+}
+
+static
+int record_freed(char *ptr)
+{
+       register int j;
+       if ((j = FindArea(ptr)) >= 0) {
+               nowAllocated -= area[j].size;
+               /*memset(ptr, 0xdf, area[j].size); -* poison */
+               area[j].size = 0;
+               area[j].text = 0;
+               area[j].note = count_freed;
+               if ((j+1) == nowPending) {
+                       register int    k;
+                       for (k = j; (k >= 0) && !area[k].size; k--)
+                               nowPending = k;
+               }
+       }
+       return j;
+}
+
+static
+int record_alloc(char *newp, char *oldp, unsigned len)
+{
+       register int    j;
+
+       if (newp == oldp) {
+               if ((j = FindArea(oldp)) >= 0) {
+                       nowAllocated -= area[j].size;
+                       area[j].size = len;
+                       area[j].note = count_alloc;
+               } else
+                       fail_alloc("could not find", oldp);
+       } else {
+               if (oldp != 0)
+                       record_freed(oldp);
+               if ((j = FindArea((char *)0)) >= 0) {
+                       area[j].text = newp;
+                       area[j].size = len;
+                       area[j].note = count_alloc;
+               } else
+                       fail_alloc("no room in table", newp);
+       }
+
+       nowAllocated += len;
+       if (nowAllocated > maxAllocated)
+               maxAllocated = nowAllocated;
+       return len;
+}
+
+#define        OK_ALLOC(p,q,n) ((p != 0) && (record_alloc(p,q,n) >= 0))
+#define        OK_FREE(p)      ((p != 0) && (record_freed(p) >= 0))
+#else
+#define        OK_ALLOC(p,q,n) (p != 0)
+#define        OK_FREE(p)      (p != 0)
+#endif /* DOALLOC */
+
+#ifdef DEBUG2
+#define        LOG_PTR(msg,num)        Trace("%s %p\n", msg, num);
+#define        LOG_LEN(msg,num)        Trace("%s %d\n", msg, num);
+#else
+#define LOG_PTR(msg,num)
+#define        LOG_LEN(msg,num)
+#endif
+
+/************************************************************************
+ *     public entrypoints                                              *
+ ************************************************************************/
+#if DOALLOC
+void *
+doalloc (void *oldp, unsigned amount)
+{
+       register void   *newp;
+
+       if (oldp != 0)
+               oldp -= BEFORE;
+       count_alloc += (oldp == 0);
+#if 0
+       if ((count_alloc > 99914 && count_alloc < 99920)) {
+               Trace("doalloc #%d\n", count_alloc);
+               WalkBack();
+       }
+#endif
+       LOG_LEN("allocate", amount)
+       LOG_PTR("  old = ", oldp)
+       amount += (BEFORE+AFTER);       /* patch */
+
+       newp = (oldp != 0) ? realloc(oldp, amount) : malloc(amount);
+       if (!OK_ALLOC(newp,oldp,amount)) {
+               perror("doalloc");
+               fail_alloc("doalloc", oldp);
+               /*NOT REACHED*/
+       }
+
+       LOG_PTR("  new = ", newp)
+       return (newp+BEFORE);
+}
+
+/*
+ * Entrypoint so we can validate pointers
+ */
+void
+dofree(void *oldp)
+{
+       oldp -= BEFORE;
+       count_freed++;
+       LOG_PTR("dealloc ", oldp)
+
+       if (OK_FREE(oldp)) {
+               free(oldp);
+               return;
+       }
+
+       fail_alloc("free (not found)", oldp);
+}
+#endif
+
+void
+show_alloc(void)
+{
+#if    DOALLOC
+       static  char    *format = ".. %-24.24s %10ld\n";
+
+       Trace("** allocator metrics:\n");
+       Trace(format, "allocs:", count_alloc);
+       Trace(format, "frees:",  count_freed);
+       {
+               register int    j, count = 0;
+               register long   total   = 0;
+
+               for (j = 0; j < nowPending; j++) {
+                       if (area[j].text) {
+                               if (count++ < 10)
+                                       Trace("...%d) %ld bytes in alloc #%d:%p\n",
+                                               j,
+                                               area[j].size,
+                                               area[j].note,
+                                               area[j].text);
+                               total += area[j].size;
+                       }
+               }
+               Trace(format, "total bytes allocated:",   total);
+               Trace(format, "current bytes allocated:", nowAllocated);
+               Trace(format, "maximum bytes allocated:", maxAllocated);
+               Trace(format, "segment-table length:",    nowPending);
+               Trace(format, "current # of segments:",   (long)count);
+               Trace(format, "maximum # of segments:",   maxPending);
+       }
+#endif
+}
diff --git a/cproto-4.6/trace.h b/cproto-4.6/trace.h
new file mode 100644 (file)
index 0000000..ba8599a
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Id: trace.h,v 4.2 1998/01/19 00:49:35 cthuang Exp $ */
+
+#ifndef TRACE_H
+#define TRACE_H
+
+#if !defined(__GNUC__) && !defined(__attribute__)
+#define __attribute__(p)
+#endif
+
+extern void Trace(char *f, ...) __attribute__((format (printf,1,2)));
+extern void show_alloc(void);
+extern void Elapsed(char *msg);
+extern void WalkBack(void);
+extern void fail_alloc(char *msg, char *ptr);
+
+#ifdef DOALLOC
+extern void *doalloc(void *,unsigned);
+extern void dofree(void *);
+
+#define malloc(n)    doalloc(0,n)
+#define realloc(p,n) doalloc(p,n)
+#define free(n)      dofree(n)
+#endif
+
+#endif /* TRACE_H */
diff --git a/cproto-4.6/vms/README b/cproto-4.6/vms/README
new file mode 100644 (file)
index 0000000..01cedee
--- /dev/null
@@ -0,0 +1,3 @@
+The files in this directory are used to build on VMS.
+
+descrip.mms    makefile for VAX C
diff --git a/cproto-4.6/vms/descrip.mms b/cproto-4.6/vms/descrip.mms
new file mode 100644 (file)
index 0000000..b45daff
--- /dev/null
@@ -0,0 +1,92 @@
+# $Id: descrip.mms,v 4.1 1998/01/20 00:19:35 cthuang Exp $
+# VAX/VMS "mms" script for CPROTO
+
+THIS = cproto
+
+#### Start of system configuration section. ####
+
+LEX    = flex
+#YACC  = bison /fixed_outfiles
+YACC   = bison 
+
+DEFINES        = /Define=(STDC_HEADERS)
+CFLAGS = /Include=([]) $(DEFINES)
+
+#### End of system configuration section. ####
+
+DOC_FILES = \
+       README \
+       CHANGES \
+       $(THIS).1
+
+H_FILES = \
+       yyerror.c \
+       system.h \
+       $(THIS).h \
+       patchlev.h \
+       semantic.h \
+       symbol.h
+
+C_FILES = \
+       $(THIS).c \
+       lintlibs.c \
+       semantic.c \
+       strkey.c \
+       strstr.c \
+       symbol.c \
+       getopt.c
+
+AUX_FILES = \
+       mkdirs.sh \
+       lex.l \
+       grammar.y
+
+LEX_YY = lexyy
+Y_TAB  = y_tab
+
+JUNK = \
+       $(LEX_YY).c \
+       $(Y_TAB).c
+
+OBJECTS = \
+       $(THIS).obj, \
+       lintlibs.obj, \
+       semantic.obj, \
+       strkey.obj, \
+       strstr.obj, \
+       symbol.obj, \
+       $(Y_TAB).obj, \
+       getopt.obj
+
+SOURCES = $(DOC_FILES) $(H_FILES) $(C_FILES) $(AUX_FILES)
+
+all : $(THIS).exe
+       @ write sys$output "** produced $?"
+
+$(THIS).exe : $(OBJECTS)
+       $(LINK)/exec=$(THIS) $(OBJECTS),sys$library:vaxcrtl/lib,tools$$library:alloca.obj
+
+$(Y_TAB).c : grammar.y
+       $(YACC) grammar.y/fixed_outfiles
+
+$(LEX_YY).c : lex.l
+       $(LEX) lex.l
+
+clean :
+       - if f$search("*.obj").nes."" then dele/nolog *.obj;*
+       - if f$search("*.lis").nes."" then dele/nolog *.lis;*
+       - if f$search("*.log").nes."" then dele/nolog *.log;*
+       - if f$search("*.map").nes."" then dele/nolog *.map;*
+       - if f$search("$(Y_TAB).c").nes."" then dele/nolog $(Y_TAB).c;*
+       - if f$search("$(LEX_YY).c").nes."" then dele/nolog $(LEX_YY).c;*
+
+clobber : clean
+       - if f$search("$(THIS).exe").nes."" then dele/nolog $(THIS).exe;*
+
+cproto.obj   : cproto.h system.h patchlev.h
+lintlibs.obj : cproto.h system.h semantic.h symbol.h
+semantic.obj : cproto.h system.h semantic.h
+strkey.obj   : cproto.h system.h
+symbol.obj   : cproto.h system.h symbol.h
+$(Y_TAB).obj : cproto.h system.h symbol.h semantic.h $(LEX_YY).c yyerror.c $(Y_TAB).c
+       $(CC) $(CFLAGS) $(Y_TAB).c
diff --git a/cproto-4.6/win32/README b/cproto-4.6/win32/README
new file mode 100644 (file)
index 0000000..f1a651b
--- /dev/null
@@ -0,0 +1,3 @@
+The files in this directory are used to build on Windows 95 and Windows NT.
+
+watcom.mak     makefile for Watcom C/C++
diff --git a/cproto-4.6/win32/watcom.mak b/cproto-4.6/win32/watcom.mak
new file mode 100644 (file)
index 0000000..920a6d5
--- /dev/null
@@ -0,0 +1,50 @@
+# $Id: watcom.mak,v 4.3 1998/01/22 19:49:44 cthuang Exp $
+#
+# Watcom makefile for C prototype generator
+# To use this file, do
+#
+#      wmake /u /f watcom.mak
+
+PROGRAM = cproto
+DEFINES =
+INCLUDES = -I.. -I..\porting
+
+LEX = lex
+YACC = yacc
+CC = wcl386
+CFLAGS = $(DEFINES) $(INCLUDES)
+LIBS =
+
+.c: ..
+
+.c.obj: .AUTODEPEND
+       $(CC) $(CFLAGS) /c $<
+
+O = .obj
+OBJECTS = \
+       cproto$(O) \
+       getopt$(O) \
+       lintlibs$(O) \
+       semantic$(O) \
+       strkey$(O) \
+       symbol$(O) \
+       y_tab$(O)
+
+all: $(PROGRAM).exe
+
+$(PROGRAM).exe: $(OBJECTS)
+       $(CC) $(CFLAGS) /fe=$@ $(OBJECTS) $(LIBS)
+
+getopt$(O): ..\porting\getopt.c
+       $(CC) $(CFLAGS) /c ..\porting\getopt.c
+
+cproto.man: cproto.1
+       cawf -man $*.1 | bsfilt - >$*.man
+
+clean:
+       -del $(PROGRAM).exe
+       -del *$(O)
+       -del *.err
+       -del *.log
+       -del *.out
+       -del case*.c
diff --git a/cproto-4.6/y_tab.c b/cproto-4.6/y_tab.c
new file mode 100644 (file)
index 0000000..ae10403
--- /dev/null
@@ -0,0 +1,1552 @@
+#ifndef lint
+static char yysccsid[] = "@(#)yaccpar  1.9 (Berkeley) 02/21/93 (BSDI)";
+#endif
+#include <stdlib.h>
+#define YYBYACC 1
+#define YYMAJOR 1
+#define YYMINOR 9
+#define YYEMPTY (-1)
+#define YYLEX yylex()
+#define yyclearin (yychar=YYEMPTY)
+#define yyerrok (yyerrflag=0)
+#define YYRECOVERING (yyerrflag!=0)
+#define YYPREFIX "yy"
+#line 65 "grammar.y"
+#include <stdio.h>
+#include <ctype.h>
+#include "cproto.h"
+#include "symbol.h"
+#include "semantic.h"
+
+#define YYMAXDEPTH 150
+
+extern int     yylex ARGS((void));
+
+/* declaration specifier attributes for the typedef statement currently being
+ * scanned
+ */
+static int cur_decl_spec_flags;
+
+/* pointer to parameter list for the current function definition */
+static ParameterList *func_params;
+
+/* A parser semantic action sets this pointer to the current declarator in
+ * a function parameter declaration in order to catch any comments following
+ * the parameter declaration on the same line.  If the lexer scans a comment
+ * and <cur_declarator> is not NULL, then the comment is attached to the
+ * declarator.  To ignore subsequent comments, the lexer sets this to NULL
+ * after scanning a comment or end of line.
+ */
+static Declarator *cur_declarator;
+
+/* temporary string buffer */
+static char buf[MAX_TEXT_SIZE];
+
+/* table of typedef names */
+static SymbolTable *typedef_names;
+
+/* table of define names */
+static SymbolTable *define_names;
+
+/* table of type qualifiers */
+static SymbolTable *type_qualifiers;
+
+/* information about the current input file */
+typedef struct {
+    char *base_name;           /* base input file name */
+    char *file_name;           /* current file name */
+    FILE *file;                /* input file */
+    unsigned line_num;         /* current line number in input file */
+    FILE *tmp_file;            /* temporary file */
+    long begin_comment;        /* tmp file offset after last written ) or ; */
+    long end_comment;          /* tmp file offset after last comment */
+    boolean convert;           /* if TRUE, convert function definitions */
+    boolean changed;           /* TRUE if conversion done in this file */
+} IncludeStack;
+
+static IncludeStack *cur_file; /* current input file */
+
+#include "yyerror.c"
+
+static int haveAnsiParam ARGS((void));
+
+
+/* Flags to enable us to find if a procedure returns a value.
+ */
+static int return_val, /* nonzero on BRACES iff return-expression found */
+          returned_at; /* marker for token-number to set 'return_val' */
+
+#if OPT_LINTLIBRARY
+static char *dft_decl_spec ARGS((void));
+
+static char *
+dft_decl_spec ()
+{
+    return (lintLibrary() && !return_val) ? "void" : "int";
+}
+
+#else
+#define dft_decl_spec() "int"
+#endif
+
+static int
+haveAnsiParam ()
+{
+    Parameter *p;
+    if (func_params != 0) {
+       for (p = func_params->first; p != 0; p = p->next) {
+           if (p->declarator->func_def == FUNC_ANSI) {
+               return TRUE;
+           }
+       }
+    }
+    return FALSE;
+}
+#line 106 "y.tab.c"
+#define T_IDENTIFIER 257
+#define T_TYPEDEF_NAME 258
+#define T_DEFINE_NAME 259
+#define T_AUTO 260
+#define T_EXTERN 261
+#define T_REGISTER 262
+#define T_STATIC 263
+#define T_TYPEDEF 264
+#define T_INLINE 265
+#define T_CHAR 266
+#define T_DOUBLE 267
+#define T_FLOAT 268
+#define T_INT 269
+#define T_VOID 270
+#define T_LONG 271
+#define T_SHORT 272
+#define T_SIGNED 273
+#define T_UNSIGNED 274
+#define T_ENUM 275
+#define T_STRUCT 276
+#define T_UNION 277
+#define T_TYPE_QUALIFIER 278
+#define T_BRACKETS 279
+#define T_LBRACE 280
+#define T_MATCHRBRACE 281
+#define T_ELLIPSIS 282
+#define T_INITIALIZER 283
+#define T_STRING_LITERAL 284
+#define T_ASM 285
+#define T_ASMARG 286
+#define T_VA_DCL 287
+#define YYERRCODE 256
+short yylhs[] = {                                        -1,
+    0,    0,   26,   26,   27,   27,   27,   27,   27,   27,
+   27,   31,   30,   30,   28,   28,   34,   28,   32,   33,
+   33,   35,   35,   37,   38,   29,   39,   29,   36,   36,
+   36,   40,   40,    1,    1,    2,    2,    2,    3,    3,
+    3,    3,    3,    4,    4,    4,    4,    4,    4,    4,
+    4,    4,    4,    4,    4,    5,    5,    6,    6,    6,
+   19,   19,    8,    8,    9,   41,    9,    7,    7,    7,
+   25,   23,   23,   10,   10,   11,   11,   11,   11,   11,
+   20,   20,   21,   21,   22,   22,   14,   14,   15,   15,
+   16,   16,   16,   17,   17,   18,   18,   24,   24,   12,
+   12,   12,   13,   13,   13,   13,   13,   13,   13,
+};
+short yylen[] = {                                         2,
+    0,    1,    1,    2,    1,    1,    1,    1,    3,    2,
+    2,    2,    3,    3,    2,    3,    0,    5,    1,    0,
+    1,    1,    3,    0,    0,    7,    0,    5,    0,    1,
+    1,    1,    2,    1,    2,    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+    1,    1,    1,    1,    1,    1,    1,    3,    2,    2,
+    1,    1,    1,    3,    1,    0,    4,    3,    2,    2,
+    1,    1,    1,    2,    1,    1,    3,    2,    4,    4,
+    2,    3,    0,    1,    1,    2,    1,    3,    1,    3,
+    2,    2,    1,    0,    1,    1,    3,    1,    2,    1,
+    2,    1,    3,    2,    1,    4,    3,    3,    2,
+};
+short yydefred[] = {                                      0,
+    0,    0,    0,    0,   98,   53,   57,   39,    0,   41,
+   42,   19,   43,   44,   45,   46,   47,   52,   48,   49,
+   50,   51,   71,   61,   62,   56,    0,    7,    0,    0,
+   34,   36,   37,   38,   54,   55,   27,    0,    0,    0,
+   76,    0,    0,    3,    5,    6,    8,    0,   10,   11,
+    0,   85,    0,    0,   99,    0,    0,   40,   15,   35,
+    0,   63,    0,    0,    0,   78,   72,   73,    0,    0,
+   59,    0,    0,   69,    4,    0,   77,   82,   86,    0,
+   14,   13,    9,   16,    0,   66,    0,   30,   32,    0,
+    0,   96,    0,    0,    0,   89,    0,    0,   12,   58,
+   68,    0,    0,   64,    0,    0,    0,   33,    0,  105,
+   91,   92,    0,    0,   79,    0,   80,    0,   22,    0,
+    0,   67,   25,   28,  109,    0,    0,    0,  104,    0,
+   88,   90,   97,   18,    0,    0,  103,  108,  107,    0,
+   23,   26,  106,
+};
+short yydgoto[] = {                                      29,
+   80,   31,   32,   33,   34,   35,   36,   61,   62,   37,
+   38,  112,  113,   94,   95,   96,   97,   98,   39,   40,
+   53,   54,   70,   41,   42,   43,   44,   45,   46,   47,
+   71,   48,  120,  102,  121,   90,   87,  136,   64,   91,
+  105,
+};
+short yysindex[] = {                                    -38,
+  -36,   17, -248, -241,    0,    0,    0,    0, -264,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0, -261,    0,    0,  395,
+    0,    0,    0,    0,    0,    0,    0,  -37, -245,  -11,
+    0, -245,  -38,    0,    0,    0,    0,  438,    0,    0,
+  -15,    0,   -5, -248,    0,  327,  -27,    0,    0,    0,
+  -16,    0,  -22,  279,  351,    0,    0,    0, -239, -234,
+    0,  -37, -234,    0,    0,  438,    0,    0,    0,  395,
+    0,    0,    0,    0,   17,    0,  279,    0,    0, -232,
+  372,    0,  150,   24,   27,    0,   33,   32,    0,    0,
+    0,   17,  -22,    0, -206, -202, -199,    0,  127,    0,
+    0,    0,  -35,  203,    0,  302,    0, -174,    0,   28,
+   44,    0,    0,    0,    0,   48,   49,  258,    0,  -35,
+    0,    0,    0,    0,   17, -189,    0,    0,    0,   52,
+    0,    0,    0,
+};
+short yyrindex[] = {                                     95,
+    0,    0,  157,    0,    0,    0,    0,    0,  417,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,  -10,    0,    0,
+    0,    0,   96,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,  231,  173,    0,    0,    0,    0,    0,    0,
+    0,    0,   50, -183,   57,    0,    0,    0,    0,   81,
+    0,   20,  104,    0,    0,   16,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0, -183,    0,    0,    0,
+ -180,    0,  -26,    0,   60,    0,    0,   61,    0,    0,
+    0,   45,    1,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    9,   25,    0,    0,    0,    0,    0,    0,
+   46,    0,    0,    0,    0,    0,    0,    0,    0,   29,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,
+};
+short yygindex[] = {                                      0,
+   19,   -8,    0,    0,   -2,    0,    0,    0,   18,    6,
+  -34,   -3,   -7,  -95,    0,   -6,    0,    0,    0,  -46,
+    0,    0,   69,    0,    0,    0,   70,  -47,    0,    0,
+  -32,    0,    0,    0,    0,   30,    0,    0,    0,    0,
+    0,
+};
+#define YYTABLESIZE 716
+short yytable[] = {                                       4,
+   52,    2,   65,    3,  128,   72,   78,   51,   81,   74,
+    7,   67,   68,  127,   93,   55,   89,   93,   30,   56,
+   28,   60,   50,   82,   57,   77,    4,   85,    2,   26,
+   75,   83,  140,   75,   69,   63,    3,  100,   86,   89,
+  101,   99,   84,  108,   65,   69,  114,  107,   75,  102,
+   75,   79,  102,   17,    4,   17,    2,   17,    3,   65,
+   74,   30,  114,   74,  115,  100,   76,   60,  100,  101,
+  116,   60,  101,  117,   17,  118,  122,  123,   74,   72,
+   74,  124,  133,   93,   60,  103,  134,  135,  137,  138,
+  103,  142,  143,   65,    1,    2,   29,   94,  111,   31,
+   87,   95,  104,   20,   21,  126,  130,  119,   65,  132,
+   73,    0,   75,    0,   51,    0,  106,    0,   60,    0,
+   60,   60,   60,    0,   60,    0,    0,   93,    0,    0,
+    0,    0,    0,    0,   93,    0,    0,    0,    0,   60,
+  141,   70,    0,   70,   70,   70,   93,   70,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,   70,    0,    4,    0,  109,  125,    3,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    4,    0,  109,
+    0,    3,    0,    0,   83,    0,   83,   83,   83,    0,
+   83,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+   84,    0,   84,   84,   84,    0,   84,    1,    5,    6,
+    7,    8,    9,   10,   11,   12,   13,   14,   15,   16,
+   17,   18,   19,   20,   21,   22,   23,   24,   25,   26,
+    4,   66,  109,  129,   49,    5,   27,   75,   75,   75,
+   75,   75,   75,   75,   75,   75,   75,   75,   75,   75,
+   75,   75,   75,   75,   75,   75,   75,   75,   81,   75,
+   81,   81,   17,    5,   81,    0,   75,   74,   74,   74,
+   74,   74,   74,   74,   74,   74,   74,   74,   74,   74,
+   74,   74,   74,   74,   74,   74,   74,   74,  139,   74,
+    0,    0,    0,    0,    0,    0,   74,   24,   24,   24,
+   24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
+   24,   24,   24,   24,   24,   24,   24,   24,    0,   24,
+    0,    0,    0,    0,    0,    0,   24,   60,   60,   60,
+   60,   60,   60,   60,    0,   60,   60,   60,   60,   60,
+   60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
+   70,   70,   70,   70,   70,   70,   70,    0,   70,   70,
+   70,   70,   70,   70,   70,   70,   70,   70,   70,   70,
+   70,   70,   70,    5,    6,    7,    8,   58,   10,   11,
+    0,   13,   14,   15,   16,   17,   18,   19,   20,   21,
+   22,   23,   24,   25,   26,  110,    5,    6,    7,    8,
+   58,   10,   11,   83,   13,   14,   15,   16,   17,   18,
+   19,   20,   21,   22,   23,   24,   25,   26,  110,   84,
+    0,    0,    4,    0,    2,   83,    3,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,   84,    0,   59,   40,    0,   40,    0,   40,    5,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,   40,    0,    0,    0,    0,
+    0,  110,    0,    0,    0,    0,    0,   81,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+    0,    0,    0,    0,    0,    0,    0,    0,    0,   81,
+    0,    0,    0,    0,    0,    6,    7,    8,   58,   10,
+   11,    0,   13,   14,   15,   16,   17,   18,   19,   20,
+   21,   22,   23,   24,   25,   26,    6,    7,    8,   58,
+   10,   11,   12,   13,   14,   15,   16,   17,   18,   19,
+   20,   21,   22,   23,   24,   25,   26,    0,    0,    6,
+    7,    8,   58,   10,   11,   88,   13,   14,   15,   16,
+   17,   18,   19,   20,   21,   22,   23,   24,   25,   26,
+    0,    0,    0,  131,    6,    7,    8,   58,   10,   11,
+   12,   13,   14,   15,   16,   17,   18,   19,   20,   21,
+   22,   23,   24,   25,   26,    0,   69,   92,    6,    7,
+    8,   58,   10,   11,    0,   13,   14,   15,   16,   17,
+   18,   19,   20,   21,   22,   23,   24,   25,   26,    6,
+    7,    8,   58,   10,   11,   12,   13,   14,   15,   16,
+   17,   18,   19,   20,   21,   22,   23,   24,   25,   26,
+    0,    5,    6,    7,    8,   58,   10,   11,    0,   13,
+   14,   15,   16,   17,   18,   19,   20,   21,   22,   23,
+   24,   25,   26,   40,   40,   40,   40,   40,   40,   40,
+    0,   40,   40,   40,   40,   40,   40,   40,   40,   40,
+   40,   40,   40,   40,   40,    6,    7,    8,   58,   10,
+   11,    0,   13,   14,   15,   16,   17,   18,   19,   20,
+   21,   22,   23,   24,   25,   26,
+};
+short yycheck[] = {                                      38,
+    3,   40,   40,   42,   40,   40,   53,    2,   56,   42,
+  259,  257,  258,  109,   41,  257,   64,   44,    0,  284,
+   59,   30,   59,   56,  286,   41,   38,   44,   40,  278,
+   41,   59,  128,   44,  280,   30,   42,   70,   61,   87,
+   73,  281,   59,   91,   44,  280,   93,  280,   59,   41,
+   61,   54,   44,   38,   38,   40,   40,   42,   42,   59,
+   41,   43,  109,   44,   41,   41,   48,   76,   44,   41,
+   44,   80,   44,   41,   59,   44,  283,  280,   59,  114,
+   61,  281,  257,   65,   93,   80,   59,   44,   41,   41,
+   85,  281,   41,   44,    0,    0,  280,   41,   93,  280,
+   41,   41,   85,   59,   59,  109,  114,  102,   59,  116,
+   42,   -1,   43,   -1,  109,   -1,   87,   -1,   38,   -1,
+   40,   41,   42,   -1,   44,   -1,   -1,  109,   -1,   -1,
+   -1,   -1,   -1,   -1,  116,   -1,   -1,   -1,   -1,   59,
+  135,   38,   -1,   40,   41,   42,  128,   44,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   59,   -1,   38,   -1,   40,   41,   42,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   38,   -1,   40,
+   -1,   42,   -1,   -1,   38,   -1,   40,   41,   42,   -1,
+   44,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   38,   -1,   40,   41,   42,   -1,   44,  256,  257,  258,
+  259,  260,  261,  262,  263,  264,  265,  266,  267,  268,
+  269,  270,  271,  272,  273,  274,  275,  276,  277,  278,
+   38,  279,   40,  279,  281,  257,  285,  258,  259,  260,
+  261,  262,  263,  264,  265,  266,  267,  268,  269,  270,
+  271,  272,  273,  274,  275,  276,  277,  278,   38,  280,
+   40,   41,  257,  257,   44,   -1,  287,  258,  259,  260,
+  261,  262,  263,  264,  265,  266,  267,  268,  269,  270,
+  271,  272,  273,  274,  275,  276,  277,  278,   41,  280,
+   -1,   -1,   -1,   -1,   -1,   -1,  287,  258,  259,  260,
+  261,  262,  263,  264,  265,  266,  267,  268,  269,  270,
+  271,  272,  273,  274,  275,  276,  277,  278,   -1,  280,
+   -1,   -1,   -1,   -1,   -1,   -1,  287,  257,  258,  259,
+  260,  261,  262,  263,   -1,  265,  266,  267,  268,  269,
+  270,  271,  272,  273,  274,  275,  276,  277,  278,  279,
+  257,  258,  259,  260,  261,  262,  263,   -1,  265,  266,
+  267,  268,  269,  270,  271,  272,  273,  274,  275,  276,
+  277,  278,  279,  257,  258,  259,  260,  261,  262,  263,
+   -1,  265,  266,  267,  268,  269,  270,  271,  272,  273,
+  274,  275,  276,  277,  278,  279,  257,  258,  259,  260,
+  261,  262,  263,  257,  265,  266,  267,  268,  269,  270,
+  271,  272,  273,  274,  275,  276,  277,  278,  279,  257,
+   -1,   -1,   38,   -1,   40,  279,   42,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,  279,   -1,   59,   38,   -1,   40,   -1,   42,  257,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   59,   -1,   -1,   -1,   -1,
+   -1,  279,   -1,   -1,   -1,   -1,   -1,  257,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  279,
+   -1,   -1,   -1,   -1,   -1,  258,  259,  260,  261,  262,
+  263,   -1,  265,  266,  267,  268,  269,  270,  271,  272,
+  273,  274,  275,  276,  277,  278,  258,  259,  260,  261,
+  262,  263,  264,  265,  266,  267,  268,  269,  270,  271,
+  272,  273,  274,  275,  276,  277,  278,   -1,   -1,  258,
+  259,  260,  261,  262,  263,  287,  265,  266,  267,  268,
+  269,  270,  271,  272,  273,  274,  275,  276,  277,  278,
+   -1,   -1,   -1,  282,  258,  259,  260,  261,  262,  263,
+  264,  265,  266,  267,  268,  269,  270,  271,  272,  273,
+  274,  275,  276,  277,  278,   -1,  280,  257,  258,  259,
+  260,  261,  262,  263,   -1,  265,  266,  267,  268,  269,
+  270,  271,  272,  273,  274,  275,  276,  277,  278,  258,
+  259,  260,  261,  262,  263,  264,  265,  266,  267,  268,
+  269,  270,  271,  272,  273,  274,  275,  276,  277,  278,
+   -1,  257,  258,  259,  260,  261,  262,  263,   -1,  265,
+  266,  267,  268,  269,  270,  271,  272,  273,  274,  275,
+  276,  277,  278,  257,  258,  259,  260,  261,  262,  263,
+   -1,  265,  266,  267,  268,  269,  270,  271,  272,  273,
+  274,  275,  276,  277,  278,  258,  259,  260,  261,  262,
+  263,   -1,  265,  266,  267,  268,  269,  270,  271,  272,
+  273,  274,  275,  276,  277,  278,
+};
+#define YYFINAL 29
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#define YYMAXTOKEN 287
+#if YYDEBUG
+char *yyname[] = {
+"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,"'&'",0,"'('","')'","'*'",0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,
+"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+"T_IDENTIFIER","T_TYPEDEF_NAME","T_DEFINE_NAME","T_AUTO","T_EXTERN",
+"T_REGISTER","T_STATIC","T_TYPEDEF","T_INLINE","T_CHAR","T_DOUBLE","T_FLOAT",
+"T_INT","T_VOID","T_LONG","T_SHORT","T_SIGNED","T_UNSIGNED","T_ENUM","T_STRUCT",
+"T_UNION","T_TYPE_QUALIFIER","T_BRACKETS","T_LBRACE","T_MATCHRBRACE",
+"T_ELLIPSIS","T_INITIALIZER","T_STRING_LITERAL","T_ASM","T_ASMARG","T_VA_DCL",
+};
+char *yyrule[] = {
+"$accept : program",
+"program :",
+"program : translation_unit",
+"translation_unit : external_declaration",
+"translation_unit : translation_unit external_declaration",
+"external_declaration : declaration",
+"external_declaration : function_definition",
+"external_declaration : ';'",
+"external_declaration : linkage_specification",
+"external_declaration : T_ASM T_ASMARG ';'",
+"external_declaration : error T_MATCHRBRACE",
+"external_declaration : error ';'",
+"braces : T_LBRACE T_MATCHRBRACE",
+"linkage_specification : T_EXTERN T_STRING_LITERAL braces",
+"linkage_specification : T_EXTERN T_STRING_LITERAL declaration",
+"declaration : decl_specifiers ';'",
+"declaration : decl_specifiers init_declarator_list ';'",
+"$$1 :",
+"declaration : any_typedef decl_specifiers $$1 opt_declarator_list ';'",
+"any_typedef : T_TYPEDEF",
+"opt_declarator_list :",
+"opt_declarator_list : declarator_list",
+"declarator_list : declarator",
+"declarator_list : declarator_list ',' declarator",
+"$$2 :",
+"$$3 :",
+"function_definition : decl_specifiers declarator $$2 opt_declaration_list T_LBRACE $$3 T_MATCHRBRACE",
+"$$4 :",
+"function_definition : declarator $$4 opt_declaration_list T_LBRACE T_MATCHRBRACE",
+"opt_declaration_list :",
+"opt_declaration_list : T_VA_DCL",
+"opt_declaration_list : declaration_list",
+"declaration_list : declaration",
+"declaration_list : declaration_list declaration",
+"decl_specifiers : decl_specifier",
+"decl_specifiers : decl_specifiers decl_specifier",
+"decl_specifier : storage_class",
+"decl_specifier : type_specifier",
+"decl_specifier : type_qualifier",
+"storage_class : T_AUTO",
+"storage_class : T_EXTERN",
+"storage_class : T_REGISTER",
+"storage_class : T_STATIC",
+"storage_class : T_INLINE",
+"type_specifier : T_CHAR",
+"type_specifier : T_DOUBLE",
+"type_specifier : T_FLOAT",
+"type_specifier : T_INT",
+"type_specifier : T_LONG",
+"type_specifier : T_SHORT",
+"type_specifier : T_SIGNED",
+"type_specifier : T_UNSIGNED",
+"type_specifier : T_VOID",
+"type_specifier : T_TYPEDEF_NAME",
+"type_specifier : struct_or_union_specifier",
+"type_specifier : enum_specifier",
+"type_qualifier : T_TYPE_QUALIFIER",
+"type_qualifier : T_DEFINE_NAME",
+"struct_or_union_specifier : struct_or_union any_id braces",
+"struct_or_union_specifier : struct_or_union braces",
+"struct_or_union_specifier : struct_or_union any_id",
+"struct_or_union : T_STRUCT",
+"struct_or_union : T_UNION",
+"init_declarator_list : init_declarator",
+"init_declarator_list : init_declarator_list ',' init_declarator",
+"init_declarator : declarator",
+"$$5 :",
+"init_declarator : declarator '=' $$5 T_INITIALIZER",
+"enum_specifier : enumeration any_id braces",
+"enum_specifier : enumeration braces",
+"enum_specifier : enumeration any_id",
+"enumeration : T_ENUM",
+"any_id : T_IDENTIFIER",
+"any_id : T_TYPEDEF_NAME",
+"declarator : pointer direct_declarator",
+"declarator : direct_declarator",
+"direct_declarator : identifier_or_ref",
+"direct_declarator : '(' declarator ')'",
+"direct_declarator : direct_declarator T_BRACKETS",
+"direct_declarator : direct_declarator '(' parameter_type_list ')'",
+"direct_declarator : direct_declarator '(' opt_identifier_list ')'",
+"pointer : '*' opt_type_qualifiers",
+"pointer : '*' opt_type_qualifiers pointer",
+"opt_type_qualifiers :",
+"opt_type_qualifiers : type_qualifier_list",
+"type_qualifier_list : type_qualifier",
+"type_qualifier_list : type_qualifier_list type_qualifier",
+"parameter_type_list : parameter_list",
+"parameter_type_list : parameter_list ',' T_ELLIPSIS",
+"parameter_list : parameter_declaration",
+"parameter_list : parameter_list ',' parameter_declaration",
+"parameter_declaration : decl_specifiers declarator",
+"parameter_declaration : decl_specifiers abs_declarator",
+"parameter_declaration : decl_specifiers",
+"opt_identifier_list :",
+"opt_identifier_list : identifier_list",
+"identifier_list : T_IDENTIFIER",
+"identifier_list : identifier_list ',' T_IDENTIFIER",
+"identifier_or_ref : T_IDENTIFIER",
+"identifier_or_ref : '&' T_IDENTIFIER",
+"abs_declarator : pointer",
+"abs_declarator : pointer direct_abs_declarator",
+"abs_declarator : direct_abs_declarator",
+"direct_abs_declarator : '(' abs_declarator ')'",
+"direct_abs_declarator : direct_abs_declarator T_BRACKETS",
+"direct_abs_declarator : T_BRACKETS",
+"direct_abs_declarator : direct_abs_declarator '(' parameter_type_list ')'",
+"direct_abs_declarator : direct_abs_declarator '(' ')'",
+"direct_abs_declarator : '(' parameter_type_list ')'",
+"direct_abs_declarator : '(' ')'",
+};
+#endif
+#ifdef YYSTACKSIZE
+#undef YYMAXDEPTH
+#define YYMAXDEPTH YYSTACKSIZE
+#else
+#ifdef YYMAXDEPTH
+#define YYSTACKSIZE YYMAXDEPTH
+#else
+#define YYSTACKSIZE 10000
+#define YYMAXDEPTH 10000
+#endif
+#endif
+#define YYINITSTACKSIZE 200
+int yydebug;
+int yynerrs;
+struct yystack {
+    short *ssp;
+    YYSTYPE *vsp;
+    short *ss;
+    YYSTYPE *vs;
+    int stacksize;
+    short *sslim;
+};
+int yychar; /* some people use this, so we copy it in & out */
+int yyerrflag; /* must be global for yyerrok & YYRECOVERING */
+YYSTYPE yylval;
+#line 792 "grammar.y"
+
+#if defined(__EMX__) || defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(vms)
+# ifdef USE_flex
+#  include "lexyy.c"
+# else
+#  include "lex_yy.c"
+# endif
+#else
+# include "lex.yy.c"
+#endif
+
+static void
+yaccError (msg)
+char *msg;
+{
+    func_params = NULL;
+    put_error();               /* tell what line we're on, and what file */
+    fprintf(stderr, "%s at token '%s'\n", msg, yytext);
+}
+
+/* Initialize the table of type qualifier keywords recognized by the lexical
+ * analyzer.
+ */
+void
+init_parser ()
+{
+    static char *keywords[] = {
+       "const", "volatile", "interrupt",
+#ifdef vms
+       "noshare", "readonly",
+#endif
+#if defined(MSDOS) || defined(OS2)
+       "cdecl", "far", "huge", "near", "pascal",
+       "_cdecl", "_export", "_far", "_fastcall", "_fortran", "_huge",
+       "_interrupt", "_loadds", "_near", "_pascal", "_saveregs", "_segment",
+       "_cs", "_ds", "_es", "_ss", "_seg",
+       "__cdecl", "__export", "__far", "__fastcall", "__fortran", "__huge",
+       "__inline", "__interrupt", "__loadds", "__near", "__pascal",
+       "__saveregs", "__segment", "__stdcall", "__syscall",
+#ifdef OS2
+       "__far16",
+#endif
+#else
+       "__const__",    "__const",
+       "__volatile__", "__volatile",
+       "__inline__",   "__inline",
+#endif
+    };
+    int i;
+
+    /* Initialize type qualifier table. */
+    type_qualifiers = new_symbol_table();
+    for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
+       new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
+    }
+}
+
+/* Process the C source file.  Write function prototypes to the standard
+ * output.  Convert function definitions and write the converted source
+ * code to a temporary file.
+ */
+void
+process_file (infile, name)
+FILE *infile;
+char *name;
+{
+    char *s;
+
+    if (strlen(name) > 2) {
+       s = name + strlen(name) - 2;
+       if (*s == '.') {
+           ++s;
+           if (*s == 'l' || *s == 'y')
+               BEGIN LEXYACC;
+#if defined(MSDOS) || defined(OS2)
+           if (*s == 'L' || *s == 'Y')
+               BEGIN LEXYACC;
+#endif
+       }
+    }
+
+    included_files = new_symbol_table();
+    typedef_names = new_symbol_table();
+    define_names = new_symbol_table();
+    inc_depth = -1;
+    curly = 0;
+    ly_count = 0;
+    func_params = NULL;
+    yyin = infile;
+    include_file(strcpy(base_file, name), func_style != FUNC_NONE);
+    if (file_comments) {
+#if OPT_LINTLIBRARY
+       if (lintLibrary()) {
+           put_blankline(stdout);
+           begin_tracking();
+       }
+#endif
+       put_string(stdout, "/* ");
+       put_string(stdout, cur_file_name());
+       put_string(stdout, " */\n");
+    }
+    yyparse();
+    free_symbol_table(define_names);
+    free_symbol_table(typedef_names);
+    free_symbol_table(included_files);
+}
+
+#ifdef NO_LEAKS
+void
+free_parser()
+{
+    free_symbol_table (type_qualifiers);
+#ifdef FLEX_SCANNER
+    if (yy_current_buffer != 0)
+       yy_delete_buffer(yy_current_buffer);
+#endif
+}
+#endif
+#line 656 "y.tab.c"
+/* allocate initial stack */
+#if defined(__STDC__) || defined(__cplusplus)
+static int yyinitstack(struct yystack *sp)
+#else
+static int yyinitstack(sp)
+    struct yystack *sp;
+#endif
+{
+    int newsize;
+    short *newss;
+    YYSTYPE *newvs;
+
+    newsize = YYINITSTACKSIZE;
+    newss = (short *)malloc(newsize * sizeof *newss);
+    newvs = (YYSTYPE *)malloc(newsize * sizeof *newvs);
+    sp->ss = sp->ssp = newss;
+    sp->vs = sp->vsp = newvs;
+    if (newss == NULL || newvs == NULL) return -1;
+    sp->stacksize = newsize;
+    sp->sslim = newss + newsize - 1;
+    return 0;
+}
+
+/* double stack size, up to YYMAXDEPTH */
+#if defined(__STDC__) || defined(__cplusplus)
+static int yygrowstack(struct yystack *sp)
+#else
+static int yygrowstack(sp)
+    struct yystack *sp;
+#endif
+{
+    int newsize, i;
+    short *newss;
+    YYSTYPE *newvs;
+
+    if ((newsize = sp->stacksize) >= YYMAXDEPTH) return -1;
+    if ((newsize *= 2) > YYMAXDEPTH) newsize = YYMAXDEPTH;
+    i = sp->ssp - sp->ss;
+    if ((newss = (short *)realloc(sp->ss, newsize * sizeof *newss)) == NULL)
+        return -1;
+    sp->ss = newss;
+    sp->ssp = newss + i;
+    if ((newvs = (YYSTYPE *)realloc(sp->vs, newsize * sizeof *newvs)) == NULL)
+        return -1;
+    sp->vs = newvs;
+    sp->vsp = newvs + i;
+    sp->stacksize = newsize;
+    sp->sslim = newss + newsize - 1;
+    return 0;
+}
+
+#define YYFREESTACK(sp) { free((sp)->ss); free((sp)->vs); }
+
+#define YYABORT goto yyabort
+#define YYREJECT goto yyabort
+#define YYACCEPT goto yyaccept
+#define YYERROR goto yyerrlab
+int
+yyparse()
+{
+    register int yym, yyn, yystate, yych;
+    register YYSTYPE *yyvsp;
+    YYSTYPE yyval;
+    struct yystack yystk;
+#if YYDEBUG
+    register char *yys;
+    extern char *getenv();
+
+    if (yys = getenv("YYDEBUG"))
+    {
+        yyn = *yys;
+        if (yyn >= '0' && yyn <= '9')
+            yydebug = yyn - '0';
+    }
+#endif
+
+    yynerrs = 0;
+    yyerrflag = 0;
+    yychar = yych = YYEMPTY;
+
+    if (yyinitstack(&yystk)) goto yyoverflow;
+    *yystk.ssp = yystate = 0;
+
+yyloop:
+    if (yyn = yydefred[yystate]) goto yyreduce;
+    if (yych < 0)
+    {
+        if ((yych = YYLEX) < 0) yych = 0;
+        yychar = yych;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yych <= YYMAXTOKEN) yys = yyname[yych];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, reading %d (%s)\n",
+                    YYPREFIX, yystate, yych, yys);
+        }
+#endif
+    }
+    if ((yyn = yysindex[yystate]) && (yyn += yych) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yych)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: state %d, shifting to state %d\n",
+                    YYPREFIX, yystate, yytable[yyn]);
+#endif
+        if (yystk.ssp >= yystk.sslim && yygrowstack(&yystk))
+            goto yyoverflow;
+        *++yystk.ssp = yystate = yytable[yyn];
+        *++yystk.vsp = yylval;
+        yychar = yych = YYEMPTY;
+        if (yyerrflag > 0)  --yyerrflag;
+        goto yyloop;
+    }
+    if ((yyn = yyrindex[yystate]) && (yyn += yych) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yych)
+    {
+        yyn = yytable[yyn];
+        goto yyreduce;
+    }
+    if (yyerrflag) goto yyinrecovery;
+#ifdef lint
+    goto yynewerror;
+#endif
+yynewerror:
+    yyerror("syntax error");
+#ifdef lint
+    goto yyerrlab;
+#endif
+yyerrlab:
+    ++yynerrs;
+yyinrecovery:
+    if (yyerrflag < 3)
+    {
+        yyerrflag = 3;
+        for (;;)
+        {
+            if ((yyn = yysindex[*yystk.ssp]) &&
+                    (yyn += YYERRCODE) >= 0 &&
+                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: state %d, error recovery shifting\
+ to state %d\n", YYPREFIX, *yystk.ssp, yytable[yyn]);
+#endif
+                if (yystk.ssp >= yystk.sslim && yygrowstack(&yystk))
+                    goto yyoverflow;
+                *++yystk.ssp = yystate = yytable[yyn];
+                *++yystk.vsp = yylval;
+                goto yyloop;
+            }
+            else
+            {
+#if YYDEBUG
+                if (yydebug)
+                    printf("%sdebug: error recovery discarding state %d\n",
+                            YYPREFIX, *yystk.ssp);
+#endif
+                if (yystk.ssp <= yystk.ss) goto yyabort;
+                --yystk.ssp;
+                --yystk.vsp;
+            }
+        }
+    }
+    else
+    {
+        if (yych == 0) goto yyabort;
+#if YYDEBUG
+        if (yydebug)
+        {
+            yys = 0;
+            if (yych <= YYMAXTOKEN) yys = yyname[yych];
+            if (!yys) yys = "illegal-symbol";
+            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
+                    YYPREFIX, yystate, yych, yys);
+        }
+#endif
+        yychar = yych = YYEMPTY;
+        goto yyloop;
+    }
+yyreduce:
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
+                YYPREFIX, yystate, yyn, yyrule[yyn]);
+#endif
+    yym = yylen[yyn];
+    yyvsp = yystk.vsp; /* for speed in code under switch() */
+    yyval = yyvsp[1-yym];
+    switch (yyn)
+    {
+case 10:
+#line 175 "grammar.y"
+{
+           yyerrok;
+       }
+break;
+case 11:
+#line 179 "grammar.y"
+{
+           yyerrok;
+       }
+break;
+case 13:
+#line 190 "grammar.y"
+{
+           /* Provide an empty action here so bison will not complain about
+            * incompatible types in the default action it normally would
+            * have generated.
+            */
+       }
+break;
+case 14:
+#line 197 "grammar.y"
+{
+           /* empty */
+       }
+break;
+case 15:
+#line 204 "grammar.y"
+{
+#if OPT_LINTLIBRARY
+           if (types_out && want_typedef()) {
+               gen_declarations(&yyvsp[-1].decl_spec, (DeclaratorList *)0);
+               flush_varargs();
+           }
+#endif
+           free_decl_spec(&yyvsp[-1].decl_spec);
+           end_typedef();
+       }
+break;
+case 16:
+#line 215 "grammar.y"
+{
+           if (func_params != NULL) {
+               set_param_types(func_params, &yyvsp[-2].decl_spec, &yyvsp[-1].decl_list);
+           } else {
+               gen_declarations(&yyvsp[-2].decl_spec, &yyvsp[-1].decl_list);
+#if OPT_LINTLIBRARY
+               flush_varargs();
+#endif
+               free_decl_list(&yyvsp[-1].decl_list);
+           }
+           free_decl_spec(&yyvsp[-2].decl_spec);
+           end_typedef();
+       }
+break;
+case 17:
+#line 229 "grammar.y"
+{
+           cur_decl_spec_flags = yyvsp[0].decl_spec.flags;
+           free_decl_spec(&yyvsp[0].decl_spec);
+       }
+break;
+case 18:
+#line 234 "grammar.y"
+{
+           end_typedef();
+       }
+break;
+case 19:
+#line 241 "grammar.y"
+{
+           begin_typedef();
+       }
+break;
+case 22:
+#line 253 "grammar.y"
+{
+           int flags = cur_decl_spec_flags;
+
+           /* If the typedef is a pointer type, then reset the short type
+            * flags so it does not get promoted.
+            */
+           if (strcmp(yyvsp[0].declarator->text, yyvsp[0].declarator->name) != 0)
+               flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
+           new_symbol(typedef_names, yyvsp[0].declarator->name, NULL, flags);
+           free_declarator(yyvsp[0].declarator);
+       }
+break;
+case 23:
+#line 265 "grammar.y"
+{
+           int flags = cur_decl_spec_flags;
+
+           if (strcmp(yyvsp[0].declarator->text, yyvsp[0].declarator->name) != 0)
+               flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
+           new_symbol(typedef_names, yyvsp[0].declarator->name, NULL, flags);
+           free_declarator(yyvsp[0].declarator);
+       }
+break;
+case 24:
+#line 277 "grammar.y"
+{
+           check_untagged(&yyvsp[-1].decl_spec);
+           if (yyvsp[0].declarator->func_def == FUNC_NONE) {
+               yyerror("syntax error");
+               YYERROR;
+           }
+           func_params = &(yyvsp[0].declarator->head->params);
+           func_params->begin_comment = cur_file->begin_comment;
+           func_params->end_comment = cur_file->end_comment;
+       }
+break;
+case 25:
+#line 288 "grammar.y"
+{
+           /* If we're converting to K&R and we've got a nominally K&R
+            * function which has a parameter which is ANSI (i.e., a prototyped
+            * function pointer), then we must override the deciphered value of
+            * 'func_def' so that the parameter will be converted.
+            */
+           if (func_style == FUNC_TRADITIONAL
+            && haveAnsiParam()
+            && yyvsp[-3].declarator->head->func_def == func_style) {
+               yyvsp[-3].declarator->head->func_def = FUNC_BOTH;
+           }
+
+           func_params = NULL;
+
+           if (cur_file->convert)
+               gen_func_definition(&yyvsp[-4].decl_spec, yyvsp[-3].declarator);
+           gen_prototype(&yyvsp[-4].decl_spec, yyvsp[-3].declarator);
+#if OPT_LINTLIBRARY
+           flush_varargs();
+#endif
+           free_decl_spec(&yyvsp[-4].decl_spec);
+           free_declarator(yyvsp[-3].declarator);
+       }
+break;
+case 27:
+#line 313 "grammar.y"
+{
+           if (yyvsp[0].declarator->func_def == FUNC_NONE) {
+               yyerror("syntax error");
+               YYERROR;
+           }
+           func_params = &(yyvsp[0].declarator->head->params);
+           func_params->begin_comment = cur_file->begin_comment;
+           func_params->end_comment = cur_file->end_comment;
+       }
+break;
+case 28:
+#line 323 "grammar.y"
+{
+           DeclSpec decl_spec;
+
+           func_params = NULL;
+
+           new_decl_spec(&decl_spec, dft_decl_spec(), yyvsp[-4].declarator->begin, DS_NONE);
+           if (cur_file->convert)
+               gen_func_definition(&decl_spec, yyvsp[-4].declarator);
+           gen_prototype(&decl_spec, yyvsp[-4].declarator);
+#if OPT_LINTLIBRARY
+           flush_varargs();
+#endif
+           free_decl_spec(&decl_spec);
+           free_declarator(yyvsp[-4].declarator);
+       }
+break;
+case 35:
+#line 354 "grammar.y"
+{
+           join_decl_specs(&yyval.decl_spec, &yyvsp[-1].decl_spec, &yyvsp[0].decl_spec);
+           free(yyvsp[-1].decl_spec.text);
+           free(yyvsp[0].decl_spec.text);
+       }
+break;
+case 39:
+#line 369 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
+       }
+break;
+case 40:
+#line 373 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_EXTERN);
+       }
+break;
+case 41:
+#line 377 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
+       }
+break;
+case 42:
+#line 381 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_STATIC);
+       }
+break;
+case 43:
+#line 385 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_JUNK);
+       }
+break;
+case 44:
+#line 392 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_CHAR);
+       }
+break;
+case 45:
+#line 396 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
+       }
+break;
+case 46:
+#line 400 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_FLOAT);
+       }
+break;
+case 47:
+#line 404 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
+       }
+break;
+case 48:
+#line 408 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
+       }
+break;
+case 49:
+#line 412 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_SHORT);
+       }
+break;
+case 50:
+#line 416 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
+       }
+break;
+case 51:
+#line 420 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
+       }
+break;
+case 52:
+#line 424 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
+       }
+break;
+case 53:
+#line 428 "grammar.y"
+{
+           Symbol *s;
+           s = find_symbol(typedef_names, yyvsp[0].text.text);
+           if (s != NULL)
+               new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, s->flags);
+       }
+break;
+case 56:
+#line 440 "grammar.y"
+{
+           new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, DS_NONE);
+       }
+break;
+case 57:
+#line 444 "grammar.y"
+{
+           /* This rule allows the <pointer> nonterminal to scan #define
+            * names as if they were type modifiers.
+            */
+           Symbol *s;
+           s = find_symbol(define_names, yyvsp[0].text.text);
+           if (s != NULL)
+               new_decl_spec(&yyval.decl_spec, yyvsp[0].text.text, yyvsp[0].text.begin, s->flags);
+       }
+break;
+case 58:
+#line 457 "grammar.y"
+{
+           char *s;
+           if ((s = implied_typedef()) == 0)
+               (void)sprintf(s = buf, "%s %s", yyvsp[-2].text.text, yyvsp[-1].text.text);
+           new_decl_spec(&yyval.decl_spec, s, yyvsp[-2].text.begin, DS_NONE);
+       }
+break;
+case 59:
+#line 464 "grammar.y"
+{
+           char *s;
+           if ((s = implied_typedef()) == 0)
+               (void)sprintf(s = buf, "%s {}", yyvsp[-1].text.text);
+           new_decl_spec(&yyval.decl_spec, s, yyvsp[-1].text.begin, DS_NONE);
+       }
+break;
+case 60:
+#line 471 "grammar.y"
+{
+           (void)sprintf(buf, "%s %s", yyvsp[-1].text.text, yyvsp[0].text.text);
+           new_decl_spec(&yyval.decl_spec, buf, yyvsp[-1].text.begin, DS_NONE);
+       }
+break;
+case 61:
+#line 479 "grammar.y"
+{
+           imply_typedef(yyval.text.text);
+       }
+break;
+case 62:
+#line 483 "grammar.y"
+{
+           imply_typedef(yyval.text.text);
+       }
+break;
+case 63:
+#line 490 "grammar.y"
+{
+           new_decl_list(&yyval.decl_list, yyvsp[0].declarator);
+       }
+break;
+case 64:
+#line 494 "grammar.y"
+{
+           add_decl_list(&yyval.decl_list, &yyvsp[-2].decl_list, yyvsp[0].declarator);
+       }
+break;
+case 65:
+#line 501 "grammar.y"
+{
+           if (yyvsp[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
+               func_style == FUNC_TRADITIONAL && cur_file->convert) {
+               gen_func_declarator(yyvsp[0].declarator);
+               fputs(cur_text(), cur_file->tmp_file);
+           }
+           cur_declarator = yyval.declarator;
+       }
+break;
+case 66:
+#line 510 "grammar.y"
+{
+           if (yyvsp[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
+               func_style == FUNC_TRADITIONAL && cur_file->convert) {
+               gen_func_declarator(yyvsp[-1].declarator);
+               fputs(" =", cur_file->tmp_file);
+           }
+       }
+break;
+case 68:
+#line 522 "grammar.y"
+{
+           char *s;
+           if ((s = implied_typedef()) == 0)
+               (void)sprintf(s = buf, "enum %s", yyvsp[-1].text.text);
+           new_decl_spec(&yyval.decl_spec, s, yyvsp[-2].text.begin, DS_NONE);
+       }
+break;
+case 69:
+#line 529 "grammar.y"
+{
+           char *s;
+           if ((s = implied_typedef()) == 0)
+               (void)sprintf(s = buf, "%s {}", yyvsp[-1].text.text);
+           new_decl_spec(&yyval.decl_spec, s, yyvsp[-1].text.begin, DS_NONE);
+       }
+break;
+case 70:
+#line 536 "grammar.y"
+{
+           (void)sprintf(buf, "enum %s", yyvsp[0].text.text);
+           new_decl_spec(&yyval.decl_spec, buf, yyvsp[-1].text.begin, DS_NONE);
+       }
+break;
+case 71:
+#line 544 "grammar.y"
+{
+           imply_typedef("enum");
+           yyval.text = yyvsp[0].text;
+       }
+break;
+case 74:
+#line 557 "grammar.y"
+{
+           yyval.declarator = yyvsp[0].declarator;
+           (void)sprintf(buf, "%s%s", yyvsp[-1].text.text, yyval.declarator->text);
+           free(yyval.declarator->text);
+           yyval.declarator->text = xstrdup(buf);
+           yyval.declarator->begin = yyvsp[-1].text.begin;
+           yyval.declarator->pointer = TRUE;
+       }
+break;
+case 76:
+#line 570 "grammar.y"
+{
+           yyval.declarator = new_declarator(yyvsp[0].text.text, yyvsp[0].text.text, yyvsp[0].text.begin);
+       }
+break;
+case 77:
+#line 574 "grammar.y"
+{
+           yyval.declarator = yyvsp[-1].declarator;
+           (void)sprintf(buf, "(%s)", yyval.declarator->text);
+           free(yyval.declarator->text);
+           yyval.declarator->text = xstrdup(buf);
+           yyval.declarator->begin = yyvsp[-2].text.begin;
+       }
+break;
+case 78:
+#line 582 "grammar.y"
+{
+           yyval.declarator = yyvsp[-1].declarator;
+           (void)sprintf(buf, "%s%s", yyval.declarator->text, yyvsp[0].text.text);
+           free(yyval.declarator->text);
+           yyval.declarator->text = xstrdup(buf);
+       }
+break;
+case 79:
+#line 589 "grammar.y"
+{
+           yyval.declarator = new_declarator("%s()", yyvsp[-3].declarator->name, yyvsp[-3].declarator->begin);
+           yyval.declarator->params = yyvsp[-1].param_list;
+           yyval.declarator->func_stack = yyvsp[-3].declarator;
+           yyval.declarator->head = (yyvsp[-3].declarator->func_stack == NULL) ? yyval.declarator : yyvsp[-3].declarator->head;
+           yyval.declarator->func_def = FUNC_ANSI;
+       }
+break;
+case 80:
+#line 597 "grammar.y"
+{
+           yyval.declarator = new_declarator("%s()", yyvsp[-3].declarator->name, yyvsp[-3].declarator->begin);
+           yyval.declarator->params = yyvsp[-1].param_list;
+           yyval.declarator->func_stack = yyvsp[-3].declarator;
+           yyval.declarator->head = (yyvsp[-3].declarator->func_stack == NULL) ? yyval.declarator : yyvsp[-3].declarator->head;
+           yyval.declarator->func_def = FUNC_TRADITIONAL;
+       }
+break;
+case 81:
+#line 608 "grammar.y"
+{
+           (void)sprintf(yyval.text.text, "*%s", yyvsp[0].text.text);
+           yyval.text.begin = yyvsp[-1].text.begin;
+       }
+break;
+case 82:
+#line 613 "grammar.y"
+{
+           (void)sprintf(yyval.text.text, "*%s%s", yyvsp[-1].text.text, yyvsp[0].text.text);
+           yyval.text.begin = yyvsp[-2].text.begin;
+       }
+break;
+case 83:
+#line 621 "grammar.y"
+{
+           strcpy(yyval.text.text, "");
+           yyval.text.begin = 0L;
+       }
+break;
+case 85:
+#line 630 "grammar.y"
+{
+           (void)sprintf(yyval.text.text, "%s ", yyvsp[0].decl_spec.text);
+           yyval.text.begin = yyvsp[0].decl_spec.begin;
+           free(yyvsp[0].decl_spec.text);
+       }
+break;
+case 86:
+#line 636 "grammar.y"
+{
+           (void)sprintf(yyval.text.text, "%s%s ", yyvsp[-1].text.text, yyvsp[0].decl_spec.text);
+           yyval.text.begin = yyvsp[-1].text.begin;
+           free(yyvsp[0].decl_spec.text);
+       }
+break;
+case 88:
+#line 646 "grammar.y"
+{
+           add_ident_list(&yyval.param_list, &yyvsp[-2].param_list, "...");
+       }
+break;
+case 89:
+#line 653 "grammar.y"
+{
+           new_param_list(&yyval.param_list, yyvsp[0].parameter);
+       }
+break;
+case 90:
+#line 657 "grammar.y"
+{
+           add_param_list(&yyval.param_list, &yyvsp[-2].param_list, yyvsp[0].parameter);
+       }
+break;
+case 91:
+#line 664 "grammar.y"
+{
+           check_untagged(&yyvsp[-1].decl_spec);
+           yyval.parameter = new_parameter(&yyvsp[-1].decl_spec, yyvsp[0].declarator);
+       }
+break;
+case 92:
+#line 669 "grammar.y"
+{
+           check_untagged(&yyvsp[-1].decl_spec);
+           yyval.parameter = new_parameter(&yyvsp[-1].decl_spec, yyvsp[0].declarator);
+       }
+break;
+case 93:
+#line 674 "grammar.y"
+{
+           check_untagged(&yyvsp[0].decl_spec);
+           yyval.parameter = new_parameter(&yyvsp[0].decl_spec, (Declarator *)0);
+       }
+break;
+case 94:
+#line 682 "grammar.y"
+{
+           new_ident_list(&yyval.param_list);
+       }
+break;
+case 96:
+#line 690 "grammar.y"
+{
+           new_ident_list(&yyval.param_list);
+           add_ident_list(&yyval.param_list, &yyval.param_list, yyvsp[0].text.text);
+       }
+break;
+case 97:
+#line 695 "grammar.y"
+{
+           add_ident_list(&yyval.param_list, &yyvsp[-2].param_list, yyvsp[0].text.text);
+       }
+break;
+case 98:
+#line 702 "grammar.y"
+{
+           yyval.text = yyvsp[0].text;
+       }
+break;
+case 99:
+#line 706 "grammar.y"
+{
+#if OPT_LINTLIBRARY
+           if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
+               yyval.text = yyvsp[0].text;
+           } else
+#endif
+               (void)sprintf(yyval.text.text, "&%s", yyvsp[0].text.text);
+           yyval.text.begin = yyvsp[-1].text.begin;
+       }
+break;
+case 100:
+#line 719 "grammar.y"
+{
+           yyval.declarator = new_declarator(yyvsp[0].text.text, "", yyvsp[0].text.begin);
+       }
+break;
+case 101:
+#line 723 "grammar.y"
+{
+           yyval.declarator = yyvsp[0].declarator;
+           (void)sprintf(buf, "%s%s", yyvsp[-1].text.text, yyval.declarator->text);
+           free(yyval.declarator->text);
+           yyval.declarator->text = xstrdup(buf);
+           yyval.declarator->begin = yyvsp[-1].text.begin;
+       }
+break;
+case 103:
+#line 735 "grammar.y"
+{
+           yyval.declarator = yyvsp[-1].declarator;
+           (void)sprintf(buf, "(%s)", yyval.declarator->text);
+           free(yyval.declarator->text);
+           yyval.declarator->text = xstrdup(buf);
+           yyval.declarator->begin = yyvsp[-2].text.begin;
+       }
+break;
+case 104:
+#line 743 "grammar.y"
+{
+           yyval.declarator = yyvsp[-1].declarator;
+           (void)sprintf(buf, "%s%s", yyval.declarator->text, yyvsp[0].text.text);
+           free(yyval.declarator->text);
+           yyval.declarator->text = xstrdup(buf);
+       }
+break;
+case 105:
+#line 750 "grammar.y"
+{
+           yyval.declarator = new_declarator(yyvsp[0].text.text, "", yyvsp[0].text.begin);
+       }
+break;
+case 106:
+#line 754 "grammar.y"
+{
+           yyval.declarator = new_declarator("%s()", "", yyvsp[-3].declarator->begin);
+           yyval.declarator->params = yyvsp[-1].param_list;
+           yyval.declarator->func_stack = yyvsp[-3].declarator;
+           yyval.declarator->head = (yyvsp[-3].declarator->func_stack == NULL) ? yyval.declarator : yyvsp[-3].declarator->head;
+           yyval.declarator->func_def = FUNC_ANSI;
+       }
+break;
+case 107:
+#line 762 "grammar.y"
+{
+           yyval.declarator = new_declarator("%s()", "", yyvsp[-2].declarator->begin);
+           yyval.declarator->func_stack = yyvsp[-2].declarator;
+           yyval.declarator->head = (yyvsp[-2].declarator->func_stack == NULL) ? yyval.declarator : yyvsp[-2].declarator->head;
+           yyval.declarator->func_def = FUNC_ANSI;
+       }
+break;
+case 108:
+#line 769 "grammar.y"
+{
+           Declarator *d;
+           
+           d = new_declarator("", "", yyvsp[-2].text.begin);
+           yyval.declarator = new_declarator("%s()", "", yyvsp[-2].text.begin);
+           yyval.declarator->params = yyvsp[-1].param_list;
+           yyval.declarator->func_stack = d;
+           yyval.declarator->head = yyval.declarator;
+           yyval.declarator->func_def = FUNC_ANSI;
+       }
+break;
+case 109:
+#line 780 "grammar.y"
+{
+           Declarator *d;
+           
+           d = new_declarator("", "", yyvsp[-1].text.begin);
+           yyval.declarator = new_declarator("%s()", "", yyvsp[-1].text.begin);
+           yyval.declarator->func_stack = d;
+           yyval.declarator->head = yyval.declarator;
+           yyval.declarator->func_def = FUNC_ANSI;
+       }
+break;
+#line 1495 "y.tab.c"
+    }
+    yystk.ssp -= yym;
+    yystate = *yystk.ssp;
+    yystk.vsp -= yym;
+    yym = yylhs[yyn];
+    yych = yychar;
+    if (yystate == 0 && yym == 0)
+    {
+#if YYDEBUG
+        if (yydebug)
+            printf("%sdebug: after reduction, shifting from state 0 to\
+ state %d\n", YYPREFIX, YYFINAL);
+#endif
+        yystate = YYFINAL;
+        *++yystk.ssp = YYFINAL;
+        *++yystk.vsp = yyval;
+        if (yych < 0)
+        {
+            if ((yych = YYLEX) < 0) yych = 0;
+            yychar = yych;
+#if YYDEBUG
+            if (yydebug)
+            {
+                yys = 0;
+                if (yych <= YYMAXTOKEN) yys = yyname[yych];
+                if (!yys) yys = "illegal-symbol";
+                printf("%sdebug: state %d, reading %d (%s)\n",
+                        YYPREFIX, YYFINAL, yych, yys);
+            }
+#endif
+        }
+        if (yych == 0) goto yyaccept;
+        goto yyloop;
+    }
+    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
+            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
+        yystate = yytable[yyn];
+    else
+        yystate = yydgoto[yym];
+#if YYDEBUG
+    if (yydebug)
+        printf("%sdebug: after reduction, shifting from state %d \
+to state %d\n", YYPREFIX, *yystk.ssp, yystate);
+#endif
+    if (yystk.ssp >= yystk.sslim && yygrowstack(&yystk))
+        goto yyoverflow;
+    *++yystk.ssp = yystate;
+    *++yystk.vsp = yyval;
+    goto yyloop;
+yyoverflow:
+    yyerror("yacc stack overflow");
+yyabort:
+    YYFREESTACK(&yystk);
+    return (1);
+yyaccept:
+    YYFREESTACK(&yystk);
+    return (0);
+}
diff --git a/cproto-4.6/yyerror.c b/cproto-4.6/yyerror.c
new file mode 100644 (file)
index 0000000..3c9c9bf
--- /dev/null
@@ -0,0 +1,178 @@
+/* $Id: yyerror.c,v 4.3 1996/04/13 04:29:18 cthuang Exp $
+ *
+ * This file is included into grammar.y to provide the 'yyerror()' function. 
+ * If the yacc/bison parser is one that we know how to backtrack, we'll augment
+ * the "syntax error" message with information that shows what type of token we
+ * expected.
+ */
+
+/* 'yyerror()' has to be a macro, since it must be expanded inline to subvert
+ * the internal state of 'yyparse()'.
+ */
+#if BISON_HAS_YYTNAME  /* bison 1.22 */
+#if YYDEBUG
+/* this is better than defining YYERROR_VERBOSE */
+#define        yyerror(text) {\
+    register int n, c1, count = 0;\
+    yaccError(text);\
+    if (yypact[yystate] != YYFLAG)\
+       for (c1 = 0; c1 < YYLAST; c1++) {\
+           n = yypact[yystate] + c1;\
+           if (n >= 0 && n < YYLAST\
+            && yycheck[n] == c1 && yytname[c1] != 0)\
+               yaccExpected(yytname[c1], count++);\
+       }\
+    yaccExpected("", -1);\
+}
+#endif
+#endif /* BISON_HAS_YYTNAME */
+
+#if YACC_HAS_YYTOKS_2
+#undef  YACC_HAS_YYTOKS
+#define YACC_HAS_YYTOKS 1
+#define YaccState yy_state
+#endif
+
+#if YACC_HAS_YYTOKS            /* Solaris, Gould */
+#if YYDEBUG
+#ifndef YaccState
+#define YaccState yystate      /* sometimes 'yy_state' */
+#endif
+#define        yyerror(text) {\
+    register int       n, x, c1, y, count = 0;\
+    yaccError(text);\
+    if (((n = yypact[YaccState]) > YYFLAG) && (n < YYLAST)) {\
+       for (x = ((n > 0) ? n : 0); x < YYLAST; ++x) {\
+           c1 = x - n;\
+           if ((yychk[yyact[x]] == c1) && (c1 != YYERRCODE)) {\
+               if (isascii(c1)) {\
+                   static char tmp[] = "'%'";\
+                   tmp[1] = c1;\
+                   yaccExpected(tmp, count++);\
+               } else {\
+                   for (y = 0; yytoks[y].t_val >= 0; y++) {\
+                       if (yytoks[y].t_val == c1) {\
+                           yaccExpected(yytoks[y].t_name, count++);\
+                           break;\
+                       }\
+                   }\
+               }\
+           }\
+       }\
+    }\
+    yaccExpected("", -1);\
+}
+#endif
+#endif /* YACC_HAS_YYTOKS */
+
+#if YACC_HAS_YYNAME    /* Linux's yacc */
+#if YYDEBUG
+#define        yyerror(text) {\
+    register int n, x, c1, count = 0;\
+    yaccError(text);\
+    if (((n = yysindex[yystate]) != 0) && (n < YYTABLESIZE)) {\
+       for (x = ((n > 0) ? n : 0); x < YYTABLESIZE; ++x) {\
+           c1 = x - n;\
+           if ((yycheck[x] == c1) && (c1 != YYERRCODE)) {\
+               yaccExpected(yyname[c1] ? yyname[c1] : "illegal symbol",\
+                   count++);\
+           }\
+       }\
+    }\
+    yaccExpected("", -1);\
+} 
+#endif
+#endif /* YACC_HAS_YYNAME */
+
+
+/*
+ * Any way we define it, 'yyerror()' is a real function (that we provide,
+ * rather than use the one from a library).
+ */
+static void yaccError    ARGS((char *));
+
+#ifdef yyerror
+static int  compar       ARGS((const void *a, const void *b));
+static void yaccExpected ARGS((const char *, int count));
+
+static
+int compar(p1, p2)
+const void *p1;
+const void *p2;
+{
+    return (strcmp(*(char **)p1, *(char **)p2));
+}
+
+static
+void yaccExpected (s, count)
+const char *s;
+int count;
+{
+    static struct {
+       char *actual, *name;
+    } tbl[] = {
+       {"...", "T_ELLIPSIS"},
+       {"[]",  "T_BRACKETS"},
+       {"{",   "T_LBRACE"},
+       {"}",   "T_MATCHRBRACE"},
+    };
+    register int j, k, x;
+    char *t = (char *)s;
+    char *tag;
+    char tmp[80];
+    static int last;
+    static char        *vec[10];       /* patch: don't know how big */
+
+    if (count < 0) {
+       if (last++ >= 0) {
+           qsort((char *)vec, (size_t)last, sizeof(vec[0]), compar);
+           /* limit length of error message */
+           k = 80 - (strlen(vec[last-1]) + 2);
+           for (j = 0; j < last; j++) {
+               tag = j ? " " : "Expected: ";
+               s = vec[j];
+               if (j != (last - 1)) {
+                   x = strlen(s) + strlen(tag);
+                   if (k <= 0)
+                       continue;
+                   else if ((k - x) <= 0)
+                       s = "...";
+                   k -= x;
+               }
+               fprintf(stderr, "%s%s", tag, s);
+           }
+           fprintf(stderr, "\n");
+           while (--last >= 0)
+               free(vec[last]);
+       }
+    } else {
+       if (!strncmp(t, "T_", 2)) {
+           int found = FALSE;
+           for (j = 0; j < sizeof(tbl)/sizeof(tbl[0]); j++) {
+               if (!strcmp(t, tbl[j].name)) {
+                   t = tbl[j].actual;
+                   found = TRUE;
+                   break;
+               }
+           }
+           if (!found) {
+               t = strncpy(tmp, t + 2, sizeof(tmp)-1);
+               for (k = 0; t[k] != '\0'; k++) {
+                   if (t[k] == '_')
+                       t[k] = '-';
+                   else if (isalpha(t[k]) && isupper(t[k]))
+                       t[k] = tolower(t[k]);
+               }
+           }
+       }
+       if (count > (sizeof(vec)/sizeof(vec[0]))-1) {
+           count = (sizeof(vec)/sizeof(vec[0]))-1;
+           free(vec[count]);
+       }
+       vec[count] = xstrdup(t);
+    }
+    last = count;
+}
+#else
+#define yyerror(s) yaccError(s)
+#endif /* yyerror */