home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume34 / cproto / patch05 / patch5
Encoding:
Text File  |  1992-11-29  |  48.7 KB  |  1,849 lines

  1. diff  -c2 old/CHANGES new/CHANGES
  2. *** old/CHANGES    Wed Jun 10 21:03:00 1992
  3. --- new/CHANGES    Sat Nov 28 23:18:24 1992
  4. ***************
  5. *** 1,4 ****
  6. --- 1,46 ----
  7.   Version 3
  8.   
  9. + Patchlevel 5
  10. + - Fix: The -v option did not output declarations for function pointers.
  11. + - Fix: String literals continued over more than one line messed up the
  12. +   line number count.
  13. + - Fix: The program generated incorrect prototypes for functions that take
  14. +   a variable argument list using <varargs.h>.
  15. + - Fix: When converting functions from the standard input, cproto generated
  16. +   no output if no functions needed to be converted.
  17. + - Fix: Now does not output a warning if an untagged struct is found in a
  18. +   typedef declaration.
  19. + - Added the -b option which rewrites function definition heads to
  20. +   include both old style and new style declarations separated by a
  21. +   conditional compilation directive.  For example, the program can
  22. +   generate
  23. +     #ifdef ANSI_FUNC
  24. +     int
  25. +     main (int argc, char *argv[])
  26. +     #else
  27. +     int
  28. +     main (argc, argv)
  29. +     int argc;
  30. +     char *argv[]
  31. +     #endif
  32. +     {
  33. +     }
  34. +   Added the -B option to set the preprocessor directive that appears
  35. +   at the beginning of such definitions.
  36. + - Added the keyword "interrupt" to the set of type qualifiers when compiled
  37. +   on a UNIX system.
  38. + - The MS-DOS version now recognizes the type modifiers introduced by
  39. +   Microsoft C/C++ 7.00.
  40. + - Now recognizes ANSI C trigraphs (yuck!).
  41. + - Now use "#if __STDC__" instead of "#if defined(__STDC__)".
  42. + - GNU bison orders the y.tab.c sections differently than yacc, which
  43. +   resulted in references to variables before they were declared.  The
  44. +   grammar specification was modified to also be compatible with bison.
  45.   Patchlevel 4
  46.   
  47. ***************
  48. *** 7,11 ****
  49.     For example, for the definition
  50.   
  51. !       typedef char *caddr_t;
  52.   
  53.       int strlen (s)
  54. --- 49,53 ----
  55.     For example, for the definition
  56.   
  57. !     typedef char *caddr_t;
  58.   
  59.       int strlen (s)
  60. ***************
  61. *** 16,20 ****
  62.     cproto generated the incorrect prototype
  63.   
  64. !       int strlen(int s);
  65.   
  66.   - Added implementation of the ANSI function tmpfile() for systems that
  67. --- 58,62 ----
  68.     cproto generated the incorrect prototype
  69.   
  70. !     int strlen(int s);
  71.   
  72.   - Added implementation of the ANSI function tmpfile() for systems that
  73. ***************
  74. *** 64,68 ****
  75.     For example, for the definition
  76.   
  77. !       typedef unsigned short ushort;
  78.   
  79.       void test (x)
  80. --- 106,110 ----
  81.     For example, for the definition
  82.   
  83. !     typedef unsigned short ushort;
  84.   
  85.       void test (x)
  86. ***************
  87. *** 73,81 ****
  88.     cproto generated the incorrect prototype
  89.   
  90. !       void test(ushort x);
  91.   
  92.     while the correct one is
  93.   
  94. !       void test(int x);
  95.   
  96.   - Fix: Incorrect prototypes were generated for functions that returned
  97. --- 115,123 ----
  98.     cproto generated the incorrect prototype
  99.   
  100. !     void test(ushort x);
  101.   
  102.     while the correct one is
  103.   
  104. !     void test(int x);
  105.   
  106.   - Fix: Incorrect prototypes were generated for functions that returned
  107. diff  -c2 old/config.h new/config.h
  108. *** old/config.h    Fri Jul 03 13:37:52 1992
  109. --- new/config.h    Sat Nov 28 23:27:44 1992
  110. ***************
  111. *** 1,3 ****
  112. ! /* $Id: config.h 3.4 92/07/03 13:37:48 cthuang Exp $
  113.    *
  114.    * cproto configuration and system dependencies
  115. --- 1,3 ----
  116. ! /* $Id: config.h 3.5 1992/11/29 04:27:30 cthuang Exp $
  117.    *
  118.    * cproto configuration and system dependencies
  119. ***************
  120. *** 43,47 ****
  121.   #endif
  122.   
  123. ! #if defined(__STDC__) || defined(MSDOS)
  124.   #include <stdlib.h>
  125.   #include <string.h>
  126. --- 43,47 ----
  127.   #endif
  128.   
  129. ! #if __STDC__ || defined(MSDOS)
  130.   #include <stdlib.h>
  131.   #include <string.h>
  132. diff  -c2 old/cproto.1 new/cproto.1
  133. *** old/cproto.1    Wed Jun 10 21:03:02 1992
  134. --- new/cproto.1    Sat Nov 28 23:34:08 1992
  135. ***************
  136. *** 1,3 ****
  137. ! .\" $Id: cproto.1 3.6 92/06/10 20:55:39 cthuang Exp $
  138.   .\"
  139.   .de EX        \"Begin example
  140. --- 1,3 ----
  141. ! .\" $Id: cproto.1 3.7 1992/11/29 04:34:05 cthuang Exp $
  142.   .\"
  143.   .de EX        \"Begin example
  144. ***************
  145. *** 14,18 ****
  146.   .if t .sp .5
  147.   ..
  148. ! .TH CPROTO 1 "April 7, 1992"
  149.   .SH NAME
  150.   cproto \- generate C function prototypes and convert function definitions
  151. --- 14,18 ----
  152.   .if t .sp .5
  153.   ..
  154. ! .TH CPROTO 1 "October 24, 1992"
  155.   .SH NAME
  156.   cproto \- generate C function prototypes and convert function definitions
  157. ***************
  158. *** 31,35 ****
  159.   Optionally,
  160.   .B cproto
  161. ! also outputs declarations for any variables defined in the file.
  162.   If no
  163.   .I file
  164. --- 31,35 ----
  165.   Optionally,
  166.   .B cproto
  167. ! also outputs declarations for variables defined in the files.
  168.   If no
  169.   .I file
  170. ***************
  171. *** 88,98 ****
  172.   .SH OPTIONS
  173.   .TP
  174. - .B \-a
  175. - Convert function definitions from the old style to the ANSI C style.
  176. - .TP
  177.   .B \-e
  178.   Output the keyword
  179.   .B extern
  180. ! in front of every declaration having global scope.
  181.   .TP
  182.   .BI \-f n
  183. --- 88,95 ----
  184.   .SH OPTIONS
  185.   .TP
  186.   .B \-e
  187.   Output the keyword
  188.   .B extern
  189. ! in front of every generated prototype or declaration that has global scope.
  190.   .TP
  191.   .BI \-f n
  192. ***************
  193. *** 169,177 ****
  194.   declarations as well.
  195.   .TP
  196.   .B \-t
  197.   Convert function definitions from the ANSI C style to the traditional style.
  198.   .TP
  199. ! .B \-v
  200. ! Also output declarations for variables defined in the source.
  201.   .LP
  202.   .nf
  203. --- 166,205 ----
  204.   declarations as well.
  205.   .TP
  206. + .B \-v
  207. + Also output declarations for variables defined in the source.
  208. + .TP
  209. + .B \-a
  210. + Convert function definitions from the old style to the ANSI C style.
  211. + .TP
  212.   .B \-t
  213.   Convert function definitions from the ANSI C style to the traditional style.
  214.   .TP
  215. ! .B \-b
  216. ! Rewrite function definition heads to include both old style and new style
  217. ! declarations separated by a conditional compilation directive.
  218. ! For example, the program can generate this function definition:
  219. ! .EX
  220. ! #ifdef ANSI_FUNC
  221. ! int
  222. ! main (int argc, char *argv[])
  223. ! #else
  224. ! int
  225. ! main (argc, argv)
  226. ! int argc;
  227. ! char *argv[]
  228. ! #endif
  229. ! {
  230. ! }
  231. ! .EE
  232. ! .TP
  233. ! .BI \-B directive
  234. ! Set the conditional compilation directive to output at the beginning of
  235. ! function definitions generated by the \-b option.
  236. ! The default is
  237. ! .EX
  238. ! #ifdef ANSI_FUNC
  239. ! .EE 
  240.   .LP
  241.   .nf
  242. ***************
  243. *** 185,189 ****
  244.   The format is specified by a template in the form
  245.   .EX
  246. ! " int main ( a, b )"
  247.   .EE
  248.   but you may replace each space in this string with any number of
  249. --- 213,217 ----
  250.   The format is specified by a template in the form
  251.   .EX
  252. ! " int f ( a, b )"
  253.   .EE
  254.   but you may replace each space in this string with any number of
  255. ***************
  256. *** 191,195 ****
  257.   For example, the option
  258.   .EX
  259. ! -F"int main(\\n\\ta,\\n\\tb\\n\\t)"
  260.   .EE
  261.   will produce
  262. --- 219,223 ----
  263.   For example, the option
  264.   .EX
  265. ! -F"int f(\\n\\ta,\\n\\tb\\n\\t)"
  266.   .EE
  267.   will produce
  268. ***************
  269. *** 201,205 ****
  270.   .EE
  271.   .TP
  272. ! .BI \-D name\[=value\]
  273.   This option is passed through to the preprocessor and is used to define 
  274.   symbols for use with conditionals such as
  275. --- 229,233 ----
  276.   .EE
  277.   .TP
  278. ! .BI \-D name[=value]
  279.   This option is passed through to the preprocessor and is used to define 
  280.   symbols for use with conditionals such as
  281. diff  -c2 old/cproto.c new/cproto.c
  282. *** old/cproto.c    Wed Jun 10 21:03:08 1992
  283. --- new/cproto.c    Sat Nov 28 23:27:52 1992
  284. ***************
  285. *** 1,3 ****
  286. ! /* $Id: cproto.c 3.6 92/06/10 20:56:26 cthuang Exp $
  287.    *
  288.    * C function prototype generator and function definition converter
  289. --- 1,3 ----
  290. ! /* $Id: cproto.c 3.7 1992/11/29 04:27:49 cthuang Exp $
  291.    *
  292.    * C function prototype generator and function definition converter
  293. ***************
  294. *** 4,8 ****
  295.    */
  296.   #ifndef lint
  297. ! static char rcsid[] = "$Id: cproto.c 3.6 92/06/10 20:56:26 cthuang Exp $";
  298.   #endif
  299.   #include <stdio.h>
  300. --- 4,8 ----
  301.    */
  302.   #ifndef lint
  303. ! static char rcsid[] = "$Id: cproto.c 3.7 1992/11/29 04:27:49 cthuang Exp $";
  304.   #endif
  305.   #include <stdio.h>
  306. ***************
  307. *** 48,51 ****
  308. --- 48,54 ----
  309.   boolean proto_comments = TRUE;
  310.   
  311. + /* Conditional compilation directive output in front of function definitions */
  312. + char *func_directive = "#ifdef ANSI_FUNC";
  313.   /* Output formats for function declarators */
  314.   FuncFormat fmt[] = {
  315. ***************
  316. *** 111,115 ****
  317.   put_error ()
  318.   {
  319. !     fprintf(stderr, "\"%s\", line %d: ", cur_file_name(), cur_line_num());
  320.   }
  321.   
  322. --- 114,118 ----
  323.   put_error ()
  324.   {
  325. !     fprintf(stderr, "\"%s\", line %u: ", cur_file_name(), cur_line_num());
  326.   }
  327.   
  328. ***************
  329. *** 226,255 ****
  330.       fprintf(stderr, "usage: %s [ option ... ] [ file ... ]\n", progname);
  331.       fputs("Options:\n", stderr);
  332. !     fputs("  -a       Convert function definitions to ANSI style\n", stderr);
  333. !     fputs("  -c       Omit comments in generated prototypes\n", stderr);
  334. !     fputs("  -e       Output \"extern\" keyword before global declarations\n",
  335. !     stderr);
  336. !     fputs("  -f n     Set function prototype style (0 to 4)\n", stderr);
  337. !     fputs("  -p       Disable formal parameter promotion\n", stderr);
  338. !     fputs("  -q       Disable include file read failure messages\n", stderr);
  339. !     fputs("  -s       Output static declarations\n", stderr);
  340. !     fputs("  -t       Convert function definitions to traditional style\n",
  341. !     stderr);
  342. !     fputs("  -v       Output variable declarations\n", stderr);
  343. !     fputs("  -m name  Set name of prototype macro\n", stderr);
  344. !     fputs("  -d       Omit prototype macro definition\n", stderr);
  345. !     fputs("  -P fmt   Set prototype format template \" int main (a, b)\"\n",
  346. !     stderr);
  347. !     fputs("  -F fmt   Set function definition format template \" int main (a, b)\"\n",
  348. !     stderr);
  349. !     fputs("  -C fmt   Set format for function definition with parameter comments\n",
  350. !     stderr);
  351. !     fputs("  -D name[=value]\n", stderr);
  352. !     fputs("  -U name\n", stderr);
  353. !     fputs("  -I directory\n", stderr);
  354. !     fputs("           Set C preprocessor options\n", stderr);
  355. !     fputs("  -E cpp   Run specified C preprocessor command\n", stderr);
  356. !     fputs("  -E 0     Do not run any C preprocessor\n", stderr);
  357. !     fputs("  -V       Print version information\n", stderr);
  358.       exit(1);
  359.   }
  360. --- 229,252 ----
  361.       fprintf(stderr, "usage: %s [ option ... ] [ file ... ]\n", progname);
  362.       fputs("Options:\n", stderr);
  363. !     fputs("  -a, -t           Convert function definitions to ANSI or traditional style\n", stderr);
  364. !     fputs("  -b               Rewrite function definitions in both styles\n", stderr);
  365. !     fputs("  -c               Omit comments in generated prototypes\n", stderr);
  366. !     fputs("  -e               Output \"extern\" keyword before global declarations\n", stderr);
  367. !     fputs("  -f n             Set function prototype style (0 to 4)\n", stderr);
  368. !     fputs("  -p               Disable formal parameter promotion\n", stderr);
  369. !     fputs("  -q               Disable include file read failure messages\n", stderr);
  370. !     fputs("  -s               Output static declarations\n", stderr);
  371. !     fputs("  -v               Output variable declarations\n", stderr);
  372. !     fputs("  -m name          Set name of prototype macro\n", stderr);
  373. !     fputs("  -d               Omit prototype macro definition\n", stderr);
  374. !     fputs("  -P template      Set prototype format template \" int f (a, b)\"\n", stderr);
  375. !     fputs("  -F template      Set function definition format template \" int f (a, b)\"\n", stderr);
  376. !     fputs("  -C template      Set format for function definition with parameter comments\n", stderr);
  377. !     fputs("  -D name[=value]  Define C preprocessor symbol\n", stderr);
  378. !     fputs("  -U name          Undefine C preprocessor symbol\n", stderr);
  379. !     fputs("  -I directory     Add #include search directory\n", stderr);
  380. !     fputs("  -E command       Run specified C preprocessor command\n", stderr);
  381. !     fputs("  -E 0             Do not run any C preprocessor\n", stderr);
  382. !     fputs("  -V               Print version information\n", stderr);
  383.       exit(1);
  384.   }
  385. ***************
  386. *** 291,295 ****
  387.   #ifdef CPP
  388.       /* Allocate buffer for C preprocessor command line. */
  389. !     n = strlen(CPP) + 1;
  390.       for (i = 0; i < argc; ++i) {
  391.       n += strlen(argv[i]) + 1;
  392. --- 288,292 ----
  393.   #ifdef CPP
  394.       /* Allocate buffer for C preprocessor command line. */
  395. !     n = strlen(cpp) + 1;
  396.       for (i = 0; i < argc; ++i) {
  397.       n += strlen(argv[i]) + 1;
  398. ***************
  399. *** 300,304 ****
  400.   #endif
  401.   
  402. !     while ((c = getopt(argc, argv, "aC:cD:dE:eF:f:I:m:P:pqstU:Vv")) != EOF) {
  403.       switch (c) {
  404.       case 'I':
  405. --- 297,301 ----
  406.   #endif
  407.   
  408. !     while ((c = getopt(argc, argv, "aB:bC:cD:dE:eF:f:I:m:P:pqstU:Vv")) != EOF) {
  409.       switch (c) {
  410.       case 'I':
  411. ***************
  412. *** 319,322 ****
  413. --- 316,325 ----
  414.           func_style = FUNC_ANSI;
  415.           break;
  416. +     case 'B':
  417. +         func_directive = optarg;
  418. +         break;
  419. +     case 'b':
  420. +         func_style = FUNC_BOTH;
  421. +         break;
  422.       case 'c':
  423.           proto_comments = FALSE;
  424. ***************
  425. *** 429,433 ****
  426.   
  427.       if (proto_style == PROTO_MACRO && define_macro) {
  428. !     printf("#if defined(__STDC__) || defined(__cplusplus)\n");
  429.       printf("#define %s(s) s\n", macro_name);
  430.       printf("#else\n");
  431. --- 432,436 ----
  432.   
  433.       if (proto_style == PROTO_MACRO && define_macro) {
  434. !     printf("#if __STDC__ || defined(__cplusplus)\n");
  435.       printf("#define %s(s) s\n", macro_name);
  436.       printf("#else\n");
  437. diff  -c2 old/cproto.h new/cproto.h
  438. *** old/cproto.h    Wed Jun 10 21:03:08 1992
  439. --- new/cproto.h    Sat Nov 28 23:27:46 1992
  440. ***************
  441. *** 1,3 ****
  442. ! /* $Id: cproto.h 3.5 92/04/11 19:27:44 cthuang Exp $
  443.    *
  444.    * Declarations for C function prototype generator
  445. --- 1,3 ----
  446. ! /* $Id: cproto.h 3.6 1992/11/29 04:27:30 cthuang Exp $
  447.    *
  448.    * Declarations for C function prototype generator
  449. ***************
  450. *** 45,48 ****
  451. --- 45,49 ----
  452.   #define FUNC_TRADITIONAL    1    /* traditional style */
  453.   #define FUNC_ANSI        2    /* ANSI style */
  454. + #define FUNC_BOTH        3    /* both styles */
  455.   typedef int FuncDefStyle;
  456.   
  457. ***************
  458. *** 56,59 ****
  459. --- 57,61 ----
  460.       FuncDefStyle func_def;        /* style of function definition */
  461.       ParameterList params;        /* function parameters */
  462. +     boolean pointer;            /* TRUE if it declares a pointer */
  463.       struct declarator *head;        /* head function declarator */
  464.       struct declarator *func_stack;    /* stack of function declarators */
  465. ***************
  466. *** 79,83 ****
  467.       Text text;
  468.       DeclSpec decl_spec;
  469. !     Parameter parameter;
  470.       ParameterList param_list;
  471.       Declarator *declarator;
  472. --- 81,85 ----
  473.       Text text;
  474.       DeclSpec decl_spec;
  475. !     Parameter *parameter;
  476.       ParameterList param_list;
  477.       Declarator *declarator;
  478. ***************
  479. *** 127,130 ****
  480. --- 129,133 ----
  481.   extern boolean proto_comments;
  482.   extern boolean quiet;
  483. + extern char *func_directive;
  484.   extern int num_inc_dir;
  485.   extern char *inc_dir[];
  486. ***************
  487. *** 137,141 ****
  488.   extern void put_error();
  489.   extern void init_parser(), process_file(), pop_file();
  490. ! extern char *cur_file_name();
  491.   extern unsigned cur_line_num();
  492.   extern FILE *cur_tmp_file();
  493. --- 140,144 ----
  494.   extern void put_error();
  495.   extern void init_parser(), process_file(), pop_file();
  496. ! extern char *cur_file_name(), *cur_text();
  497.   extern unsigned cur_line_num();
  498.   extern FILE *cur_tmp_file();
  499. diff  -c2 old/grammar.y new/grammar.y
  500. *** old/grammar.y    Wed Jun 10 21:03:02 1992
  501. --- new/grammar.y    Sat Nov 28 23:27:42 1992
  502. ***************
  503. *** 1,3 ****
  504. ! /* $Id: grammar.y 3.6 92/06/10 20:56:07 cthuang Exp $
  505.    *
  506.    * yacc grammar for C function prototype generator
  507. --- 1,3 ----
  508. ! /* $Id: grammar.y 3.7 1992/11/29 04:27:30 cthuang Exp $
  509.    *
  510.    * yacc grammar for C function prototype generator
  511. ***************
  512. *** 46,49 ****
  513. --- 46,52 ----
  514.       T_ASMARG
  515.   
  516. +     /* va_dcl from <varargs.h> */
  517. +     T_VA_DCL
  518.   %type <decl_spec> decl_specifiers decl_specifier
  519.   %type <decl_spec> storage_class type_specifier type_qualifier
  520. ***************
  521. *** 66,78 ****
  522.   #define YYMAXDEPTH 150
  523.   
  524. ! /* Declaration specifier attributes for the typedef statement currently being
  525. !  * scanned.
  526.    */
  527.   static int cur_decl_spec_flags;
  528.   
  529. ! /* Pointer to parameter list for the current function definition. */
  530.   static ParameterList *func_params;
  531.   
  532. ! /* Pointer to current declarator in function parameter declaration. */
  533.   static Declarator *cur_declarator;
  534.   
  535. --- 69,87 ----
  536.   #define YYMAXDEPTH 150
  537.   
  538. ! /* declaration specifier attributes for the typedef statement currently being
  539. !  * scanned
  540.    */
  541.   static int cur_decl_spec_flags;
  542.   
  543. ! /* pointer to parameter list for the current function definition */
  544.   static ParameterList *func_params;
  545.   
  546. ! /* A parser semantic action sets this pointer to the current declarator in
  547. !  * a function parameter declaration in order to catch any comments following
  548. !  * the parameter declaration on the same line.  If the lexer scans a comment
  549. !  * and <cur_declarator> is not NULL, then the comment is attached to the
  550. !  * declarator.  To ignore subsequent comments, the lexer sets this to NULL
  551. !  * after scanning a comment or end of line.
  552. !  */
  553.   static Declarator *cur_declarator;
  554.   
  555. ***************
  556. *** 80,88 ****
  557.   static char buf[MAX_TEXT_SIZE];
  558.   
  559. ! /* Table of typedef names */
  560.   static SymbolTable *typedef_names;
  561.   
  562. ! /* Table of type qualifiers */
  563.   static SymbolTable *type_qualifiers;
  564.   %}
  565.   %%
  566. --- 89,114 ----
  567.   static char buf[MAX_TEXT_SIZE];
  568.   
  569. ! /* table of typedef names */
  570.   static SymbolTable *typedef_names;
  571.   
  572. ! /* table of type qualifiers */
  573.   static SymbolTable *type_qualifiers;
  574. + /* information about the current input file */
  575. + typedef struct {
  576. +     char *base_name;        /* base input file name */
  577. +     char *file_name;        /* current file name */
  578. +     FILE *file;         /* input file */
  579. +     unsigned line_num;        /* current line number in input file */
  580. +     FILE *tmp_file;        /* temporary file */
  581. +     long begin_comment;     /* tmp file offset after last written ) or ; */
  582. +     long end_comment;        /* tmp file offset after last comment */
  583. +     boolean convert;        /* if TRUE, convert function definitions */
  584. +     boolean changed;        /* TRUE if conversion done in this file */
  585. + } IncludeStack;
  586. + static IncludeStack *cur_file;    /* current input file */
  587. + extern void yyerror();
  588.   %}
  589.   %%
  590. ***************
  591. *** 120,124 ****
  592. --- 146,159 ----
  593.   linkage_specification
  594.       : T_EXTERN T_STRING_LITERAL braces
  595. +     {
  596. +         /* Provide an empty action here so bison will not complain about
  597. +          * incompatible types in the default action it normally would
  598. +          * have generated.
  599. +          */
  600. +     }
  601.       | T_EXTERN T_STRING_LITERAL declaration
  602. +     {
  603. +         /* empty */
  604. +     }
  605.       ;
  606.   
  607. ***************
  608. *** 130,134 ****
  609.       | decl_specifiers init_declarator_list ';'
  610.       {
  611. -         check_untagged(&$1);
  612.           if (func_params != NULL) {
  613.           set_param_types(func_params, &$1, &$2);
  614. --- 165,168 ----
  615. ***************
  616. *** 227,230 ****
  617. --- 261,265 ----
  618.   opt_declaration_list
  619.       : /* empty */
  620. +     | T_VA_DCL
  621.       | declaration_list
  622.       ;
  623. ***************
  624. *** 372,376 ****
  625.           func_style == FUNC_TRADITIONAL && cur_file->convert) {
  626.           gen_func_declarator($1);
  627. !         fputs(yytext, cur_file->tmp_file);
  628.           }
  629.           cur_declarator = $$;
  630. --- 407,411 ----
  631.           func_style == FUNC_TRADITIONAL && cur_file->convert) {
  632.           gen_func_declarator($1);
  633. !         fputs(cur_text(), cur_file->tmp_file);
  634.           }
  635.           cur_declarator = $$;
  636. ***************
  637. *** 417,420 ****
  638. --- 452,456 ----
  639.           $$->text = xstrdup(buf);
  640.           $$->begin = $1.begin;
  641. +         $$->pointer = TRUE;
  642.       }
  643.       | direct_declarator
  644. ***************
  645. *** 507,515 ****
  646.       : parameter_declaration
  647.       {
  648. !         new_param_list(&$$, &$1);
  649.       }
  650.       | parameter_list ',' parameter_declaration
  651.       {
  652. !         add_param_list(&$$, &$1, &$3);
  653.       }
  654.       ;
  655. --- 543,551 ----
  656.       : parameter_declaration
  657.       {
  658. !         new_param_list(&$$, $1);
  659.       }
  660.       | parameter_list ',' parameter_declaration
  661.       {
  662. !         add_param_list(&$$, &$1, $3);
  663.       }
  664.       ;
  665. ***************
  666. *** 519,523 ****
  667.       {
  668.           check_untagged(&$1);
  669. !         new_parameter(&$$, &$1, $2);
  670.       }
  671.       | decl_specifiers abs_declarator
  672. --- 555,559 ----
  673.       {
  674.           check_untagged(&$1);
  675. !         $$ = new_parameter(&$1, $2);
  676.       }
  677.       | decl_specifiers abs_declarator
  678. ***************
  679. *** 524,528 ****
  680.       {
  681.           check_untagged(&$1);
  682. !         new_parameter(&$$, &$1, $2);
  683.       }
  684.       | decl_specifiers
  685. --- 560,564 ----
  686.       {
  687.           check_untagged(&$1);
  688. !         $$ = new_parameter(&$1, $2);
  689.       }
  690.       | decl_specifiers
  691. ***************
  692. *** 529,533 ****
  693.       {
  694.           check_untagged(&$1);
  695. !         new_parameter(&$$, &$1, NULL);
  696.       }
  697.       ;
  698. --- 565,569 ----
  699.       {
  700.           check_untagged(&$1);
  701. !         $$ = new_parameter(&$1, NULL);
  702.       }
  703.       ;
  704. ***************
  705. *** 628,631 ****
  706. --- 664,668 ----
  707.   
  708.   %%
  709.   #ifdef MSDOS
  710.   #include "lex_yy.c"
  711. ***************
  712. *** 650,659 ****
  713.   {
  714.       static char *keywords[] = {
  715. !     "const", "volatile",
  716.   #ifdef MSDOS
  717.       "_cdecl", "_export", "_far", "_fastcall", "_fortran", "_huge",
  718.       "_interrupt", "_loadds", "_near", "_pascal", "_saveregs", "_segment",
  719.       "_cs", "_ds", "_es", "_ss", "_seg",
  720. !     "cdecl", "far", "huge", "interrupt", "near", "pascal",
  721.   #endif
  722.       };
  723. --- 687,700 ----
  724.   {
  725.       static char *keywords[] = {
  726. !     "const", "volatile", "interrupt",
  727.   #ifdef MSDOS
  728. +     "cdecl", "far", "huge", "near", "pascal",
  729.       "_cdecl", "_export", "_far", "_fastcall", "_fortran", "_huge",
  730.       "_interrupt", "_loadds", "_near", "_pascal", "_saveregs", "_segment",
  731.       "_cs", "_ds", "_es", "_ss", "_seg",
  732. !     "__cdecl", "__export", "__far", "__fastcall", "__fortran", "__huge",
  733. !     "__inline", "__interrupt", "__loadds", "__near", "__pascal",
  734. !     "__saveregs", "__segment", "__stdcall", "__syscall",
  735. !     "__cs", "__ds", "__es", "__ss", "__seg",
  736.   #endif
  737.       };
  738. diff  -c2 old/lex.l new/lex.l
  739. *** old/lex.l    Wed Jun 10 21:03:02 1992
  740. --- new/lex.l    Sat Nov 28 23:54:16 1992
  741. ***************
  742. *** 1,4 ****
  743.   %{
  744. ! /* $Id: lex.l 3.7 92/06/10 20:56:04 cthuang Exp $
  745.    *
  746.    * Lexical analyzer for C function prototype generator
  747. --- 1,4 ----
  748.   %{
  749. ! /* $Id: lex.l 3.8 1992/11/29 04:54:14 cthuang Exp $
  750.    *
  751.    * Lexical analyzer for C function prototype generator
  752. ***************
  753. *** 8,32 ****
  754.   static int ly_count;    /* number of occurances of %% */
  755.   
  756. - /* information about the current input file */
  757. - typedef struct {
  758. -     char *base_name;        /* base input file name */
  759. -     char *file_name;        /* current file name */
  760. -     FILE *file;         /* input file */
  761. -     unsigned line_num;        /* current line number in input file */
  762. -     FILE *tmp_file;        /* temporary file */
  763. -     long begin_comment;     /* tmp file offset after last written ) or ; */
  764. -     long end_comment;        /* tmp file offset after last comment */
  765. -     boolean convert;        /* if TRUE, convert function definitions */
  766. -     boolean changed;        /* TRUE if conversion done in this file */
  767.   #ifdef FLEX_SCANNER
  768. !     YY_BUFFER_STATE buffer;    /* flex scanner state */
  769.   #endif
  770. - } IncludeStack;
  771.   
  772.   static int inc_depth;                /* include nesting level */
  773.   static IncludeStack inc_stack[MAX_INC_DEPTH];    /* stack of included files */
  774. - static IncludeStack *cur_file;            /* current file */
  775.   static SymbolTable *included_files;        /* files already included */
  776.   
  777.   static void save_text();
  778.   static void save_text_offset();
  779. --- 8,21 ----
  780.   static int ly_count;    /* number of occurances of %% */
  781.   
  782.   #ifdef FLEX_SCANNER
  783. ! /* flex scanner state */
  784. ! static YY_BUFFER_STATE buffer_stack[MAX_INC_DEPTH];
  785.   #endif
  786.   
  787.   static int inc_depth;                /* include nesting level */
  788.   static IncludeStack inc_stack[MAX_INC_DEPTH];    /* stack of included files */
  789.   static SymbolTable *included_files;        /* files already included */
  790.   
  791. + static void update_line_num();
  792.   static void save_text();
  793.   static void save_text_offset();
  794. ***************
  795. *** 35,42 ****
  796.   static void do_include();
  797.   
  798.   #ifdef yywrap
  799.   #undef yywrap
  800.   #endif
  801. - static int yywrap();
  802.   %}
  803.   
  804. --- 24,31 ----
  805.   static void do_include();
  806.   
  807. + extern void yyerror();
  808.   #ifdef yywrap
  809.   #undef yywrap
  810.   #endif
  811.   %}
  812.   
  813. ***************
  814. *** 45,49 ****
  815.   DIGIT        [0-9]
  816.   ID        {LETTER}({LETTER}|{DIGIT})*
  817. ! STRING        \"(\\\"|[^"\n])*\"
  818.   QUOTED        ({STRING}|\'(\\\'|[^'\n])*\'|\\.)
  819.   
  820. --- 34,38 ----
  821.   DIGIT        [0-9]
  822.   ID        {LETTER}({LETTER}|{DIGIT})*
  823. ! STRING        \"(\\\"|[^"])*\"
  824.   QUOTED        ({STRING}|\'(\\\'|[^'\n])*\'|\\.)
  825.   
  826. ***************
  827. *** 59,66 ****
  828.   <LEXYACC>^"%%"        { save_text(); if (++ly_count >= 2) BEGIN INITIAL; }
  829.   <LEXYACC>^"%{"        { save_text(); BEGIN INITIAL; }
  830. ! <LEXYACC>{QUOTED}|.    save_text();
  831.   <INITIAL>^"%}"        { save_text(); BEGIN LEXYACC; }
  832.   
  833.   <INITIAL>#{WS}*     { save_text(); BEGIN CPP1; }
  834.   
  835.   <CPP1>define{WS}+{ID}    {
  836. --- 48,57 ----
  837.   <LEXYACC>^"%%"        { save_text(); if (++ly_count >= 2) BEGIN INITIAL; }
  838.   <LEXYACC>^"%{"        { save_text(); BEGIN INITIAL; }
  839. ! <LEXYACC>{QUOTED}    { save_text(); update_line_num(); }
  840. ! <LEXYACC>.        save_text();
  841.   <INITIAL>^"%}"        { save_text(); BEGIN LEXYACC; }
  842.   
  843.   <INITIAL>#{WS}*     { save_text(); BEGIN CPP1; }
  844. + <INITIAL>"??="{WS}*     { save_text(); BEGIN CPP1; }
  845.   
  846.   <CPP1>define{WS}+{ID}    {
  847. ***************
  848. *** 125,129 ****
  849.               }
  850.   <INITIAL>"..."        { save_text(); return T_ELLIPSIS; }
  851. ! <INITIAL>{STRING}    { save_text(); return T_STRING_LITERAL; }
  852.   
  853.   <INITIAL>asm        { save_text(); BEGIN ASM; return T_ASM; }
  854. --- 116,124 ----
  855.               }
  856.   <INITIAL>"..."        { save_text(); return T_ELLIPSIS; }
  857. ! <INITIAL>{STRING}    {
  858. !                 save_text();
  859. !                 update_line_num();
  860. !                 return T_STRING_LITERAL;
  861. !             }
  862.   
  863.   <INITIAL>asm        { save_text(); BEGIN ASM; return T_ASM; }
  864. ***************
  865. *** 130,136 ****
  866.   <ASM>"("        save_text();
  867.   <ASM>")"        { save_text(); BEGIN INITIAL; return T_ASMARG; }
  868. ! <ASM>{QUOTED}|.     save_text();
  869.   
  870. ! <INITIAL>_based[^(]*\([^)]*\)    { save_text_offset(); return T_TYPE_QUALIFIER; }
  871.   
  872.   <INITIAL>auto        { save_text_offset(); return T_AUTO; }
  873. --- 125,132 ----
  874.   <ASM>"("        save_text();
  875.   <ASM>")"        { save_text(); BEGIN INITIAL; return T_ASMARG; }
  876. ! <ASM>{QUOTED}         { save_text(); update_line_num(); }
  877. ! <ASM>.             save_text();
  878.   
  879. ! <INITIAL>__?based[^(]*\([^)]*\)    { save_text_offset(); return T_TYPE_QUALIFIER; }
  880.   
  881.   <INITIAL>auto        { save_text_offset(); return T_AUTO; }
  882. ***************
  883. *** 152,155 ****
  884. --- 148,152 ----
  885.   <INITIAL>struct     { save_text_offset(); return T_STRUCT; }
  886.   <INITIAL>union        { save_text_offset(); return T_UNION; }
  887. + <INITIAL>va_dcl        { save_text_offset(); return T_VA_DCL; }
  888.   
  889.   <INITIAL>{ID}        {
  890. ***************
  891. *** 167,177 ****
  892.                    * containing a ] appears between the brackets.
  893.                    */
  894. -                 int i;
  895.                   save_text_offset();
  896. !                 for (i = 0; i < yyleng; ++i) {
  897. !                 if (yytext[i] == '\n')
  898. !                     cur_file->line_num++;
  899. !                 }
  900.                   return T_BRACKETS;
  901.               }
  902. --- 164,174 ----
  903.                    * containing a ] appears between the brackets.
  904.                    */
  905.                   save_text_offset();
  906. !                 update_line_num();
  907. !                 return T_BRACKETS;
  908. !             }
  909. ! <INITIAL>"??("[^?]*"??)"    {
  910. !                 save_text_offset();
  911. !                 update_line_num();
  912.                   return T_BRACKETS;
  913.               }
  914. ***************
  915. *** 184,188 ****
  916.                   return T_INITIALIZER;
  917.               }
  918. ! <INIT1>{QUOTED}|.    save_text();
  919.   
  920.   <INIT2>"{"        { save_text(); ++curly; }
  921. --- 181,186 ----
  922.                   return T_INITIALIZER;
  923.               }
  924. ! <INIT1>{QUOTED}        { save_text(); update_line_num(); }
  925. ! <INIT1>.        save_text();
  926.   
  927.   <INIT2>"{"        { save_text(); ++curly; }
  928. ***************
  929. *** 194,198 ****
  930.                   }
  931.               }
  932. ! <INIT2>{QUOTED}|.    save_text();
  933.   
  934.   <INITIAL>"{"        {
  935. --- 192,197 ----
  936.                   }
  937.               }
  938. ! <INIT2>{QUOTED}        { save_text(); update_line_num(); }
  939. ! <INIT2>.        save_text();
  940.   
  941.   <INITIAL>"{"        {
  942. ***************
  943. *** 210,214 ****
  944.                   }
  945.               }
  946. ! <CURLY>{QUOTED}|.    save_text();
  947.   
  948.   [ \t\f]+        save_text();
  949. --- 209,214 ----
  950.                   }
  951.               }
  952. ! <CURLY>{QUOTED}        { save_text(); update_line_num(); }
  953. ! <CURLY>.        save_text();
  954.   
  955.   [ \t\f]+        save_text();
  956. ***************
  957. *** 220,223 ****
  958. --- 220,236 ----
  959.   %%
  960.   
  961. + /* If the matched text contains any new line characters, then update the
  962. +  * current line number.
  963. +  */
  964. + static void
  965. + update_line_num ()
  966. + {
  967. +     char *p = yytext;
  968. +     while (*p != '\0') {
  969. +     if (*p++ == '\n')
  970. +         cur_file->line_num++;
  971. +     }
  972. + }
  973.   /* Save the matched text in the temporary file.
  974.    */
  975. ***************
  976. *** 277,281 ****
  977.   }
  978.   
  979. ! /* Scan rest of preprocessor statement.
  980.    */
  981.   static void
  982. --- 290,294 ----
  983.   }
  984.   
  985. ! /* Scan rest of preprocessor directive.
  986.    */
  987.   static void
  988. ***************
  989. *** 282,286 ****
  990.   get_cpp_directive ()
  991.   {
  992. !     int c, lastc = '\0';
  993.   
  994.       while ((c = input()) != 0) {
  995. --- 295,301 ----
  996.   get_cpp_directive ()
  997.   {
  998. !     char c, lastc[4];
  999. !     
  1000. !     lastc[0] = lastc[1] = lastc[2] = lastc[3] = '\0';
  1001.   
  1002.       while ((c = input()) != 0) {
  1003. ***************
  1004. *** 290,294 ****
  1005.       case '\n':
  1006.           cur_file->line_num++;
  1007. !         if (lastc != '\\') {
  1008.           BEGIN INITIAL;
  1009.           return;
  1010. --- 305,309 ----
  1011.       case '\n':
  1012.           cur_file->line_num++;
  1013. !         if (lastc[2] != '\\' && strcmp(lastc, "??""/") != 0) {
  1014.           BEGIN INITIAL;
  1015.           return;
  1016. ***************
  1017. *** 296,304 ****
  1018.           break;
  1019.       case '*':
  1020. !         if (lastc == '/')
  1021.           get_comment();
  1022.           break;
  1023.       }
  1024. !     lastc = c;
  1025.       }
  1026.   }
  1027. --- 311,321 ----
  1028.           break;
  1029.       case '*':
  1030. !         if (lastc[2] == '/')
  1031.           get_comment();
  1032.           break;
  1033.       }
  1034. !     lastc[0] = lastc[1];
  1035. !     lastc[1] = lastc[2];
  1036. !     lastc[2] = c;
  1037.       }
  1038.   }
  1039. ***************
  1040. *** 344,347 ****
  1041. --- 361,372 ----
  1042.   }
  1043.   
  1044. + /* Return the text of the current lexical token.
  1045. +  */
  1046. + char *
  1047. + cur_text ()
  1048. + {
  1049. +     return yytext;
  1050. + }
  1051.   #ifdef NEED_tmpfile
  1052.   /*
  1053. ***************
  1054. *** 356,360 ****
  1055.   tmpfile ()
  1056.   {
  1057. !     char name[1024];
  1058.       char *tmpdir;
  1059.       FILE *f;
  1060. --- 381,385 ----
  1061.   tmpfile ()
  1062.   {
  1063. !     char name[MAX_TEXT_SIZE];
  1064.       char *tmpdir;
  1065.       FILE *f;
  1066. ***************
  1067. *** 400,405 ****
  1068.   
  1069.   #ifdef FLEX_SCANNER
  1070. !     cur_file->buffer = yy_create_buffer(yyin, YY_BUF_SIZE);
  1071. !     yy_switch_to_buffer(cur_file->buffer);
  1072.   #endif
  1073.   
  1074. --- 425,430 ----
  1075.   
  1076.   #ifdef FLEX_SCANNER
  1077. !     buffer_stack[inc_depth] = yy_create_buffer(yyin, YY_BUF_SIZE);
  1078. !     yy_switch_to_buffer(buffer_stack[inc_depth]);
  1079.   #endif
  1080.   
  1081. ***************
  1082. *** 408,412 ****
  1083.       cur_file->tmp_file = tmpfile();
  1084.       if (cur_file->tmp_file == NULL) {
  1085. !         fprintf(stderr, "%s: cannot create temporary file %s\n", progname);
  1086.           cur_file->convert = FALSE;
  1087.       }
  1088. --- 433,437 ----
  1089.       cur_file->tmp_file = tmpfile();
  1090.       if (cur_file->tmp_file == NULL) {
  1091. !         fprintf(stderr, "%s: cannot create temporary file\n", progname);
  1092.           cur_file->convert = FALSE;
  1093.       }
  1094. ***************
  1095. *** 449,456 ****
  1096.   
  1097.       if (cur_file->convert) {
  1098. !     if (cur_file->changed) {
  1099. !         if (yyin == stdin) {
  1100. !         put_file(stdout);
  1101. !         } else if ((outf = fopen(cur_file->base_name, "w")) != NULL) {
  1102.           put_file(outf);
  1103.           fclose(outf);
  1104. --- 474,481 ----
  1105.   
  1106.       if (cur_file->convert) {
  1107. !     if (yyin == stdin) {
  1108. !         put_file(stdout);
  1109. !     } else if (cur_file->changed) {
  1110. !         if ((outf = fopen(cur_file->base_name, "w")) != NULL) {
  1111.           put_file(outf);
  1112.           fclose(outf);
  1113. ***************
  1114. *** 457,461 ****
  1115.           } else {
  1116.           fprintf(stderr, "%s: cannot create file %s\n", progname,
  1117. !             cur_file->base_name);
  1118.           }
  1119.       }
  1120. --- 482,486 ----
  1121.           } else {
  1122.           fprintf(stderr, "%s: cannot create file %s\n", progname,
  1123. !          cur_file->base_name);
  1124.           }
  1125.       }
  1126. ***************
  1127. *** 475,479 ****
  1128.   
  1129.   #ifdef FLEX_SCANNER
  1130. !     yy_switch_to_buffer(cur_file->buffer);
  1131.   #endif
  1132.       }
  1133. --- 500,504 ----
  1134.   
  1135.   #ifdef FLEX_SCANNER
  1136. !     yy_switch_to_buffer(buffer_stack[inc_depth]);
  1137.   #endif
  1138.       }
  1139. ***************
  1140. *** 524,528 ****
  1141.    * nested include file.
  1142.    */
  1143. ! static int
  1144.   yywrap ()
  1145.   {
  1146. --- 549,553 ----
  1147.    * nested include file.
  1148.    */
  1149. ! int
  1150.   yywrap ()
  1151.   {
  1152. diff  -c2 old/Makefile.bc new/Makefile.bc
  1153. *** old/Makefile.bc    Wed Jun 10 21:03:02 1992
  1154. --- new/Makefile.bc    Sat Nov 28 23:27:32 1992
  1155. ***************
  1156. *** 1,3 ****
  1157. ! # $Id: makefile.bc 3.1 92/03/03 10:45:53 cthuang Exp $
  1158.   #
  1159.   # Borland C++ makefile for C prototype generator
  1160. --- 1,3 ----
  1161. ! # $Id: Makefile.bc 3.1 1992/03/03 10:45:53 cthuang Exp $
  1162.   #
  1163.   # Borland C++ makefile for C prototype generator
  1164. diff  -c2 old/Makefile.msc new/Makefile.msc
  1165. *** old/Makefile.msc    Wed Jun 10 21:03:02 1992
  1166. --- new/Makefile.msc    Sat Nov 28 23:27:36 1992
  1167. ***************
  1168. *** 1,3 ****
  1169. ! # $Id: makefile.msc 3.3 92/06/10 20:55:56 cthuang Exp $
  1170.   #
  1171.   # Microsoft C makefile for C prototype generator
  1172. --- 1,3 ----
  1173. ! # $Id: Makefile.msc 3.4 1992/11/29 04:27:30 cthuang Exp $
  1174.   #
  1175.   # Microsoft C makefile for C prototype generator
  1176. ***************
  1177. *** 11,16 ****
  1178.   CC = cl
  1179.   CFLAGS = -AC $(DEFINES)
  1180. ! LIBS = \c6\lib\setargv.obj
  1181. ! LDFLAGS = /link /noe /stack:4096
  1182.   
  1183.   DIST1 = README CHANGES cproto.man
  1184. --- 11,16 ----
  1185.   CC = cl
  1186.   CFLAGS = -AC $(DEFINES)
  1187. ! LIBS = \c7\lib\setargv.obj
  1188. ! LDFLAGS = /F 1000
  1189.   
  1190.   DIST1 = README CHANGES cproto.man
  1191. diff  -c2 old/Makefile.uni new/Makefile.uni
  1192. *** old/Makefile.uni    Wed Jun 10 21:03:02 1992
  1193. --- new/Makefile.uni    Sat Nov 28 23:27:36 1992
  1194. ***************
  1195. *** 1,3 ****
  1196. ! # $Id: makefile.uni 3.5 92/06/10 20:56:00 cthuang Exp $
  1197.   #
  1198.   # UNIX makefile for C prototype generator
  1199. --- 1,3 ----
  1200. ! # $Id: Makefile.uni 3.5 1992/06/10 20:56:00 cthuang Exp $
  1201.   #
  1202.   # UNIX makefile for C prototype generator
  1203. diff  -c2 old/patchlev.h new/patchlev.h
  1204. *** old/patchlev.h    Wed Jun 10 21:03:08 1992
  1205. --- new/patchlev.h    Fri Jun 26 08:27:12 1992
  1206. ***************
  1207. *** 1 ****
  1208. ! #define PATCHLEVEL 4
  1209. --- 1 ----
  1210. ! #define PATCHLEVEL 5
  1211. diff  -c2 old/popen.c new/popen.c
  1212. *** old/popen.c    Wed Jun 10 21:03:08 1992
  1213. --- new/popen.c    Sat Nov 28 23:27:52 1992
  1214. ***************
  1215. *** 1,3 ****
  1216. ! /* $Id: popen.c 3.3 92/06/10 20:56:30 cthuang Exp $
  1217.    *
  1218.    * Imitate a UNIX pipe in MS-DOS.
  1219. --- 1,3 ----
  1220. ! /* $Id: popen.c 3.3 1992/06/10 20:56:30 cthuang Exp $
  1221.    *
  1222.    * Imitate a UNIX pipe in MS-DOS.
  1223. diff  -c2 old/semantic.c new/semantic.c
  1224. *** old/semantic.c    Wed Jun 10 21:03:08 1992
  1225. --- new/semantic.c    Sat Nov 28 23:27:56 1992
  1226. ***************
  1227. *** 1,3 ****
  1228. ! /* $Id: semantic.c 3.6 92/06/10 20:56:35 cthuang Exp $
  1229.    *
  1230.    * Semantic actions executed by the parser of the
  1231. --- 1,3 ----
  1232. ! /* $Id: semantic.c 3.7 1992/11/29 04:27:49 cthuang Exp $
  1233.    *
  1234.    * Semantic actions executed by the parser of the
  1235. ***************
  1236. *** 11,15 ****
  1237.   static Declarator *func_declarator;
  1238.   
  1239. ! /* Where the declarator appears */
  1240.   static int where;
  1241.   
  1242. --- 11,18 ----
  1243.   static Declarator *func_declarator;
  1244.   
  1245. ! /* Role of the function declarator
  1246. !  * FUNC_PROTO if it is the declarator in a function prototype.
  1247. !  * FUNC_DEF if it is the declarator in a function definition.
  1248. !  */
  1249.   static int where;
  1250.   
  1251. ***************
  1252. *** 105,108 ****
  1253. --- 108,112 ----
  1254.       d->head = d;
  1255.       d->func_stack = NULL;
  1256. +     d->pointer = FALSE;
  1257.       return d;
  1258.   }
  1259. ***************
  1260. *** 116,120 ****
  1261.       free(d->text);
  1262.       free(d->name);
  1263. !     free_param_list(&(d->params));
  1264.       if (d->func_stack != NULL)
  1265.       free_declarator(d->func_stack);
  1266. --- 120,124 ----
  1267.       free(d->text);
  1268.       free(d->name);
  1269. !     free_param_list(&d->params);
  1270.       if (d->func_stack != NULL)
  1271.       free_declarator(d->func_stack);
  1272. ***************
  1273. *** 162,175 ****
  1274.   }
  1275.   
  1276. ! /* Initialize the parameter structure.
  1277.    */
  1278. ! void
  1279. ! new_parameter (param, decl_spec, declarator)
  1280. ! Parameter *param;        /* parameter to be initialized */
  1281.   DeclSpec *decl_spec;
  1282.   Declarator *declarator;
  1283.   {
  1284.       if (decl_spec == NULL) {
  1285. !     new_decl_spec(&(param->decl_spec), "", 0L, DS_JUNK);
  1286.       } else {
  1287.       param->decl_spec = *decl_spec;
  1288. --- 166,181 ----
  1289.   }
  1290.   
  1291. ! /* Create a new parameter structure.
  1292.    */
  1293. ! Parameter *
  1294. ! new_parameter (decl_spec, declarator)
  1295.   DeclSpec *decl_spec;
  1296.   Declarator *declarator;
  1297.   {
  1298. +     Parameter *param;
  1299. +     param = (Parameter *)xmalloc(sizeof(Parameter));
  1300.       if (decl_spec == NULL) {
  1301. !     new_decl_spec(¶m->decl_spec, "", 0L, DS_NONE);
  1302.       } else {
  1303.       param->decl_spec = *decl_spec;
  1304. ***************
  1305. *** 182,185 ****
  1306. --- 188,192 ----
  1307.   
  1308.       param->comment = NULL;
  1309. +     return param;
  1310.   }
  1311.   
  1312. ***************
  1313. *** 190,197 ****
  1314.   Parameter *param;
  1315.   {
  1316. !     free_decl_spec(&(param->decl_spec));
  1317.       free_declarator(param->declarator);
  1318.       if (param->comment != NULL)
  1319.       free(param->comment);
  1320.   }
  1321.   
  1322. --- 197,205 ----
  1323.   Parameter *param;
  1324.   {
  1325. !     free_decl_spec(¶m->decl_spec);
  1326.       free_declarator(param->declarator);
  1327.       if (param->comment != NULL)
  1328.       free(param->comment);
  1329. +     free(param);
  1330.   }
  1331.   
  1332. ***************
  1333. *** 213,223 ****
  1334.   Parameter *param;
  1335.   {
  1336. !     Parameter *p;
  1337. !     p = (Parameter *)xmalloc(sizeof(Parameter));
  1338. !     *p = *param;
  1339. !     
  1340. !     param_list->first = param_list->last = p;
  1341. !     p->next = NULL;
  1342.   
  1343.       param_list->begin_comment = param_list->end_comment = 0;
  1344. --- 221,226 ----
  1345.   Parameter *param;
  1346.   {
  1347. !     param_list->first = param_list->last = param;
  1348. !     param->next = NULL;
  1349.   
  1350.       param_list->begin_comment = param_list->end_comment = 0;
  1351. ***************
  1352. *** 237,241 ****
  1353.       next = p->next;
  1354.       free_parameter(p);
  1355. -     free(p);
  1356.       p = next;
  1357.       }
  1358. --- 240,243 ----
  1359. ***************
  1360. *** 245,249 ****
  1361.   }
  1362.   
  1363. ! /* Add the function parameter declaration to the list.
  1364.    */
  1365.   void
  1366. --- 247,251 ----
  1367.   }
  1368.   
  1369. ! /* Add the parameter to the function parameter list.
  1370.    */
  1371.   void
  1372. ***************
  1373. *** 252,264 ****
  1374.   Parameter *param;
  1375.   {
  1376. -     Parameter *p;
  1377. -     p = (Parameter *)xmalloc(sizeof(Parameter));
  1378. -     *p = *param;
  1379.       to->first = from->first;
  1380. !     from->last->next = p;
  1381. !     to->last = p;
  1382. !     p->next = NULL;
  1383.   }
  1384.   
  1385. --- 254,261 ----
  1386.   Parameter *param;
  1387.   {
  1388.       to->first = from->first;
  1389. !     from->last->next = param;
  1390. !     to->last = param;
  1391. !     param->next = NULL;
  1392.   }
  1393.   
  1394. ***************
  1395. *** 285,291 ****
  1396.       Declarator *declarator;
  1397.   
  1398. -     p = (Parameter *)xmalloc(sizeof(Parameter));
  1399.       declarator = new_declarator(name, name, 0L);
  1400. !     new_parameter(p, NULL, declarator);
  1401.   
  1402.       to->first = from->first;
  1403. --- 282,287 ----
  1404.       Declarator *declarator;
  1405.   
  1406.       declarator = new_declarator(name, name, 0L);
  1407. !     p = new_parameter(NULL, declarator);
  1408.   
  1409.       to->first = from->first;
  1410. ***************
  1411. *** 387,392 ****
  1412.       p = declarator->params.first;
  1413.       if (is_void_parameter(p)) {
  1414. !     if (p != NULL || ((where == FUNC_PROTO || where == FUNC_DEF) &&
  1415. !      declarator == func_declarator))
  1416.           fputs("void", outf);
  1417.       } else {
  1418. --- 383,387 ----
  1419.       p = declarator->params.first;
  1420.       if (is_void_parameter(p)) {
  1421. !     if (p != NULL)
  1422.           fputs("void", outf);
  1423.       } else {
  1424. ***************
  1425. *** 578,586 ****
  1426.   DeclSpec *decl_spec;
  1427.   {
  1428. !     if (extern_out && (decl_spec->flags & DS_STATIC) == 0) {
  1429. !     if (strstr(decl_spec->text, "extern") == NULL) {
  1430. !         fputs("extern ", outf);
  1431. !     }
  1432. !     }
  1433.       fputs(decl_spec->text, outf);
  1434.       fputc(' ', outf);
  1435. --- 573,579 ----
  1436.   DeclSpec *decl_spec;
  1437.   {
  1438. !     if (extern_out && !(decl_spec->flags & DS_STATIC) &&
  1439. !      strstr(decl_spec->text, "extern") == NULL)
  1440. !     fputs("extern ", outf);
  1441.       fputs(decl_spec->text, outf);
  1442.       fputc(' ', outf);
  1443. ***************
  1444. *** 601,604 ****
  1445. --- 594,598 ----
  1446.       return;
  1447.   
  1448. +     check_untagged(decl_spec);
  1449.       func_declarator = NULL;
  1450.       where = FUNC_OTHER;
  1451. ***************
  1452. *** 605,609 ****
  1453.       format = FMT_OTHER;
  1454.       for (d = decl_list->first; d != NULL; d = d->next) {
  1455. !     if (d->func_def == FUNC_NONE) {
  1456.           fputs(fmt[FMT_PROTO].decl_spec_prefix, stdout);
  1457.           put_decl_spec(stdout, decl_spec);
  1458. --- 599,603 ----
  1459.       format = FMT_OTHER;
  1460.       for (d = decl_list->first; d != NULL; d = d->next) {
  1461. !     if (d->func_def == FUNC_NONE || d->head->func_stack->pointer) {
  1462.           fputs(fmt[FMT_PROTO].decl_spec_prefix, stdout);
  1463.           put_decl_spec(stdout, decl_spec);
  1464. ***************
  1465. *** 614,617 ****
  1466. --- 608,644 ----
  1467.   }
  1468.   
  1469. + /* Generate a prototype for a function that uses varargs by replacing the
  1470. +  * "va_alist" parameter with an empty parameter list.
  1471. +  */
  1472. + static void
  1473. + check_varargs (declarator)
  1474. + Declarator *declarator;
  1475. + {
  1476. +     Parameter *p;
  1477. +     if ((p = declarator->params.first) != NULL && p->next == NULL &&
  1478. +     strcmp(p->declarator->name, "va_alist") == 0)
  1479. +     {
  1480. +     free_param_list(&declarator->params);
  1481. +     declarator->params.first = NULL;
  1482. +     }
  1483. + }
  1484. + /* If the parameter list is empty, then replace it with "void".
  1485. +  */
  1486. + static void
  1487. + check_void_param (declarator)
  1488. + Declarator *declarator;
  1489. + {
  1490. +     DeclSpec decl_spec;
  1491. +     Parameter *p;
  1492. +     if (declarator->params.first == NULL) {
  1493. +     new_decl_spec(&decl_spec, "void", 0L, DS_NONE);
  1494. +     p = new_parameter(&decl_spec, NULL);
  1495. +     new_param_list(&declarator->params, p);
  1496. +     }
  1497. + }
  1498.   /* If a parameter name appears in the parameter list of a traditional style
  1499.    * function definition but is not declared in the parameter declarations,
  1500. ***************
  1501. *** 646,649 ****
  1502. --- 673,678 ----
  1503.   
  1504.       func_declarator = declarator->head;
  1505. +     check_void_param(func_declarator);
  1506. +     check_varargs(func_declarator);
  1507.       set_param_decl_spec(func_declarator);
  1508.   
  1509. ***************
  1510. *** 673,676 ****
  1511. --- 702,728 ----
  1512.   }
  1513.   
  1514. + /* Output parameter declarations for old style function definition.
  1515. +  */
  1516. + static void
  1517. + put_param_decl (declarator)
  1518. + Declarator *declarator;
  1519. + {
  1520. +     Parameter *p;
  1521. +     p = declarator->params.first;
  1522. +     if (!is_void_parameter(p)) {
  1523. +     fputc('\n', cur_tmp_file());
  1524. +     put_parameter(cur_tmp_file(), p);
  1525. +     fputc(';', cur_tmp_file());
  1526. +     p = p->next;
  1527. +     while (p != NULL && strcmp(p->declarator->text, "...") != 0) {
  1528. +         fputc('\n', cur_tmp_file());
  1529. +         put_parameter(cur_tmp_file(), p);
  1530. +         fputc(';', cur_tmp_file());
  1531. +         p = p->next;
  1532. +     }
  1533. +     }
  1534. + }
  1535.   /* Generate a function definition head.
  1536.    */
  1537. ***************
  1538. *** 685,690 ****
  1539.       int comment_len, n;
  1540.   
  1541. !     /* Return if the function is already defined in the desired style. */
  1542. !     if (declarator->func_def == func_style)
  1543.       return;
  1544.   
  1545. --- 737,743 ----
  1546.       int comment_len, n;
  1547.   
  1548. !     /* Do nothing if the function is already defined in the desired style. */
  1549. !     func_declarator = declarator->head;
  1550. !     if (func_declarator->func_def == func_style)
  1551.       return;
  1552.   
  1553. ***************
  1554. *** 698,706 ****
  1555.       fread(comment, sizeof(char), comment_len, cur_tmp_file());
  1556.   
  1557. -     func_declarator = declarator->head;
  1558.       format = FMT_FUNC;
  1559. !     /* Save the text before the parameter declarations. */
  1560. !     if (func_style == FUNC_ANSI) {
  1561.       params = &func_declarator->params;
  1562.       n = (int)(params->end_comment - params->begin_comment);
  1563. --- 751,757 ----
  1564.       fread(comment, sizeof(char), comment_len, cur_tmp_file());
  1565.   
  1566.       format = FMT_FUNC;
  1567. !     if (func_declarator->func_def == FUNC_TRADITIONAL) {
  1568. !     /* Save the text before the parameter declarations. */
  1569.       params = &func_declarator->params;
  1570.       n = (int)(params->end_comment - params->begin_comment);
  1571. ***************
  1572. *** 712,729 ****
  1573.           format = FMT_FUNC_COMMENT;
  1574.       }
  1575. -     }
  1576.   
  1577. !     /* Get the parameter comments. */
  1578. !     for (p = func_declarator->params.first; p != NULL; p = p->next) {
  1579. !     n = (int)(p->declarator->end_comment - p->declarator->begin_comment);
  1580. !     if (n > 0) {
  1581. !         p->comment = xmalloc(n+1);
  1582. !         fseek(cur_tmp_file(), p->declarator->begin_comment, 0);
  1583. !         fread(p->comment, sizeof(char), n, cur_tmp_file());
  1584. !         p->comment[n] = '\0';
  1585. !         format = FMT_FUNC_COMMENT;
  1586.       }
  1587.       }
  1588.   
  1589.       set_param_decl_spec(func_declarator);
  1590.   
  1591. --- 763,781 ----
  1592.           format = FMT_FUNC_COMMENT;
  1593.       }
  1594.   
  1595. !     /* Get the parameter comments. */
  1596. !     for (p = func_declarator->params.first; p != NULL; p = p->next) {
  1597. !         n = (int)(p->declarator->end_comment - p->declarator->begin_comment);
  1598. !         if (n > 0) {
  1599. !             p->comment = xmalloc(n+1);
  1600. !             fseek(cur_tmp_file(), p->declarator->begin_comment, 0);
  1601. !             fread(p->comment, sizeof(char), n, cur_tmp_file());
  1602. !             p->comment[n] = '\0';
  1603. !             format = FMT_FUNC_COMMENT;
  1604. !         }
  1605.       }
  1606.       }
  1607.   
  1608. +     check_void_param(func_declarator);
  1609.       set_param_decl_spec(func_declarator);
  1610.   
  1611. ***************
  1612. *** 731,760 ****
  1613.        * and overwrite it with the converted function head.
  1614.        */
  1615.       fseek(cur_tmp_file(), decl_spec->begin, 0);
  1616.   
  1617. !     /* Output declarator specifiers. */
  1618. !     fputs(fmt[format].decl_spec_prefix, cur_tmp_file());
  1619. !     fputs(decl_spec->text, cur_tmp_file());
  1620. !     fputc(' ', cur_tmp_file());
  1621. !     /* Output function declarator. */
  1622. !     where = FUNC_DEF;
  1623. !     put_func_declarator(cur_tmp_file(), declarator);
  1624.   
  1625. !     if (func_style == FUNC_TRADITIONAL) {
  1626. !     /* Output traditional style parameter declarations. */
  1627. !     p = func_declarator->params.first;
  1628. !     if (!is_void_parameter(p)) {
  1629.           fputc('\n', cur_tmp_file());
  1630. !         put_parameter(cur_tmp_file(), p);
  1631. !         fputc(';', cur_tmp_file());
  1632. !         p = p->next;
  1633. !         while (p != NULL && strcmp(p->declarator->text, "...") != 0) {
  1634. !         fputc('\n', cur_tmp_file());
  1635. !         put_parameter(cur_tmp_file(), p);
  1636. !         fputc(';', cur_tmp_file());
  1637. !         p = p->next;
  1638. !         }
  1639. !     }
  1640.       }
  1641.   
  1642. --- 783,844 ----
  1643.        * and overwrite it with the converted function head.
  1644.        */
  1645. +     where = FUNC_DEF;
  1646.       fseek(cur_tmp_file(), decl_spec->begin, 0);
  1647.   
  1648. !     if (func_style == FUNC_BOTH) {
  1649. !     char *cur_func;
  1650. !     int func_len;
  1651. !     /* Save the current function definition head. */
  1652. !     func_len = (int)(cur_begin_comment() - decl_spec->begin);
  1653. !     cur_func = xmalloc(func_len);
  1654. !     fread(cur_func, sizeof(char), func_len, cur_tmp_file());
  1655. !     fseek(cur_tmp_file(), decl_spec->begin, 0);
  1656. !     fprintf(cur_tmp_file(), "%s\n\n", func_directive);
  1657. !     /* Output new style function definition head. */
  1658. !     if (func_declarator->func_def == FUNC_ANSI) {
  1659. !         fwrite(cur_func, sizeof(char), func_len, cur_tmp_file());
  1660. !     } else {
  1661. !         fputs(fmt[format].decl_spec_prefix, cur_tmp_file());
  1662. !         fputs(decl_spec->text, cur_tmp_file());
  1663. !         fputc(' ', cur_tmp_file());
  1664. !         func_style = FUNC_ANSI;
  1665. !         put_func_declarator(cur_tmp_file(), declarator);
  1666. !     }
  1667. !     fputs("\n#else\n\n", cur_tmp_file());
  1668. !     /* Output old style function definition head. */
  1669. !     if (func_declarator->func_def == FUNC_TRADITIONAL) {
  1670. !         fwrite(cur_func, sizeof(char), func_len, cur_tmp_file());
  1671. !     } else {
  1672. !         fputs(fmt[format].decl_spec_prefix, cur_tmp_file());
  1673. !         fputs(decl_spec->text, cur_tmp_file());
  1674. !         fputc(' ', cur_tmp_file());
  1675. !          format = FMT_FUNC;
  1676. !         func_style = FUNC_TRADITIONAL;
  1677. !         put_func_declarator(cur_tmp_file(), declarator);
  1678. !         put_param_decl(func_declarator);
  1679. !     }
  1680.   
  1681. !     fputs("\n#endif", cur_tmp_file());
  1682. !     if (*comment != '\n')
  1683.           fputc('\n', cur_tmp_file());
  1684. !     func_style = FUNC_BOTH;
  1685. !     free(cur_func);
  1686. !     } else {
  1687. !     /* Output declarator specifiers. */
  1688. !     fputs(fmt[format].decl_spec_prefix, cur_tmp_file());
  1689. !     fputs(decl_spec->text, cur_tmp_file());
  1690. !     fputc(' ', cur_tmp_file());
  1691. !     /* Output function declarator. */
  1692. !     put_func_declarator(cur_tmp_file(), declarator);
  1693. !     if (func_style == FUNC_TRADITIONAL)
  1694. !         put_param_decl(func_declarator);
  1695.       }
  1696.   
  1697. diff  -c2 old/semantic.h new/semantic.h
  1698. *** old/semantic.h    Wed Jun 10 21:03:08 1992
  1699. --- new/semantic.h    Sat Nov 28 23:27:48 1992
  1700. ***************
  1701. *** 1,3 ****
  1702. ! /* $Id: semantic.h 3.3 92/06/10 20:56:19 cthuang Exp $
  1703.    *
  1704.    * Declarations of semantic action routines
  1705. --- 1,3 ----
  1706. ! /* $Id: semantic.h 3.4 1992/11/29 04:27:30 cthuang Exp $
  1707.    *
  1708.    * Declarations of semantic action routines
  1709. ***************
  1710. *** 22,27 ****
  1711.   extern void add_decl_list(/*
  1712.       DeclaratorList *to, DeclaratorList *from, Declarator *declarator*/);
  1713. ! extern void new_parameter(/*
  1714. !     Parameter *param, DeclSpec *decl_spec, Declarator *declarator*/);
  1715.   extern void free_parameter(/*
  1716.       Parameter *param*/);
  1717. --- 22,27 ----
  1718.   extern void add_decl_list(/*
  1719.       DeclaratorList *to, DeclaratorList *from, Declarator *declarator*/);
  1720. ! extern Parameter *new_parameter(/*
  1721. !     DeclSpec *decl_spec, Declarator *declarator*/);
  1722.   extern void free_parameter(/*
  1723.       Parameter *param*/);
  1724. diff  -c2 old/strstr.c new/strstr.c
  1725. *** old/strstr.c    Wed Jun 10 21:03:08 1992
  1726. --- new/strstr.c    Sat Nov 28 23:27:58 1992
  1727. ***************
  1728. *** 1,3 ****
  1729. ! /* $Id: strstr.c 3.2 92/03/06 00:51:10 cthuang Exp $
  1730.    *
  1731.    * Simple implementation of the ANSI strstr() function
  1732. --- 1,3 ----
  1733. ! /* $Id: strstr.c 3.3 1992/11/29 04:27:49 cthuang Exp $
  1734.    *
  1735.    * Simple implementation of the ANSI strstr() function
  1736. ***************
  1737. *** 17,21 ****
  1738.       int keylen;
  1739.   
  1740. !     keylen = strlen(key);
  1741.       s = strchr(src, *key);
  1742.       while (s != NULL) {
  1743. --- 17,23 ----
  1744.       int keylen;
  1745.   
  1746. !     if ((keylen = strlen(key)) == 0)
  1747. !     return src;
  1748.       s = strchr(src, *key);
  1749.       while (s != NULL) {
  1750. diff  -c2 old/symbol.c new/symbol.c
  1751. *** old/symbol.c    Wed Jun 10 21:03:08 1992
  1752. --- new/symbol.c    Sat Nov 28 23:28:00 1992
  1753. ***************
  1754. *** 1,3 ****
  1755. ! /* $Id: symbol.c 3.1 92/03/03 10:43:52 cthuang Exp $
  1756.    *
  1757.    * Implements a symbol table abstract data type.
  1758. --- 1,3 ----
  1759. ! /* $Id: symbol.c 3.2 1992/11/29 04:27:49 cthuang Exp $
  1760.    *
  1761.    * Implements a symbol table abstract data type.
  1762. ***************
  1763. *** 95,99 ****
  1764.   /* If the symbol <name> does not already exist in symbol table <symtab>,
  1765.    * then add the symbol to the symbol table.
  1766. !  * Return a pointer to the symbol or NULL on an error.
  1767.    */
  1768.   Symbol *
  1769. --- 95,99 ----
  1770.   /* If the symbol <name> does not already exist in symbol table <symtab>,
  1771.    * then add the symbol to the symbol table.
  1772. !  * Return a pointer to the symbol.
  1773.    */
  1774.   Symbol *
  1775. ***************
  1776. *** 107,117 ****
  1777.   
  1778.       if ((sym = find_symbol(symtab, name)) == NULL) {
  1779. !     if ((sym = (Symbol *)xmalloc(sizeof(Symbol))) != NULL) {
  1780. !         sym->name = xstrdup(name);
  1781. !         sym->flags = flags;
  1782. !         i = hash(name);
  1783. !         sym->next = symtab->bucket[i];
  1784. !         symtab->bucket[i] = sym;
  1785. !     }
  1786.       }
  1787.       return sym;
  1788. --- 107,116 ----
  1789.   
  1790.       if ((sym = find_symbol(symtab, name)) == NULL) {
  1791. !     sym = (Symbol *)xmalloc(sizeof(Symbol));
  1792. !     sym->name = xstrdup(name);
  1793. !     sym->flags = flags;
  1794. !     i = hash(name);
  1795. !     sym->next = symtab->bucket[i];
  1796. !     symtab->bucket[i] = sym;
  1797.       }
  1798.       return sym;
  1799. diff  -c2 old/symbol.h new/symbol.h
  1800. *** old/symbol.h    Wed Jun 10 21:03:08 1992
  1801. --- new/symbol.h    Sat Nov 28 23:27:48 1992
  1802. ***************
  1803. *** 1,3 ****
  1804. ! /* $Id: symbol.h 3.3 92/03/14 11:57:48 cthuang Exp $
  1805.    *
  1806.    * A symbol table is a collection of string identifiers stored in a
  1807. --- 1,3 ----
  1808. ! /* $Id: symbol.h 3.3 1992/03/14 11:57:48 cthuang Exp $
  1809.    *
  1810.    * A symbol table is a collection of string identifiers stored in a
  1811.