summaryrefslogtreecommitdiff
path: root/Build/source/texk/mendexk/fwrite.c
diff options
context:
space:
mode:
authorHironobu Yamashita <h.y.acetaminophen@gmail.com>2021-06-13 11:12:25 +0000
committerHironobu Yamashita <h.y.acetaminophen@gmail.com>2021-06-13 11:12:25 +0000
commit1ea6ce62b6cea8d2b60116445ac2393790507d7f (patch)
treed98759ed71305dae66cb121d56879a1547780119 /Build/source/texk/mendexk/fwrite.c
parent44958b1376805463a7f24c6b8a369b55ebc129b7 (diff)
mendex: bug fixes, including security fix (2021-06-13)
git-svn-id: svn://tug.org/texlive/trunk@59571 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/mendexk/fwrite.c')
-rw-r--r--Build/source/texk/mendexk/fwrite.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/Build/source/texk/mendexk/fwrite.c b/Build/source/texk/mendexk/fwrite.c
index 48162ef75e6..078e334c845 100644
--- a/Build/source/texk/mendexk/fwrite.c
+++ b/Build/source/texk/mendexk/fwrite.c
@@ -121,11 +121,12 @@ void indwrite(char *filename, struct index *ind, int pagenum)
{
int i,j,hpoint=0;
char datama[2048],lbuff[BUFFERLEN];
- FILE *fp;
+ FILE *fp=NULL;
int conv_euc_to_euc;
- if (filename && kpse_out_name_ok(filename)) fp=fopen(filename,"wb");
- else {
+ if (filename && kpse_out_name_ok(filename))
+ fp=fopen(filename,"wb");
+ if (fp == NULL) {
fp=stdout;
#ifdef WIN32
setmode(fileno(fp), _O_BINARY);
@@ -218,7 +219,15 @@ void indwrite(char *filename, struct index *ind, int pagenum)
if ((alphabet(ind[i-1].dic[0][0]))||(japanese(ind[i-1].dic[0]))){
fputs(group_skip,fp);
if (lethead_flag && symbol_flag) {
- fprintf(fp,"%s%s%s",lethead_prefix,symbol,lethead_suffix);
+ if (strlen(symbol)) {
+ fprintf(fp,"%s%s%s",lethead_prefix,symbol,lethead_suffix);
+ }
+ else if (lethead_flag>0) {
+ fprintf(fp,"%s%s%s",lethead_prefix,symhead_positive,lethead_suffix);
+ }
+ else if (lethead_flag<0) {
+ fprintf(fp,"%s%s%s",lethead_prefix,symhead_negative,lethead_suffix);
+ }
}
}
}
@@ -309,7 +318,7 @@ void indwrite(char *filename, struct index *ind, int pagenum)
}
fputs(postamble,fp);
- if (filename) fclose(fp);
+ if (fp!=stdout) fclose(fp);
}
/* write page block */