summaryrefslogtreecommitdiff
path: root/Build/source/texk/upmendex
diff options
context:
space:
mode:
authorTakuji Tanaka <ttk@t-lab.opal.ne.jp>2021-09-19 08:57:18 +0000
committerTakuji Tanaka <ttk@t-lab.opal.ne.jp>2021-09-19 08:57:18 +0000
commitebd49895acbb9983700fd9d54959dbeda259b086 (patch)
tree03a60e466d412f609012888d7fdc6f2ee2ad98b6 /Build/source/texk/upmendex
parentdd87c8d28d4a1a158bb90493591ad005e43470ee (diff)
upmendex: modify heuristic detection of page number types
git-svn-id: svn://tug.org/texlive/trunk@60549 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/upmendex')
-rw-r--r--Build/source/texk/upmendex/ChangeLog8
-rw-r--r--Build/source/texk/upmendex/fread.c24
-rw-r--r--Build/source/texk/upmendex/tests/pprec3.ist11
-rw-r--r--Build/source/texk/upmendex/tests/pprec4.ist11
-rw-r--r--Build/source/texk/upmendex/tests/pprecB-0.ind5
-rw-r--r--Build/source/texk/upmendex/tests/pprecB-3.ind5
-rw-r--r--Build/source/texk/upmendex/tests/pprecB-4.ind5
-rw-r--r--Build/source/texk/upmendex/tests/pprecB.idx9
-rw-r--r--Build/source/texk/upmendex/tests/range.idx14
-rw-r--r--Build/source/texk/upmendex/tests/range1.ind4
-rw-r--r--Build/source/texk/upmendex/tests/range2.ind4
-rw-r--r--Build/source/texk/upmendex/tests/range3.ind4
-rwxr-xr-xBuild/source/texk/upmendex/tests/upmendex.test14
13 files changed, 94 insertions, 24 deletions
diff --git a/Build/source/texk/upmendex/ChangeLog b/Build/source/texk/upmendex/ChangeLog
index 045305ef8c9..65c5ba4519a 100644
--- a/Build/source/texk/upmendex/ChangeLog
+++ b/Build/source/texk/upmendex/ChangeLog
@@ -1,3 +1,11 @@
+2021-09-19 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
+
+ * fread.c:
+ Modify heuristic detection of page number types.
+ * tests/upmendex.test, tests/range.idx, tests/range[123].ind,
+ tests/pprecB.idx, tests/pprec[34].ist, tests/pprecB-[034].ind:
+ Update tests.
+
2021-09-18 TANAKA Takuji <ttk@t-lab.opal.ne.jp>
* fread.c, fwrite.c, sort.c, mendex.h, {,ex}var.h:
diff --git a/Build/source/texk/upmendex/fread.c b/Build/source/texk/upmendex/fread.c
index ba1d3514856..66d3e0b1449 100644
--- a/Build/source/texk/upmendex/fread.c
+++ b/Build/source/texk/upmendex/fread.c
@@ -344,7 +344,7 @@ LOOP:
copy_multibyte_char(buff, table, &j, &k);
}
- table[k]='\0';
+ table[k]='\0';
for (k=0;k<=ind[l].num;k++) {
if (strcmp(ind[l].p[k].page,table)==0) {
@@ -356,9 +356,9 @@ LOOP:
ind[l].num++;
if (!((ind[l].num)%16)) ind[l].p=(struct page *)xrealloc(ind[l].p,sizeof(struct page)*((int)((ind[l].num)/16)+1)*16);
- ind[l].p[ind[l].num].page=xstrdup(table);
+ ind[l].p[ind[l].num].page=xstrdup(table);
- ind[l].p[ind[l].num].enc=xstrdup(estr);
+ ind[l].p[ind[l].num].enc=xstrdup(estr);
chkpageattr(&ind[l].p[ind[l].num]);
}
}
@@ -388,15 +388,15 @@ LOOP:
nest++;
if (buff[j]==arg_close) {
if (nest==0) {
- table[k]='\0';
- ind[i].p[0].page=xstrdup(table);
+ table[k]='\0';
+ ind[i].p[0].page=xstrdup(table);
break;
}
else nest--;
}
copy_multibyte_char(buff, table, &j, &k);
}
- ind[l].p[0].enc=xstrdup(estr);
+ ind[l].p[0].enc=xstrdup(estr);
chkpageattr(&ind[i].p[0]);
}
}
@@ -538,7 +538,7 @@ ATTRLOOP:
switch(page_precedence[pattr[cc]]) {
case 'r':
if (strchr("ivxlcdm",*page0)==NULL ||
- (strchr("lcdm",*page0) && strchr(page_precedence,'a') && strlen(buff)==1 && pcpos)) {
+ (strchr("lcdm",*page0) && strchr(page_precedence,'a') && strlen(buff)==1 && pcpos)) {
/* heuristic detection as alphabet since L=50, C=100, D=100, M=1000 are quite large */
if (pattr[cc]<pplen-1)
pattr[cc]++;
@@ -549,7 +549,7 @@ ATTRLOOP:
break;
case 'R':
if (strchr("IVXLCDM",*page0)==NULL ||
- (strchr("LCDM",*page0) && strchr(page_precedence,'A') && strlen(buff)==1 && pcpos)) {
+ (strchr("LCDM",*page0) && strchr(page_precedence,'A') && strlen(buff)==1 && pcpos)) {
/* heuristic detection as alphabet since L=50, C=100, D=100, M=1000 are quite large */
if (pattr[cc]<pplen-1)
pattr[cc]++;
@@ -568,7 +568,9 @@ ATTRLOOP:
}
break;
case 'a':
- if (*page0<'a' || *page0>'z' || strlen(buff)>1) {
+ if (*page0<'a' || *page0>'z' || strlen(buff)>1 ||
+ (strchr("ivx",*page0) && strchr(page_precedence,'r') && !pcpos)) {
+ /* heuristic detection as roman number since I=1, V=5, X=10 are quite small */
if (pattr[cc]<pplen-1)
pattr[cc]++;
else pattr[cc]=0;
@@ -577,7 +579,9 @@ ATTRLOOP:
}
break;
case 'A':
- if (*page0<'A' || *page0>'Z' || strlen(buff)>1) {
+ if (*page0<'A' || *page0>'Z' || strlen(buff)>1 ||
+ (strchr("IVX",*page0) && strchr(page_precedence,'R') && !pcpos)) {
+ /* heuristic detection as roman number since I=1, V=5, X=10 are quite small */
if (pattr[cc]<pplen-1)
pattr[cc]++;
else pattr[cc]=0;
diff --git a/Build/source/texk/upmendex/tests/pprec3.ist b/Build/source/texk/upmendex/tests/pprec3.ist
new file mode 100644
index 00000000000..b8f33af1dd8
--- /dev/null
+++ b/Build/source/texk/upmendex/tests/pprec3.ist
@@ -0,0 +1,11 @@
+% -*- coding: utf-8 -*-
+
+page_precedence "naA"
+
+delim_0 "[[delim0]]"
+delim_1 "[[delim1]]"
+delim_2 "[[delim2]]"
+delim_r "[[delimr]]"
+suffix_2p "[[sfx 2p]]"
+suffix_3p "[[sfx 3p]]"
+
diff --git a/Build/source/texk/upmendex/tests/pprec4.ist b/Build/source/texk/upmendex/tests/pprec4.ist
new file mode 100644
index 00000000000..768fec7642b
--- /dev/null
+++ b/Build/source/texk/upmendex/tests/pprec4.ist
@@ -0,0 +1,11 @@
+% -*- coding: utf-8 -*-
+
+page_precedence "Ana"
+
+delim_0 "[[delim0]]"
+delim_1 "[[delim1]]"
+delim_2 "[[delim2]]"
+delim_r "[[delimr]]"
+suffix_2p "[[sfx 2p]]"
+suffix_3p "[[sfx 3p]]"
+
diff --git a/Build/source/texk/upmendex/tests/pprecB-0.ind b/Build/source/texk/upmendex/tests/pprecB-0.ind
new file mode 100644
index 00000000000..1e23d9fb4a7
--- /dev/null
+++ b/Build/source/texk/upmendex/tests/pprecB-0.ind
@@ -0,0 +1,5 @@
+\begin{theindex}
+
+ \item entryA[[delim0]]1[[sfx 3p]], a[[sfx 3p]], A[[sfx 3p]]
+
+\end{theindex}
diff --git a/Build/source/texk/upmendex/tests/pprecB-3.ind b/Build/source/texk/upmendex/tests/pprecB-3.ind
new file mode 100644
index 00000000000..1e23d9fb4a7
--- /dev/null
+++ b/Build/source/texk/upmendex/tests/pprecB-3.ind
@@ -0,0 +1,5 @@
+\begin{theindex}
+
+ \item entryA[[delim0]]1[[sfx 3p]], a[[sfx 3p]], A[[sfx 3p]]
+
+\end{theindex}
diff --git a/Build/source/texk/upmendex/tests/pprecB-4.ind b/Build/source/texk/upmendex/tests/pprecB-4.ind
new file mode 100644
index 00000000000..3943ad48549
--- /dev/null
+++ b/Build/source/texk/upmendex/tests/pprecB-4.ind
@@ -0,0 +1,5 @@
+\begin{theindex}
+
+ \item entryA[[delim0]]A[[sfx 3p]], 1[[sfx 3p]], a[[sfx 3p]]
+
+\end{theindex}
diff --git a/Build/source/texk/upmendex/tests/pprecB.idx b/Build/source/texk/upmendex/tests/pprecB.idx
new file mode 100644
index 00000000000..a1d8fc31ae2
--- /dev/null
+++ b/Build/source/texk/upmendex/tests/pprecB.idx
@@ -0,0 +1,9 @@
+\indexentry{entryA}{a}
+\indexentry{entryA}{b}
+\indexentry{entryA}{c}
+\indexentry{entryA}{1}
+\indexentry{entryA}{2}
+\indexentry{entryA}{3}
+\indexentry{entryA}{A}
+\indexentry{entryA}{B}
+\indexentry{entryA}{C}
diff --git a/Build/source/texk/upmendex/tests/range.idx b/Build/source/texk/upmendex/tests/range.idx
index e77882010c6..3eccb113aa4 100644
--- a/Build/source/texk/upmendex/tests/range.idx
+++ b/Build/source/texk/upmendex/tests/range.idx
@@ -58,13 +58,13 @@
\indexentry{entryF}{D-DIII}
\indexentry{entryF}{D-DIV}
-\indexentry{entryP}{A-a-1-I-iii}
-\indexentry{entryP}{A-a-2-I-iii}
-\indexentry{entryP}{A-a-3-I-iii}
-\indexentry{entryP}{A-a-1-II-iii}
-\indexentry{entryP}{A-a-1-III-iii}
-\indexentry{entryP}{A-a-1-I-iv}
-\indexentry{entryP}{A-a-1-I-v}
+\indexentry{entryP}{A-a-1-VII-iii}
+\indexentry{entryP}{A-a-2-VII-iii}
+\indexentry{entryP}{A-a-3-VII-iii}
+\indexentry{entryP}{A-a-1-VIII-iii}
+\indexentry{entryP}{A-a-1-IX-iii}
+\indexentry{entryP}{A-a-1-VII-iv}
+\indexentry{entryP}{A-a-1-VII-v}
\indexentry{entryQ}{1-2-3-4-5-6-7-8-9-10}
\indexentry{entryQ}{1-2-3-4-5-6-7-8-9-11}
diff --git a/Build/source/texk/upmendex/tests/range1.ind b/Build/source/texk/upmendex/tests/range1.ind
index 0dc1d842a9f..c5f047a55e5 100644
--- a/Build/source/texk/upmendex/tests/range1.ind
+++ b/Build/source/texk/upmendex/tests/range1.ind
@@ -15,8 +15,8 @@
\item entryF, C-I[[sfx mp]], D-DI[[sfx mp]], V-LIII[[sfx mp]]
\item entryF1, C-I[[sfx mp]], \bold{D-DII}, D-DI[[sfx mp]],
V-LIII[[sfx mp]]
- \item entryP, A-a-1-I-iii[[sfx mp]], A-a-1-II-iii, A-a-1-III-iii,
- A-a-2-I-iii, A-a-3-I-iii
+ \item entryP, A-a-1-VII-iii[[sfx mp]], A-a-1-VIII-iii, A-a-1-IX-iii,
+ A-a-2-VII-iii, A-a-3-VII-iii
\item entryQ, 1-2-3-4-5-6-7-8-9-10[[sfx 2p]],
1-2-3-4-5-6-7-8-9-14[[sfx mp]],
1-2-3-4-5-6-7-8-9-22[[sfx mp]],
diff --git a/Build/source/texk/upmendex/tests/range2.ind b/Build/source/texk/upmendex/tests/range2.ind
index 9e0bd8ce5e3..789eb3f75c7 100644
--- a/Build/source/texk/upmendex/tests/range2.ind
+++ b/Build/source/texk/upmendex/tests/range2.ind
@@ -16,8 +16,8 @@
V-LIII[[delim r]]V-LVI
\item entryF1, C-I[[delim r]]C-IV, \bold{D-DII}, D-DI[[delim r]]D-DIV,
V-LIII[[delim r]]V-LVI
- \item entryP, A-a-1-I-iii[[sfx 3p]], A-a-1-II-iii, A-a-1-III-iii,
- A-a-2-I-iii, A-a-3-I-iii
+ \item entryP, A-a-1-VII-iii[[sfx 3p]], A-a-1-VIII-iii, A-a-1-IX-iii,
+ A-a-2-VII-iii, A-a-3-VII-iii
\item entryQ, 1-2-3-4-5-6-7-8-9-10[[sfx 2p]],
1-2-3-4-5-6-7-8-9-14[[sfx 3p]],
1-2-3-4-5-6-7-8-9-22[[delim r]]1-2-3-4-5-6-7-8-9-25,
diff --git a/Build/source/texk/upmendex/tests/range3.ind b/Build/source/texk/upmendex/tests/range3.ind
index f5b5f5268ff..519730a138e 100644
--- a/Build/source/texk/upmendex/tests/range3.ind
+++ b/Build/source/texk/upmendex/tests/range3.ind
@@ -15,8 +15,8 @@
\item entryF, C-I[[sfx mp]], D-DI[[sfx mp]], V-LIII[[sfx mp]]
\item entryF1, C-I[[sfx mp]], \bold{D-DII}, D-DI[[sfx mp]],
V-LIII[[sfx mp]]
- \item entryP, A-a-1-I-iii[[sfx 3p]], A-a-1-II-iii, A-a-1-III-iii,
- A-a-2-I-iii, A-a-3-I-iii
+ \item entryP, A-a-1-VII-iii[[sfx 3p]], A-a-1-VIII-iii, A-a-1-IX-iii,
+ A-a-2-VII-iii, A-a-3-VII-iii
\item entryQ, 1-2-3-4-5-6-7-8-9-10[[sfx 2p]],
1-2-3-4-5-6-7-8-9-14[[sfx 3p]],
1-2-3-4-5-6-7-8-9-22[[sfx mp]],
diff --git a/Build/source/texk/upmendex/tests/upmendex.test b/Build/source/texk/upmendex/tests/upmendex.test
index 54152ca7a06..6a5d935a0ae 100755
--- a/Build/source/texk/upmendex/tests/upmendex.test
+++ b/Build/source/texk/upmendex/tests/upmendex.test
@@ -7,7 +7,7 @@
TEXMFCNF=$srcdir/../kpathsea
export TEXMFCNF
-rm -f foo.* uni.* pprec*.* range*.* locale*.* attr*.* rule*.*
+rm -f foo.* uni.* range*.* pprec*.* locale*.* attr*.* rule*.*
./upmendex $srcdir/tests/foo.idx -o foo.ind1 -t foo.ilg1 \
&& diff $srcdir/tests/foo.ind foo.ind1 || exit 1
@@ -54,6 +54,18 @@ cat $srcdir/tests/uni.idx | \
-o pprecA-2.ind1 -t pprecA-2.ilg \
&& diff $srcdir/tests/pprecA-2.ind pprecA-2.ind1 || exit 1
+./upmendex -s $srcdir/tests/pprec0.ist $srcdir/tests/pprecB.idx \
+ -o pprecB-0.ind1 -t pprecB-0.ilg \
+ && diff $srcdir/tests/pprecB-0.ind pprecB-0.ind1 || exit 1
+
+./upmendex -s $srcdir/tests/pprec3.ist $srcdir/tests/pprecB.idx \
+ -o pprecB-3.ind1 -t pprecB-3.ilg \
+ && diff $srcdir/tests/pprecB-3.ind pprecB-3.ind1 || exit 1
+
+./upmendex -s $srcdir/tests/pprec4.ist $srcdir/tests/pprecB.idx \
+ -o pprecB-4.ind1 -t pprecB-4.ilg \
+ && diff $srcdir/tests/pprecB-4.ind pprecB-4.ind1 || exit 1
+
# test for icu_locale
./upmendex -s $srcdir/tests/uni.ist -s $srcdir/tests/locale1.ist $srcdir/tests/rule.idx \
-o locale1.ind1 -t locale1.ilg \