2 static char *RCSid() { return RCSid("$Id: doc2gih.c,v 1.15 2005/06/03 05:11:55 sfeam Exp $"); }
5 /* GNUPLOT - doc2gih.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 * doc2gih.c -- program to convert Gnuplot .DOC format to gnuplot
39 * interactive help (.GIH) format.
41 * This involves stripping all lines with a leading digit or
42 * a leading @, #, or %.
43 * Modified by Russell Lang from hlp2ms.c by Thomas Williams
45 * usage: doc2gih [file.doc [file.gih]]
47 * Original version by David Kotz used the following one line script!
48 * sed '/^[0-9@#%]/d' file.doc > file.gih
59 void convert __PROTO((FILE *, FILE *));
60 void process_line __PROTO((char *, FILE *));
63 main (int argc, char **argv)
72 fprintf(stderr, "Usage: %s [infile [outfile]]\n", argv[0]);
76 if ((infile = fopen(argv[1], "r")) == (FILE *) NULL) {
77 fprintf(stderr, "%s: Can't open %s for reading\n",
83 if ((outfile = fopen(argv[2], "w")) == (FILE *) NULL) {
84 fprintf(stderr, "%s: Can't open %s for writing\n",
90 convert(infile, outfile);
97 convert (FILE *inf, FILE *outf)
99 static char line[MAX_LINE_LEN+1];
101 while (get_line(line, sizeof(line), inf))
102 process_line(line, outf);
107 process_line(char *line, FILE *b)
109 static int line_count = 0;
113 switch (line[0]) { /* control character */
114 case '?':{ /* interactive help entry */
115 (void) fputs(line, b);
118 case '@':{ /* start/end table */
121 case '#':{ /* latex table entry */
124 case '=':{ /* latex index entry */
127 case '%':{ /* troff table entry */
130 case '^':{ /* html entry */
133 case '\n': /* empty text line */
134 case ' ':{ /* normal text line */
135 (void) fputs(line, b);
139 if (isdigit((int)line[0])) { /* start of section */
142 fprintf(stderr, "unknown control code '%c' in column 1, line %d\n",
143 line[0], line_count);