home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / patches / 47 < prev    next >
Encoding:
Text File  |  1992-11-21  |  8.4 KB  |  293 lines

  1. Newsgroups: alt.sources.patches
  2. Path: sparky!uunet!munnari.oz.au!metro!mama!greyham
  3. From: greyham@research.canon.oz.au (Graham Stoney)
  4. Subject: c2man: generate man pages from C comments; patch v1.9 -> v1.10
  5. Message-ID: <By08zp.6M4@research.canon.oz.au>
  6. Followup-To: alt.sources.d
  7. Summary: A program to help document C functions with minimal extra effort.
  8. Keywords: c2man, Unix, man, ANSI-C, documentation generator
  9. Sender: news@research.canon.oz.au
  10. Organization: Canon Information Systems Research Australia
  11. Date: Fri, 20 Nov 1992 08:02:13 GMT
  12. Lines: 279
  13.  
  14. Archive-name: c2man/patch.1.9-1.10
  15. Submitted-by: greyham@research.canon.oz.au
  16.  
  17. This official patch brings c2man v1.9 up to v1.10.
  18.  
  19. I wait around and collect a few bug-fixes into the one patch before posting; but
  20. somehow I always get a bug report immediately after every posting!
  21.  
  22. See the CHANGES file for more details.
  23.  
  24. As before, any feedback, comments or tips are greatly appreciated.
  25.  
  26. Graham
  27.  
  28. *** 1.11    1992/11/03 06:17:28
  29. --- CHANGES    1992/11/06 03:25:08
  30. ***************
  31. *** 104,106 ****
  32. --- 104,112 ----
  33.       Don't error on "typedef int NewType; NewType a;"
  34.   
  35.       -Ssection option added by jerry@kesa24.kesa.com (Jerry E. Dunmire).
  36. + Version 1.10:
  37. +     Accept comments around a final ellipsis parameter.
  38. +     Make parameter declarations in the prototype and the PARAMETERS section
  39. +     identical.
  40. *** 1.13    1992/10/15 07:53:08
  41. --- Makefile    1992/11/20 07:55:02
  42. ***************
  43. *** 1,4 ****
  44. ! # $Id: Makefile,v 1.13 1992/10/15 07:53:08 greyham Exp $
  45.   #
  46.   # UNIX makefile for manual page generator
  47.   #
  48. --- 1,4 ----
  49. ! # $Id: Makefile,v 1.14 1992/11/20 07:54:48 greyham Exp $
  50.   #
  51.   # UNIX makefile for manual page generator
  52.   #
  53. ***************
  54. *** 100,106 ****
  55.       $(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LIBS)
  56.   
  57.   y.tab.c: grammar.y
  58. !     @echo Expect 33 shift/reduce conflicts.
  59.       $(YACC) grammar.y
  60.   
  61.   # don't compile y.tab.c with all warnings; yacc/bison are not up to it.
  62. --- 100,106 ----
  63.       $(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LIBS)
  64.   
  65.   y.tab.c: grammar.y
  66. !     @echo Expect 34 shift/reduce conflicts.
  67.       $(YACC) grammar.y
  68.   
  69.   # don't compile y.tab.c with all warnings; yacc/bison are not up to it.
  70. *** 1.10    1992/11/03 06:17:28
  71. --- README    1992/11/06 03:29:16
  72. ***************
  73. *** 1,4 ****
  74. ! This is c2man (Version 1.9), a program for generating Unix style manual pages
  75.   in nroff/troff -man format directly from ordinary comments embedded in C source
  76.   code. It owes a huge debt to the public domain program cproto, by Chin Huang,
  77.   from which much of the code is derived.
  78. --- 1,4 ----
  79. ! This is c2man (Version 1.10), a program for generating Unix style manual pages
  80.   in nroff/troff -man format directly from ordinary comments embedded in C source
  81.   code. It owes a huge debt to the public domain program cproto, by Chin Huang,
  82.   from which much of the code is derived.
  83. *** 1.9    1992/11/03 06:17:28
  84. --- c2man.c    1992/11/20 07:56:13
  85. ***************
  86. *** 1,10 ****
  87. ! /* $Id: c2man.c,v 1.9 1992/11/03 06:17:28 greyham Exp $
  88.    *
  89.    * C Manual page generator.
  90.    * Reads C source code and outputs manual pages.
  91.    */
  92.   #ifndef lint
  93. ! static char *rcsid = "$Id: c2man.c,v 1.9 1992/11/03 06:17:28 greyham Exp $";
  94.   #endif
  95.   #include <stdio.h>
  96.   #include <ctype.h>
  97. --- 1,10 ----
  98. ! /* $Id: c2man.c,v 1.10 1992/11/20 07:56:01 greyham Exp $
  99.    *
  100.    * C Manual page generator.
  101.    * Reads C source code and outputs manual pages.
  102.    */
  103.   #ifndef lint
  104. ! static char *rcsid = "$Id: c2man.c,v 1.10 1992/11/20 07:56:01 greyham Exp $";
  105.   #endif
  106.   #include <stdio.h>
  107.   #include <ctype.h>
  108. *** 1.8    1992/11/03 06:17:28
  109. --- grammar.y    1992/11/20 07:55:14
  110. ***************
  111. *** 1,4 ****
  112. ! /* $Id: grammar.y,v 1.8 1992/11/03 06:17:28 greyham Exp $
  113.    *
  114.    * yacc grammar for C manual page generator
  115.    * This was derived from the grammar given in Appendix A of
  116. --- 1,4 ----
  117. ! /* $Id: grammar.y,v 1.9 1992/11/20 07:54:48 greyham Exp $
  118.    *
  119.    * yacc grammar for C manual page generator
  120.    * This was derived from the grammar given in Appendix A of
  121. ***************
  122. *** 534,542 ****
  123.           $$ = $1;
  124.           if ($2)    comment_last_parameter(&$1, $2);
  125.       }
  126. !     | parameter_list ',' T_ELLIPSIS
  127.       {
  128.           add_ident_list(&$$, &$1, strdup("..."));
  129.       }
  130.       ;
  131.   
  132. --- 534,553 ----
  133.           $$ = $1;
  134.           if ($2)    comment_last_parameter(&$1, $2);
  135.       }
  136. !     | parameter_list ',' opt_eolcomment
  137. !         opt_comment T_ELLIPSIS opt_comment opt_eolcomment
  138.       {
  139. +         if ($3)    comment_last_parameter(&$1, $3);
  140.           add_ident_list(&$$, &$1, strdup("..."));
  141. +         switch (($4 != NULL) + ($6 != NULL) + ($7 != NULL))
  142. +         {
  143. +         case 0:    break;
  144. +         case 1:    comment_last_parameter(&$$, $4 ? $4 : $6 ? $6 : $7);
  145. +             break;
  146. +         default:    yyerror("ellipsis parameter has multiple comments");
  147. +                 break;
  148. +         }
  149.       }
  150.       ;
  151.   
  152. *** 1.12    1992/11/03 06:17:28
  153. --- manpage.c    1992/11/20 07:55:42
  154. ***************
  155. *** 1,4 ****
  156. ! /* $Id: manpage.c,v 1.12 1992/11/03 06:17:28 greyham Exp $
  157.    * stuff to do with manual page outputing
  158.    */
  159.   
  160. --- 1,4 ----
  161. ! /* $Id: manpage.c,v 1.13 1992/11/20 07:54:48 greyham Exp $
  162.    * stuff to do with manual page outputing
  163.    */
  164.   
  165. ***************
  166. *** 179,197 ****
  167.   {
  168.       Parameter *p;
  169.   
  170. -     /* Check for parameter names with no declaration specifiers.  This
  171. -      * happens when a parameter name appears in the identifier list of a
  172. -      * function definition but does not appear in the parameter declaration
  173. -      * part.  The default type in this cause is "int".
  174. -      */
  175. -     for (p = params->first; p != NULL; p = p->next) {
  176. -     if (strlen(p->decl_spec.text) == 0 &&
  177. -         strcmp(p->declarator.text, "...") != 0) {
  178. -         free(p->decl_spec.text);
  179. -         p->decl_spec.text = strdup("int");
  180. -     }
  181. -     }
  182.       for (p = params->first; p != NULL; p = p->next)
  183.       {
  184.       /* use the declarator comment if we can */
  185. --- 179,184 ----
  186. ***************
  187. *** 200,213 ****
  188.       if (p->suppress)    continue;
  189.        
  190.           put_string(".TP\n.BR \"");
  191. !     output_decl_spec(&p->decl_spec);
  192. !     
  193. !     /* not all parameters must have declarators: might be a prototype */
  194. !     if (p->declarator.text)
  195. !     {
  196. !         putchar(' ');
  197. !         output_declarator(&p->declarator, FALSE);    /* all on one line */
  198. !     }
  199.       
  200.       /* include function name if it's a duplicate */
  201.       if (p->duplicate)
  202. --- 187,193 ----
  203.       if (p->suppress)    continue;
  204.        
  205.           put_string(".TP\n.BR \"");
  206. !     output_parameter(p);
  207.       
  208.       /* include function name if it's a duplicate */
  209.       if (p->duplicate)
  210. *** 1.6    1992/08/25 06:41:02
  211. --- semantic.c    1992/11/20 07:55:39
  212. ***************
  213. *** 1,4 ****
  214. ! /* $Id: semantic.c,v 1.6 1992/08/25 06:41:02 greyham Exp $
  215.    *
  216.    * C manual page generator
  217.    * These routines implement the semantic actions executed by the yacc parser.
  218. --- 1,4 ----
  219. ! /* $Id: semantic.c,v 1.7 1992/11/20 07:54:48 greyham Exp $
  220.    *
  221.    * C manual page generator
  222.    * These routines implement the semantic actions executed by the yacc parser.
  223. ***************
  224. *** 468,480 ****
  225.   
  226.   /* Output a function parameter.
  227.    */
  228. ! static void
  229.   output_parameter (p)
  230.   Parameter *p;
  231.   {
  232. !     put_string(p->decl_spec.text);
  233.       if (p->declarator.text) {
  234. !     if (strcmp(p->declarator.text, "...") != 0)
  235.           putchar(' ');
  236.       /* don't format parameters; keep it all on one line */
  237.       output_declarator(&(p->declarator), FALSE);
  238. --- 468,491 ----
  239.   
  240.   /* Output a function parameter.
  241.    */
  242. ! void
  243.   output_parameter (p)
  244.   Parameter *p;
  245.   {
  246. !     if (p->decl_spec.text)
  247. !     put_string(p->decl_spec.text);
  248. !     else
  249. !     /* Check for parameter names with no declaration specifiers.  This
  250. !      * happens when a parameter name appears in the identifier list of a
  251. !      * function definition but does not appear in the parameter declaration
  252. !      * part.  The default type in this cause is "int".
  253. !      */
  254. !     if (p->declarator.text && strcmp(p->declarator.text, "...") != 0)
  255. !     put_string("int ");
  256. !     /* not all parameters must have declarators: might be a prototype */
  257.       if (p->declarator.text) {
  258. !     if (p->decl_spec.text)
  259.           putchar(' ');
  260.       /* don't format parameters; keep it all on one line */
  261.       output_declarator(&(p->declarator), FALSE);
  262. *** 1.4    1992/08/25 06:41:02
  263. --- semantic.h    1992/11/20 07:55:19
  264. ***************
  265. *** 1,4 ****
  266. ! /* $Id: semantic.h,v 1.4 1992/08/25 06:41:02 greyham Exp $
  267.    *
  268.    * Declarations for semantic action routines
  269.    */
  270. --- 1,4 ----
  271. ! /* $Id: semantic.h,v 1.5 1992/11/20 07:54:48 greyham Exp $
  272.    *
  273.    * Declarations for semantic action routines
  274.    */
  275. ***************
  276. *** 96,101 ****
  277. --- 96,105 ----
  278.       DeclSpec *decl_spec,
  279.       Declarator *declarator
  280.       );
  281. + /* Output a function parameter.*/
  282. + void output_parameter (Parameter *p);
  283.   int
  284.   remember_declarations (
  285.   char *comment,            /* comment associated */
  286.