2 static char *RCSid() { return RCSid("$Id: doc2hlp.c,v 1.16 2005/06/03 05:11:55 sfeam Exp $"); }
5 /* GNUPLOT - doc2hlp.c */
8 * Copyright 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley
10 * Permission to use, copy, and distribute this software and its
11 * documentation for any purpose with or without fee is hereby granted,
12 * provided that the above copyright notice appear in all copies and
13 * that both that copyright notice and this permission notice appear
14 * in supporting documentation.
16 * Permission to modify the software is granted, but not the right to
17 * distribute the complete modified source code. Modifications are to
18 * be distributed as patches to the released version. Permission to
19 * distribute binaries produced by compiling modified sources is granted,
21 * 1. distribute the corresponding source modifications from the
22 * released version in the form of a patch file along with the binaries,
23 * 2. add special version identification to distinguish your version
24 * in addition to the base release version number,
25 * 3. provide your name and address as the primary contact for the
26 * support of your modified version, and
27 * 4. retain our contact information in regard to use of the base
29 * Permission to distribute the released version of the source code along
30 * with corresponding source modifications in the form of a patch file is
31 * granted with same provisions 2 through 4 for binary distributions.
33 * This software is provided "as is" without express or implied warranty
34 * to the extent permitted by applicable law.
38 * doc2hlp.c -- program to convert Gnuplot .DOC format to
39 * VMS help (.HLP) format.
41 * This involves stripping all lines with a leading ?,
43 * Modified by Russell Lang from hlp2ms.c by Thomas Williams
45 * usage: doc2hlp [file.doc [file.hlp]]
47 * Original version by David Kotz used the following one line script!
48 * sed '/^[?@#%]/d' file.doc > file.hlp
59 extern TBOOLEAN single_top_level;
61 void convert __PROTO((FILE *, FILE *));
62 void process_line __PROTO((char *, FILE *));
65 main (int argc, char **argv)
73 single_top_level = TRUE;
76 fprintf(stderr, "Usage: %s [infile [outfile]]\n", argv[0]);
80 if ((infile = fopen(argv[1], "r")) == (FILE *) NULL) {
81 fprintf(stderr, "%s: Can't open %s for reading\n",
87 if ((outfile = fopen(argv[2], "w")) == (FILE *) NULL) {
88 fprintf(stderr, "%s: Can't open %s for writing\n",
94 convert(infile, outfile);
101 convert (FILE *inf, FILE *outf)
103 static char line[MAX_LINE_LEN+1];
105 while (get_line(line, sizeof(line), inf))
106 process_line(line, outf);
111 process_line (char *line, FILE *b)
113 static int line_count = 0;
117 switch (line[0]) { /* control character */
118 case '?':{ /* interactive help entry */
121 case '@':{ /* start/end table */
124 case '=': /* latex index entry */
125 case '#':{ /* latex table entry */
128 case '%':{ /* troff table entry */
131 case '^':{ /* html entry */
134 case '\n': /* empty text line */
135 case ' ':{ /* normal text line */
136 (void) fputs(line, b);
140 if (isdigit((int)line[0])) { /* start of section */
141 (void) fputs(line, b);
143 fprintf(stderr, "unknown control code '%c' in column 1, line %d\n",
144 line[0], line_count);