Annotation of OpenXM_contrib/gnuplot/docs/doc2hlp.c, Revision 1.1.1.2
1.1 maekawa 1: #ifndef lint
1.1.1.2 ! maekawa 2: static char *RCSid = "$Id: doc2hlp.c,v 1.7 1998/10/19 13:17:32 lhecking Exp $";
1.1 maekawa 3: #endif
4:
5: /* GNUPLOT - doc2hlp.c */
6:
7: /*[
8: * Copyright 1986 - 1993, 1998 Thomas Williams, Colin Kelley
9: *
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.
15: *
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,
20: * provided you
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
28: * software.
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.
32: *
33: * This software is provided "as is" without express or implied warranty
34: * to the extent permitted by applicable law.
35: ]*/
36:
37: /*
38: * doc2hlp.c -- program to convert Gnuplot .DOC format to
39: * VMS help (.HLP) format.
40: *
41: * This involves stripping all lines with a leading ?,
42: * @, #, or %.
43: * Modified by Russell Lang from hlp2ms.c by Thomas Williams
44: *
45: * usage: doc2hlp [file.doc [file.hlp]]
46: *
47: * Original version by David Kotz used the following one line script!
48: * sed '/^[?@#%]/d' file.doc > file.hlp
49: */
50:
51: #ifdef HAVE_CONFIG_H
52: #include "config.h"
53: #endif
54:
55: #include "ansichek.h"
56: #include "stdfn.h"
57: #include "doc2x.h"
58:
59: extern boolean single_top_level;
60:
61: void convert __PROTO((FILE *, FILE *));
62: void process_line __PROTO((char *, FILE *));
63:
64: int main(argc, argv)
65: int argc;
66: char **argv;
67: {
68: FILE *infile;
69: FILE *outfile;
70:
71: infile = stdin;
72: outfile = stdout;
73:
74: single_top_level = TRUE;
75:
76: if (argc > 3) {
77: fprintf(stderr, "Usage: %s [infile [outfile]]\n", argv[0]);
78: exit(EXIT_FAILURE);
79: }
80: if (argc >= 2) {
81: if ((infile = fopen(argv[1], "r")) == (FILE *) NULL) {
82: fprintf(stderr, "%s: Can't open %s for reading\n",
83: argv[0], argv[1]);
84: exit(EXIT_FAILURE);
85: }
86: }
87: if (argc == 3) {
88: if ((outfile = fopen(argv[2], "w")) == (FILE *) NULL) {
89: fprintf(stderr, "%s: Can't open %s for writing\n",
90: argv[0], argv[2]);
91: exit(EXIT_FAILURE);
92: }
93: }
94:
95: convert(infile, outfile);
96:
97: exit(EXIT_SUCCESS);
98: }
99:
100:
101: void convert (inf, outf)
102: FILE *inf, *outf;
103: {
104: static char line[MAX_LINE_LEN+1];
105:
106: while (get_line(line, sizeof(line), inf))
107: process_line(line, outf);
108: }
109:
110:
111: void process_line(line, b)
112: char *line;
113: FILE *b;
114: {
115: static int line_count = 0;
116:
117: line_count++;
118:
119: switch (line[0]) { /* control character */
120: case '?':{ /* interactive help entry */
121: break; /* ignore */
122: }
123: case '@':{ /* start/end table */
124: break; /* ignore */
125: }
126: case '#':{ /* latex table entry */
127: break; /* ignore */
128: }
129: case '%':{ /* troff table entry */
130: break; /* ignore */
131: }
132: case '^':{ /* html entry */
133: break; /* ignore */
134: }
135: case '\n': /* empty text line */
136: case ' ':{ /* normal text line */
137: (void) fputs(line, b);
138: break;
139: }
140: default:{
141: if (isdigit((int)line[0])) { /* start of section */
142: (void) fputs(line, b);
143: } else
144: fprintf(stderr, "unknown control code '%c' in column 1, line %d\n",
145: line[0], line_count);
146: break;
147: }
148: }
149: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>