diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | buttress.h | 14 | ||||
| -rw-r--r-- | error.c | 7 | ||||
| -rw-r--r-- | input.c | 2 | ||||
| -rw-r--r-- | inputs/test.but | 4 | ||||
| -rw-r--r-- | keywords.c | 5 | ||||
| -rw-r--r-- | main.c | 5 |
7 files changed, 30 insertions, 9 deletions
@@ -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)) @@ -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 { @@ -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) @@ -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. @@ -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; } @@ -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); |