home *** CD-ROM | disk | FTP | other *** search
- diff -c old/CHANGES ./CHANGES
- *** old/CHANGES Wed Apr 03 21:42:20 1991
- --- ./CHANGES Wed Apr 03 21:52:24 1991
- ***************
- *** 1,5 ****
- --- 1,15 ----
- Version 2
-
- + Patchlevel 2
- +
- + - Cproto is now able to generate prototypes for functions defined in lex
- + and yacc source files named on the command line. Lex and yacc source
- + files are recognized by the .l or .y extension.
- + - Fix: The memory allocated to the typedef symbol table was not being
- + freed after scanning each source file.
- + - Fix: Failing to reset a variable during error recovery caused
- + segmentation faults.
- +
- Patchlevel 1
-
- - Fix: Cproto incorrectly generated the parameter "int ..." in
- diff -c old/grammar.y ./grammar.y
- *** old/grammar.y Wed Apr 03 21:42:26 1991
- --- ./grammar.y Wed Apr 03 21:52:28 1991
- ***************
- *** 1,4 ****
- ! /* $Id: grammar.y 2.2 91/03/30 13:19:00 cthuang Exp $
- *
- * yacc grammar for C prototype generator
- * This was derived from the grammar given in Appendix A of
- --- 1,4 ----
- ! /* $Id: grammar.y 2.3 91/04/03 21:27:01 cthuang Exp $
- *
- * yacc grammar for C prototype generator
- * This was derived from the grammar given in Appendix A of
- ***************
- *** 558,563 ****
- --- 558,564 ----
- yyerror (msg)
- char *msg;
- {
- + func_params = FALSE;
- output_error();
- fprintf(stderr, "%s\n", msg);
- }
- ***************
- *** 565,572 ****
- void
- parse_file ()
- {
- printf("/* %s */\n", cur_file);
- - line_num = 1;
- typedef_names = create_symbol_table();
- yyparse();
- }
- --- 566,583 ----
- void
- parse_file ()
- {
- + char *s;
- +
- + if (strlen(cur_file) > 2) {
- + s = cur_file + strlen(cur_file) - 2;
- + if (strcmp(s, ".l") == 0 || strcmp(s, ".y") == 0)
- + BEGIN LEXYACC;
- + }
- +
- printf("/* %s */\n", cur_file);
- typedef_names = create_symbol_table();
- + line_num = 1;
- + ly_count = 0;
- yyparse();
- + destroy_symbol_table(typedef_names);
- }
- diff -c old/lex.l ./lex.l
- *** old/lex.l Thu Mar 28 15:41:56 1991
- --- ./lex.l Wed Apr 03 21:52:26 1991
- ***************
- *** 1,5 ****
- %{
- ! /* $Id: lex.l 2.1 91/03/25 11:40:27 cthuang Exp $
- *
- * C function prototype generator
- * Lexical analyzer specification
- --- 1,5 ----
- %{
- ! /* $Id: lex.l 2.2 91/04/03 21:31:11 cthuang Exp $
- *
- * C function prototype generator
- * Lexical analyzer specification
- ***************
- *** 17,22 ****
- --- 17,23 ----
- char cur_file[MAX_TEXT_LENGTH]; /* current file name */
- int line_num = 1; /* current line number in file */
- static int curly = 0; /* number of curly brace nesting levels */
- + static int ly_count = 0; /* number of occurances of %% */
-
- typedef struct {
- FILE *fp;
- ***************
- *** 29,38 ****
- static void do_include();
- %}
-
- ! %s CPP1 CPP2 INIT1 INIT2 CURLY COMMENT
- %%
-
- \n ++line_num;
-
- <INITIAL>^#{WS}* BEGIN CPP1;
- <CPP1>define{WS}+{ID}.*\\$ {
- --- 30,47 ----
- static void do_include();
- %}
-
- ! %s CPP1 CPP2 INIT1 INIT2 CURLY COMMENT LEXYACC
- %%
-
- \n ++line_num;
- +
- + <LEXYACC>^"%%" {
- + if (++ly_count >= 2)
- + BEGIN INITIAL;
- + }
- + <LEXYACC>^"%{" BEGIN INITIAL;
- + <LEXYACC>. ;
- + <INITIAL>^"%}" BEGIN LEXYACC;
-
- <INITIAL>^#{WS}* BEGIN CPP1;
- <CPP1>define{WS}+{ID}.*\\$ {
- diff -c old/Makefile ./Makefile
- *** old/Makefile Wed Apr 03 21:42:28 1991
- --- ./Makefile Wed Apr 03 21:52:26 1991
- ***************
- *** 1,4 ****
- ! # $Id: Makefile 2.2 91/03/30 13:19:06 cthuang Exp $
- #
- # MSDOS makefile for C prototype generator
-
- --- 1,4 ----
- ! # $Id: Makefile 2.3 91/04/03 21:26:50 cthuang Exp $
- #
- # MSDOS makefile for C prototype generator
-
- ***************
- *** 34,40 ****
- $(LEX) lex.l
-
- cproto.man: cproto.1
- ! cawf -man $*.1 >$@
-
- TAGS: $(SOURCES)
- etags -t $(SOURCES)
- --- 34,40 ----
- $(LEX) lex.l
-
- cproto.man: cproto.1
- ! cawf -man $*.1 | bsfilt - >$@
-
- TAGS: $(SOURCES)
- etags -t $(SOURCES)
- ***************
- *** 63,71 ****
- zip:
- pkzip -u cproto README CHANGES Makefile.* *.1 *.c *.h grammar.y lex.l
-
- ! ci:
- ci -u2 $(DIST1) $(DIST3)
- ci -u2 $(DIST4)
-
- # DO NOT DELETE THIS LINE -- make depend depends on it.
-
- --- 63,75 ----
- zip:
- pkzip -u cproto README CHANGES Makefile.* *.1 *.c *.h grammar.y lex.l
-
- ! ci: rmcr
- ci -u2 $(DIST1) $(DIST3)
- ci -u2 $(DIST4)
- +
- + rmcr:
- + rmcr $(DIST1) $(DIST3)
- + rmcr $(DIST4)
-
- # DO NOT DELETE THIS LINE -- make depend depends on it.
-
- diff -c old/patchlev.h ./patchlev.h
- *** old/patchlev.h Wed Apr 03 21:42:30 1991
- --- ./patchlev.h Wed Apr 03 21:52:28 1991
- ***************
- *** 1,1 ****
- ! #define PATCHLEVEL 1
- --- 1,1 ----
- ! #define PATCHLEVEL 2
- diff -c old/symbol.c ./symbol.c
- *** old/symbol.c Thu Mar 28 15:42:00 1991
- --- ./symbol.c Wed Apr 03 21:52:32 1991
- ***************
- *** 1,4 ****
- ! /* $Id: symbol.c 2.1 91/02/28 11:16:35 cthuang Exp $
- *
- * Symbol table maintenance. Implements an abstract data type called
- * the symbol table.
- --- 1,4 ----
- ! /* $Id: symbol.c 2.2 91/04/03 21:30:54 cthuang Exp $
- *
- * Symbol table maintenance. Implements an abstract data type called
- * the symbol table.
- ***************
- *** 7,12 ****
- --- 7,13 ----
- #include "config.h"
- #include "symbol.h"
-
- +
- /* Create a symbol table.
- * Return a pointer to the symbol table or NULL if an error occurs.
- */
- ***************
- *** 24,36 ****
- }
-
-
- /* This is a simple hash function mapping a symbol name to a hash bucket. */
-
- ! static int
- hash (name)
- char *name;
- {
- ! return (name[0] + name[1] + strlen(name)) % SYM_MAX_HASH;
- }
-
-
- --- 25,65 ----
- }
-
-
- + /* Free the memory allocated to the symbol table.
- + */
- + void
- + destroy_symbol_table (symtab)
- + SymbolTable *symtab;
- + {
- + int i;
- + Symbol *sym, *next;
- +
- + for (i = 0; i < SYM_MAX_HASH; ++i) {
- + sym = symtab->bucket[i];
- + while (sym != NULL) {
- + next = sym->next;
- + free(sym->name);
- + free(sym);
- + sym = next;
- + }
- + }
- + }
- +
- +
- /* This is a simple hash function mapping a symbol name to a hash bucket. */
-
- ! static unsigned int
- hash (name)
- char *name;
- {
- ! char *s;
- ! unsigned int h;
- !
- ! h = 0;
- ! s = name;
- ! while (*s != '\0')
- ! h += *s++;
- ! return h % SYM_MAX_HASH;
- }
-
-
- diff -c old/symbol.h ./symbol.h
- *** old/symbol.h Thu Mar 28 15:41:58 1991
- --- ./symbol.h Wed Apr 03 21:52:30 1991
- ***************
- *** 1,4 ****
- ! /* $Id: symbol.h 2.1 91/02/28 11:16:22 cthuang Exp $
- *
- * Definitions for a symbol table
- */
- --- 1,4 ----
- ! /* $Id: symbol.h 2.2 91/04/03 21:30:33 cthuang Exp $
- *
- * Definitions for a symbol table
- */
- ***************
- *** 18,23 ****
- --- 18,24 ----
- } SymbolTable;
-
- extern SymbolTable *create_symbol_table(); /* Create symbol table */
- + extern void destroy_symbol_table(); /* Create symbol table */
- extern Symbol *find_symbol(); /* Lookup symbol name */
- extern Symbol *new_symbol(); /* Define new symbol */
-
-