aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog4
-rw-r--r--src/hyper/ex2ht.c266
-rw-r--r--src/hyper/hthits.c599
-rw-r--r--src/include/all_hyper_proto.H11
-rw-r--r--src/include/ex2ht.H114
-rw-r--r--src/include/hthits.H112
6 files changed, 433 insertions, 463 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 8c8b3746..dedd6eec 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
2008-05-21 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * hyper/hthits.c (regerr): Remove.
+ * include/ex2ht.H1: Remove.
+ * include/hthits.H1: Remove.
+
* lib/cfuns-c.c (oa_getenv): Fix thinko.
(oa_getcwd): Likewise.
* lib/cfuns-c.c (oa_access_file_for_read): Likewise.
diff --git a/src/hyper/ex2ht.c b/src/hyper/ex2ht.c
index de6afe03..994ad277 100644
--- a/src/hyper/ex2ht.c
+++ b/src/hyper/ex2ht.c
@@ -36,7 +36,6 @@
/* ex2ht creates a cover page for structured HyperDoc example pages */
-#define _EX2HT_C
#include "openaxiom-c-macros.h"
#include "debug.h"
@@ -47,6 +46,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
+#include "cfuns.h"
@@ -59,43 +59,120 @@ extern int utimes(const char *, const struct timeval [2]);
#define MaxLineLength 512
#define MaxFiles 100
-char *files[MaxFiles];
-int numFiles = 0;
-struct timeval latest_date[2] ={{0,0},{0,0}};
+static char *files[MaxFiles];
+static int numFiles = 0;
+static struct timeval latest_date[2] ={{0,0},{0,0}};
-#include "ex2ht.H1"
+static FILE *coverFile;
-int
-main(int argc, char **argv)
+static void
+addFile(const char* filename)
{
- int i;
+ FILE *file = fopen(filename, "r");
+ int c;
- if (argc == 1) {
- fprintf(stderr, "usage: %s exfile.ht ...\n", argv[0]);
- return (-1);
+ if (file == NULL) {
+ fprintf(stderr, "Couln't open %s for reading\n", filename);
+ exit(-1);
}
- openCoverPage();
- for (i = 1; i < argc; i++)
- exToHt(argv[i]);
- closeCoverPage();
- for (i = 0; i < numFiles; i++)
- addFile(files[i]);
- closeCoverFile();
- return 0;
+ while ((c = getc(file)) != EOF)
+ putc(c, coverFile);
+ putc('\n', coverFile);
+ fclose(file);
+ oa_unlink(filename);
}
-char *
-allocString(char *s)
+
+static void
+emitCoverLink(const char* name, char *title)
{
- char *t = (char *) malloc(strlen(s) + 1);
+ fprintf(coverFile, "{\\downlink{%s}{%s}}\n", title, name);
+}
- strcpy(t, s);
- return t;
+static void
+closeCoverFile(void)
+{
+ fclose(coverFile);
+#ifdef HP9platform
+ times("coverex.ht",latest_date);
+#else
+ utimes("coverex.ht",latest_date);
+#endif
+}
+
+static void
+closeCoverPage(void)
+{
+ fprintf(coverFile, "}\\endscroll\\end{page}\n\n");
+}
+/* cover page functions */
+
+static void
+openCoverPage(void)
+{
+ coverFile = fopen("coverex.ht", "w");
+ if (coverFile == NULL) {
+ fprintf(stderr, "couldn't open coverex.ht for writing\n");
+ exit(-1);
+ }
+ fprintf(coverFile, "%% DO NOT EDIT! Created by ex2ht.\n\n");
+ fprintf(coverFile, "\\begin{page}{ExampleCoverPage}{Examples Of AXIOM Commands}\n");
+ fprintf(coverFile, "\\beginscroll\\table{\n");
+}
+
+static void
+emitSpadCommand(const char* line, const char* prefix, FILE *outFile)
+{
+ int braceCount = 1;
+ char command[MaxLineLength], *t = command;
+
+ while (1) {
+ if (*line == '}')
+ braceCount--;
+ if (braceCount == 0)
+ break;
+ if (*line == '{')
+ braceCount++;
+ *t++ = *line++;
+ }
+ *t = '\0';
+ fprintf(outFile, "%s%s}\n", prefix, command);
+}
+
+/* s is pageName}{title} */
+static void
+emitMenuEntry(const char* line, FILE *outFile)
+{
+ char pageName[MaxLineLength], title[MaxLineLength];
+ char *p = pageName, *t = title;
+
+ while (*line != '}')
+ *p++ = *line++;
+ *p = '\0';
+ line++;
+ while (*line != '}')
+ *t++ = *line++;
+ *t = '\0';
+ fprintf(outFile, "\\menudownlink%s}{%s}\n", title, pageName);
+}
+
+static void
+emitHeader(FILE *outFile, char *pageName, char *pageTitle)
+{
+ fprintf(outFile, "\\begin{page}{%s}{%s}\n", pageName, pageTitle);
+ fprintf(outFile, "\\beginscroll\\beginmenu\n");
}
-char *
-strPrefix(char *prefix, char *s)
+static void
+emitFooter(FILE *outFile)
+{
+ fprintf(outFile, "\\endmenu\\endscroll\\end{page}\n");
+}
+
+
+static char *
+strPrefix(char* prefix, char *s)
{
while (*prefix != '\0' && *prefix == *s) {
prefix++;
@@ -106,8 +183,19 @@ strPrefix(char *prefix, char *s)
return NULL;
}
-char *
-getExTitle(FILE *inFile, char *line)
+
+static char *
+allocString(const char* s)
+{
+ char *t = (char *) malloc(strlen(s) + 1);
+
+ strcpy(t, s);
+ return t;
+}
+
+
+static char *
+getExTitle(FILE *inFile, char* line)
{
char *title;
@@ -120,10 +208,12 @@ getExTitle(FILE *inFile, char *line)
return NULL;
}
-void
-exToHt(char *filename)
+
+static void
+exToHt(const char* filename)
{
- char line[MaxLineLength], *line2;
+ char line[MaxLineLength];
+ const char* line2;
char *title, *pagename;
FILE *inFile = fopen(filename, "r");
FILE *outFile;
@@ -179,108 +269,22 @@ exToHt(char *filename)
}
}
-void
-emitHeader(FILE *outFile, char *pageName, char *pageTitle)
-{
- fprintf(outFile, "\\begin{page}{%s}{%s}\n", pageName, pageTitle);
- fprintf(outFile, "\\beginscroll\\beginmenu\n");
-}
-
-void
-emitFooter(FILE *outFile)
-{
- fprintf(outFile, "\\endmenu\\endscroll\\end{page}\n");
-}
-
-/* s is pageName}{title} */
-void
-emitMenuEntry(char *line, FILE *outFile)
-{
- char pageName[MaxLineLength], title[MaxLineLength];
- char *p = pageName, *t = title;
-
- while (*line != '}')
- *p++ = *line++;
- *p = '\0';
- line++;
- while (*line != '}')
- *t++ = *line++;
- *t = '\0';
- fprintf(outFile, "\\menudownlink%s}{%s}\n", title, pageName);
-}
-
-void
-emitSpadCommand(char *line, char *prefix, FILE *outFile)
-{
- int braceCount = 1;
- char command[MaxLineLength], *t = command;
-
- while (1) {
- if (*line == '}')
- braceCount--;
- if (braceCount == 0)
- break;
- if (*line == '{')
- braceCount++;
- *t++ = *line++;
- }
- *t = '\0';
- fprintf(outFile, "%s%s}\n", prefix, command);
-}
-
-/* cover page functions */
-
-FILE *coverFile;
-
-void
-openCoverPage(void)
-{
- coverFile = fopen("coverex.ht", "w");
- if (coverFile == NULL) {
- fprintf(stderr, "couldn't open coverex.ht for writing\n");
- exit(-1);
- }
- fprintf(coverFile, "%% DO NOT EDIT! Created by ex2ht.\n\n");
- fprintf(coverFile, "\\begin{page}{ExampleCoverPage}{Examples Of AXIOM Commands}\n");
- fprintf(coverFile, "\\beginscroll\\table{\n");
-}
-
-void
-closeCoverPage(void)
-{
- fprintf(coverFile, "}\\endscroll\\end{page}\n\n");
-}
-
-void
-closeCoverFile(void)
-{
- fclose(coverFile);
-#ifdef HP9platform
- times("coverex.ht",latest_date);
-#else
- utimes("coverex.ht",latest_date);
-#endif
-}
-
-void
-emitCoverLink(char *name, char *title)
-{
- fprintf(coverFile, "{\\downlink{%s}{%s}}\n", title, name);
-}
-void
-addFile(char *filename)
+int
+main(int argc, char **argv)
{
- FILE *file = fopen(filename, "r");
- int c;
+ int i;
- if (file == NULL) {
- fprintf(stderr, "Couln't open %s for reading\n", filename);
- exit(-1);
+ if (argc == 1) {
+ fprintf(stderr, "usage: %s exfile.ht ...\n", argv[0]);
+ return (-1);
}
- while ((c = getc(file)) != EOF)
- putc(c, coverFile);
- putc('\n', coverFile);
- fclose(file);
- unlink(filename);
+ openCoverPage();
+ for (i = 1; i < argc; i++)
+ exToHt(argv[i]);
+ closeCoverPage();
+ for (i = 0; i < numFiles; i++)
+ addFile(files[i]);
+ closeCoverFile();
+ return 0;
}
diff --git a/src/hyper/hthits.c b/src/hyper/hthits.c
index ffaf2ad9..f7162f51 100644
--- a/src/hyper/hthits.c
+++ b/src/hyper/hthits.c
@@ -48,7 +48,7 @@
*
* SMW Feb 91
*/
-#define _HTHITS_C
+
#include "openaxiom-c-macros.h"
#include "debug.h"
@@ -69,13 +69,11 @@
#define MAX_ENTRY_NAME 1024 /* E.g. DifferentialCalculusPage */
#define MAX_COMP_REGEX 1024
-typedef struct pgInfo {
+typedef struct PgInfo {
char name[MAX_ENTRY_NAME];
long start, size;
} PgInfo ;
-#include "hthits.H1"
-
/*
* Global variables set according to the command line.
*/
@@ -86,343 +84,334 @@ char *htdbFName;
int gverifydates=0;
regex_t reg_pattern;
-int
-main(int argc,char ** argv)
+static void
+badDB(void)
{
- cmdline(argc, argv);
-
- regcomp(&reg_pattern, pattern, REG_NEWLINE);
-
- handleHtdb();
- return(0);
+ fprintf(stderr, "%s: bad database file %s\n", progName, htdbFName);
+ exit(1);
}
-void
-cmdline(int argc,char ** argv)
-{
- progName = argv[0];
-
- if (argc != 3) {
- fprintf(stderr, "Usage: %s pattern htdb-file\n", progName);
- exit(1);
- }
- pattern = argv[1];
- htdbFName = argv[2];
-}
-
-void
-handleHtdb(void)
+static void
+untexbuf(register char* s)
{
- FILE *htdbFile;
- int c;
-
- htdbFile = fopen(htdbFName, "r");
- if (htdbFile == NULL)
- badDB();
-
- while ((c = getc(htdbFile)) != EOF) {
- if (c != '\t')
- badDB();
- ungetc(c, htdbFile);
-
- handleFile(htdbFile);
- }
- fclose(htdbFile);
+ register char *d = s;
+
+ while (*s)
+ switch (*s) {
+ case '\\':
+ *d++ = ' ';
+ s++;
+ if (*s != '%')
+ while (isalpha(*s))
+ s++;
+ break;
+ case '%':
+ *d++ = ' ';
+ s++;
+ while (*s && *s != '\n')
+ s++;
+ break;
+ case '{':
+ case '}':
+ case '#':
+ *d++ = ' ';
+ s++;
+ break;
+ default:
+ *d++ = *s++;
+ }
+ *d = 0;
}
-void
-handleFile(FILE *htdbFile)
+/*
+ * Any newlines and separator characters in the title are changed to blanks.
+ */
+
+static void
+splitpage(char* buf, char** ptitle, char** pbody)
{
- static PgInfo *pgInfoV = 0;
- static int pgInfoC = 0;
-
- char htdbLine[MAX_HTDB_LINE];
- char htfname[MAX_HTDB_LINE];
- time_t httime;
- long htsize;
- struct stat htstat;
-
- long fstart, fend;
- int rc, i, npages;
-
- char entname[MAX_ENTRY_NAME], enttype[MAX_ENTRY_TYPE];
- long entoffset, entlineno;
-
- fgets(htdbLine, MAX_HTDB_LINE, htdbFile);
-
- sscanf(htdbLine, " %s %ld", htfname, &httime);
-
- /*
- * 1. Verify file: get size and check modification time.
- */
- rc = stat(htfname, &htstat);
- if (rc == -1) {
- fprintf(stderr, "%s: Cannot access %s\n", progName, htfname);
- exit(1);
- }
- if (gverifydates && (htstat.st_mtime != httime)) {
-
- fprintf(stderr, "%s: Out of date file %s\n", progName, htfname);
- exit(1);
- }
- htsize = htstat.st_size;
-
- /*
- * 2. Count the pages in the file.
- */
- npages = 0;
- fstart = ftell(htdbFile);
- fend = ftell(htdbFile);
-
- while (fgets(htdbLine, MAX_HTDB_LINE, htdbFile) != NULL) {
- if (htdbLine[0] == '\t')
- break;
- if (!strncmp(htdbLine, "\\page", 5))
- npages++;
- fend = ftell(htdbFile);
- }
-
- /*
- * 3. Find offset and size of each \page (skipping \newcommands etc.)
- */
- if (npages > pgInfoC) {
- if (pgInfoV)
- free(pgInfoV);
-
- pgInfoC = npages;
- pgInfoV = (PgInfo *)
- malloc(npages * sizeof(PgInfo));
-
- if (!pgInfoV) {
- fprintf(stderr, "%s: out of memory\n", progName);
- exit(1);
- }
- }
-
- fseek(htdbFile, fstart, 0);
-
- for (i = 0; fgets(htdbLine, MAX_HTDB_LINE, htdbFile) != NULL;) {
- if (htdbLine[0] == '\t')
+ int n, depth, tno;
+ char *s;
+
+ switch (buf[1]) {
+ case 'p':
+ tno = 2;
+ break; /* \page{Name}{Title} */
+ case 'b':
+ tno = 3;
+ break; /* \begin{page}{Name}{Title} */
+ default:
+ fprintf(stderr, "%s: Invalid page format: %s\n", progName, buf);
+ exit(1);
+ }
+
+ n = 0;
+ depth = 0;
+
+ for (s = buf; *s; s++) {
+ if (*s == '{')
+ if (++depth == 1 && ++n == tno)
+ *ptitle = s + 1;
+ if (*s == '}')
+ if (depth-- == 1 && n == tno) {
+ *s = 0;
+ *pbody = s + 1;
break;
+ }
+ }
+}
- sscanf(htdbLine, "%s %s %ld %ld",
- enttype, entname, &entoffset, &entlineno);
-
- if (i > 0 && pgInfoV[i - 1].size == -1)
- pgInfoV[i - 1].size = entoffset - pgInfoV[i - 1].start;
-
- if (!strcmp(enttype, "\\page")) {
- strncpy(pgInfoV[i].name, entname, MAX_ENTRY_NAME);
- pgInfoV[i].start = entoffset;
- pgInfoV[i].size = -1;
-
- i++;
- }
- }
- if (i > 0 && pgInfoV[i - 1].size == -1)
- pgInfoV[i - 1].size = htsize - pgInfoV[i - 1].start;
-
- if (i != npages)
- badDB();
- /*
- * 4. Position database input to read next file-description
- */
- fseek(htdbFile, fend, 0);
+/*
+ * Given string s and length n, output ` followed by the first n characters
+ * of s with ` and newline converted to blanks. This function destructively
+ * modifies s.
+ */
- /*
- * 5. Process the pages of the file.
- */
- handleFilePages(htfname, npages, pgInfoV);
+static void
+squirt(char* s, int n)
+{
+ register char *t, *e;
+ int c;
+
+ c = s[n];
+
+ for (t = s, e = s + n; t < e; t++)
+ if (*t == '`' || *t == '\n')
+ *t = ' ';
+
+ if (s[n] != 0) {
+ s[n] = 0;
+ }
+ printf("{%.*s}", n, s);
+ s[n] = c;
}
-void
-handleFilePages(char *fname, int pgc, PgInfo *pgv)
+static void
+searchPage(char* pgname, char* pgtitle, char* pgbody)
{
- FILE *infile;
- int i;
-
- infile = fopen(fname, "r");
- if (infile == NULL) {
- fprintf(stderr, "%s: Cannot read file %s\n", progName, fname);
- exit(1);
- }
-
-
- for (i = 0; i < pgc; i++)
- handlePage(infile, pgv + i);
-
- fclose(infile);
-
+ char *bodyrest;
+ regmatch_t match_pos;
+ int nhits = 0;
+
+ if (!regexec(&reg_pattern, pgtitle, 1, &match_pos, 0))
+ nhits++;
+
+ bodyrest = pgbody;
+ while (!regexec(&reg_pattern, bodyrest, 1, &match_pos, 0)) {
+ nhits++;
+ bodyrest += match_pos.rm_eo;
+ }
+ if (nhits) {
+ printf("\\newsearchresultentry{%d}{%s}",nhits, pgtitle);
+ squirt(pgname, strlen(pgname));
+ printf("\n");
+ }
}
-void
-handlePage(FILE *infile,PgInfo * pg)
+static void
+handlePage(FILE* infile, PgInfo* pg)
{
- static char *pgBuf = 0;
- static int pgBufSize = 0;
-
- char *title, *body;
-
- if (pg->size > pgBufSize - 1) {
- if (pgBuf)
- free(pgBuf);
- pgBufSize = pg->size + 20000;
- pgBuf = (char *)malloc(pgBufSize);
-
- if (!pgBuf) {
- fprintf(stderr,"%s: Out of memory\n", progName);
- exit(1);
- }
- }
-
- fseek(infile, pg->start, 0);
- fread(pgBuf, pg->size, 1, infile);
- pgBuf[pg->size] = 0;
-
- splitpage(pgBuf, &title, &body);
- /*untexbuf(title);*/
- untexbuf(body);
+ static char *pgBuf = 0;
+ static int pgBufSize = 0;
+
+ char *title, *body;
+
+ if (pg->size > pgBufSize - 1) {
+ if (pgBuf)
+ free(pgBuf);
+ pgBufSize = pg->size + 20000;
+ pgBuf = (char *)malloc(pgBufSize);
+
+ if (!pgBuf) {
+ fprintf(stderr,"%s: Out of memory\n", progName);
+ exit(1);
+ }
+ }
+
+ fseek(infile, pg->start, 0);
+ fread(pgBuf, pg->size, 1, infile);
+ pgBuf[pg->size] = 0;
+
+ splitpage(pgBuf, &title, &body);
+ /*untexbuf(title);*/
+ untexbuf(body);
#ifdef DEBUG
- printf("-------------- %s -------------\n%s", pg->name, pgBuf);
- printf("============== %s =============\n", title);
- printf("%s", body);
+ printf("-------------- %s -------------\n%s", pg->name, pgBuf);
+ printf("============== %s =============\n", title);
+ printf("%s", body);
#endif
-
- searchPage(pg->name, title, body);
-
+
+ searchPage(pg->name, title, body);
}
-void
-searchPage(char *pgname,char * pgtitle,char * pgbody)
+static void
+handleFilePages(const char* fname, int pgc, PgInfo* pgv)
{
- char *bodyrest;
- regmatch_t match_pos;
- int nhits = 0;
-
- if (!regexec(&reg_pattern, pgtitle, 1, &match_pos, 0))
- nhits++;
-
- bodyrest = pgbody;
- while (!regexec(&reg_pattern, bodyrest, 1, &match_pos, 0)) {
- nhits++;
- bodyrest += match_pos.rm_eo;
- }
- if (nhits) {
- printf("\\newsearchresultentry{%d}{%s}",nhits, pgtitle);
- squirt(pgname, strlen(pgname));
- printf("\n");
- }
+ FILE *infile;
+ int i;
+
+ infile = fopen(fname, "r");
+ if (infile == NULL) {
+ fprintf(stderr, "%s: Cannot read file %s\n", progName, fname);
+ exit(1);
+ }
+
+ for (i = 0; i < pgc; i++)
+ handlePage(infile, pgv + i);
+
+ fclose(infile);
}
-/*
- * Given string s and length n, output ` followed by the first n characters
- * of s with ` and newline converted to blanks. This function destructively
- * modifies s.
- */
-
-void
-squirt(char *s, int n)
+static void
+handleFile(FILE* htdbFile)
{
- register char *t, *e;
- int c;
-
- c = s[n];
-
- for (t = s, e = s + n; t < e; t++)
- if (*t == '`' || *t == '\n')
- *t = ' ';
-
- if (s[n] != 0) {
- s[n] = 0;
- }
- printf("{%.*s}", n, s);
- s[n] = c;
+ static PgInfo *pgInfoV = 0;
+ static int pgInfoC = 0;
+
+ char htdbLine[MAX_HTDB_LINE];
+ char htfname[MAX_HTDB_LINE];
+ time_t httime;
+ long htsize;
+ struct stat htstat;
+
+ long fstart, fend;
+ int rc, i, npages;
+
+ char entname[MAX_ENTRY_NAME], enttype[MAX_ENTRY_TYPE];
+ long entoffset, entlineno;
+
+ fgets(htdbLine, MAX_HTDB_LINE, htdbFile);
+
+ sscanf(htdbLine, " %s %ld", htfname, &httime);
+
+ /*
+ * 1. Verify file: get size and check modification time.
+ */
+ rc = stat(htfname, &htstat);
+ if (rc == -1) {
+ fprintf(stderr, "%s: Cannot access %s\n", progName, htfname);
+ exit(1);
+ }
+ if (gverifydates && (htstat.st_mtime != httime)) {
+
+ fprintf(stderr, "%s: Out of date file %s\n", progName, htfname);
+ exit(1);
+ }
+ htsize = htstat.st_size;
+
+ /*
+ * 2. Count the pages in the file.
+ */
+ npages = 0;
+ fstart = ftell(htdbFile);
+ fend = ftell(htdbFile);
+
+ while (fgets(htdbLine, MAX_HTDB_LINE, htdbFile) != NULL) {
+ if (htdbLine[0] == '\t')
+ break;
+ if (!strncmp(htdbLine, "\\page", 5))
+ npages++;
+ fend = ftell(htdbFile);
+ }
+
+ /*
+ * 3. Find offset and size of each \page (skipping \newcommands etc.)
+ */
+ if (npages > pgInfoC) {
+ if (pgInfoV)
+ free(pgInfoV);
+
+ pgInfoC = npages;
+ pgInfoV = (PgInfo *)
+ malloc(npages * sizeof(PgInfo));
+
+ if (!pgInfoV) {
+ fprintf(stderr, "%s: out of memory\n", progName);
+ exit(1);
+ }
+ }
+
+ fseek(htdbFile, fstart, 0);
+
+ for (i = 0; fgets(htdbLine, MAX_HTDB_LINE, htdbFile) != NULL;) {
+ if (htdbLine[0] == '\t')
+ break;
+
+ sscanf(htdbLine, "%s %s %ld %ld",
+ enttype, entname, &entoffset, &entlineno);
+
+ if (i > 0 && pgInfoV[i - 1].size == -1)
+ pgInfoV[i - 1].size = entoffset - pgInfoV[i - 1].start;
+
+ if (!strcmp(enttype, "\\page")) {
+ strncpy(pgInfoV[i].name, entname, MAX_ENTRY_NAME);
+ pgInfoV[i].start = entoffset;
+ pgInfoV[i].size = -1;
+
+ i++;
+ }
+ }
+ if (i > 0 && pgInfoV[i - 1].size == -1)
+ pgInfoV[i - 1].size = htsize - pgInfoV[i - 1].start;
+
+ if (i != npages)
+ badDB();
+
+ /*
+ * 4. Position database input to read next file-description
+ */
+ fseek(htdbFile, fend, 0);
+
+ /*
+ * 5. Process the pages of the file.
+ */
+ handleFilePages(htfname, npages, pgInfoV);
}
-/*
- * Any newlines and separator characters in the title are changed to blanks.
- */
-void
-splitpage(char *buf, char **ptitle, char **pbody)
+static void
+handleHtdb(void)
{
- int n, depth, tno;
- char *s;
-
- switch (buf[1]) {
- case 'p':
- tno = 2;
- break; /* \page{Name}{Title} */
- case 'b':
- tno = 3;
- break; /* \begin{page}{Name}{Title} */
- default:
- fprintf(stderr, "%s: Invalid page format: %s\n", progName, buf);
- exit(1);
- }
-
- n = 0;
- depth = 0;
-
- for (s = buf; *s; s++) {
- if (*s == '{')
- if (++depth == 1 && ++n == tno)
- *ptitle = s + 1;
- if (*s == '}')
- if (depth-- == 1 && n == tno) {
- *s = 0;
- *pbody = s + 1;
- break;
- }
- }
+ FILE *htdbFile;
+ int c;
+
+ htdbFile = fopen(htdbFName, "r");
+ if (htdbFile == NULL)
+ badDB();
+
+ while ((c = getc(htdbFile)) != EOF) {
+ if (c != '\t')
+ badDB();
+ ungetc(c, htdbFile);
+
+ handleFile(htdbFile);
+ }
+ fclose(htdbFile);
}
-
-void
-untexbuf(register char *s)
+static void
+cmdline(int argc, char** argv)
{
- register char *d = s;
-
- while (*s)
- switch (*s) {
- case '\\':
- *d++ = ' ';
- s++;
- if (*s != '%')
- while (isalpha(*s))
- s++;
- break;
- case '%':
- *d++ = ' ';
- s++;
- while (*s && *s != '\n')
- s++;
- break;
- case '{':
- case '}':
- case '#':
- *d++ = ' ';
- s++;
- break;
- default:
- *d++ = *s++;
- }
- *d = 0;
+ progName = argv[0];
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage: %s pattern htdb-file\n", progName);
+ exit(1);
+ }
+
+ pattern = argv[1];
+ htdbFName = argv[2];
}
-void
-badDB(void)
-{
- fprintf(stderr, "%s: bad database file %s\n", progName, htdbFName);
- exit(1);
-}
-void
-regerr(int code)
+int
+main(int argc, char** argv)
{
- fprintf(stderr, "%s: regular expression error %d for \"%s\"\n",
- progName, code, pattern);
+ cmdline(argc, argv);
+ regcomp(&reg_pattern, pattern, REG_NEWLINE);
+ handleHtdb();
+ return(0);
}
diff --git a/src/include/all_hyper_proto.H1 b/src/include/all_hyper_proto.H1
index 0218d96a..ac6d8ce1 100644
--- a/src/include/all_hyper_proto.H1
+++ b/src/include/all_hyper_proto.H1
@@ -3,7 +3,6 @@
#include "cond.H1"
#include "display.H1"
#include "event.H1"
-#include "ex2ht.H1"
#include "form_ext.H1"
#include "extent1.H1"
#include "extent2.H1"
diff --git a/src/include/ex2ht.H1 b/src/include/ex2ht.H1
deleted file mode 100644
index 2dc0334d..00000000
--- a/src/include/ex2ht.H1
+++ /dev/null
@@ -1,14 +0,0 @@
-extern int main(int argc , char * * argv);
-extern void openCoverPage(void);
-extern void exToHt(char * filename);
-extern void closeCoverPage(void);
-extern void addFile(char * filename);
-extern void closeCoverFile(void);
-extern char * allocString(char * s);
-extern char * strPrefix(char * prefix , char * s);
-extern char * getExTitle(FILE * inFile , char * line);
-extern void emitCoverLink(char * name , char * title);
-extern void emitHeader(FILE * outFile , char * pageName , char * pageTitle);
-extern void emitMenuEntry(char * line , FILE * outFile);
-extern void emitSpadCommand(char * line , char * prefix , FILE * outFile);
-extern void emitFooter(FILE * outFile);
diff --git a/src/include/hthits.H1 b/src/include/hthits.H1
deleted file mode 100644
index f210bb49..00000000
--- a/src/include/hthits.H1
+++ /dev/null
@@ -1,12 +0,0 @@
-extern void regerr(int code);
-extern int main(int argc , char * * argv);
-extern void cmdline(int argc , char * * argv);
-extern void handleHtdb(void);
-extern void badDB(void);
-extern void handleFile(FILE * htdbFile);
-extern void handleFilePages(char * fname , int pgc , PgInfo * pgv);
-extern void handlePage(FILE * infile , PgInfo * pg);
-extern void splitpage(char * buf , char * * ptitle , char * * pbody);
-extern void untexbuf(register char * s);
-extern void searchPage(char * pgname , char * pgtitle , char * pgbody);
-extern void squirt(char * s , int n);