Bug#534641: mendex bug
Dear all,
I hope there is still someone listening.
Since quite some time there is a bug in mendex.
See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=534641
Easy to reproduce:
With the following idx file:
\indexentry{foo|(}{1}
\indexentry{foo|mac}{1}
\indexentry{foo|)}{1}
mendex produces
...
\item foo, 1}, 1
...
instead of
...
\item foo, \mac{1}, 1
...
I looked through the current sources in TeX Live and found that
in fwrite.c, function range_check:
if (strlen(ind.p[j].enc)>0) {
sprintf(tmpbuff,"%s%s%s",encap_prefix,ind.p[j].enc,encap_infix);
sprintf(tmpbuff,"%s%s%s",ind.p[j].page,encap_suffix,delim_n);
linecheck(lbuff,tmpbuff);
}
that looks suspicious. The tmpbuff is overwritten on the second
incantation, and in fact the
encap_prefix (which is \)
ind.p[j].enc (which is the macro name)
encap_infix (which is {)
are missing from the output.
So my guess is that the correct version would be to have
sprintf(tmpbuff,"%s%s%s%s%s%s",encap_prefix,ind.p[j].enc,encap_infix,ind.p[j].page,encap_suffix,delim_n);
instead.
And indeed, with that change the output is as expected.
Checking the differences I see that the *reverse change* was introduced
between 2.6c and 2.6d. So till 2.6c the above line was there.
I am not sure who is currently maintaining mendex, but I would
suggest to fix it as lined out above.I attach a patch against
current TeX Live sources (as far as I see).
Norbert
------------------------------------------------------------------------
PREINING, Norbert http://www.preining.info
JAIST, Japan TeX Live & Debian Developer
DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094
------------------------------------------------------------------------
diff --git a/texk/mendexk/ChangeLog b/texk/mendexk/ChangeLog
index fe87113..571bc64 100644
--- a/texk/mendexk/ChangeLog
+++ b/texk/mendexk/ChangeLog
@@ -1,3 +1,8 @@
+2013-09-07 Norbert Preining <preining@logic.at>
+
+ * fwrite.c: fix missing output when range operators are
+ used with macro definitions
+
2012-11-19 Peter Breitenlohner <peb@mppmu.mpg.de>
* Makefile.am: Avoid use of deprecated INCLUDES.
diff --git a/texk/mendexk/fwrite.c b/texk/mendexk/fwrite.c
index 8c18782..bc5a0ec 100644
--- a/texk/mendexk/fwrite.c
+++ b/texk/mendexk/fwrite.c
@@ -384,8 +384,7 @@ static int range_check(struct index ind, int count, char *lbuff)
ind.p[j].enc++;
}
if (strlen(ind.p[j].enc)>0) {
- sprintf(tmpbuff,"%s%s%s",encap_prefix,ind.p[j].enc,encap_infix);
- sprintf(tmpbuff,"%s%s%s",ind.p[j].page,encap_suffix,delim_n);
+ sprintf(tmpbuff,"%s%s%s%s%s%s",encap_prefix,ind.p[j].enc,encap_infix,ind.p[j].page,encap_suffix,delim_n);
linecheck(lbuff,tmpbuff);
}
}
Reply to: