diff options
author | Karl Berry <karl@freefriends.org> | 2021-05-09 21:27:28 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-05-09 21:27:28 +0000 |
commit | 5fefcba6e29705444628d35033c7fac17e401e51 (patch) | |
tree | 6f623a0d1bf3b69d86aa3c09523caac44c86c1fc | |
parent | d0c57b555c102fbeee2fc27163d46face6ec3afd (diff) |
ensure signed comparisons are signed; new test
git-svn-id: svn://tug.org/texlive/trunk@59151 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Build/source/texk/mendexk/ChangeLog | 13 | ||||
-rw-r--r-- | Build/source/texk/mendexk/fwrite.c | 18 | ||||
-rw-r--r-- | Build/source/texk/mendexk/mendex.h | 4 | ||||
-rwxr-xr-x | Build/source/texk/mendexk/tests/mendex.test | 18 | ||||
-rw-r--r-- | Build/source/texk/mendexk/tests/rangetwo.idx | 2 | ||||
-rw-r--r-- | Build/source/texk/mendexk/tests/rangetwo.ind | 5 | ||||
-rw-r--r-- | Build/source/texk/mendexk/tests/rangetwo.ist | 2 |
7 files changed, 47 insertions, 15 deletions
diff --git a/Build/source/texk/mendexk/ChangeLog b/Build/source/texk/mendexk/ChangeLog index 0e7115a86a9..84673ed9861 100644 --- a/Build/source/texk/mendexk/ChangeLog +++ b/Build/source/texk/mendexk/ChangeLog @@ -1,3 +1,16 @@ +2021-05-09 Karl Berry <karl@freefriends.org> + + * mendex.h (page.attr): use int, not char, since we do signed + comparison and aarch64 apparently treats char as unsigned. + (index.words): use unsigned char for consistency. + * fwrite.c (printpage): factor out beginning/end page values. + * tests/rangetwo.idx, + * tests/rangetwo.ind, + * tests/rangetwo.ist: new simple test. + * tests/mendex.test: run the rangetwo test. + Report from Johannes Hielscher, + https://tug.org/pipermail/tlbuild/2021q1/004873.html. + 2021-03-23 Karl Berry <karl@tug.org> * TL'21. diff --git a/Build/source/texk/mendexk/fwrite.c b/Build/source/texk/mendexk/fwrite.c index 2cd0f4bd491..48162ef75e6 100644 --- a/Build/source/texk/mendexk/fwrite.c +++ b/Build/source/texk/mendexk/fwrite.c @@ -326,7 +326,11 @@ static void printpage(struct index *ind, FILE *fp, int num, char *lbuff) for(j=0;j<ind[num].num;j++) { cc=range_check(ind[num],j,lbuff); if (cc>j) { - if (pnumconv(ind[num].p[j].page,ind[num].p[j].attr[0])==pnumconv(ind[num].p[cc].page,ind[num].p[cc].attr[0])) { + int epage = pnumconv(ind[num].p[cc].page, + ind[num].p[cc].attr[0]); + int bpage = pnumconv(ind[num].p[j].page, + ind[num].p[j].attr[0]); + if (epage==bpage) { j=cc-1; continue; } @@ -337,20 +341,18 @@ static void printpage(struct index *ind, FILE *fp, int num, char *lbuff) if (strlen(ind[num].p[j].enc)>0) { SPRINTF(buff,"%s%s%s",encap_prefix,ind[num].p[j].enc,encap_infix); } - if (strlen(suffix_3p)>0 && (pnumconv(ind[num].p[cc].page,ind[num].p[cc].attr[0])-pnumconv(ind[num].p[j].page,ind[num].p[j].attr[0]))==2) { - SAPPENDF(buff,"%s",ind[num].p[j].page); + /* print beginning of range */ + SAPPENDF(buff,"%s",ind[num].p[j].page); + if (strlen(suffix_3p)>0 && (epage-bpage)==2) { SAPPENDF(buff,"%s",suffix_3p); } - else if (strlen(suffix_mp)>0 && (pnumconv(ind[num].p[cc].page,ind[num].p[cc].attr[0])-pnumconv(ind[num].p[j].page,ind[num].p[j].attr[0]))>=2) { - SAPPENDF(buff,"%s",ind[num].p[j].page); + else if (strlen(suffix_mp)>0 && (epage-bpage)>=2) { SAPPENDF(buff,"%s",suffix_mp); } - else if (strlen(suffix_2p)>0 && (pnumconv(ind[num].p[cc].page,ind[num].p[cc].attr[0])-pnumconv(ind[num].p[j].page,ind[num].p[j].attr[0]))==1) { - SAPPENDF(buff,"%s",ind[num].p[j].page); + else if (strlen(suffix_2p)>0 && (epage-bpage)==1) { SAPPENDF(buff,"%s",suffix_2p); } else { - SAPPENDF(buff,"%s",ind[num].p[j].page); SAPPENDF(buff,"%s",delim_r); SAPPENDF(buff,"%s",ind[num].p[cc].page); } diff --git a/Build/source/texk/mendexk/mendex.h b/Build/source/texk/mendexk/mendex.h index 8f513b5cc25..ee4541ea0f5 100644 --- a/Build/source/texk/mendexk/mendex.h +++ b/Build/source/texk/mendexk/mendex.h @@ -14,12 +14,12 @@ struct page { char *page; char *enc; - char attr[3]; + int attr[3]; }; struct index { int num; - char words; + unsigned char words; char *org[3]; char *dic[3]; char *idx[3]; diff --git a/Build/source/texk/mendexk/tests/mendex.test b/Build/source/texk/mendexk/tests/mendex.test index 99c73507fe9..26441808bf4 100755 --- a/Build/source/texk/mendexk/tests/mendex.test +++ b/Build/source/texk/mendexk/tests/mendex.test @@ -1,6 +1,6 @@ #! /bin/sh -vx # $Id$ -# Copyright 2017 Karl Berry <tex-live@tug.org> +# Copyright 2017-2021 Karl Berry <tex-live@tug.org> # Copyright 2013 Peter Breitenlohner <tex-live@tug.org> # You may freely use, modify and/or distribute this file. @@ -24,13 +24,21 @@ cat $srcdir/tests/uni.idx | \ >uni.ind2 2>uni.ilg2 \ && diff $srcdir/tests/uni.ind uni.ind2 || exit 1 -# test for page_precedence -./mendex -s $srcdir/tests/pprec0.ist $srcdir/tests/pprecA.idx -o pprecA-0.ind1 -t pprecA-0.ilg \ +# test for two-element range suffix_2p +./mendex -s $srcdir/tests/rangetwo.ist $srcdir/tests/rangetwo.idx \ + -o rangetwo.ind1 -t rangetwo.ilg \ + && diff $srcdir/tests/rangetwo.ind rangetwo.ind1 || exit 1 + +# test for page_precedence and suffix_3p +./mendex -s $srcdir/tests/pprec0.ist $srcdir/tests/pprecA.idx \ + -o pprecA-0.ind1 -t pprecA-0.ilg \ && diff $srcdir/tests/pprecA-0.ind pprecA-0.ind1 || exit 1 -./mendex -s $srcdir/tests/pprec1.ist $srcdir/tests/pprecA.idx -o pprecA-1.ind1 -t pprecA-1.ilg \ +./mendex -s $srcdir/tests/pprec1.ist $srcdir/tests/pprecA.idx \ + -o pprecA-1.ind1 -t pprecA-1.ilg \ && diff $srcdir/tests/pprecA-1.ind pprecA-1.ind1 || exit 1 -./mendex -s $srcdir/tests/pprec2.ist $srcdir/tests/pprecA.idx -o pprecA-2.ind1 -t pprecA-2.ilg \ +./mendex -s $srcdir/tests/pprec2.ist $srcdir/tests/pprecA.idx \ + -o pprecA-2.ind1 -t pprecA-2.ilg \ && diff $srcdir/tests/pprecA-2.ind pprecA-2.ind1 || exit 1 diff --git a/Build/source/texk/mendexk/tests/rangetwo.idx b/Build/source/texk/mendexk/tests/rangetwo.idx new file mode 100644 index 00000000000..d941f7e8315 --- /dev/null +++ b/Build/source/texk/mendexk/tests/rangetwo.idx @@ -0,0 +1,2 @@ +\indexentry{entryA}{1} +\indexentry{entryA}{2} diff --git a/Build/source/texk/mendexk/tests/rangetwo.ind b/Build/source/texk/mendexk/tests/rangetwo.ind new file mode 100644 index 00000000000..1119d2fa8e9 --- /dev/null +++ b/Build/source/texk/mendexk/tests/rangetwo.ind @@ -0,0 +1,5 @@ +\begin{theindex} + + \item entryA, 1[[sfx2p]] + +\end{theindex} diff --git a/Build/source/texk/mendexk/tests/rangetwo.ist b/Build/source/texk/mendexk/tests/rangetwo.ist new file mode 100644 index 00000000000..3e986c8935d --- /dev/null +++ b/Build/source/texk/mendexk/tests/rangetwo.ist @@ -0,0 +1,2 @@ +suffix_2p "[[sfx2p]]" + |