|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T d
Length: 1949 (0x79d)
Types: TextFile
Names: »doc2gih.c«
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
└─⟦63303ae94⟧ »unix3.14/TeX3.14.tar.Z«
└─⟦c58930e5c⟧
└─⟦this⟧ »TeX3.14/TeXcontrib/gnuplot/docs/doc2gih.c«
/*
* doc2gih.c -- program to convert Gnuplot .DOC format to gnuplot
* interactive help (.GIH) format.
*
* This involves stripping all lines with a leading digit or
* a leading @, #, or %.
* Modified by Russell Lang from hlp2ms.c by Thomas Williams
*
* usage: doc2gih < file.doc > file.gih
*
* Original version by David Kotz used the following one line script!
* sed '/^[0-9@#%]/d' file.doc > file.gih
*/
#include <stdio.h>
#include <ctype.h>
#define MAX_LINE_LEN 256
#define TRUE 1
#define FALSE 0
main(argc,argv)
int argc;
char **argv;
{
FILE * infile;
FILE * outfile;
infile = stdin;
outfile = stdout;
if (argc > 3) {
fprintf(stderr,"Usage: %s infile outfile\n", argv[0]);
exit(1);
}
if (argc >= 2)
if ( (infile = fopen(argv[1],"r")) == (FILE *)NULL) {
fprintf(stderr,"%s: Can't open %s for reading\n",
argv[0], argv[1]);
exit(1);
}
if (argc == 3)
if ( (outfile = fopen(argv[2],"w")) == (FILE *)NULL) {
fprintf(stderr,"%s: Can't open %s for writing\n",
argv[0], argv[2]);
}
convert(infile,outfile);
exit(0);
}
convert(a,b)
FILE *a,*b;
{
static char line[MAX_LINE_LEN];
while (fgets(line,MAX_LINE_LEN,a)) {
process_line(line, b);
}
}
process_line(line, b)
char *line;
FILE *b;
{
switch(line[0]) { /* control character */
case '?': { /* interactive help entry */
(void) fputs(line,b);
break;
}
case '@': { /* start/end table */
break; /* ignore */
}
case '#': { /* latex table entry */
break; /* ignore */
}
case '%': { /* troff table entry */
break; /* ignore */
}
case '\n': /* empty text line */
case ' ': { /* normal text line */
(void) fputs(line,b);
break;
}
default: {
if (isdigit(line[0])) { /* start of section */
/* ignore */
} else
fprintf(stderr, "unknown control code '%c' in column 1\n",
line[0]);
break;
}
}
}