home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume17 / cproto / patch01 / patch1 < prev   
Encoding:
Text File  |  1991-04-04  |  12.9 KB  |  538 lines

  1. diff -c old/CHANGES ./CHANGES
  2. *** old/CHANGES    Thu Mar 28 15:41:44 1991
  3. --- ./CHANGES    Sat Mar 30 13:18:50 1991
  4. ***************
  5. *** 1,5 ****
  6. --- 1,14 ----
  7.   Version 2
  8.   
  9. + Patchlevel 1
  10. + - Fix: Cproto incorrectly generated the parameter "int ..." in
  11. +   prototypes of functions taking variable parameters.
  12. + - Fix: Function definitions can now be followed by an optional
  13. +   semicolon.  I found this feature in every C compiler I tried.
  14. + Patchlevel 0
  15.   - Added formal parameter promotion.
  16.   - Added prototype style that surrounds prototypes with a guard macro.
  17.   - Handles C++ style comment //.
  18. diff -c old/cproto.1 ./cproto.1
  19. *** old/cproto.1    Thu Mar 28 15:41:44 1991
  20. --- ./cproto.1    Sat Mar 30 13:18:54 1991
  21. ***************
  22. *** 1,4 ****
  23. ! .\" $Id: cproto.1 2.1 91/03/25 10:13:30 cthuang Exp $
  24.   .\"
  25.   .de EX          \"Begin example
  26.   .ne 5
  27. --- 1,4 ----
  28. ! .\" $Id: cproto.1 2.2 91/03/30 13:18:50 cthuang Exp $
  29.   .\"
  30.   .de EX          \"Begin example
  31.   .ne 5
  32. ***************
  33. *** 140,149 ****
  34.   .TP
  35.   .B \-V
  36.   Print version information.
  37. - .SH AUTHOR
  38. - Chin Huang
  39. - cthuang@contact.uucp
  40. - chin.huang@canrem.uucp
  41.   .SH BUGS
  42.   When cproto finds an error, it usually outputs the not very descriptive
  43.   message "syntax error".
  44. --- 140,145 ----
  45. ***************
  46. *** 154,159 ****
  47. --- 150,161 ----
  48.   \\n    newline
  49.   \\t    tab
  50.   .EE
  51. + .SH AUTHOR
  52. + .nf
  53. + Chin Huang
  54. + cthuang@contact.uucp
  55. + chin.huang@canrem.uucp
  56. + .fi
  57.   .SH "SEE ALSO"
  58.   cc(1),
  59.   cpp(1)
  60. diff -c old/cproto.c ./cproto.c
  61. *** old/cproto.c    Thu Mar 28 15:41:58 1991
  62. --- ./cproto.c    Sat Mar 30 13:19:00 1991
  63. ***************
  64. *** 1,10 ****
  65. ! /* $Id: cproto.c 2.1 91/03/25 11:40:34 cthuang Exp $
  66.    *
  67.    * C prototype generator
  68.    * Reads C source code and outputs ANSI C function prototypes.
  69.    */
  70.   #ifndef lint
  71. ! static char *rcsid = "$Id: cproto.c 2.1 91/03/25 11:40:34 cthuang Exp $";
  72.   #endif
  73.   #include <stdio.h>
  74.   #include <ctype.h>
  75. --- 1,10 ----
  76. ! /* $Id: cproto.c 2.2 91/03/30 13:18:55 cthuang Exp $
  77.    *
  78.    * C prototype generator
  79.    * Reads C source code and outputs ANSI C function prototypes.
  80.    */
  81.   #ifndef lint
  82. ! static char *rcsid = "$Id: cproto.c 2.2 91/03/30 13:18:55 cthuang Exp $";
  83.   #endif
  84.   #include <stdio.h>
  85.   #include <ctype.h>
  86. ***************
  87. *** 149,156 ****
  88.   static void
  89.   usage ()
  90.   {
  91. !     fprintf(stderr,
  92. !     "usage: %s [ option ... ] [ file ... ]\n", progname);
  93.       fputs("  -e      output \"extern\" keyword before global declarations\n",
  94.       stderr);
  95.       fputs("  -f n    select function prototype style (0 to 4)\n", stderr);
  96. --- 149,155 ----
  97.   static void
  98.   usage ()
  99.   {
  100. !     fprintf(stderr, "usage: %s [ option ... ] [ file ... ]\n", progname);
  101.       fputs("  -e      output \"extern\" keyword before global declarations\n",
  102.       stderr);
  103.       fputs("  -f n    select function prototype style (0 to 4)\n", stderr);
  104. ***************
  105. *** 163,175 ****
  106.       fputs("  -U name\n", stderr);
  107.       fputs("  -I directory\n", stderr);
  108.       fputs("          C preprocessor options\n", stderr);
  109. !     fputs(
  110. !     "  -F fmt  set prototype template in the form \"int main (a, b)\"\n",
  111.       stderr);
  112.       fputs("  -V      print version information\n", stderr);
  113.       exit(1);
  114.   }
  115.   
  116.   main (argc, argv)
  117.   int argc;
  118.   char **argv;
  119. --- 162,174 ----
  120.       fputs("  -U name\n", stderr);
  121.       fputs("  -I directory\n", stderr);
  122.       fputs("          C preprocessor options\n", stderr);
  123. !     fputs("  -F fmt  set prototype template in the form \"int main (a, b)\"\n",
  124.       stderr);
  125.       fputs("  -V      print version information\n", stderr);
  126.       exit(1);
  127.   }
  128.   
  129. + int
  130.   main (argc, argv)
  131.   int argc;
  132.   char **argv;
  133. ***************
  134. *** 288,294 ****
  135.       }
  136.   
  137.       if (optind == argc) {
  138. !     printf("/* stdin */\n");
  139.       parse_file();
  140.       } else {
  141.       for (i = optind; i < argc; ++i) {
  142. --- 287,293 ----
  143.       }
  144.   
  145.       if (optind == argc) {
  146. !     strcpy(cur_file, "stdin");
  147.       parse_file();
  148.       } else {
  149.       for (i = optind; i < argc; ++i) {
  150. ***************
  151. *** 305,312 ****
  152.           }
  153.   #endif
  154.           strcpy(cur_file, argv[i]);
  155. -         line_num = 1;
  156. -         printf("/* %s */\n", cur_file);
  157.           parse_file();
  158.   #ifdef MSDOS
  159.           fclose(yyin);
  160. --- 304,309 ----
  161. diff -c old/grammar.y ./grammar.y
  162. *** old/grammar.y    Thu Mar 28 15:41:56 1991
  163. --- ./grammar.y    Sat Mar 30 13:19:04 1991
  164. ***************
  165. *** 1,4 ****
  166. ! /* $Id: grammar.y 2.1 91/02/28 11:16:07 cthuang Exp $
  167.    *
  168.    * yacc grammar for C prototype generator
  169.    * This was derived from the grammar given in Appendix A of
  170. --- 1,4 ----
  171. ! /* $Id: grammar.y 2.2 91/03/30 13:19:00 cthuang Exp $
  172.    *
  173.    * yacc grammar for C prototype generator
  174.    * This was derived from the grammar given in Appendix A of
  175. ***************
  176. *** 88,93 ****
  177. --- 88,94 ----
  178.   external_declaration
  179.       : declaration
  180.       | function_definition
  181. +     | function_definition ';'
  182.       | T_EXTERN T_QUOTEC T_BRACES
  183.       | error
  184.       ;
  185. ***************
  186. *** 564,569 ****
  187. --- 565,572 ----
  188.   void
  189.   parse_file ()
  190.   {
  191. +     printf("/* %s */\n", cur_file);
  192. +     line_num = 1;
  193.       typedef_names = create_symbol_table();
  194.       yyparse();
  195.   }
  196. diff -c old/Makefile ./Makefile
  197. *** old/Makefile    Thu Mar 28 15:41:44 1991
  198. --- ./Makefile    Sat Mar 30 13:19:08 1991
  199. ***************
  200. *** 1,4 ****
  201. ! # $Id: makefile 2.1 91/03/25 10:56:54 cthuang Exp $
  202.   #
  203.   # MSDOS makefile for C prototype generator
  204.   
  205. --- 1,4 ----
  206. ! # $Id: Makefile 2.2 91/03/30 13:19:06 cthuang Exp $
  207.   #
  208.   # MSDOS makefile for C prototype generator
  209.   
  210. ***************
  211. *** 9,24 ****
  212.   
  213.   DEFINES = -DMSDOS
  214.   
  215. ! DIST1 =        README CHANGES Makefile Makefile.uni cproto.1
  216. ! DIST2 =        $(SOURCES)
  217.   SOURCES =    lex.l grammar.y \
  218.           config.h cproto.h patchlev.h semantic.h symbol.h \
  219.           cproto.c semantic.c string.c symbol.c
  220.   CSOURCES =    cproto.c semantic.c string.c symbol.c y_tab.c
  221. ! OBJECTS =    cproto.obj semantic.obj getopt.obj symbol.obj \
  222. !         y_tab.obj
  223.   
  224. ! all: cproto.exe
  225.   
  226.   cproto.exe: $(OBJECTS)
  227.       $(CC) $(CFLAGS) $(OBJECTS)
  228. --- 9,25 ----
  229.   
  230.   DEFINES = -DMSDOS
  231.   
  232. ! DIST1 =        README CHANGES
  233. ! DIST2 =        cproto.man
  234. ! DIST3 =        cproto.1 Makefile Makefile.uni
  235. ! DIST4 =        $(SOURCES)
  236.   SOURCES =    lex.l grammar.y \
  237.           config.h cproto.h patchlev.h semantic.h symbol.h \
  238.           cproto.c semantic.c string.c symbol.c
  239.   CSOURCES =    cproto.c semantic.c string.c symbol.c y_tab.c
  240. ! OBJECTS =    cproto.obj semantic.obj getopt.obj symbol.obj y_tab.obj
  241.   
  242. ! all: cproto.exe cproto.man
  243.   
  244.   cproto.exe: $(OBJECTS)
  245.       $(CC) $(CFLAGS) $(OBJECTS)
  246. ***************
  247. *** 32,37 ****
  248. --- 33,41 ----
  249.   lex_yy.c: lex.l
  250.       $(LEX) lex.l
  251.   
  252. + cproto.man: cproto.1
  253. +     cawf -man $*.1 >$@
  254.   TAGS: $(SOURCES)
  255.       etags -t $(SOURCES)
  256.   
  257. ***************
  258. *** 41,47 ****
  259.       erase *.log
  260.       erase lex_yy.c
  261.       erase y_tab.c
  262. !     erase cproto1.exe
  263.       
  264.   lint:
  265.       lint -B $(DEFINES) $(CSOURCES)
  266. --- 45,51 ----
  267.       erase *.log
  268.       erase lex_yy.c
  269.       erase y_tab.c
  270. !     erase cproto.exe
  271.       
  272.   lint:
  273.       lint -B $(DEFINES) $(CSOURCES)
  274. ***************
  275. *** 50,68 ****
  276.       cpr $(SOURCES) | lpr -J'cproto'
  277.   
  278.   shar:
  279. !     rmcr $(DIST1)
  280. !     rmcr $(DIST2)
  281. !     shar $(DIST1) >cproto.sh1
  282. !     rmcr cproto.sh1
  283. !     shar $(DIST2) >cproto.sh2
  284. !     rmcr cproto.sh2
  285.   
  286.   zip:
  287.       pkzip -u cproto README CHANGES Makefile.* *.1 *.c *.h grammar.y lex.l
  288.   
  289.   ci:
  290. !     ci -r2 -u $(DIST1)
  291. !     ci -r2 -u $(DIST2)
  292.   
  293.   # DO NOT DELETE THIS LINE -- make depend depends on it.
  294.   
  295. --- 54,71 ----
  296.       cpr $(SOURCES) | lpr -J'cproto'
  297.   
  298.   shar:
  299. !     rmcr $(DIST1) $(DIST2) $(DIST3)
  300. !     rmcr $(DIST4)
  301. !     shar $(DIST1) $(DIST2) $(DIST3) >cproto.sh1
  302. !     shar $(DIST4) >cproto.sh2
  303. !     rmcr cproto.sh1 cproto.sh2
  304.   
  305.   zip:
  306.       pkzip -u cproto README CHANGES Makefile.* *.1 *.c *.h grammar.y lex.l
  307.   
  308.   ci:
  309. !     ci -u2 $(DIST1) $(DIST3)
  310. !     ci -u2 $(DIST4)
  311.   
  312.   # DO NOT DELETE THIS LINE -- make depend depends on it.
  313.   
  314. diff -c old/Makefile.uni ./Makefile.uni
  315. *** old/Makefile.uni    Thu Mar 28 15:41:44 1991
  316. --- ./Makefile.uni    Sat Mar 30 13:19:10 1991
  317. ***************
  318. *** 1,4 ****
  319. ! # $Id: Makefile.uni 2.1 91/02/28 11:15:54 cthuang Exp $
  320.   #
  321.   # UNIX makefile for C prototype generator
  322.   
  323. --- 1,4 ----
  324. ! # $Id: Makefile.uni 2.2 91/03/30 13:19:09 cthuang Exp $
  325.   #
  326.   # UNIX makefile for C prototype generator
  327.   
  328. ***************
  329. *** 9,16 ****
  330.   # Define SYSV for System V, otherwise BSD is assumed.
  331.   #DEFINES = -DSYSV
  332.   
  333. ! DIST1 =        README CHANGES Makefile Makefile.dos cproto.1
  334. ! DIST2 =        $(SOURCES)
  335.   SOURCES =    lex.l grammar.y \
  336.           config.h cproto.h patchlev.h semantic.h symbol.h \
  337.           cproto.c semantic.c string.c symbol.c
  338. --- 9,18 ----
  339.   # Define SYSV for System V, otherwise BSD is assumed.
  340.   #DEFINES = -DSYSV
  341.   
  342. ! DIST1 =        README CHANGES
  343. ! DIST2 =        cproto.man
  344. ! DIST3 =        cproto.1 Makefile Makefile.dos
  345. ! DIST4 =        $(SOURCES)
  346.   SOURCES =    lex.l grammar.y \
  347.           config.h cproto.h patchlev.h semantic.h symbol.h \
  348.           cproto.c semantic.c string.c symbol.c
  349. ***************
  350. *** 17,23 ****
  351.   CSOURCES =    cproto.c semantic.c string.c symbol.c y.tab.c
  352.   OBJECTS =    cproto.o semantic.o string.o symbol.o y.tab.o
  353.   
  354. ! all: cproto
  355.   
  356.   cproto: $(OBJECTS)
  357.       $(CC) $(CFLAGS) -o $@ $(OBJECTS)
  358. --- 19,25 ----
  359.   CSOURCES =    cproto.c semantic.c string.c symbol.c y.tab.c
  360.   OBJECTS =    cproto.o semantic.o string.o symbol.o y.tab.o
  361.   
  362. ! all: cproto cproto.man
  363.   
  364.   cproto: $(OBJECTS)
  365.       $(CC) $(CFLAGS) -o $@ $(OBJECTS)
  366. ***************
  367. *** 28,38 ****
  368.   lex.yy.c: lex.l
  369.       $(LEX) lex.l
  370.   
  371.   TAGS: $(SOURCES)
  372.       etags -t $(SOURCES)
  373.   
  374.   clean:
  375. !     rm *.o *.bak *.log cproto1.exe
  376.       
  377.   lint:
  378.       lint -B $(DEFINES) $(CSOURCES)
  379. --- 30,43 ----
  380.   lex.yy.c: lex.l
  381.       $(LEX) lex.l
  382.   
  383. + cproto.man: cproto.1
  384. +     nroff -man $*.1 >$@
  385.   TAGS: $(SOURCES)
  386.       etags -t $(SOURCES)
  387.   
  388.   clean:
  389. !     rm *.o *.bak *.log cproto
  390.       
  391.   lint:
  392.       lint -B $(DEFINES) $(CSOURCES)
  393. ***************
  394. *** 41,51 ****
  395.       cpr $(SOURCES) | lpr -J'cproto'
  396.   
  397.   shar:
  398. !     shar $(DIST1) >cproto.sh1
  399. !     shar $(DIST2) >cproto.sh2
  400.   
  401.   ci:
  402. !     ci -u $(DIST1) $(DIST2)
  403.   
  404.   depend:
  405.       makedepend $(CSOURCES)
  406. --- 46,56 ----
  407.       cpr $(SOURCES) | lpr -J'cproto'
  408.   
  409.   shar:
  410. !     shar $(DIST1) $(DIST2) $(DIST3) >cproto.sh1
  411. !     shar $(DIST4) >cproto.sh2
  412.   
  413.   ci:
  414. !     ci -u2 $(DIST1) $(DIST3) $(DIST4)
  415.   
  416.   depend:
  417.       makedepend $(CSOURCES)
  418. diff -c old/patchlev.h ./patchlev.h
  419. *** old/patchlev.h    Thu Mar 28 15:41:58 1991
  420. --- ./patchlev.h    Sat Mar 30 13:19:38 1991
  421. ***************
  422. *** 1,1 ****
  423. ! #define PATCHLEVEL 0
  424. --- 1,1 ----
  425. ! #define PATCHLEVEL 1
  426. diff -c old/semantic.c ./semantic.c
  427. *** old/semantic.c    Thu Mar 28 15:42:00 1991
  428. --- ./semantic.c    Sat Mar 30 13:19:44 1991
  429. ***************
  430. *** 1,4 ****
  431. ! /* $Id: semantic.c 2.1 91/03/25 11:40:31 cthuang Exp $
  432.    *
  433.    * C prototype generator
  434.    * These routines implement the semantic actions executed by the yacc parser.
  435. --- 1,4 ----
  436. ! /* $Id: semantic.c 2.2 91/03/30 13:19:39 cthuang Exp $
  437.    *
  438.    * C prototype generator
  439.    * These routines implement the semantic actions executed by the yacc parser.
  440. ***************
  441. *** 303,309 ****
  442. --- 303,311 ----
  443.           output_error();
  444.           fprintf(stderr, "declared argument \"%s\" is missing\n", d->name);
  445.       } else {
  446. +         free(p->declarator.text);
  447.           p->declarator.text = strdup(d->text);
  448.           decl_spec_text = decl_spec->text;
  449.           if (promote_param && strcmp(d->text, d->name) == 0) {
  450.               s = rindex(decl_spec_text, ' ');
  451. ***************
  452. *** 313,318 ****
  453. --- 315,321 ----
  454.           else if (strcmp(s, "float") == 0)
  455.               decl_spec_text = "double";
  456.           }
  457. +         free(p->decl_spec.text);
  458.           p->decl_spec.text = strdup(decl_spec_text);
  459.       }
  460.       }
  461. ***************
  462. *** 378,384 ****
  463.       *s = *(p->declarator.name);
  464.       } else {
  465.       if (strlen(p->declarator.text) > 0) {
  466. !         putchar(' ');
  467.           output_declarator(&(p->declarator));
  468.       }
  469.       }
  470. --- 381,388 ----
  471.       *s = *(p->declarator.name);
  472.       } else {
  473.       if (strlen(p->declarator.text) > 0) {
  474. !         if (strcmp(p->declarator.text, "...") != 0)
  475. !         putchar(' ');
  476.           output_declarator(&(p->declarator));
  477.       }
  478.       }
  479. ***************
  480. *** 464,470 ****
  481.        * part.  The default type in this cause is "int".
  482.        */
  483.       for (p = declarator->params.first; p != NULL; p = p->next) {
  484. !     if (strlen(p->decl_spec.text) == 0) {
  485.           free(p->decl_spec.text);
  486.           p->decl_spec.text = strdup("int");
  487.       }
  488. --- 468,475 ----
  489.        * part.  The default type in this cause is "int".
  490.        */
  491.       for (p = declarator->params.first; p != NULL; p = p->next) {
  492. !     if (strlen(p->decl_spec.text) == 0 &&
  493. !         strcmp(p->declarator.text, "...") != 0) {
  494.           free(p->decl_spec.text);
  495.           p->decl_spec.text = strdup("int");
  496.       }
  497. diff -c old/semantic.h ./semantic.h
  498. *** old/semantic.h    Thu Mar 28 15:41:58 1991
  499. --- ./semantic.h    Sat Mar 30 13:19:46 1991
  500. ***************
  501. *** 1,6 ****
  502. ! /* $Id: semantic.h 2.1 91/02/28 11:16:19 cthuang Exp $
  503.    *
  504. !  * Declarations for semantics action routines
  505.    */
  506.   
  507.   extern boolean is_typedef_name(/*
  508. --- 1,6 ----
  509. ! /* $Id: semantic.h 2.2 91/03/30 13:19:44 cthuang Exp $
  510.    *
  511. !  * Declarations for semantic action routines
  512.    */
  513.   
  514.   extern boolean is_typedef_name(/*
  515. ***************
  516. *** 9,15 ****
  517.   extern void new_decl_spec(/*
  518.       DeclSpec *decl_spec,
  519.       char *text,
  520. !     unsigned short flags
  521.       */);
  522.   extern void join_decl_specs(/*
  523.       DeclSpec *result,
  524. --- 9,15 ----
  525.   extern void new_decl_spec(/*
  526.       DeclSpec *decl_spec,
  527.       char *text,
  528. !     int flags
  529.       */);
  530.   extern void join_decl_specs(/*
  531.       DeclSpec *result,
  532.