summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--buttress.h14
-rw-r--r--error.c7
-rw-r--r--input.c2
-rw-r--r--inputs/test.but4
-rw-r--r--keywords.c5
-rw-r--r--main.c5
7 files changed, 30 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 518ea56..ab67cbc 100644
--- a/Makefile
+++ b/Makefile
@@ -44,7 +44,7 @@ endif
SRC := ../
MODULES := main malloc ustring error help licence version misc
-MODULES += input keywords contents index style
+MODULES += input keywords contents index style biblio
OBJECTS := $(addsuffix .o,$(MODULES))
DEPS := $(addsuffix .d,$(MODULES))
diff --git a/buttress.h b/buttress.h
index 6ec6cd1..aec26d0 100644
--- a/buttress.h
+++ b/buttress.h
@@ -66,6 +66,7 @@ struct paragraph_Tag {
word *words; /* list of words in paragraph */
int aux; /* number, in a numbered paragraph */
word *kwtext; /* chapter/section indication */
+ filepos fpos;
};
enum {
para_IM, /* index merge */
@@ -76,7 +77,8 @@ enum {
para_Heading,
para_Subsect,
para_Normal,
- para_Biblio,
+ para_Biblio, /* causes no output unless turned ... */
+ para_BiblioCited, /* ... into this paragraph type */
para_Bullet,
para_NumberedList,
para_Code,
@@ -136,7 +138,8 @@ enum {
err_missingrbrace, /* unclosed braces at end of para */
err_nestedstyles, /* unable to nest text styles */
err_nestedindex, /* unable to nest `\i' thingys */
- err_nosuchkw /* unresolved cross-reference */
+ err_nosuchkw, /* unresolved cross-reference */
+ err_multiBR /* multiple \BRs on same keyword */
};
/*
@@ -212,7 +215,9 @@ struct keyword_Tag {
wchar_t *key; /* the keyword itself */
word *text; /* "Chapter 2", "Appendix Q"... */
/* (NB: filepos are not set) */
+ paragraph *para; /* the paragraph referenced */
};
+keyword *kw_lookup(keywordlist *, wchar_t *);
keywordlist *get_keywords(paragraph *);
void free_keywords(keywordlist *);
void subst_keywords(paragraph *, keywordlist *);
@@ -229,6 +234,11 @@ word *number_mktext(numberstate *, int, int, int);
void number_free(numberstate *);
/*
+ * biblio.c
+ */
+void gen_citations(paragraph *, keywordlist *);
+
+/*
* style.c
*/
struct userstyle_Tag {
diff --git a/error.c b/error.c
index f6621f2..678ddaa 100644
--- a/error.c
+++ b/error.c
@@ -123,6 +123,13 @@ static void do_error(int code, va_list ap) {
sprintf(error, "unable to resolve cross-reference to `%.200s'", sp);
flags = FILEPOS;
break;
+ case err_multiBR:
+ fpos = *va_arg(ap, filepos *);
+ wsp = va_arg(ap, wchar_t *);
+ sp = ustrtoa(wsp, auxbuf, sizeof(auxbuf));
+ sprintf(error, "multiple `\\BR' entries given for `%.200s'", sp);
+ flags = FILEPOS;
+ break;
}
if (flags & PREFIX)
diff --git a/input.c b/input.c
index c6231a7..8d5c1dc 100644
--- a/input.c
+++ b/input.c
@@ -485,6 +485,7 @@ static void read_file(paragraph ***ret, input *in) {
*/
if (t.type == tok_cmd && t.cmd == c_c && !isbrace(in)) {
par.type = para_Code;
+ par.fpos = t.pos;
while (1) {
dtor(t), t = get_codepar_token(in);
wd.type = word_WeakCode;
@@ -524,6 +525,7 @@ static void read_file(paragraph ***ret, input *in) {
if (t.type == tok_cmd) {
int needkw;
+ par.fpos = t.pos;
switch (t.cmd) {
default:
needkw = -1;
diff --git a/inputs/test.but b/inputs/test.but
index d5ce52d..5c15dd2 100644
--- a/inputs/test.but
+++ b/inputs/test.but
@@ -6,7 +6,7 @@ feature that Buttress's input format supports. Creation date
\copyright Copyright 1999 Simon Tatham. All rights reserved.
-\versionid $Id: test.but,v 1.4 1999/08/09 10:02:07 simon Exp $
+\versionid $Id: test.but,v 1.5 1999/08/15 18:35:20 simon Exp $
\C{chap} First chapter title
@@ -83,7 +83,7 @@ the document even though there is no \cw{\\k} citing it.
\BR{book} [SillyCitation]
-\nocite{bookwithoutcitation}{foo}
+\nocite{nocite}
\B{uncited} If this text appears, there's an actual error.
diff --git a/keywords.c b/keywords.c
index ff213c1..da882bf 100644
--- a/keywords.c
+++ b/keywords.c
@@ -61,7 +61,7 @@ static void heap_sort(keywordlist *kl) {
/* FIXME: check for duplicate keys; do what about them? */
}
-static keyword *kw_lookup(keywordlist *kl, wchar_t *str) {
+keyword *kw_lookup(keywordlist *kl, wchar_t *str) {
int i, j, k, cmp;
i = -1;
@@ -102,12 +102,13 @@ keywordlist *get_keywords(paragraph *source) {
prevpara = source->type;
if (source->keyword && *source->keyword) {
- if (source->kwtext) {
+ if (source->kwtext || source->type == para_Biblio) {
wchar_t *p = source->keyword;
while (*p) {
keyword *kw = smalloc(sizeof(*kw));
kw->key = p;
kw->text = source->kwtext;
+ kw->para = source;
heap_add(kl, kw);
p += ustrlen(p) + 1;
}
diff --git a/main.c b/main.c
index 6850212..36d8e3a 100644
--- a/main.c
+++ b/main.c
@@ -182,9 +182,10 @@ int main(int argc, char **argv) {
sfree(infiles);
keywords = get_keywords(sourceform);
- dbg_prtkws(keywords);
-
+ gen_citations(sourceform, keywords);
subst_keywords(sourceform, keywords);
+
+ dbg_prtkws(keywords);
dbg_prtsource(sourceform);
free_para_list(sourceform);