summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bk_text.c12
-rw-r--r--buttress.h1
-rw-r--r--input.c24
-rw-r--r--inputs/test.but6
4 files changed, 32 insertions, 11 deletions
diff --git a/bk_text.c b/bk_text.c
index 2b58c06..2f32b47 100644
--- a/bk_text.c
+++ b/bk_text.c
@@ -23,6 +23,7 @@ static int text_convert(wchar_t *, char **);
static void text_title(FILE *, word *, word *, alignment, wchar_t, int, int);
static void text_heading(FILE *, word *, word *, int, int);
+static void text_rule(FILE *, int, int);
static void text_para(FILE *, word *, char *, word *, int, int, int);
static void text_codepara(FILE *, word *, int, int);
static void text_versionid(FILE *, word *);
@@ -139,6 +140,10 @@ void text_backend(paragraph *sourceform, keywordlist *keywords, index *idx) {
text_heading(fp, p->kwtext2, p->words, conf.indent, conf.width);
break;
+ case para_Rule:
+ text_rule(fp, conf.indent, conf.width);
+ break;
+
case para_Normal:
case para_BiblioCited: /* FIXME: put the citation on front */
case para_Bullet:
@@ -410,6 +415,13 @@ static void text_heading(FILE *fp, word *prefix, word *text,
sfree(t.text);
}
+static void text_rule(FILE *fp, int indent, int width) {
+ while (indent--) putc(' ', fp);
+ while (width--) putc('-', fp); /* FIXME: configurability! */
+ putc('\n', fp);
+ putc('\n', fp);
+}
+
static void text_para(FILE *fp, word *prefix, char *prefixextra, word *text,
int indent, int extraindent, int width) {
wrappedline *wrapping, *p;
diff --git a/buttress.h b/buttress.h
index 1ce39d7..0c54752 100644
--- a/buttress.h
+++ b/buttress.h
@@ -74,6 +74,7 @@ struct paragraph_Tag {
enum {
para_IM, /* index merge */
para_BR, /* bibliography rewrite */
+ para_Rule, /* random horizontal rule */
para_Chapter,
para_Appendix,
para_UnnumberedChapter,
diff --git a/input.c b/input.c
index f74023a..4e40455 100644
--- a/input.c
+++ b/input.c
@@ -123,6 +123,7 @@ enum {
c_n, /* numbered list */
c_nocite, /* bibliography trickery */
c_preamble, /* document preamble text */
+ c_rule, /* horizontal rule */
c_title, /* document title */
c_u, /* aux field is char code */
c_versionid /* document RCS id */
@@ -182,6 +183,7 @@ static void match_kw(token *tok) {
{"n", c_n}, /* numbered list */
{"nocite", c_nocite}, /* bibliography trickery */
{"preamble", c_preamble}, /* document preamble text */
+ {"rule", c_rule}, /* horizontal rule */
{"title", c_title}, /* document title */
{"versionid", c_versionid}, /* document RCS id */
{"{", c__escaped}, /* escaped lbrace (\{) */
@@ -521,11 +523,12 @@ static void read_file(paragraph ***ret, input *in, index *idx) {
/*
* `needkw' values:
*
- * 0 -- no keywords at all
* 1 -- exactly one keyword
* 2 -- at least one keyword
* 4 -- any number of keywords including zero
* 8 -- at least one keyword and then nothing else
+ * 16 -- nothing at all! no keywords, no body
+ * 32 -- no keywords at all
*/
case c_A: needkw = 2; par.type = para_Appendix; break;
case c_B: needkw = 2; par.type = para_Biblio; break;
@@ -535,19 +538,20 @@ static void read_file(paragraph ***ret, input *in, index *idx) {
case c_IM: needkw = 2; par.type = para_IM; break;
case c_S: needkw = 2; par.type = para_Subsect;
par.aux = t.aux; break;
- case c_U: needkw = 0; par.type = para_UnnumberedChapter; break;
+ case c_U: needkw = 32; par.type = para_UnnumberedChapter; break;
/* For \b and \n the keyword is optional */
case c_b: needkw = 4; par.type = para_Bullet; break;
case c_n: needkw = 4; par.type = para_NumberedList; break;
- case c_copyright: needkw = 0; par.type = para_Copyright; break;
+ case c_copyright: needkw = 32; par.type = para_Copyright; break;
/* For \nocite the keyword is _everything_ */
case c_nocite: needkw = 8; par.type = para_NoCite; break;
- case c_preamble: needkw = 0; par.type = para_Preamble; break;
- case c_title: needkw = 0; par.type = para_Title; break;
- case c_versionid: needkw = 0; par.type = para_VersionID; break;
+ case c_preamble: needkw = 32; par.type = para_Preamble; break;
+ case c_rule: needkw = 16; par.type = para_Rule; break;
+ case c_title: needkw = 32; par.type = para_Title; break;
+ case c_versionid: needkw = 32; par.type = para_VersionID; break;
}
- if (needkw >= 0) {
+ if (needkw > 0) {
rdstring rs = { 0, 0, NULL };
int nkeys = 0;
filepos fp;
@@ -580,7 +584,7 @@ static void read_file(paragraph ***ret, input *in, index *idx) {
rdadd(&rs, 0); /* add string terminator */
/* See whether we have the right number of keywords. */
- if (needkw == 0 && nkeys > 0)
+ if ((needkw & 48) && nkeys > 0)
error(err_kwillegal, &fp);
if ((needkw & 11) && nkeys == 0)
error(err_kwexpected, &fp);
@@ -589,8 +593,8 @@ static void read_file(paragraph ***ret, input *in, index *idx) {
par.keyword = rdtrim(&rs);
- /* Move to EOP in case of needkw==8 (no body) */
- if (needkw == 8) {
+ /* Move to EOP in case of needkw==8 or 16 (no body) */
+ if (needkw & 24) {
if (t.type != tok_eop) {
error(err_bodyillegal, &t.pos);
/* Error recovery: eat the rest of the paragraph */
diff --git a/inputs/test.but b/inputs/test.but
index 57fcea2..86d6b8c 100644
--- a/inputs/test.but
+++ b/inputs/test.but
@@ -7,7 +7,7 @@ date \date{%Y.%m.%d} (default format is \date).
\copyright Copyright 1999 Simon \#{second comment}Tatham. All rights
reserved.
-\versionid $Id: test.but,v 1.7 1999/10/21 13:26:48 simon Exp $
+\versionid $Id: test.but,v 1.8 1999/10/22 16:04:02 simon Exp $
\C{ch\\ap} First chapter title
@@ -40,6 +40,10 @@ This is a list:
\b Eek.
+This is a horizontal rule:
+
+\rule
+
This is a numbered list:
\n Ooh.