summaryrefslogtreecommitdiff
path: root/Build/source/texk/mendexk
diff options
context:
space:
mode:
authorTakuji Tanaka <KXD02663@nifty.ne.jp>2014-05-12 15:08:09 +0000
committerTakuji Tanaka <KXD02663@nifty.ne.jp>2014-05-12 15:08:09 +0000
commitba524fa0746d58f2baefe7a004b618d81bf545c0 (patch)
tree7ef31f4cbf908eef3fd0338789dd349d55f36b4a /Build/source/texk/mendexk
parenta5fb67b08ffa700629d01d9698dd135c80fad47f (diff)
mendexk: Copy multibyte character correctly
git-svn-id: svn://tug.org/texlive/trunk@33996 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/mendexk')
-rw-r--r--Build/source/texk/mendexk/ChangeLog6
-rw-r--r--Build/source/texk/mendexk/fread.c66
-rw-r--r--Build/source/texk/mendexk/tests/uni.idx2
-rw-r--r--Build/source/texk/mendexk/tests/uni.ind2
4 files changed, 41 insertions, 35 deletions
diff --git a/Build/source/texk/mendexk/ChangeLog b/Build/source/texk/mendexk/ChangeLog
index 915c77b95cf..c3686a0c785 100644
--- a/Build/source/texk/mendexk/ChangeLog
+++ b/Build/source/texk/mendexk/ChangeLog
@@ -1,3 +1,9 @@
+2014-05-12 TANAKA Takuji <KXD02663@nifty.ne.jp>
+
+ * fread.c: Add copy_multibyte_char() to
+ copy multibyte character correctly.
+ * tests/uni.{idx,ind}: Update.
+
2014-05-12 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
* fread.c: Wide char is not always even bytes in getestr().
diff --git a/Build/source/texk/mendexk/fread.c b/Build/source/texk/mendexk/fread.c
index 9788dd5692c..8edb29d5720 100644
--- a/Build/source/texk/mendexk/fread.c
+++ b/Build/source/texk/mendexk/fread.c
@@ -10,6 +10,7 @@
static int getestr(char *buff, char *estr);
static void chkpageattr(struct page *p);
+static void copy_multibyte_char(char *buff1, char *buff2, int *i, int *j);
/* read idx file */
int idxread(char *filename, int start)
@@ -204,21 +205,8 @@ LOOP:
}
else quo=0;
- wbuff[k]=buff[j];
if (buff[j]!=escape) esc=0;
- if ((unsigned char)buff[j]>=0x80) {
- int len = multibytelen((unsigned char)buff[j]);
- if (len<0) {
- verb_printf(efp,"\nWarning: Illegal input of lead byte 0x%x in UTF-8.",(unsigned char)buff[j]);
- k--;
- continue;
- }
- while(--len) {
- wbuff[k+1]=buff[j+1];
- j++;
- k++;
- }
- }
+ copy_multibyte_char(buff, wbuff, &j, &k);
}
ind[i].words=indent+1;
@@ -286,12 +274,7 @@ LOOP:
}
else nest--;
}
- else if ((unsigned char)buff[j]>=0x80) {
- table[k]=buff[j];
- j++;
- k++;
- }
- table[k]=buff[j];
+ copy_multibyte_char(buff, table, &j, &k);
}
ind[0].p[0].enc=xstrdup(estr);
chkpageattr(&ind[0].p[0]);
@@ -353,12 +336,7 @@ LOOP:
if (nest==0) break;
else nest--;
}
- else if ((unsigned char)buff[j]>=0x80) {
- table[k]=buff[j];
- j++;
- k++;
- }
- table[k]=buff[j];
+ copy_multibyte_char(buff, table, &j, &k);
}
table[k]='\0';
@@ -411,12 +389,7 @@ LOOP:
}
else nest--;
}
- else if ((unsigned char)buff[j]>=0x80) {
- table[k]=buff[j];
- j++;
- k++;
- }
- table[k]=buff[j];
+ copy_multibyte_char(buff, table, &j, &k);
}
ind[l].p[0].enc=xstrdup(estr);
chkpageattr(&ind[i].p[0]);
@@ -454,12 +427,39 @@ static int getestr(char *buff, char *estr)
}
if (buff[i]==arg_open) nest++;
else if (buff[i]==arg_close) nest--;
- estr[i]=buff[i];
+ copy_multibyte_char(buff, estr, &i, NULL);
}
return -1;
}
+static void copy_multibyte_char(char *buff1, char *buff2, int *i, int *j)
+{
+ int len;
+
+ if ((unsigned char)buff1[*i]<0x80) {
+ if (j!=NULL)
+ buff2[*j]=buff1[*i];
+ else
+ buff2[*i]=buff1[*i];
+ return;
+ }
+ len = multibytelen((unsigned char)buff1[*i]);
+ if (len<0) {
+ verb_printf(efp,"\nWarning: Illegal input of lead byte 0x%x in UTF-8.",(unsigned char)buff1[*i]);
+ (*i)++;
+ return;
+ }
+ while(len--) {
+ if (j!=NULL)
+ buff2[(*j)++]=buff1[(*i)++];
+ else
+ buff2[(*i)++]=buff1[(*i)];
+ }
+ if (j!=NULL) (*j)--;
+ (*i)--;
+}
+
static void chkpageattr(struct page *p)
{
int i,j,cc=0;
diff --git a/Build/source/texk/mendexk/tests/uni.idx b/Build/source/texk/mendexk/tests/uni.idx
index 52a0b8ecea9..57b4710309c 100644
--- a/Build/source/texk/mendexk/tests/uni.idx
+++ b/Build/source/texk/mendexk/tests/uni.idx
@@ -1,5 +1,5 @@
\indexentry{もりおうがい@森鷗外}{1}
-\indexentry{さとみとん@里見弴}{1}
+\indexentry{さとみとん@里見弴|see{あ}}{1}
\indexentry{𠮟咤激励}{1}
\indexentry{Mendex}{1}
\indexentry{Mendex!のインストール}{1}
diff --git a/Build/source/texk/mendexk/tests/uni.ind b/Build/source/texk/mendexk/tests/uni.ind
index aa142686417..61afdd7c96b 100644
--- a/Build/source/texk/mendexk/tests/uni.ind
+++ b/Build/source/texk/mendexk/tests/uni.ind
@@ -10,7 +10,7 @@
\indexspace
\centerline{\bfseries ◆◆◆ サ ◆◆◆}\par\nobreak
- \item 里見弴\leaders\hbox{$\cdot$}\hfill 1
+ \item 里見弴\leaders\hbox{$\cdot$}\hfill \see{あ}{1}
\indexspace