summaryrefslogtreecommitdiff
path: root/index.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-04-10 08:59:19 +0000
committerSimon Tatham <anakin@pobox.com>2004-04-10 08:59:19 +0000
commitcb859ab83ed22a1b0dc9fd017cb0d68e0037d750 (patch)
tree1218ea2baf44c3ec3b312c3a6b2606e78fcce06c /index.c
parent221e2fcc83aa527bf515d40a754d69dc5793bb4f (diff)
downloadhalibut-cb859ab83ed22a1b0dc9fd017cb0d68e0037d750.zip
halibut-cb859ab83ed22a1b0dc9fd017cb0d68e0037d750.tar.gz
halibut-cb859ab83ed22a1b0dc9fd017cb0d68e0037d750.tar.bz2
halibut-cb859ab83ed22a1b0dc9fd017cb0d68e0037d750.tar.xz
Info backend now takes care to avoid magic characters in node names
and index terms (the Info format doesn't like them). In the course of this I've had to introduce some infrastructure for carrying a filepos forward from the definition of every RHS index term so that a particular backend can provide a usefully localised report of which index term had a problem. [originally from svn r4051]
Diffstat (limited to 'index.c')
-rw-r--r--index.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/index.c b/index.c
index c312f07..9850750 100644
--- a/index.c
+++ b/index.c
@@ -21,6 +21,7 @@ static indextag *make_indextag(void) {
ret->name = NULL;
ret->implicit_text = NULL;
ret->explicit_texts = NULL;
+ ret->explicit_fpos = NULL;
ret->nexplicit = ret->explicit_size = ret->nrefs = 0;
ret->refs = NULL;
return ret;
@@ -57,7 +58,8 @@ indextag *index_findtag(indexdata *idx, wchar_t *name) {
* Guarantee on calling sequence: all implicit merges are given
* before the explicit ones.
*/
-void index_merge(indexdata *idx, int is_explicit, wchar_t *tags, word *text) {
+void index_merge(indexdata *idx, int is_explicit, wchar_t *tags, word *text,
+ filepos *fpos) {
indextag *t, *existing;
/*
@@ -105,6 +107,7 @@ void index_merge(indexdata *idx, int is_explicit, wchar_t *tags, word *text) {
* Otherwise, this is a new tag with an implicit \IM.
*/
t->implicit_text = text;
+ t->implicit_fpos = *fpos;
} else {
sfree(t);
t = existing;
@@ -130,8 +133,12 @@ void index_merge(indexdata *idx, int is_explicit, wchar_t *tags, word *text) {
t->explicit_size = t->nexplicit + 8;
t->explicit_texts = resize(t->explicit_texts,
t->explicit_size);
+ t->explicit_fpos = resize(t->explicit_fpos,
+ t->explicit_size);
}
- t->explicit_texts[t->nexplicit++] = text;
+ t->explicit_texts[t->nexplicit] = text;
+ t->explicit_fpos[t->nexplicit] = *fpos;
+ t->nexplicit++;
}
}
}
@@ -147,6 +154,7 @@ void index_merge(indexdata *idx, int is_explicit, wchar_t *tags, word *text) {
void build_index(indexdata *i) {
indextag *t;
word **ta;
+ filepos *fa;
int ti;
int j;
@@ -154,15 +162,18 @@ void build_index(indexdata *i) {
if (t->implicit_text) {
t->nrefs = 1;
ta = &t->implicit_text;
+ fa = &t->implicit_fpos;
} else {
t->nrefs = t->nexplicit;
ta = t->explicit_texts;
+ fa = t->explicit_fpos;
}
if (t->nrefs) {
t->refs = mknewa(indexentry *, t->nrefs);
for (j = 0; j < t->nrefs; j++) {
indexentry *ent = mknew(indexentry);
ent->text = *ta++;
+ ent->fpos = *fa++;
t->refs[j] = add234(i->entries, ent);
if (t->refs[j] != ent) /* duplicate */
sfree(ent);