home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-05-30 | 31.4 KB | 1,179 lines |
- diff -c2 old/CHANGES new/CHANGES
- *** old/CHANGES Tue Dec 01 21:03:42 1992
- --- new/CHANGES Tue May 25 21:11:18 1993
- ***************
- *** 1,4 ****
- --- 1,28 ----
- Version 3
-
- + Patchlevel 7
- +
- + - Fix: The processing of string literals is now more robust.
- +
- + - Removed the -f4 option which generated prototypes like
- +
- + int main P_((int argc, char **argv));
- +
- + Use the -m option now to put a guard macro around the prototype
- + parameter list. Use the -m option together with -f3 (which is the
- + default) to produce the same output as the old -f4 option. The option
- + to set the guard macro name is now -M.
- +
- + - Comments in prototype parameter lists are now disabled by default.
- + Use the -c option now to output these comments.
- +
- + - Can now process #include directives in which the file is specified with
- + a #define macro.
- +
- + - Now does not convert function definitions that take the formal
- + parameter va_alist from <varargs.h>.
- +
- + - Now recognizes the GNU C modifiers __const and __inline__.
- +
- Patchlevel 6
-
- diff -c2 old/config.h new/config.h
- *** old/config.h Sat Nov 28 23:27:44 1992
- --- new/config.h Tue May 25 21:48:48 1993
- ***************
- *** 1,3 ****
- ! /* $Id: config.h 3.5 1992/11/29 04:27:30 cthuang Exp $
- *
- * cproto configuration and system dependencies
- --- 1,3 ----
- ! /* $Id: config.h 3.6 1993/05/26 01:48:42 cthuang Exp $
- *
- * cproto configuration and system dependencies
- ***************
- *** 4,8 ****
- */
-
- ! /* Borland C predefines __MSDOS__ */
- #ifdef __MSDOS__
- #ifndef MSDOS
- --- 4,8 ----
- */
-
- ! /* Borland C++ for MS-DOS predefines __MSDOS__ */
- #ifdef __MSDOS__
- #ifndef MSDOS
- ***************
- *** 11,17 ****
- --- 11,29 ----
- #endif
-
- + /* Borland C++ for OS/2 predefines __OS2__ */
- + #ifdef __OS2__
- + #ifndef OS2
- + #define OS2
- + #endif
- + #endif
- +
- /* Turbo C preprocessor */
- #ifdef TURBO_CPP
- #define CPP "cpp -P-"
- + #else
- + #ifdef OS2
- + #define popen _popen
- + #define pclose _pclose
- + #endif
- #endif
-
- ***************
- *** 43,47 ****
- #endif
-
- ! #if __STDC__ || defined(MSDOS)
- #include <stdlib.h>
- #include <string.h>
- --- 55,59 ----
- #endif
-
- ! #if __STDC__ || defined(MSDOS) || defined(OS2)
- #include <stdlib.h>
- #include <string.h>
- diff -c2 old/cproto.1 new/cproto.1
- *** old/cproto.1 Sat Nov 28 23:34:08 1992
- --- new/cproto.1 Tue May 25 21:36:04 1993
- ***************
- *** 1,3 ****
- ! .\" $Id: cproto.1 3.7 1992/11/29 04:34:05 cthuang Exp $
- .\"
- .de EX \"Begin example
- --- 1,3 ----
- ! .\" $Id: cproto.1 3.8 1993/05/26 01:34:15 cthuang Exp $
- .\"
- .de EX \"Begin example
- ***************
- *** 14,18 ****
- .if t .sp .5
- ..
- ! .TH CPROTO 1 "October 24, 1992"
- .SH NAME
- cproto \- generate C function prototypes and convert function definitions
- --- 14,18 ----
- .if t .sp .5
- ..
- ! .TH CPROTO 1 "May 24, 1993"
- .SH NAME
- cproto \- generate C function prototypes and convert function definitions
- ***************
- *** 96,100 ****
- Set the style of generated function prototypes where
- .I n
- ! is a number from 0 to 4.
- For example, consider the function definition
- .EX
- --- 96,100 ----
- Set the style of generated function prototypes where
- .I n
- ! is a number from 0 to 3.
- For example, consider the function definition
- .EX
- ***************
- *** 119,123 ****
- int main(int argc, char *argv[]);
- .EE
- ! A value of 4 produces prototypes guarded by a macro:
- .EX
- int main P_((int argc, char *argv[]));
- --- 119,131 ----
- int main(int argc, char *argv[]);
- .EE
- ! .TP
- ! .B \-c
- ! The parameter comments in the prototypes generated by
- ! the \-f1 and \-f2 options are omitted by default.
- ! Use this option to enable the output of these comments.
- ! .TP
- ! .B \-m
- ! Put a macro around the parameter list of every generated prototype.
- ! For example:
- .EX
- int main P_((int argc, char *argv[]));
- ***************
- *** 124,139 ****
- .EE
- .TP
- ! .B \-c
- ! Omit the parameter comments in the prototypes generated by
- ! the \-f1 and \-f2 options.
- ! This option also omits the comments naming the source files from which
- ! the prototypes were generated.
- ! .TP
- ! .BI \-m name
- ! Set the name of the macro used to guard prototypes when option \-f4 is selected.
- The default is "P_".
- .TP
- .B \-d
- ! Omit the definition of the prototype macro named by the \-m option.
- .TP
- .B \-p
- --- 132,142 ----
- .EE
- .TP
- ! .BI \-M name
- ! Set the name of the macro used to surround prototype parameter lists
- ! when option \-m is selected.
- The default is "P_".
- .TP
- .B \-d
- ! Omit the definition of the prototype macro used by the \-m option.
- .TP
- .B \-p
- ***************
- *** 256,259 ****
- --- 259,264 ----
- The environment variable CPROTO is scanned for
- a list of options in the same format as the command line options.
- + Options given on the command line override any corresponding
- + environment option.
- .SH BUGS
- If an untagged struct, union or enum declaration appears in
- diff -c2 old/cproto.c new/cproto.c
- *** old/cproto.c Sat Nov 28 23:27:52 1992
- --- new/cproto.c Tue May 25 21:36:46 1993
- ***************
- *** 1,3 ****
- ! /* $Id: cproto.c 3.7 1992/11/29 04:27:49 cthuang Exp $
- *
- * C function prototype generator and function definition converter
- --- 1,3 ----
- ! /* $Id: cproto.c 3.8 1993/05/26 01:36:41 cthuang Exp $
- *
- * C function prototype generator and function definition converter
- ***************
- *** 4,8 ****
- */
- #ifndef lint
- ! static char rcsid[] = "$Id: cproto.c 3.7 1992/11/29 04:27:49 cthuang Exp $";
- #endif
- #include <stdio.h>
- --- 4,8 ----
- */
- #ifndef lint
- ! static char rcsid[] = "$Id: cproto.c 3.8 1993/05/26 01:36:41 cthuang Exp $";
- #endif
- #include <stdio.h>
- ***************
- *** 39,42 ****
- --- 39,45 ----
- FuncDefStyle func_style = FUNC_NONE;
-
- + /* If TRUE, put guard macro around prototype parameters */
- + boolean proto_macro = FALSE;
- +
- /* Name of macro to guard prototypes */
- char *macro_name = "P_";
- ***************
- *** 46,50 ****
-
- /* If TRUE, output comments in prototypes */
- ! boolean proto_comments = TRUE;
-
- /* Conditional compilation directive output in front of function definitions */
- --- 49,56 ----
-
- /* If TRUE, output comments in prototypes */
- ! boolean proto_comments = FALSE;
- !
- ! /* If TRUE, output comments naming source files */
- ! boolean file_comments = TRUE;
-
- /* Conditional compilation directive output in front of function definitions */
- ***************
- *** 231,237 ****
- 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);
- --- 237,243 ----
- fputs(" -a, -t Convert function definitions to ANSI or traditional style\n", stderr);
- fputs(" -b Rewrite function definitions in both styles\n", stderr);
- ! fputs(" -c Enable comments in prototype parameters\n", stderr);
- fputs(" -e Output \"extern\" keyword before global declarations\n", stderr);
- ! fputs(" -f n Set function prototype style (0 to 3)\n", stderr);
- fputs(" -p Disable formal parameter promotion\n", stderr);
- fputs(" -q Disable include file read failure messages\n", stderr);
- ***************
- *** 238,242 ****
- 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);
- --- 244,249 ----
- fputs(" -s Output static declarations\n", stderr);
- fputs(" -v Output variable declarations\n", stderr);
- ! fputs(" -m Put macro around prototype parameters\n", stderr);
- ! fputs(" -M name Set name of prototype macro\n", stderr);
- fputs(" -d Omit prototype macro definition\n", stderr);
- fputs(" -P template Set prototype format template \" int f (a, b)\"\n", stderr);
- ***************
- *** 297,301 ****
- #endif
-
- ! while ((c = getopt(argc, argv, "aB:bC:cD:dE:eF:f:I:m:P:pqstU:Vv")) != EOF) {
- switch (c) {
- case 'I':
- --- 304,308 ----
- #endif
-
- ! while ((c = getopt(argc, argv, "aB:bC:cD:dE:eF:f:I:mM:P:pqstU:Vv")) != EOF) {
- switch (c) {
- case 'I':
- ***************
- *** 323,327 ****
- break;
- case 'c':
- ! proto_comments = FALSE;
- break;
- case 'd':
- --- 330,334 ----
- break;
- case 'c':
- ! proto_comments = TRUE;
- break;
- case 'd':
- ***************
- *** 387,394 ****
- case 'f':
- proto_style = atoi(optarg);
- ! if (proto_style < 0 || proto_style > PROTO_MACRO)
- usage();
- break;
- case 'm':
- macro_name = optarg;
- break;
- --- 394,404 ----
- case 'f':
- proto_style = atoi(optarg);
- ! if (proto_style < 0 || proto_style > PROTO_ANSI)
- usage();
- break;
- case 'm':
- + proto_macro = TRUE;
- + break;
- + case 'M':
- macro_name = optarg;
- break;
- ***************
- *** 431,435 ****
- process_options(&argc, &argv);
-
- ! if (proto_style == PROTO_MACRO && define_macro) {
- printf("#if __STDC__ || defined(__cplusplus)\n");
- printf("#define %s(s) s\n", macro_name);
- --- 441,445 ----
- process_options(&argc, &argv);
-
- ! if (proto_macro && define_macro) {
- printf("#if __STDC__ || defined(__cplusplus)\n");
- printf("#define %s(s) s\n", macro_name);
- ***************
- *** 444,448 ****
- proto_style = PROTO_NONE;
- variables_out = FALSE;
- ! proto_comments = FALSE;
- }
- process_file(stdin, "stdin");
- --- 454,458 ----
- proto_style = PROTO_NONE;
- variables_out = FALSE;
- ! file_comments = FALSE;
- }
- process_file(stdin, "stdin");
- ***************
- *** 484,488 ****
- }
-
- ! if (proto_style == PROTO_MACRO && define_macro) {
- printf("\n#undef %s\n", macro_name);
- }
- --- 494,498 ----
- }
-
- ! if (proto_macro && define_macro) {
- printf("\n#undef %s\n", macro_name);
- }
- diff -c2 old/cproto.h new/cproto.h
- *** old/cproto.h Sat Nov 28 23:27:46 1992
- --- new/cproto.h Tue May 25 21:36:26 1993
- ***************
- *** 1,3 ****
- ! /* $Id: cproto.h 3.6 1992/11/29 04:27:30 cthuang Exp $
- *
- * Declarations for C function prototype generator
- --- 1,3 ----
- ! /* $Id: cproto.h 3.7 1993/05/26 01:36:04 cthuang Exp $
- *
- * Declarations for C function prototype generator
- ***************
- *** 92,96 ****
- #define PROTO_ABSTRACT 2 /* comment out parameter names */
- #define PROTO_ANSI 3 /* ANSI C prototype */
- - #define PROTO_MACRO 4 /* macro around parameters */
- typedef int PrototypeStyle;
-
- --- 92,95 ----
- ***************
- *** 125,131 ****
- --- 124,132 ----
- extern PrototypeStyle proto_style;
- extern FuncDefStyle func_style;
- + extern boolean proto_macro;
- extern boolean define_macro;
- extern char *macro_name;
- extern boolean proto_comments;
- + extern boolean file_comments;
- extern boolean quiet;
- extern char *func_directive;
- diff -c2 old/grammar.y new/grammar.y
- *** old/grammar.y Sat Nov 28 23:27:42 1992
- --- new/grammar.y Tue May 25 21:48:44 1993
- ***************
- *** 1,3 ****
- ! /* $Id: grammar.y 3.7 1992/11/29 04:27:30 cthuang Exp $
- *
- * yacc grammar for C function prototype generator
- --- 1,3 ----
- ! /* $Id: grammar.y 3.8 1993/05/26 01:48:42 cthuang Exp $
- *
- * yacc grammar for C function prototype generator
- ***************
- *** 8,12 ****
- %token <text> '(' '*'
- /* identifiers that are not reserved words */
- ! T_IDENTIFIER T_TYPEDEF_NAME
-
- /* storage class */
- --- 8,12 ----
- %token <text> '(' '*'
- /* identifiers that are not reserved words */
- ! T_IDENTIFIER T_TYPEDEF_NAME T_DEFINE_NAME
-
- /* storage class */
- ***************
- *** 92,95 ****
- --- 92,98 ----
- static SymbolTable *typedef_names;
-
- + /* table of define names */
- + static SymbolTable *define_names;
- +
- /* table of type qualifiers */
- static SymbolTable *type_qualifiers;
- ***************
- *** 196,200 ****
- if (strcmp($1->text, $1->name) != 0)
- flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
- ! new_symbol(typedef_names, $1->name, flags);
- free_declarator($1);
- }
- --- 199,203 ----
- if (strcmp($1->text, $1->name) != 0)
- flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
- ! new_symbol(typedef_names, $1->name, NULL, flags);
- free_declarator($1);
- }
- ***************
- *** 205,209 ****
- if (strcmp($3->text, $3->name) != 0)
- flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
- ! new_symbol(typedef_names, $3->name, flags);
- free_declarator($3);
- }
- --- 208,212 ----
- if (strcmp($3->text, $3->name) != 0)
- flags &= ~(DS_CHAR | DS_SHORT | DS_FLOAT);
- ! new_symbol(typedef_names, $3->name, NULL, flags);
- free_declarator($3);
- }
- ***************
- *** 346,349 ****
- --- 349,359 ----
- new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
- }
- + | T_TYPEDEF_NAME
- + {
- + Symbol *s;
- + s = find_symbol(typedef_names, $1.text);
- + if (s != NULL)
- + new_decl_spec(&$$, $1.text, $1.begin, s->flags);
- + }
- | struct_or_union_specifier
- | enum_specifier
- ***************
- *** 355,367 ****
- new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
- }
- ! | T_TYPEDEF_NAME
- {
- ! /* A typedef name is actually a type specifier, but since the
- ! * typedef symbol table also stores #define names, this production
- ! * is here so the <pointer> nonterminal will scan #define names.
- */
- Symbol *s;
- ! s = find_symbol(typedef_names, $1.text);
- ! new_decl_spec(&$$, $1.text, $1.begin, s->flags);
- }
- ;
- --- 365,377 ----
- new_decl_spec(&$$, $1.text, $1.begin, DS_NONE);
- }
- ! | T_DEFINE_NAME
- {
- ! /* This rule allows the <pointer> nonterminal to scan #define
- ! * names as if they were type modifiers.
- */
- Symbol *s;
- ! s = find_symbol(define_names, $1.text);
- ! if (s != NULL)
- ! new_decl_spec(&$$, $1.text, $1.begin, s->flags);
- }
- ;
- ***************
- *** 665,669 ****
- %%
-
- ! #ifdef MSDOS
- #include "lex_yy.c"
- #else
- --- 675,679 ----
- %%
-
- ! #if defined(MSDOS) || defined(OS2)
- #include "lex_yy.c"
- #else
- ***************
- *** 688,692 ****
- static char *keywords[] = {
- "const", "volatile", "interrupt",
- ! #ifdef MSDOS
- "cdecl", "far", "huge", "near", "pascal",
- "_cdecl", "_export", "_far", "_fastcall", "_fortran", "_huge",
- --- 698,702 ----
- static char *keywords[] = {
- "const", "volatile", "interrupt",
- ! #if defined(MSDOS) || defined(OS2)
- "cdecl", "far", "huge", "near", "pascal",
- "_cdecl", "_export", "_far", "_fastcall", "_fortran", "_huge",
- ***************
- *** 696,700 ****
- "__inline", "__interrupt", "__loadds", "__near", "__pascal",
- "__saveregs", "__segment", "__stdcall", "__syscall",
- ! "__cs", "__ds", "__es", "__ss", "__seg",
- #endif
- };
- --- 706,714 ----
- "__inline", "__interrupt", "__loadds", "__near", "__pascal",
- "__saveregs", "__segment", "__stdcall", "__syscall",
- ! #ifdef OS2
- ! "__far16",
- ! #endif
- ! #else
- ! "__const", "__inline__",
- #endif
- };
- ***************
- *** 704,708 ****
- type_qualifiers = new_symbol_table();
- for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
- ! new_symbol(type_qualifiers, keywords[i], DS_NONE);
- }
- }
- --- 718,722 ----
- type_qualifiers = new_symbol_table();
- for (i = 0; i < sizeof(keywords)/sizeof(keywords[0]); ++i) {
- ! new_symbol(type_qualifiers, keywords[i], NULL, DS_NONE);
- }
- }
- ***************
- *** 725,729 ****
- if (*s == 'l' || *s == 'y')
- BEGIN LEXYACC;
- ! #ifdef MSDOS
- if (*s == 'L' || *s == 'Y')
- BEGIN LEXYACC;
- --- 739,743 ----
- if (*s == 'l' || *s == 'y')
- BEGIN LEXYACC;
- ! #if defined(MSDOS) || defined(OS2)
- if (*s == 'L' || *s == 'Y')
- BEGIN LEXYACC;
- ***************
- *** 734,737 ****
- --- 748,752 ----
- included_files = new_symbol_table();
- typedef_names = new_symbol_table();
- + define_names = new_symbol_table();
- inc_depth = -1;
- curly = 0;
- ***************
- *** 740,746 ****
- yyin = infile;
- include_file(name, func_style != FUNC_NONE);
- ! if (proto_comments)
- printf("/* %s */\n", cur_file_name());
- yyparse();
- free_symbol_table(typedef_names);
- free_symbol_table(included_files);
- --- 755,762 ----
- yyin = infile;
- include_file(name, func_style != FUNC_NONE);
- ! if (file_comments)
- printf("/* %s */\n", cur_file_name());
- yyparse();
- + free_symbol_table(define_names);
- free_symbol_table(typedef_names);
- free_symbol_table(included_files);
- diff -c2 old/lex.l new/lex.l
- *** old/lex.l Tue Dec 01 21:04:42 1992
- --- new/lex.l Tue May 25 21:36:16 1993
- ***************
- *** 1,4 ****
- %{
- ! /* $Id: lex.l 3.9 1992/12/02 02:04:35 cthuang Exp $
- *
- * Lexical analyzer for C function prototype generator
- --- 1,4 ----
- %{
- ! /* $Id: lex.l 3.10 1993/05/26 01:36:04 cthuang Exp $
- *
- * Lexical analyzer for C function prototype generator
- ***************
- *** 34,38 ****
- DIGIT [0-9]
- ID {LETTER}({LETTER}|{DIGIT})*
- ! STRING \"(\\\"|[^"])*\"
- QUOTED ({STRING}|\'(\\\'|[^'\n])*\'|\\.)
-
- --- 34,38 ----
- DIGIT [0-9]
- ID {LETTER}({LETTER}|{DIGIT})*
- ! STRING \"(\\.|\\\n|[^"\\])*\"
- QUOTED ({STRING}|\'(\\\'|[^'\n])*\'|\\.)
-
- ***************
- *** 56,76 ****
-
- <CPP1>define{WS}+{ID} {
- ! save_text();
- ! sscanf(yytext, "define %s", buf);
- ! get_cpp_directive();
- ! new_symbol(typedef_names, buf, DS_EXTERN);
- ! }
-
- - <CPP1>include{WS}*\"[^"]+\" {
- save_text();
- ! sscanf(yytext, "include \"%[^\"]\"", buf);
- ! get_cpp_directive();
- ! do_include(buf, FALSE);
- }
- ! <CPP1>include{WS}*\<[^>]+\> {
- save_text();
- ! sscanf(yytext, "include <%[^>]>", buf);
- ! get_cpp_directive();
- ! do_include(buf, TRUE);
- }
-
- --- 56,81 ----
-
- <CPP1>define{WS}+{ID} {
- ! char name[MAX_TEXT_SIZE], value[MAX_TEXT_SIZE];
-
- save_text();
- ! sscanf(yytext, "define %s", name);
- ! get_cpp_directive(buf, sizeof(buf));
- ! sscanf(buf, "%s", value);
- ! new_symbol(define_names, name, value, DS_NONE);
- }
- !
- ! <CPP1>include{WS}* {
- save_text();
- ! get_cpp_directive(buf, sizeof(buf));
- ! if (buf[0] != '"' && buf[0] != '<') {
- ! Symbol *sym = find_symbol(define_names, buf);
- ! if (sym != NULL && sym->value != NULL) {
- ! strcpy(buf, sym->value);
- ! } else {
- ! buf[0] = '\0';
- ! }
- ! }
- ! if (buf[0] != '\0')
- ! do_include(buf);
- }
-
- ***************
- *** 96,100 ****
- }
-
- ! <CPP1>. { save_text(); get_cpp_directive(); }
-
- <INITIAL>"(" { save_text_offset(); return '('; }
- --- 101,105 ----
- }
-
- ! <CPP1>. { save_text(); get_cpp_directive(NULL, 0); }
-
- <INITIAL>"(" { save_text_offset(); return '('; }
- ***************
- *** 156,159 ****
- --- 161,166 ----
- else if (find_symbol(typedef_names, yytext) != NULL)
- return T_TYPEDEF_NAME;
- + else if (find_symbol(define_names, yytext) != NULL)
- + return T_DEFINE_NAME;
- else
- return T_IDENTIFIER;
- ***************
- *** 290,302 ****
- }
-
- ! /* Scan rest of preprocessor directive.
- */
- static void
- ! get_cpp_directive ()
- {
- - static char cont_trigraph[] = { '?', '?', '/', '\0' };
- char c, lastc[4];
-
- lastc[0] = lastc[1] = lastc[2] = lastc[3] = '\0';
-
- while ((c = input()) != 0) {
- --- 297,313 ----
- }
-
- ! /* Scan rest of preprocessor directive. If <dest> is not NULL, then store
- ! * the text in the buffer pointed to by <dest> having size <n>.
- */
- static void
- ! get_cpp_directive (dest, n)
- ! char *dest; /* buffer to store directive text */
- ! unsigned n; /* size of buffer to store directive text */
- {
- char c, lastc[4];
-
- lastc[0] = lastc[1] = lastc[2] = lastc[3] = '\0';
- + if (dest != NULL)
- + *dest = '\0';
-
- while ((c = input()) != 0) {
- ***************
- *** 303,310 ****
- if (cur_file->convert)
- fputc(c, cur_file->tmp_file);
- switch (c) {
- case '\n':
- cur_file->line_num++;
- ! if (lastc[2] != '\\' && strcmp(lastc, cont_trigraph) != 0) {
- BEGIN INITIAL;
- return;
- --- 314,322 ----
- if (cur_file->convert)
- fputc(c, cur_file->tmp_file);
- +
- switch (c) {
- case '\n':
- cur_file->line_num++;
- ! if (lastc[2] != '\\' && strcmp(lastc, "?\?/") != 0) {
- BEGIN INITIAL;
- return;
- ***************
- *** 319,322 ****
- --- 331,340 ----
- lastc[1] = lastc[2];
- lastc[2] = c;
- +
- + if (dest != NULL && n > 1) {
- + *dest++ = c;
- + *dest = '\0';
- + --n;
- + }
- }
- }
- ***************
- *** 509,518 ****
- */
- static void
- ! do_include (filename, stdinc)
- ! char *filename; /* file to include */
- ! boolean stdinc; /* TRUE if file name specified with angle brackets */
- {
- ! char path[MAX_TEXT_SIZE];
- int i;
- FILE *fp;
-
- --- 527,538 ----
- */
- static void
- ! do_include (file_spec)
- ! char *file_spec; /* path surrounded by "" or <> */
- {
- ! int stdinc; /* 1 = path surrounded by <> */
- ! char file[MAX_TEXT_SIZE], path[MAX_TEXT_SIZE];
- ! char match, *s;
- int i;
- + unsigned n;
- FILE *fp;
-
- ***************
- *** 523,536 ****
- }
-
- ! sprintf(path, stdinc ? "<%s>" : "\"%s\"", filename);
- if (find_symbol(included_files, path) != NULL)
- return;
- ! new_symbol(included_files, path, 0);
-
- for (i = stdinc != 0; i < num_inc_dir; ++i) {
- if (strlen(inc_dir[i]) == 0) {
- ! strcpy(path, filename);
- } else {
- ! sprintf(path, "%s/%s", inc_dir[i], filename);
- }
- if ((fp = fopen(path, "r")) != NULL) {
- --- 543,571 ----
- }
-
- ! if (file_spec[0] == '"') {
- ! match = '"';
- ! stdinc = 0;
- ! } else if (file_spec[0] == '<') {
- ! match = '>';
- ! stdinc = 1;
- ! } else {
- ! return;
- ! }
- ! s = strchr(file_spec+1, match);
- ! n = (s != NULL) ? (unsigned)(s - file_spec - 1) : 0;
- ! strncpy(file, file_spec+1, n);
- ! file[n] = '\0';
- !
- ! /* Do nothing if the file was already included. */
- ! sprintf(path, stdinc ? "<%s>" : "\"%s\"", file);
- if (find_symbol(included_files, path) != NULL)
- return;
- ! new_symbol(included_files, path, NULL, DS_NONE);
-
- for (i = stdinc != 0; i < num_inc_dir; ++i) {
- if (strlen(inc_dir[i]) == 0) {
- ! strcpy(path, file);
- } else {
- ! sprintf(path, "%s/%s", inc_dir[i], file);
- }
- if ((fp = fopen(path, "r")) != NULL) {
- ***************
- *** 543,547 ****
- if (!quiet) {
- put_error();
- ! fprintf(stderr, "cannot read file %s\n", filename);
- }
- }
- --- 578,582 ----
- if (!quiet) {
- put_error();
- ! fprintf(stderr, "cannot read file %s\n", file_spec);
- }
- }
- diff -c2 old/Makefile.bc new/Makefile.bc
- *** old/Makefile.bc Sat Nov 28 23:27:32 1992
- --- new/Makefile.bc Tue May 25 21:36:04 1993
- ***************
- *** 1,3 ****
- ! # $Id: Makefile.bc 3.1 1992/03/03 10:45:53 cthuang Exp $
- #
- # Borland C++ makefile for C prototype generator
- --- 1,3 ----
- ! # $Id: Makefile.bc 3.2 1993/05/26 01:34:15 cthuang Exp $
- #
- # Borland C++ makefile for C prototype generator
- ***************
- *** 10,14 ****
- YACC = yacc
- CC = bcc
- ! CFLAGS = -mc $(DEFINES)
- LIBS = \bc\lib\wildargs.obj
-
- --- 10,14 ----
- YACC = yacc
- CC = bcc
- ! CFLAGS = -mc $(DEFINES) -w-pin -w-pro
- LIBS = \bc\lib\wildargs.obj
-
- ***************
- *** 50,65 ****
-
- shar:
- - rmcr $(DIST1) $(DIST2)
- - rmcr $(DIST3) $(DIST4)
- shar $(DIST1) $(DIST2) >cproto.sh1
- shar $(DIST3) $(DIST4) >cproto.sh2
-
- - inscr:
- - inscr $(DIST1) $(DIST2)
- - inscr $(DIST3) $(DIST4)
- -
- # DO NOT DELETE THIS LINE -- make depend depends on it.
-
- ! cproto.obj: config.h cproto.h symbol.h
- popen.obj: config.h cproto.h
- semantic.obj: config.h cproto.h symbol.h semantic.h
- --- 50,59 ----
-
- shar:
- shar $(DIST1) $(DIST2) >cproto.sh1
- shar $(DIST3) $(DIST4) >cproto.sh2
-
- # DO NOT DELETE THIS LINE -- make depend depends on it.
-
- ! cproto.obj: config.h cproto.h
- popen.obj: config.h cproto.h
- semantic.obj: config.h cproto.h symbol.h semantic.h
- diff -c2 old/Makefile.msc new/Makefile.msc
- *** old/Makefile.msc Sat Nov 28 23:27:36 1992
- --- new/Makefile.msc Tue May 25 21:36:12 1993
- ***************
- *** 1,3 ****
- ! # $Id: Makefile.msc 3.4 1992/11/29 04:27:30 cthuang Exp $
- #
- # Microsoft C makefile for C prototype generator
- --- 1,3 ----
- ! # $Id: Makefile.msc 3.5 1993/05/26 01:36:04 cthuang Exp $
- #
- # Microsoft C makefile for C prototype generator
- ***************
- *** 51,66 ****
-
- shar:
- - rmcr $(DIST1) $(DIST2)
- - rmcr $(DIST3) $(DIST4)
- shar $(DIST1) $(DIST2) >cproto.sh1
- shar $(DIST3) $(DIST4) >cproto.sh2
-
- - inscr:
- - inscr $(DIST1) $(DIST2)
- - inscr $(DIST3) $(DIST4)
- -
- # DO NOT DELETE THIS LINE -- make depend depends on it.
-
- ! cproto.obj: config.h cproto.h symbol.h
- popen.obj: config.h cproto.h
- semantic.obj: config.h cproto.h symbol.h semantic.h
- --- 51,60 ----
-
- shar:
- shar $(DIST1) $(DIST2) >cproto.sh1
- shar $(DIST3) $(DIST4) >cproto.sh2
-
- # DO NOT DELETE THIS LINE -- make depend depends on it.
-
- ! cproto.obj: config.h cproto.h
- popen.obj: config.h cproto.h
- semantic.obj: config.h cproto.h symbol.h semantic.h
- diff -c2 old/Makefile.uni new/Makefile.uni
- *** old/Makefile.uni Sat Nov 28 23:27:36 1992
- --- new/Makefile.uni Tue May 25 21:36:12 1993
- ***************
- *** 1,3 ****
- ! # $Id: Makefile.uni 3.5 1992/06/10 20:56:00 cthuang Exp $
- #
- # UNIX makefile for C prototype generator
- --- 1,3 ----
- ! # $Id: Makefile.uni 3.6 1993/05/26 01:34:15 cthuang Exp $
- #
- # UNIX makefile for C prototype generator
- ***************
- *** 47,51 ****
- # DO NOT DELETE THIS LINE -- make depend depends on it.
-
- ! cproto.o: config.h cproto.h symbol.h
- semantic.o: config.h cproto.h symbol.h semantic.h
- strstr.o: config.h
- --- 47,51 ----
- # DO NOT DELETE THIS LINE -- make depend depends on it.
-
- ! cproto.o: config.h cproto.h
- semantic.o: config.h cproto.h symbol.h semantic.h
- strstr.o: config.h
- diff -c2 old/patchlev.h new/patchlev.h
- *** old/patchlev.h Tue Dec 01 09:52:28 1992
- --- new/patchlev.h Wed Dec 02 21:16:22 1992
- ***************
- *** 1 ****
- ! #define PATCHLEVEL 6
- --- 1 ----
- ! #define PATCHLEVEL 7
- diff -c2 old/semantic.c new/semantic.c
- *** old/semantic.c Sat Nov 28 23:27:56 1992
- --- new/semantic.c Tue May 25 21:36:50 1993
- ***************
- *** 1,3 ****
- ! /* $Id: semantic.c 3.7 1992/11/29 04:27:49 cthuang Exp $
- *
- * Semantic actions executed by the parser of the
- --- 1,3 ----
- ! /* $Id: semantic.c 3.8 1993/05/26 01:36:41 cthuang Exp $
- *
- * Semantic actions executed by the parser of the
- ***************
- *** 519,524 ****
- fputs(s, outf);
-
- ! if (where == FUNC_PROTO && proto_style == PROTO_MACRO &&
- ! declarator == func_declarator) {
- fprintf(outf, " %s(", macro_name);
- }
- --- 519,523 ----
- fputs(s, outf);
-
- ! if (where == FUNC_PROTO && declarator == func_declarator && proto_macro) {
- fprintf(outf, " %s(", macro_name);
- }
- ***************
- *** 529,534 ****
- fputs(t, outf);
-
- ! if (where == FUNC_PROTO && proto_style == PROTO_MACRO &&
- ! declarator == func_declarator) {
- fputc(')', outf);
- }
- --- 528,532 ----
- fputs(t, outf);
-
- ! if (where == FUNC_PROTO && declarator == func_declarator && proto_macro) {
- fputc(')', outf);
- }
- ***************
- *** 608,616 ****
- }
-
- ! /* 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;
- {
- --- 606,613 ----
- }
-
- ! /* Return TRUE if the function uses varargs.
- */
- ! static int
- ! uses_varargs (declarator)
- Declarator *declarator;
- {
- ***************
- *** 617,626 ****
- 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;
- ! }
- }
-
- --- 614,619 ----
- Parameter *p;
-
- ! return (p = declarator->params.first) != NULL && p->next == NULL &&
- ! strcmp(p->declarator->name, "va_alist") == 0;
- }
-
- ***************
- *** 673,678 ****
-
- func_declarator = declarator->head;
- check_void_param(func_declarator);
- - check_varargs(func_declarator);
- set_param_decl_spec(func_declarator);
-
- --- 666,678 ----
-
- func_declarator = declarator->head;
- + if (uses_varargs(func_declarator)) {
- + /* Generate a prototype for a function that uses varargs by replacing
- + * the "va_alist" parameter with an empty parameter list.
- + */
- + free_param_list(&func_declarator->params);
- + func_declarator->params.first = NULL;
- + }
- +
- check_void_param(func_declarator);
- set_param_decl_spec(func_declarator);
-
- ***************
- *** 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;
-
- --- 737,746 ----
- int comment_len, n;
-
- ! /* Do nothing if the function is already defined in the desired style
- ! * or if the function uses varargs.
- ! */
- func_declarator = declarator->head;
- ! if (func_declarator->func_def == func_style ||
- ! uses_varargs(func_declarator))
- return;
-
- diff -c2 old/symbol.c new/symbol.c
- *** old/symbol.c Sat Nov 28 23:28:00 1992
- --- new/symbol.c Tue May 25 21:36:54 1993
- ***************
- *** 1,3 ****
- ! /* $Id: symbol.c 3.2 1992/11/29 04:27:49 cthuang Exp $
- *
- * Implements a symbol table abstract data type.
- --- 1,3 ----
- ! /* $Id: symbol.c 3.3 1993/05/26 01:36:41 cthuang Exp $
- *
- * Implements a symbol table abstract data type.
- ***************
- *** 39,42 ****
- --- 39,43 ----
- next = sym->next;
- free(sym->name);
- + free(sym->value);
- free(sym);
- sym = next;
- ***************
- *** 98,104 ****
- */
- Symbol *
- ! new_symbol (symtab, name, flags)
- SymbolTable *symtab; /* symbol table */
- char *name; /* symbol name */
- int flags; /* symbol attributes */
- {
- --- 99,106 ----
- */
- Symbol *
- ! new_symbol (symtab, name, value, flags)
- SymbolTable *symtab; /* symbol table */
- char *name; /* symbol name */
- + char *value; /* symbol value */
- int flags; /* symbol attributes */
- {
- ***************
- *** 109,117 ****
- 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;
- }
- --- 111,122 ----
- sym = (Symbol *)xmalloc(sizeof(Symbol));
- sym->name = xstrdup(name);
- i = hash(name);
- sym->next = symtab->bucket[i];
- symtab->bucket[i] = sym;
- + } else {
- + free(sym->value);
- }
- + sym->value = (value != NULL) ? xstrdup(value) : NULL;
- + sym->flags = flags;
- return sym;
- }
- diff -c2 old/symbol.h new/symbol.h
- *** old/symbol.h Sat Nov 28 23:27:48 1992
- --- new/symbol.h Tue May 25 21:36:40 1993
- ***************
- *** 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
- --- 1,3 ----
- ! /* $Id: symbol.h 3.4 1993/05/26 01:36:04 cthuang Exp $
- *
- * A symbol table is a collection of string identifiers stored in a
- ***************
- *** 10,14 ****
- struct symbol *next; /* next symbol in list */
- char *name; /* name of symbol */
- ! unsigned short flags; /* symbol attributes */
- } Symbol;
-
- --- 10,15 ----
- struct symbol *next; /* next symbol in list */
- char *name; /* name of symbol */
- ! char *value; /* value of symbol (for defines) */
- ! short flags; /* symbol attributes */
- } Symbol;
-
-