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;
* 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;
/*
* Otherwise, this is a new tag with an implicit \IM.
*/
t->implicit_text = text;
+ t->implicit_fpos = *fpos;
} else {
sfree(t);
t = existing;
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++;
}
}
}
void build_index(indexdata *i) {
indextag *t;
word **ta;
+ filepos *fa;
int ti;
int j;
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);