home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-11-29 | 48.7 KB | 1,849 lines |
- diff -c2 old/CHANGES new/CHANGES
- *** old/CHANGES Wed Jun 10 21:03:00 1992
- --- new/CHANGES Sat Nov 28 23:18:24 1992
- ***************
- *** 1,4 ****
- --- 1,46 ----
- Version 3
-
- + 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
-
- ***************
- *** 7,11 ****
- For example, for the definition
-
- ! typedef char *caddr_t;
-
- int strlen (s)
- --- 49,53 ----
- For example, for the definition
-
- ! typedef char *caddr_t;
-
- int strlen (s)
- ***************
- *** 16,20 ****
- cproto generated the incorrect prototype
-
- ! int strlen(int s);
-
- - Added implementation of the ANSI function tmpfile() for systems that
- --- 58,62 ----
- cproto generated the incorrect prototype
-
- ! int strlen(int s);
-
- - Added implementation of the ANSI function tmpfile() for systems that
- ***************
- *** 64,68 ****
- For example, for the definition
-
- ! typedef unsigned short ushort;
-
- void test (x)
- --- 106,110 ----
- For example, for the definition
-
- ! typedef unsigned short ushort;
-
- void test (x)
- ***************
- *** 73,81 ****
- 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
- --- 115,123 ----
- 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
- diff -c2 old/config.h new/config.h
- *** old/config.h Fri Jul 03 13:37:52 1992
- --- new/config.h Sat Nov 28 23:27:44 1992
- ***************
- *** 1,3 ****
- ! /* $Id: config.h 3.4 92/07/03 13:37:48 cthuang Exp $
- *
- * cproto configuration and system dependencies
- --- 1,3 ----
- ! /* $Id: config.h 3.5 1992/11/29 04:27:30 cthuang Exp $
- *
- * cproto configuration and system dependencies
- ***************
- *** 43,47 ****
- #endif
-
- ! #if defined(__STDC__) || defined(MSDOS)
- #include <stdlib.h>
- #include <string.h>
- --- 43,47 ----
- #endif
-
- ! #if __STDC__ || defined(MSDOS)
- #include <stdlib.h>
- #include <string.h>
- diff -c2 old/cproto.1 new/cproto.1
- *** old/cproto.1 Wed Jun 10 21:03:02 1992
- --- new/cproto.1 Sat Nov 28 23:34:08 1992
- ***************
- *** 1,3 ****
- ! .\" $Id: cproto.1 3.6 92/06/10 20:55:39 cthuang Exp $
- .\"
- .de EX \"Begin example
- --- 1,3 ----
- ! .\" $Id: cproto.1 3.7 1992/11/29 04:34:05 cthuang Exp $
- .\"
- .de EX \"Begin example
- ***************
- *** 14,18 ****
- .if t .sp .5
- ..
- ! .TH CPROTO 1 "April 7, 1992"
- .SH NAME
- cproto \- generate C function prototypes and convert function definitions
- --- 14,18 ----
- .if t .sp .5
- ..
- ! .TH CPROTO 1 "October 24, 1992"
- .SH NAME
- cproto \- generate C function prototypes and convert function definitions
- ***************
- *** 31,35 ****
- Optionally,
- .B cproto
- ! also outputs declarations for any variables defined in the file.
- If no
- .I file
- --- 31,35 ----
- Optionally,
- .B cproto
- ! also outputs declarations for variables defined in the files.
- If no
- .I file
- ***************
- *** 88,98 ****
- .SH OPTIONS
- .TP
- - .B \-a
- - Convert function definitions from the old style to the ANSI C style.
- - .TP
- .B \-e
- Output the keyword
- .B extern
- ! in front of every declaration having global scope.
- .TP
- .BI \-f n
- --- 88,95 ----
- .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
- ***************
- *** 169,177 ****
- declarations as well.
- .TP
- .B \-t
- Convert function definitions from the ANSI C style to the traditional style.
- .TP
- ! .B \-v
- ! Also output declarations for variables defined in the source.
- .LP
- .nf
- --- 166,205 ----
- declarations as well.
- .TP
- + .B \-v
- + Also output declarations for variables defined in the source.
- + .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
- ***************
- *** 185,189 ****
- The format is specified by a template in the form
- .EX
- ! " int main ( a, b )"
- .EE
- but you may replace each space in this string with any number of
- --- 213,217 ----
- 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
- ***************
- *** 191,195 ****
- For example, the option
- .EX
- ! -F"int main(\\n\\ta,\\n\\tb\\n\\t)"
- .EE
- will produce
- --- 219,223 ----
- For example, the option
- .EX
- ! -F"int f(\\n\\ta,\\n\\tb\\n\\t)"
- .EE
- will produce
- ***************
- *** 201,205 ****
- .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
- --- 229,233 ----
- .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
- diff -c2 old/cproto.c new/cproto.c
- *** old/cproto.c Wed Jun 10 21:03:08 1992
- --- new/cproto.c Sat Nov 28 23:27:52 1992
- ***************
- *** 1,3 ****
- ! /* $Id: cproto.c 3.6 92/06/10 20:56:26 cthuang Exp $
- *
- * C function prototype generator and function definition converter
- --- 1,3 ----
- ! /* $Id: cproto.c 3.7 1992/11/29 04:27:49 cthuang Exp $
- *
- * C function prototype generator and function definition converter
- ***************
- *** 4,8 ****
- */
- #ifndef lint
- ! static char rcsid[] = "$Id: cproto.c 3.6 92/06/10 20:56:26 cthuang Exp $";
- #endif
- #include <stdio.h>
- --- 4,8 ----
- */
- #ifndef lint
- ! static char rcsid[] = "$Id: cproto.c 3.7 1992/11/29 04:27:49 cthuang Exp $";
- #endif
- #include <stdio.h>
- ***************
- *** 48,51 ****
- --- 48,54 ----
- boolean proto_comments = TRUE;
-
- + /* Conditional compilation directive output in front of function definitions */
- + char *func_directive = "#ifdef ANSI_FUNC";
- +
- /* Output formats for function declarators */
- FuncFormat fmt[] = {
- ***************
- *** 111,115 ****
- put_error ()
- {
- ! fprintf(stderr, "\"%s\", line %d: ", cur_file_name(), cur_line_num());
- }
-
- --- 114,118 ----
- put_error ()
- {
- ! fprintf(stderr, "\"%s\", line %u: ", cur_file_name(), cur_line_num());
- }
-
- ***************
- *** 226,255 ****
- fprintf(stderr, "usage: %s [ option ... ] [ file ... ]\n", progname);
- fputs("Options:\n", stderr);
- ! fputs(" -a Convert function definitions to ANSI style\n", stderr);
- ! fputs(" -c Omit comments in generated prototypes\n", stderr);
- ! fputs(" -e Output \"extern\" keyword before global declarations\n",
- ! stderr);
- ! fputs(" -f n Set function prototype style (0 to 4)\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\n", stderr);
- ! fputs(" -t Convert function definitions to traditional style\n",
- ! stderr);
- ! fputs(" -v Output variable declarations\n", stderr);
- ! fputs(" -m name Set name of prototype macro\n", stderr);
- ! fputs(" -d Omit prototype macro definition\n", stderr);
- ! fputs(" -P fmt Set prototype format template \" int main (a, b)\"\n",
- ! stderr);
- ! fputs(" -F fmt Set function definition format template \" int main (a, b)\"\n",
- ! stderr);
- ! fputs(" -C fmt Set format for function definition with parameter comments\n",
- ! stderr);
- ! fputs(" -D name[=value]\n", stderr);
- ! fputs(" -U name\n", stderr);
- ! fputs(" -I directory\n", stderr);
- ! fputs(" Set C preprocessor options\n", stderr);
- ! fputs(" -E cpp 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(1);
- }
- --- 229,252 ----
- 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 Omit comments in generated prototypes\n", stderr);
- ! fputs(" -e Output \"extern\" keyword before global declarations\n", stderr);
- ! fputs(" -f n Set function prototype style (0 to 4)\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\n", stderr);
- ! fputs(" -v Output variable declarations\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(1);
- }
- ***************
- *** 291,295 ****
- #ifdef CPP
- /* Allocate buffer for C preprocessor command line. */
- ! n = strlen(CPP) + 1;
- for (i = 0; i < argc; ++i) {
- n += strlen(argv[i]) + 1;
- --- 288,292 ----
- #ifdef CPP
- /* Allocate buffer for C preprocessor command line. */
- ! n = strlen(cpp) + 1;
- for (i = 0; i < argc; ++i) {
- n += strlen(argv[i]) + 1;
- ***************
- *** 300,304 ****
- #endif
-
- ! while ((c = getopt(argc, argv, "aC:cD:dE:eF:f:I:m:P:pqstU:Vv")) != EOF) {
- switch (c) {
- case 'I':
- --- 297,301 ----
- #endif
-
- ! while ((c = getopt(argc, argv, "aB:bC:cD:dE:eF:f:I:m:P:pqstU:Vv")) != EOF) {
- switch (c) {
- case 'I':
- ***************
- *** 319,322 ****
- --- 316,325 ----
- func_style = FUNC_ANSI;
- break;
- + case 'B':
- + func_directive = optarg;
- + break;
- + case 'b':
- + func_style = FUNC_BOTH;
- + break;
- case 'c':
- proto_comments = FALSE;
- ***************
- *** 429,433 ****
-
- if (proto_style == PROTO_MACRO && define_macro) {
- ! printf("#if defined(__STDC__) || defined(__cplusplus)\n");
- printf("#define %s(s) s\n", macro_name);
- printf("#else\n");
- --- 432,436 ----
-
- if (proto_style == PROTO_MACRO && define_macro) {
- ! printf("#if __STDC__ || defined(__cplusplus)\n");
- printf("#define %s(s) s\n", macro_name);
- printf("#else\n");
- diff -c2 old/cproto.h new/cproto.h
- *** old/cproto.h Wed Jun 10 21:03:08 1992
- --- new/cproto.h Sat Nov 28 23:27:46 1992
- ***************
- *** 1,3 ****
- ! /* $Id: cproto.h 3.5 92/04/11 19:27:44 cthuang Exp $
- *
- * Declarations for C function prototype generator
- --- 1,3 ----
- ! /* $Id: cproto.h 3.6 1992/11/29 04:27:30 cthuang Exp $
- *
- * Declarations for C function prototype generator
- ***************
- *** 45,48 ****
- --- 45,49 ----
- #define FUNC_TRADITIONAL 1 /* traditional style */
- #define FUNC_ANSI 2 /* ANSI style */
- + #define FUNC_BOTH 3 /* both styles */
- typedef int FuncDefStyle;
-
- ***************
- *** 56,59 ****
- --- 57,61 ----
- 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 */
- ***************
- *** 79,83 ****
- Text text;
- DeclSpec decl_spec;
- ! Parameter parameter;
- ParameterList param_list;
- Declarator *declarator;
- --- 81,85 ----
- Text text;
- DeclSpec decl_spec;
- ! Parameter *parameter;
- ParameterList param_list;
- Declarator *declarator;
- ***************
- *** 127,130 ****
- --- 129,133 ----
- extern boolean proto_comments;
- extern boolean quiet;
- + extern char *func_directive;
- extern int num_inc_dir;
- extern char *inc_dir[];
- ***************
- *** 137,141 ****
- extern void put_error();
- extern void init_parser(), process_file(), pop_file();
- ! extern char *cur_file_name();
- extern unsigned cur_line_num();
- extern FILE *cur_tmp_file();
- --- 140,144 ----
- extern void put_error();
- extern void init_parser(), process_file(), pop_file();
- ! extern char *cur_file_name(), *cur_text();
- extern unsigned cur_line_num();
- extern FILE *cur_tmp_file();
- diff -c2 old/grammar.y new/grammar.y
- *** old/grammar.y Wed Jun 10 21:03:02 1992
- --- new/grammar.y Sat Nov 28 23:27:42 1992
- ***************
- *** 1,3 ****
- ! /* $Id: grammar.y 3.6 92/06/10 20:56:07 cthuang Exp $
- *
- * yacc grammar for C function prototype generator
- --- 1,3 ----
- ! /* $Id: grammar.y 3.7 1992/11/29 04:27:30 cthuang Exp $
- *
- * yacc grammar for C function prototype generator
- ***************
- *** 46,49 ****
- --- 46,52 ----
- 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
- ***************
- *** 66,78 ****
- #define YYMAXDEPTH 150
-
- ! /* 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;
-
- ! /* Pointer to current declarator in function parameter declaration. */
- static Declarator *cur_declarator;
-
- --- 69,87 ----
- #define YYMAXDEPTH 150
-
- ! /* 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;
-
- ***************
- *** 80,88 ****
- static char buf[MAX_TEXT_SIZE];
-
- ! /* Table of typedef names */
- static SymbolTable *typedef_names;
-
- ! /* Table of type qualifiers */
- static SymbolTable *type_qualifiers;
- %}
- %%
- --- 89,114 ----
- static char buf[MAX_TEXT_SIZE];
-
- ! /* table of typedef names */
- static SymbolTable *typedef_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 */
- +
- + extern void yyerror();
- %}
- %%
- ***************
- *** 120,124 ****
- --- 146,159 ----
- 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 */
- + }
- ;
-
- ***************
- *** 130,134 ****
- | decl_specifiers init_declarator_list ';'
- {
- - check_untagged(&$1);
- if (func_params != NULL) {
- set_param_types(func_params, &$1, &$2);
- --- 165,168 ----
- ***************
- *** 227,230 ****
- --- 261,265 ----
- opt_declaration_list
- : /* empty */
- + | T_VA_DCL
- | declaration_list
- ;
- ***************
- *** 372,376 ****
- func_style == FUNC_TRADITIONAL && cur_file->convert) {
- gen_func_declarator($1);
- ! fputs(yytext, cur_file->tmp_file);
- }
- cur_declarator = $$;
- --- 407,411 ----
- func_style == FUNC_TRADITIONAL && cur_file->convert) {
- gen_func_declarator($1);
- ! fputs(cur_text(), cur_file->tmp_file);
- }
- cur_declarator = $$;
- ***************
- *** 417,420 ****
- --- 452,456 ----
- $$->text = xstrdup(buf);
- $$->begin = $1.begin;
- + $$->pointer = TRUE;
- }
- | direct_declarator
- ***************
- *** 507,515 ****
- : parameter_declaration
- {
- ! new_param_list(&$$, &$1);
- }
- | parameter_list ',' parameter_declaration
- {
- ! add_param_list(&$$, &$1, &$3);
- }
- ;
- --- 543,551 ----
- : parameter_declaration
- {
- ! new_param_list(&$$, $1);
- }
- | parameter_list ',' parameter_declaration
- {
- ! add_param_list(&$$, &$1, $3);
- }
- ;
- ***************
- *** 519,523 ****
- {
- check_untagged(&$1);
- ! new_parameter(&$$, &$1, $2);
- }
- | decl_specifiers abs_declarator
- --- 555,559 ----
- {
- check_untagged(&$1);
- ! $$ = new_parameter(&$1, $2);
- }
- | decl_specifiers abs_declarator
- ***************
- *** 524,528 ****
- {
- check_untagged(&$1);
- ! new_parameter(&$$, &$1, $2);
- }
- | decl_specifiers
- --- 560,564 ----
- {
- check_untagged(&$1);
- ! $$ = new_parameter(&$1, $2);
- }
- | decl_specifiers
- ***************
- *** 529,533 ****
- {
- check_untagged(&$1);
- ! new_parameter(&$$, &$1, NULL);
- }
- ;
- --- 565,569 ----
- {
- check_untagged(&$1);
- ! $$ = new_parameter(&$1, NULL);
- }
- ;
- ***************
- *** 628,631 ****
- --- 664,668 ----
-
- %%
- +
- #ifdef MSDOS
- #include "lex_yy.c"
- ***************
- *** 650,659 ****
- {
- static char *keywords[] = {
- ! "const", "volatile",
- #ifdef MSDOS
- "_cdecl", "_export", "_far", "_fastcall", "_fortran", "_huge",
- "_interrupt", "_loadds", "_near", "_pascal", "_saveregs", "_segment",
- "_cs", "_ds", "_es", "_ss", "_seg",
- ! "cdecl", "far", "huge", "interrupt", "near", "pascal",
- #endif
- };
- --- 687,700 ----
- {
- static char *keywords[] = {
- ! "const", "volatile", "interrupt",
- #ifdef MSDOS
- + "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",
- ! "__cs", "__ds", "__es", "__ss", "__seg",
- #endif
- };
- diff -c2 old/lex.l new/lex.l
- *** old/lex.l Wed Jun 10 21:03:02 1992
- --- new/lex.l Sat Nov 28 23:54:16 1992
- ***************
- *** 1,4 ****
- %{
- ! /* $Id: lex.l 3.7 92/06/10 20:56:04 cthuang Exp $
- *
- * Lexical analyzer for C function prototype generator
- --- 1,4 ----
- %{
- ! /* $Id: lex.l 3.8 1992/11/29 04:54:14 cthuang Exp $
- *
- * Lexical analyzer for C function prototype generator
- ***************
- *** 8,32 ****
- static int ly_count; /* number of occurances of %% */
-
- - /* 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 */
- #ifdef FLEX_SCANNER
- ! YY_BUFFER_STATE buffer; /* flex scanner state */
- #endif
- - } IncludeStack;
-
- static int inc_depth; /* include nesting level */
- static IncludeStack inc_stack[MAX_INC_DEPTH]; /* stack of included files */
- - static IncludeStack *cur_file; /* current file */
- static SymbolTable *included_files; /* files already included */
-
- static void save_text();
- static void save_text_offset();
- --- 8,21 ----
- 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 void update_line_num();
- static void save_text();
- static void save_text_offset();
- ***************
- *** 35,42 ****
- static void do_include();
-
- #ifdef yywrap
- #undef yywrap
- #endif
- - static int yywrap();
- %}
-
- --- 24,31 ----
- static void do_include();
-
- + extern void yyerror();
- #ifdef yywrap
- #undef yywrap
- #endif
- %}
-
- ***************
- *** 45,49 ****
- DIGIT [0-9]
- ID {LETTER}({LETTER}|{DIGIT})*
- ! STRING \"(\\\"|[^"\n])*\"
- QUOTED ({STRING}|\'(\\\'|[^'\n])*\'|\\.)
-
- --- 34,38 ----
- DIGIT [0-9]
- ID {LETTER}({LETTER}|{DIGIT})*
- ! STRING \"(\\\"|[^"])*\"
- QUOTED ({STRING}|\'(\\\'|[^'\n])*\'|\\.)
-
- ***************
- *** 59,66 ****
- <LEXYACC>^"%%" { save_text(); if (++ly_count >= 2) BEGIN INITIAL; }
- <LEXYACC>^"%{" { save_text(); BEGIN INITIAL; }
- ! <LEXYACC>{QUOTED}|. save_text();
- <INITIAL>^"%}" { save_text(); BEGIN LEXYACC; }
-
- <INITIAL>#{WS}* { save_text(); BEGIN CPP1; }
-
- <CPP1>define{WS}+{ID} {
- --- 48,57 ----
- <LEXYACC>^"%%" { save_text(); if (++ly_count >= 2) BEGIN INITIAL; }
- <LEXYACC>^"%{" { save_text(); BEGIN INITIAL; }
- ! <LEXYACC>{QUOTED} { save_text(); update_line_num(); }
- ! <LEXYACC>. save_text();
- <INITIAL>^"%}" { save_text(); BEGIN LEXYACC; }
-
- <INITIAL>#{WS}* { save_text(); BEGIN CPP1; }
- + <INITIAL>"??="{WS}* { save_text(); BEGIN CPP1; }
-
- <CPP1>define{WS}+{ID} {
- ***************
- *** 125,129 ****
- }
- <INITIAL>"..." { save_text(); return T_ELLIPSIS; }
- ! <INITIAL>{STRING} { save_text(); return T_STRING_LITERAL; }
-
- <INITIAL>asm { save_text(); BEGIN ASM; return T_ASM; }
- --- 116,124 ----
- }
- <INITIAL>"..." { save_text(); return T_ELLIPSIS; }
- ! <INITIAL>{STRING} {
- ! save_text();
- ! update_line_num();
- ! return T_STRING_LITERAL;
- ! }
-
- <INITIAL>asm { save_text(); BEGIN ASM; return T_ASM; }
- ***************
- *** 130,136 ****
- <ASM>"(" save_text();
- <ASM>")" { save_text(); BEGIN INITIAL; return T_ASMARG; }
- ! <ASM>{QUOTED}|. save_text();
-
- ! <INITIAL>_based[^(]*\([^)]*\) { save_text_offset(); return T_TYPE_QUALIFIER; }
-
- <INITIAL>auto { save_text_offset(); return T_AUTO; }
- --- 125,132 ----
- <ASM>"(" save_text();
- <ASM>")" { save_text(); BEGIN INITIAL; return T_ASMARG; }
- ! <ASM>{QUOTED} { save_text(); update_line_num(); }
- ! <ASM>. save_text();
-
- ! <INITIAL>__?based[^(]*\([^)]*\) { save_text_offset(); return T_TYPE_QUALIFIER; }
-
- <INITIAL>auto { save_text_offset(); return T_AUTO; }
- ***************
- *** 152,155 ****
- --- 148,152 ----
- <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>{ID} {
- ***************
- *** 167,177 ****
- * containing a ] appears between the brackets.
- */
- - int i;
- -
- save_text_offset();
- ! for (i = 0; i < yyleng; ++i) {
- ! if (yytext[i] == '\n')
- ! cur_file->line_num++;
- ! }
- return T_BRACKETS;
- }
- --- 164,174 ----
- * 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;
- }
- ***************
- *** 184,188 ****
- return T_INITIALIZER;
- }
- ! <INIT1>{QUOTED}|. save_text();
-
- <INIT2>"{" { save_text(); ++curly; }
- --- 181,186 ----
- return T_INITIALIZER;
- }
- ! <INIT1>{QUOTED} { save_text(); update_line_num(); }
- ! <INIT1>. save_text();
-
- <INIT2>"{" { save_text(); ++curly; }
- ***************
- *** 194,198 ****
- }
- }
- ! <INIT2>{QUOTED}|. save_text();
-
- <INITIAL>"{" {
- --- 192,197 ----
- }
- }
- ! <INIT2>{QUOTED} { save_text(); update_line_num(); }
- ! <INIT2>. save_text();
-
- <INITIAL>"{" {
- ***************
- *** 210,214 ****
- }
- }
- ! <CURLY>{QUOTED}|. save_text();
-
- [ \t\f]+ save_text();
- --- 209,214 ----
- }
- }
- ! <CURLY>{QUOTED} { save_text(); update_line_num(); }
- ! <CURLY>. save_text();
-
- [ \t\f]+ save_text();
- ***************
- *** 220,223 ****
- --- 220,236 ----
- %%
-
- + /* 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.
- */
- ***************
- *** 277,281 ****
- }
-
- ! /* Scan rest of preprocessor statement.
- */
- static void
- --- 290,294 ----
- }
-
- ! /* Scan rest of preprocessor directive.
- */
- static void
- ***************
- *** 282,286 ****
- get_cpp_directive ()
- {
- ! int c, lastc = '\0';
-
- while ((c = input()) != 0) {
- --- 295,301 ----
- get_cpp_directive ()
- {
- ! char c, lastc[4];
- !
- ! lastc[0] = lastc[1] = lastc[2] = lastc[3] = '\0';
-
- while ((c = input()) != 0) {
- ***************
- *** 290,294 ****
- case '\n':
- cur_file->line_num++;
- ! if (lastc != '\\') {
- BEGIN INITIAL;
- return;
- --- 305,309 ----
- case '\n':
- cur_file->line_num++;
- ! if (lastc[2] != '\\' && strcmp(lastc, "??""/") != 0) {
- BEGIN INITIAL;
- return;
- ***************
- *** 296,304 ****
- break;
- case '*':
- ! if (lastc == '/')
- get_comment();
- break;
- }
- ! lastc = c;
- }
- }
- --- 311,321 ----
- break;
- case '*':
- ! if (lastc[2] == '/')
- get_comment();
- break;
- }
- ! lastc[0] = lastc[1];
- ! lastc[1] = lastc[2];
- ! lastc[2] = c;
- }
- }
- ***************
- *** 344,347 ****
- --- 361,372 ----
- }
-
- + /* Return the text of the current lexical token.
- + */
- + char *
- + cur_text ()
- + {
- + return yytext;
- + }
- +
- #ifdef NEED_tmpfile
- /*
- ***************
- *** 356,360 ****
- tmpfile ()
- {
- ! char name[1024];
- char *tmpdir;
- FILE *f;
- --- 381,385 ----
- tmpfile ()
- {
- ! char name[MAX_TEXT_SIZE];
- char *tmpdir;
- FILE *f;
- ***************
- *** 400,405 ****
-
- #ifdef FLEX_SCANNER
- ! cur_file->buffer = yy_create_buffer(yyin, YY_BUF_SIZE);
- ! yy_switch_to_buffer(cur_file->buffer);
- #endif
-
- --- 425,430 ----
-
- #ifdef FLEX_SCANNER
- ! buffer_stack[inc_depth] = yy_create_buffer(yyin, YY_BUF_SIZE);
- ! yy_switch_to_buffer(buffer_stack[inc_depth]);
- #endif
-
- ***************
- *** 408,412 ****
- cur_file->tmp_file = tmpfile();
- if (cur_file->tmp_file == NULL) {
- ! fprintf(stderr, "%s: cannot create temporary file %s\n", progname);
- cur_file->convert = FALSE;
- }
- --- 433,437 ----
- cur_file->tmp_file = tmpfile();
- if (cur_file->tmp_file == NULL) {
- ! fprintf(stderr, "%s: cannot create temporary file\n", progname);
- cur_file->convert = FALSE;
- }
- ***************
- *** 449,456 ****
-
- if (cur_file->convert) {
- ! if (cur_file->changed) {
- ! if (yyin == stdin) {
- ! put_file(stdout);
- ! } else if ((outf = fopen(cur_file->base_name, "w")) != NULL) {
- put_file(outf);
- fclose(outf);
- --- 474,481 ----
-
- 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);
- ***************
- *** 457,461 ****
- } else {
- fprintf(stderr, "%s: cannot create file %s\n", progname,
- ! cur_file->base_name);
- }
- }
- --- 482,486 ----
- } else {
- fprintf(stderr, "%s: cannot create file %s\n", progname,
- ! cur_file->base_name);
- }
- }
- ***************
- *** 475,479 ****
-
- #ifdef FLEX_SCANNER
- ! yy_switch_to_buffer(cur_file->buffer);
- #endif
- }
- --- 500,504 ----
-
- #ifdef FLEX_SCANNER
- ! yy_switch_to_buffer(buffer_stack[inc_depth]);
- #endif
- }
- ***************
- *** 524,528 ****
- * nested include file.
- */
- ! static int
- yywrap ()
- {
- --- 549,553 ----
- * nested include file.
- */
- ! int
- yywrap ()
- {
- diff -c2 old/Makefile.bc new/Makefile.bc
- *** old/Makefile.bc Wed Jun 10 21:03:02 1992
- --- new/Makefile.bc Sat Nov 28 23:27:32 1992
- ***************
- *** 1,3 ****
- ! # $Id: makefile.bc 3.1 92/03/03 10:45:53 cthuang Exp $
- #
- # Borland C++ makefile for C prototype generator
- --- 1,3 ----
- ! # $Id: Makefile.bc 3.1 1992/03/03 10:45:53 cthuang Exp $
- #
- # Borland C++ makefile for C prototype generator
- diff -c2 old/Makefile.msc new/Makefile.msc
- *** old/Makefile.msc Wed Jun 10 21:03:02 1992
- --- new/Makefile.msc Sat Nov 28 23:27:36 1992
- ***************
- *** 1,3 ****
- ! # $Id: makefile.msc 3.3 92/06/10 20:55:56 cthuang Exp $
- #
- # Microsoft C makefile for C prototype generator
- --- 1,3 ----
- ! # $Id: Makefile.msc 3.4 1992/11/29 04:27:30 cthuang Exp $
- #
- # Microsoft C makefile for C prototype generator
- ***************
- *** 11,16 ****
- CC = cl
- CFLAGS = -AC $(DEFINES)
- ! LIBS = \c6\lib\setargv.obj
- ! LDFLAGS = /link /noe /stack:4096
-
- DIST1 = README CHANGES cproto.man
- --- 11,16 ----
- CC = cl
- CFLAGS = -AC $(DEFINES)
- ! LIBS = \c7\lib\setargv.obj
- ! LDFLAGS = /F 1000
-
- DIST1 = README CHANGES cproto.man
- diff -c2 old/Makefile.uni new/Makefile.uni
- *** old/Makefile.uni Wed Jun 10 21:03:02 1992
- --- new/Makefile.uni Sat Nov 28 23:27:36 1992
- ***************
- *** 1,3 ****
- ! # $Id: makefile.uni 3.5 92/06/10 20:56:00 cthuang Exp $
- #
- # UNIX makefile for C prototype generator
- --- 1,3 ----
- ! # $Id: Makefile.uni 3.5 1992/06/10 20:56:00 cthuang Exp $
- #
- # UNIX makefile for C prototype generator
- diff -c2 old/patchlev.h new/patchlev.h
- *** old/patchlev.h Wed Jun 10 21:03:08 1992
- --- new/patchlev.h Fri Jun 26 08:27:12 1992
- ***************
- *** 1 ****
- ! #define PATCHLEVEL 4
- --- 1 ----
- ! #define PATCHLEVEL 5
- diff -c2 old/popen.c new/popen.c
- *** old/popen.c Wed Jun 10 21:03:08 1992
- --- new/popen.c Sat Nov 28 23:27:52 1992
- ***************
- *** 1,3 ****
- ! /* $Id: popen.c 3.3 92/06/10 20:56:30 cthuang Exp $
- *
- * Imitate a UNIX pipe in MS-DOS.
- --- 1,3 ----
- ! /* $Id: popen.c 3.3 1992/06/10 20:56:30 cthuang Exp $
- *
- * Imitate a UNIX pipe in MS-DOS.
- diff -c2 old/semantic.c new/semantic.c
- *** old/semantic.c Wed Jun 10 21:03:08 1992
- --- new/semantic.c Sat Nov 28 23:27:56 1992
- ***************
- *** 1,3 ****
- ! /* $Id: semantic.c 3.6 92/06/10 20:56:35 cthuang Exp $
- *
- * Semantic actions executed by the parser of the
- --- 1,3 ----
- ! /* $Id: semantic.c 3.7 1992/11/29 04:27:49 cthuang Exp $
- *
- * Semantic actions executed by the parser of the
- ***************
- *** 11,15 ****
- static Declarator *func_declarator;
-
- ! /* Where the declarator appears */
- static int where;
-
- --- 11,18 ----
- 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;
-
- ***************
- *** 105,108 ****
- --- 108,112 ----
- d->head = d;
- d->func_stack = NULL;
- + d->pointer = FALSE;
- return d;
- }
- ***************
- *** 116,120 ****
- free(d->text);
- free(d->name);
- ! free_param_list(&(d->params));
- if (d->func_stack != NULL)
- free_declarator(d->func_stack);
- --- 120,124 ----
- free(d->text);
- free(d->name);
- ! free_param_list(&d->params);
- if (d->func_stack != NULL)
- free_declarator(d->func_stack);
- ***************
- *** 162,175 ****
- }
-
- ! /* Initialize the parameter structure.
- */
- ! void
- ! new_parameter (param, decl_spec, declarator)
- ! Parameter *param; /* parameter to be initialized */
- DeclSpec *decl_spec;
- Declarator *declarator;
- {
- if (decl_spec == NULL) {
- ! new_decl_spec(&(param->decl_spec), "", 0L, DS_JUNK);
- } else {
- param->decl_spec = *decl_spec;
- --- 166,181 ----
- }
-
- ! /* Create a new parameter structure.
- */
- ! Parameter *
- ! new_parameter (decl_spec, declarator)
- DeclSpec *decl_spec;
- Declarator *declarator;
- {
- + Parameter *param;
- + param = (Parameter *)xmalloc(sizeof(Parameter));
- +
- if (decl_spec == NULL) {
- ! new_decl_spec(¶m->decl_spec, "", 0L, DS_NONE);
- } else {
- param->decl_spec = *decl_spec;
- ***************
- *** 182,185 ****
- --- 188,192 ----
-
- param->comment = NULL;
- + return param;
- }
-
- ***************
- *** 190,197 ****
- Parameter *param;
- {
- ! free_decl_spec(&(param->decl_spec));
- free_declarator(param->declarator);
- if (param->comment != NULL)
- free(param->comment);
- }
-
- --- 197,205 ----
- Parameter *param;
- {
- ! free_decl_spec(¶m->decl_spec);
- free_declarator(param->declarator);
- if (param->comment != NULL)
- free(param->comment);
- + free(param);
- }
-
- ***************
- *** 213,223 ****
- Parameter *param;
- {
- ! Parameter *p;
- !
- ! p = (Parameter *)xmalloc(sizeof(Parameter));
- ! *p = *param;
- !
- ! param_list->first = param_list->last = p;
- ! p->next = NULL;
-
- param_list->begin_comment = param_list->end_comment = 0;
- --- 221,226 ----
- Parameter *param;
- {
- ! param_list->first = param_list->last = param;
- ! param->next = NULL;
-
- param_list->begin_comment = param_list->end_comment = 0;
- ***************
- *** 237,241 ****
- next = p->next;
- free_parameter(p);
- - free(p);
- p = next;
- }
- --- 240,243 ----
- ***************
- *** 245,249 ****
- }
-
- ! /* Add the function parameter declaration to the list.
- */
- void
- --- 247,251 ----
- }
-
- ! /* Add the parameter to the function parameter list.
- */
- void
- ***************
- *** 252,264 ****
- Parameter *param;
- {
- - Parameter *p;
- -
- - p = (Parameter *)xmalloc(sizeof(Parameter));
- - *p = *param;
- -
- to->first = from->first;
- ! from->last->next = p;
- ! to->last = p;
- ! p->next = NULL;
- }
-
- --- 254,261 ----
- Parameter *param;
- {
- to->first = from->first;
- ! from->last->next = param;
- ! to->last = param;
- ! param->next = NULL;
- }
-
- ***************
- *** 285,291 ****
- Declarator *declarator;
-
- - p = (Parameter *)xmalloc(sizeof(Parameter));
- declarator = new_declarator(name, name, 0L);
- ! new_parameter(p, NULL, declarator);
-
- to->first = from->first;
- --- 282,287 ----
- Declarator *declarator;
-
- declarator = new_declarator(name, name, 0L);
- ! p = new_parameter(NULL, declarator);
-
- to->first = from->first;
- ***************
- *** 387,392 ****
- p = declarator->params.first;
- if (is_void_parameter(p)) {
- ! if (p != NULL || ((where == FUNC_PROTO || where == FUNC_DEF) &&
- ! declarator == func_declarator))
- fputs("void", outf);
- } else {
- --- 383,387 ----
- p = declarator->params.first;
- if (is_void_parameter(p)) {
- ! if (p != NULL)
- fputs("void", outf);
- } else {
- ***************
- *** 578,586 ****
- DeclSpec *decl_spec;
- {
- ! if (extern_out && (decl_spec->flags & DS_STATIC) == 0) {
- ! if (strstr(decl_spec->text, "extern") == NULL) {
- ! fputs("extern ", outf);
- ! }
- ! }
- fputs(decl_spec->text, outf);
- fputc(' ', outf);
- --- 573,579 ----
- DeclSpec *decl_spec;
- {
- ! if (extern_out && !(decl_spec->flags & DS_STATIC) &&
- ! strstr(decl_spec->text, "extern") == NULL)
- ! fputs("extern ", outf);
- fputs(decl_spec->text, outf);
- fputc(' ', outf);
- ***************
- *** 601,604 ****
- --- 594,598 ----
- return;
-
- + check_untagged(decl_spec);
- func_declarator = NULL;
- where = FUNC_OTHER;
- ***************
- *** 605,609 ****
- format = FMT_OTHER;
- for (d = decl_list->first; d != NULL; d = d->next) {
- ! if (d->func_def == FUNC_NONE) {
- fputs(fmt[FMT_PROTO].decl_spec_prefix, stdout);
- put_decl_spec(stdout, decl_spec);
- --- 599,603 ----
- format = FMT_OTHER;
- for (d = decl_list->first; d != NULL; d = d->next) {
- ! if (d->func_def == FUNC_NONE || d->head->func_stack->pointer) {
- fputs(fmt[FMT_PROTO].decl_spec_prefix, stdout);
- put_decl_spec(stdout, decl_spec);
- ***************
- *** 614,617 ****
- --- 608,644 ----
- }
-
- + /* Generate a prototype for a function that uses varargs by replacing the
- + * "va_alist" parameter with an empty parameter list.
- + */
- + static void
- + check_varargs (declarator)
- + Declarator *declarator;
- + {
- + Parameter *p;
- +
- + if ((p = declarator->params.first) != NULL && p->next == NULL &&
- + strcmp(p->declarator->name, "va_alist") == 0)
- + {
- + free_param_list(&declarator->params);
- + declarator->params.first = NULL;
- + }
- + }
- +
- + /* 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, NULL);
- + 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,
- ***************
- *** 646,649 ****
- --- 673,678 ----
-
- func_declarator = declarator->head;
- + check_void_param(func_declarator);
- + check_varargs(func_declarator);
- set_param_decl_spec(func_declarator);
-
- ***************
- *** 673,676 ****
- --- 702,728 ----
- }
-
- + /* Output parameter declarations for old style function definition.
- + */
- + static void
- + put_param_decl (declarator)
- + Declarator *declarator;
- + {
- + Parameter *p;
- +
- + p = declarator->params.first;
- + if (!is_void_parameter(p)) {
- + fputc('\n', cur_tmp_file());
- + put_parameter(cur_tmp_file(), p);
- + fputc(';', cur_tmp_file());
- + p = p->next;
- + while (p != NULL && strcmp(p->declarator->text, "...") != 0) {
- + fputc('\n', cur_tmp_file());
- + put_parameter(cur_tmp_file(), p);
- + fputc(';', cur_tmp_file());
- + p = p->next;
- + }
- + }
- + }
- +
- /* Generate a function definition head.
- */
- ***************
- *** 685,690 ****
- int comment_len, n;
-
- ! /* Return if the function is already defined in the desired style. */
- ! if (declarator->func_def == func_style)
- return;
-
- --- 737,743 ----
- int comment_len, n;
-
- ! /* Do nothing if the function is already defined in the desired style. */
- ! func_declarator = declarator->head;
- ! if (func_declarator->func_def == func_style)
- return;
-
- ***************
- *** 698,706 ****
- fread(comment, sizeof(char), comment_len, cur_tmp_file());
-
- - func_declarator = declarator->head;
- format = FMT_FUNC;
- !
- ! /* Save the text before the parameter declarations. */
- ! if (func_style == FUNC_ANSI) {
- params = &func_declarator->params;
- n = (int)(params->end_comment - params->begin_comment);
- --- 751,757 ----
- fread(comment, sizeof(char), comment_len, cur_tmp_file());
-
- format = FMT_FUNC;
- ! if (func_declarator->func_def == FUNC_TRADITIONAL) {
- ! /* Save the text before the parameter declarations. */
- params = &func_declarator->params;
- n = (int)(params->end_comment - params->begin_comment);
- ***************
- *** 712,729 ****
- 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(n+1);
- ! fseek(cur_tmp_file(), p->declarator->begin_comment, 0);
- ! fread(p->comment, sizeof(char), n, cur_tmp_file());
- ! p->comment[n] = '\0';
- ! format = FMT_FUNC_COMMENT;
- }
- }
-
- set_param_decl_spec(func_declarator);
-
- --- 763,781 ----
- 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(n+1);
- ! fseek(cur_tmp_file(), p->declarator->begin_comment, 0);
- ! fread(p->comment, sizeof(char), n, cur_tmp_file());
- ! p->comment[n] = '\0';
- ! format = FMT_FUNC_COMMENT;
- ! }
- }
- }
-
- + check_void_param(func_declarator);
- set_param_decl_spec(func_declarator);
-
- ***************
- *** 731,760 ****
- * and overwrite it with the converted function head.
- */
- fseek(cur_tmp_file(), decl_spec->begin, 0);
-
- ! /* 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. */
- ! where = FUNC_DEF;
- ! put_func_declarator(cur_tmp_file(), declarator);
-
- ! if (func_style == FUNC_TRADITIONAL) {
- ! /* Output traditional style parameter declarations. */
- ! p = func_declarator->params.first;
- ! if (!is_void_parameter(p)) {
- fputc('\n', cur_tmp_file());
- ! put_parameter(cur_tmp_file(), p);
- ! fputc(';', cur_tmp_file());
- ! p = p->next;
- ! while (p != NULL && strcmp(p->declarator->text, "...") != 0) {
- ! fputc('\n', cur_tmp_file());
- ! put_parameter(cur_tmp_file(), p);
- ! fputc(';', cur_tmp_file());
- ! p = p->next;
- ! }
- ! }
- }
-
- --- 783,844 ----
- * 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;
- ! int func_len;
- !
- ! /* Save the current function definition head. */
- ! func_len = (int)(cur_begin_comment() - decl_spec->begin);
- ! cur_func = xmalloc(func_len);
- ! fread(cur_func, sizeof(char), func_len, cur_tmp_file());
- !
- ! 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) {
- ! 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);
- ! }
- ! fputs("\n#else\n\n", cur_tmp_file());
- !
- ! /* Output old style function definition head. */
- ! if (func_declarator->func_def == FUNC_TRADITIONAL) {
- ! 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);
- ! put_param_decl(func_declarator);
- ! }
-
- ! fputs("\n#endif", cur_tmp_file());
- ! if (*comment != '\n')
- fputc('\n', cur_tmp_file());
- ! func_style = FUNC_BOTH;
- ! 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);
- ! if (func_style == FUNC_TRADITIONAL)
- ! put_param_decl(func_declarator);
- }
-
- diff -c2 old/semantic.h new/semantic.h
- *** old/semantic.h Wed Jun 10 21:03:08 1992
- --- new/semantic.h Sat Nov 28 23:27:48 1992
- ***************
- *** 1,3 ****
- ! /* $Id: semantic.h 3.3 92/06/10 20:56:19 cthuang Exp $
- *
- * Declarations of semantic action routines
- --- 1,3 ----
- ! /* $Id: semantic.h 3.4 1992/11/29 04:27:30 cthuang Exp $
- *
- * Declarations of semantic action routines
- ***************
- *** 22,27 ****
- extern void add_decl_list(/*
- DeclaratorList *to, DeclaratorList *from, Declarator *declarator*/);
- ! extern void new_parameter(/*
- ! Parameter *param, DeclSpec *decl_spec, Declarator *declarator*/);
- extern void free_parameter(/*
- Parameter *param*/);
- --- 22,27 ----
- extern void add_decl_list(/*
- DeclaratorList *to, DeclaratorList *from, Declarator *declarator*/);
- ! extern Parameter *new_parameter(/*
- ! DeclSpec *decl_spec, Declarator *declarator*/);
- extern void free_parameter(/*
- Parameter *param*/);
- diff -c2 old/strstr.c new/strstr.c
- *** old/strstr.c Wed Jun 10 21:03:08 1992
- --- new/strstr.c Sat Nov 28 23:27:58 1992
- ***************
- *** 1,3 ****
- ! /* $Id: strstr.c 3.2 92/03/06 00:51:10 cthuang Exp $
- *
- * Simple implementation of the ANSI strstr() function
- --- 1,3 ----
- ! /* $Id: strstr.c 3.3 1992/11/29 04:27:49 cthuang Exp $
- *
- * Simple implementation of the ANSI strstr() function
- ***************
- *** 17,21 ****
- int keylen;
-
- ! keylen = strlen(key);
- s = strchr(src, *key);
- while (s != NULL) {
- --- 17,23 ----
- int keylen;
-
- ! if ((keylen = strlen(key)) == 0)
- ! return src;
- !
- s = strchr(src, *key);
- while (s != NULL) {
- diff -c2 old/symbol.c new/symbol.c
- *** old/symbol.c Wed Jun 10 21:03:08 1992
- --- new/symbol.c Sat Nov 28 23:28:00 1992
- ***************
- *** 1,3 ****
- ! /* $Id: symbol.c 3.1 92/03/03 10:43:52 cthuang Exp $
- *
- * Implements a symbol table abstract data type.
- --- 1,3 ----
- ! /* $Id: symbol.c 3.2 1992/11/29 04:27:49 cthuang Exp $
- *
- * Implements a symbol table abstract data type.
- ***************
- *** 95,99 ****
- /* 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 or NULL on an error.
- */
- Symbol *
- --- 95,99 ----
- /* 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 *
- ***************
- *** 107,117 ****
-
- if ((sym = find_symbol(symtab, name)) == NULL) {
- ! if ((sym = (Symbol *)xmalloc(sizeof(Symbol))) != NULL) {
- ! sym->name = xstrdup(name);
- ! sym->flags = flags;
- ! i = hash(name);
- ! sym->next = symtab->bucket[i];
- ! symtab->bucket[i] = sym;
- ! }
- }
- return sym;
- --- 107,116 ----
-
- if ((sym = find_symbol(symtab, name)) == NULL) {
- ! sym = (Symbol *)xmalloc(sizeof(Symbol));
- ! sym->name = xstrdup(name);
- ! sym->flags = flags;
- ! i = hash(name);
- ! sym->next = symtab->bucket[i];
- ! symtab->bucket[i] = sym;
- }
- return sym;
- diff -c2 old/symbol.h new/symbol.h
- *** old/symbol.h Wed Jun 10 21:03:08 1992
- --- new/symbol.h Sat Nov 28 23:27:48 1992
- ***************
- *** 1,3 ****
- ! /* $Id: symbol.h 3.3 92/03/14 11:57:48 cthuang Exp $
- *
- * A symbol table is a collection of string identifiers stored in a
- --- 1,3 ----
- ! /* $Id: symbol.h 3.3 1992/03/14 11:57:48 cthuang Exp $
- *
- * A symbol table is a collection of string identifiers stored in a
-