2 static char *RCSid() { return RCSid("$Id: checkdoc.c,v 1.14 2005/06/28 22:37:31 sfeam Exp $"); }
5 /* GNUPLOT - checkdoc.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 * checkdoc -- check a doc file for correctness of first column.
40 * Prints out lines that have an illegal first character.
41 * First character must be space, digit, or ?, @, #, %,
42 * or line must be empty.
44 * usage: checkdoc [docfile]
45 * Modified by Russell Lang from hlp2ms.c by Thomas Williams
47 * Original version by David Kotz used the following one line script!
48 * sed -e '/^$/d' -e '/^[ 0-9?@#%]/d' gnuplot.doc
60 void convert __PROTO((FILE *, FILE *));
61 void process_line __PROTO((char *, FILE *));
64 main (int argc, char **argv)
70 fprintf(stderr, "Usage: %s [infile]\n", argv[0]);
74 if ((infile = fopen(argv[1], "r")) == (FILE *) NULL) {
75 fprintf(stderr, "%s: Can't open %s for reading\n",
79 convert(infile, stdout);
84 convert(FILE *a, FILE *b)
86 static char line[MAX_LINE_LEN+1];
88 while (get_line(line, sizeof(line), a)) {
89 process_line(line, b);
94 process_line(char *line, FILE *b)
96 /* check matching backticks within a paragraph */
100 if (line[0] == ' ') {
103 /* skip/count leading spaces */
108 /* it is not clear if this is an error, but it is an
109 * inconsistency, so flag it
111 fprintf(b, "spaces-only line %s:%d\n", termdoc_filename, termdoc_lineno);
113 /* accumulate count of backticks. Do not check odd-ness
114 * until end of paragraph (non-space in column 1)
123 "mismatching backticks before %s:%d\n",
124 termdoc_filename, termdoc_lineno);
129 if (strchr(line, '\t'))
130 fprintf(b, "tab character in line %s:%d\n", termdoc_filename, termdoc_lineno);
132 switch (line[0]) { /* control character */
133 case '?':{ /* interactive help entry */
136 case '<':{ /* term docs */
139 case '@':{ /* start/end table */
142 case '#':{ /* latex table entry */
145 case '%':{ /* troff table entry */
148 case '^':{ /* html entry */
151 case '=':{ /* index entry */
154 case '\n': /* empty text line */
155 case ' ':{ /* normal text line */
159 if (isdigit((int)line[0])) { /* start of section */
162 /* output bad line */
163 fprintf(b, "%s:%d:%s", termdoc_filename, termdoc_lineno, line);