🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.sources.patches
1 messages
1 total messages Started by Graham Stoney Tue, 03 Nov 1992 06:24
c2man: generate man pages from C comments; patch v1.8 -> v1.9
#1
Author: Graham Stoney
Date: Tue, 03 Nov 1992 06:24
336 lines
9599 bytes
Archive-name: c2man/patch.1.8-1.9
Submitted-by: greyham@research.canon.oz.au

This official patch brings c2man v1.8 up to v1.9.

The bug reports keep rolling in; a few more fixes.

See the CHANGES file for more details.

As before, any feedback, comments or tips are greatly appreciated.

Graham

*** 1.10	1992/10/15 07:53:08
--- CHANGES	1992/11/03 06:09:47
***************
*** 95,97 ****
--- 95,106 ----
  	Add -lPW I'd dropped from HPUX configuration.
  	
  	Fix multiple -i arguments appearing on the one line.
+ 
+ Version 1.9:
+ 	Fix silly missing fprintf arguments in c2man.c
+ 
+ 	Ignore trailing spaces after a comment at the end of a line.
+ 
+ 	Don't error on "typedef int NewType; NewType a;"
+ 
+ 	-Ssection option added by jerry@kesa24.kesa.com (Jerry E. Dunmire).
*** 1.9	1992/10/15 07:53:08
--- README	1992/10/19 01:48:26
***************
*** 1,4 ****
! This is c2man (Version 1.8), a program for generating Unix style manual pages
  in nroff/troff -man format directly from ordinary comments embedded in C source
  code. It owes a huge debt to the public domain program cproto, by Chin Huang,
  from which much of the code is derived.
--- 1,4 ----
! This is c2man (Version 1.9), a program for generating Unix style manual pages
  in nroff/troff -man format directly from ordinary comments embedded in C source
  code. It owes a huge debt to the public domain program cproto, by Chin Huang,
  from which much of the code is derived.
*** 1.10	1992/09/09 08:39:39
--- c2man.1	1992/11/03 06:17:46
***************
*** 1,4 ****
! .\" $Id: c2man.1,v 1.10 1992/09/09 08:39:39 greyham Exp $
  .de EX          \"Begin example
  .ne 5
  .if n .sp 1
--- 1,4 ----
! .\" $Id: c2man.1,v 1.11 1992/11/03 06:17:28 greyham Exp $
  .de EX          \"Begin example
  .ne 5
  .if n .sp 1
***************
*** 389,394 ****
--- 389,399 ----
  .BI \-M name
  Set the name of the manual in which the page will go.
  .TP
+ .BI \-S section
+ Set the manual section.
+ .I section
+ defaults to: 3.
+ .TP
  .BI \-F string
  Set the format used to output the prototype for functions with more than 1
  parameter
***************
*** 420,426 ****
  .EE
  .TP
  .BI \-P preprocessor
! Run a different C preprocessor to normal (use
  .B \-V
  to determine the configured default).
  For example, to use
--- 425,431 ----
  .EE
  .TP
  .BI \-P preprocessor
! Run a different C preprocessor than normal (use
  .B \-V
  to determine the configured default).
  For example, to use
***************
*** 459,465 ****
  If the code compiles OK but
  .B c2man
  rejects it, it is probably because a comment is in a position
! .b c2man
  does not accept.
  .LP
  An error at the very end of a function may indicate that the comments a the
--- 464,470 ----
  If the code compiles OK but
  .B c2man
  rejects it, it is probably because a comment is in a position
! .B c2man
  does not accept.
  .LP
  An error at the very end of a function may indicate that the comments a the
*** 1.8	1992/10/15 07:53:08
--- c2man.c	1992/11/03 06:17:55
***************
*** 1,10 ****
! /* $Id: c2man.c,v 1.8 1992/10/15 07:53:08 greyham Exp $
   *
   * C Manual page generator.
   * Reads C source code and outputs manual pages.
   */
  #ifndef lint
! static char *rcsid = "$Id: c2man.c,v 1.8 1992/10/15 07:53:08 greyham Exp $";
  #endif
  #include <stdio.h>
  #include <ctype.h>
--- 1,10 ----
! /* $Id: c2man.c,v 1.9 1992/11/03 06:17:28 greyham Exp $
   *
   * C Manual page generator.
   * Reads C source code and outputs manual pages.
   */
  #ifndef lint
! static char *rcsid = "$Id: c2man.c,v 1.9 1992/11/03 06:17:28 greyham Exp $";
  #endif
  #include <stdio.h>
  #include <ctype.h>
***************
*** 58,63 ****
--- 58,66 ----
  /* Name of the manual */
  char *manual_name = NULL;
  
+ /* Section for manual page */
+ char *section = "3";
+ 
  /* prefix for generated #include lines */
  char *header_prefix = NULL;
  
***************
*** 207,213 ****
--- 210,219 ----
      fputs("          C preprocessor options\n", stderr);
      fputs("  -F fmt  set prototype template in the form "
  					    "\"int main (a, b)\"\n",stderr);
+     fputs("  -P preprocessor\n", stderr);
+     fputs("          Alternate C preprocessor (e.g., \"gcc -E\")\n", stderr);
      fputs("  -V      be verbose and print version information\n", stderr);
+     fputs("  -S sec  set the section for the manual page (default = 3)\n", stderr);
      exit(1);
  }
  
***************
*** 239,245 ****
  	name = "c2mantmp0.c";
  	if ((tmpfile = fopen(name, "w")) == NULL)
  	{
! 	    fprintf(stderr,"%s: error opening temp file ");
  	    perror(name);
  	    free(cmd);
  	    return 0;
--- 245,253 ----
  	name = "c2mantmp0.c";
  	if ((tmpfile = fopen(name, "w")) == NULL)
  	{
! 	    int err = errno;
! 	    fprintf(stderr,"%s: error opening temp file ", progname);
! 	    errno = err;
  	    perror(name);
  	    free(cmd);
  	    return 0;
***************
*** 253,259 ****
  
  	if (fclose(tmpfile) == EOF)
  	{
! 	    fprintf(stderr,"%s: error closing temp file ");
  	    perror(name);
  	    free(cmd);
  	    return 0;
--- 261,269 ----
  
  	if (fclose(tmpfile) == EOF)
  	{
! 	    int err = errno;
! 	    fprintf(stderr,"%s: error closing temp file ", progname);
! 	    errno = err;
  	    perror(name);
  	    free(cmd);
  	    return 0;
***************
*** 319,325 ****
      cpp_opts = strconcat("-C", NULL);
  #endif    
      /* Scan command line options. */
!     while ((c = getopt(argc, argv, "D:F:I:psU:Vvo:M:H:G:gi:")) != EOF) {
  	switch (c) {
  	case 'I':
  	case 'D':
--- 329,335 ----
      cpp_opts = strconcat("-C", NULL);
  #endif    
      /* Scan command line options. */
!     while ((c = getopt(argc, argv, "P:D:F:I:psU:Vvo:M:H:G:gi:S:")) != EOF) {
  	switch (c) {
  	case 'I':
  	case 'D':
***************
*** 409,416 ****
--- 419,431 ----
  	    includefile->next = NULL;
  	    last_next_include = &includefile->next;
  	    break;
+ 	case 'S':
+ 	    section = optarg;
+ 	    break;
+ 
  	case '?':
  	default:
+ 	fputs("default eror\n", stderr);
  	    usage();
  	}
      }
*** 1.7	1992/09/09 08:39:39
--- grammar.y	1992/11/03 06:17:52
***************
*** 1,4 ****
! /* $Id: grammar.y,v 1.7 1992/09/09 08:39:39 greyham Exp $
   *
   * yacc grammar for C manual page generator
   * This was derived from the grammar given in Appendix A of
--- 1,4 ----
! /* $Id: grammar.y,v 1.8 1992/11/03 06:17:28 greyham Exp $
   *
   * yacc grammar for C manual page generator
   * This was derived from the grammar given in Appendix A of
***************
*** 175,187 ****
  	    }
  	}
  	| opt_comment T_TYPEDEF declaration_specifiers declarator_list ';'
- 								opt_eolcomment
  	{
  	    free($1);
  	    new_typedef_symbols(&$3,&$4);
  	    free_decl_spec(&$3);
  	    free_decl_list(&$4);
! 	    free($6);
  	}
  	;
  
--- 175,193 ----
  	    }
  	}
  	| opt_comment T_TYPEDEF declaration_specifiers declarator_list ';'
  	{
+ 	    /* create the typedef mid-rule, because the search for the
+ 	     * opt_eolcomment will read the next token, which may be a use of
+ 	     * the typedef.
+ 	     */
  	    free($1);
  	    new_typedef_symbols(&$3,&$4);
  	    free_decl_spec(&$3);
  	    free_decl_list(&$4);
! 	}
! 								opt_eolcomment
! 	{
! 	    free($7);
  	}
  	;
  
*** 1.8	1992/09/09 08:39:39
--- lex.l	1992/11/03 06:17:50
***************
*** 1,5 ****
  %{
! /* $Id: lex.l,v 1.8 1992/09/09 08:39:39 greyham Exp $
   *
   * C manual page generator
   * Lexical analyzer specification
--- 1,5 ----
  %{
! /* $Id: lex.l,v 1.9 1992/11/03 06:17:28 greyham Exp $
   *
   * C manual page generator
   * Lexical analyzer specification
***************
*** 356,362 ****
  		    if (remember) { add_dynbuf(c); end = dynbuf_current; }
  		}
  		break;
! 	    case END:	ateol = 0; goto leave;
  	    }
  	    break;
  	}
--- 356,363 ----
  		    if (remember) { add_dynbuf(c); end = dynbuf_current; }
  		}
  		break;
! 	    case END:
! 		if (!isspace(c)) { ateol = 0; goto leave; }
  	    }
  	    break;
  	}
*** 1.11	1992/09/09 08:39:39
--- manpage.c	1992/11/03 06:17:59
***************
*** 1,4 ****
! /* $Id: manpage.c,v 1.11 1992/09/09 08:39:39 greyham Exp $
   * stuff to do with manual page outputing
   */
  
--- 1,4 ----
! /* $Id: manpage.c,v 1.12 1992/11/03 06:17:28 greyham Exp $
   * stuff to do with manual page outputing
   */
  
***************
*** 14,20 ****
  #include "strconcat.h"
  #include "semantic.h"
  
! const char *section = "3";
  
  /* list of manual pages */
  ManualPage *firstpage = NULL;
--- 14,20 ----
  #include "strconcat.h"
  #include "semantic.h"
  
! extern char *section;		/* defined in c2man.c */
  
  /* list of manual pages */
  ManualPage *firstpage = NULL;
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads