summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2010-04-19 12:29:40 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2010-04-19 12:29:40 +0000
commit2438d33d26e1efd298278d484a4309cd5281c7ce (patch)
tree2c0fd6724e26b7a1e0aa65b2dd5e97217ecdbec7
parent08fe73b8b6eb9d22a5a6551e9126cbbb93eea300 (diff)
texk/mendexk: update from Akira
git-svn-id: svn://tug.org/texlive/trunk@17921 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Build/source/texk/mendexk/ChangeLog.TL12
-rw-r--r--Build/source/texk/mendexk/convert.c19
-rw-r--r--Build/source/texk/mendexk/fread.c11
-rw-r--r--Build/source/texk/mendexk/fwrite.c3
-rw-r--r--Build/source/texk/mendexk/kp.h2
-rw-r--r--Build/source/texk/mendexk/main.c27
-rw-r--r--Build/source/texk/mendexk/pageread.c6
-rw-r--r--Build/source/texk/mendexk/styfile.c7
8 files changed, 63 insertions, 24 deletions
diff --git a/Build/source/texk/mendexk/ChangeLog.TL b/Build/source/texk/mendexk/ChangeLog.TL
index 64b913cfd80..104cb0757c8 100644
--- a/Build/source/texk/mendexk/ChangeLog.TL
+++ b/Build/source/texk/mendexk/ChangeLog.TL
@@ -1,6 +1,18 @@
ChangeLog.TL: TeX Live (TL) changes for mendexk
===============================================
+2010-04-17 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * convert.c (dicread, dicvalread), fread.c (idxread),
+ pageread.c (lastpage), styfile.c (styread): Use kpse_in_name_ok.
+ * fwrite.c (indwrite), main.c (main): Use kpse_out_name_ok.
+ From Akira Kakuto <kakuto@fuk.kindai.ac.jp>, 17 Apr 2010 23:30:15.
+ Added #include <kpathsea/tex-file.h> for prototypes.
+
+ * convert.c (kp_dict): Move extern declaration from here ...
+ * styfile.c (kp_ist): ... and here ...
+ * kp.h (kp_ist, kp_dict): ... to here.
+
2010-04-16 Peter Breitenlohner <peb@mppmu.mpg.de>
* exvar.h, var.h (atama, page_compositor, page_precedence):
diff --git a/Build/source/texk/mendexk/convert.c b/Build/source/texk/mendexk/convert.c
index 03959bcf8ff..886d07bfafb 100644
--- a/Build/source/texk/mendexk/convert.c
+++ b/Build/source/texk/mendexk/convert.c
@@ -4,6 +4,7 @@
#include <kpathsea/config.h>
#include <kpathsea/lib.h>
+#include <kpathsea/tex-file.h>
#include <ptexenc/ptexenc.h>
#include "mendex.h"
@@ -13,7 +14,6 @@
#ifdef KPATHSEA
#include "kp.h"
-extern KpathseaSupportInfo kp_dict;
#endif
struct dictionary{
@@ -71,7 +71,10 @@ int dicread(const char *filename)
#ifdef KPATHSEA
filename = KP_find_file(&kp_dict,filename);
#endif
- fp=nkf_open(filename,"r");
+ if(kpse_in_name_ok(filename))
+ fp=nkf_open(filename,"r");
+ else
+ fp = NULL;
if (fp==NULL) {
warn_printf(efp,"Warning: Couldn't find dictionary file %s.\n",filename);
goto ENV;
@@ -105,7 +108,10 @@ ENV:
#ifdef KPATHSEA
envfile = KP_find_file(&kp_dict,envfile);
#endif
- fp=nkf_open(envfile,"r");
+ if(kpse_in_name_ok(envfile))
+ fp=nkf_open(envfile,"r");
+ else
+ fp = NULL;
if (fp==NULL) {
warn_printf(efp,"Warning: Couldn't find environment dictionary file %s.\n",envfile);
return ecount;
@@ -137,7 +143,12 @@ static int dicvalread(const char *filename, struct dictionary *dicval, int line)
unsigned char buff[256];
FILE *fp;
- fp=nkf_open(filename,"r");
+ if(kpse_in_name_ok(filename))
+ fp=nkf_open(filename,"r");
+ else {
+ fprintf(stderr, "mendex: %s is forbidden to open for reading.\n",filename);
+ exit(-1);
+ }
for (i=0;i<line;i++) {
if (mfgets(buff,255,fp)==NULL) break;
if ((buff[0]=='\n')||(buff[0]=='\0')) {
diff --git a/Build/source/texk/mendexk/fread.c b/Build/source/texk/mendexk/fread.c
index 9cd5d322eeb..9f5bc324c79 100644
--- a/Build/source/texk/mendexk/fread.c
+++ b/Build/source/texk/mendexk/fread.c
@@ -3,6 +3,7 @@
#include <string.h>
#include <kpathsea/config.h>
+#include <kpathsea/tex-file.h>
#include <ptexenc/ptexenc.h>
#include "mendex.h"
@@ -29,10 +30,16 @@ int idxread(char *filename, int start)
verb_printf(efp, "Scanning input file stdin.");
}
else {
- fp=nkf_open(filename,"r");
+ if(kpse_in_name_ok(filename))
+ fp=nkf_open(filename,"r");
+ else
+ fp=NULL;
if (fp==NULL) {
sprintf(buff,"%s.idx",filename);
- fp=nkf_open(buff,"r");
+ if(kpse_in_name_ok(buff))
+ fp=nkf_open(buff,"r");
+ else
+ fp=NULL;
if (fp==NULL) {
warn_printf(efp,"Warning: Couldn't find input file %s.\n",filename);
return 1;
diff --git a/Build/source/texk/mendexk/fwrite.c b/Build/source/texk/mendexk/fwrite.c
index aac5e7528e8..2f2b35283e2 100644
--- a/Build/source/texk/mendexk/fwrite.c
+++ b/Build/source/texk/mendexk/fwrite.c
@@ -4,6 +4,7 @@
#include <stdarg.h>
#include <kpathsea/config.h>
+#include <kpathsea/tex-file.h>
#include <ptexenc/ptexenc.h>
#include "mendex.h"
@@ -76,7 +77,7 @@ void indwrite(char *filename, struct index *ind, int pagenum)
unsigned char datama[256],lbuff[4096];
FILE *fp;
- if (filename[0]!='\0') fp=fopen(filename,"w");
+ if (filename[0]!='\0' && kpse_out_name_ok(filename)) fp=fopen(filename,"w");
else fp=stdout;
convert(atama,datama);
diff --git a/Build/source/texk/mendexk/kp.h b/Build/source/texk/mendexk/kp.h
index 3f4ba5880b2..7ad5e3e1d8a 100644
--- a/Build/source/texk/mendexk/kp.h
+++ b/Build/source/texk/mendexk/kp.h
@@ -8,6 +8,8 @@ typedef struct {
const char *suffix;
} KpathseaSupportInfo;
+extern KpathseaSupportInfo kp_ist, kp_dict;
+
extern int KP_init(char *);
extern int KP_entry_filetype(KpathseaSupportInfo *);
extern const char *KP_find_file(KpathseaSupportInfo *, const char *);
diff --git a/Build/source/texk/mendexk/main.c b/Build/source/texk/mendexk/main.c
index 7da7f7c9721..88b8682b75c 100644
--- a/Build/source/texk/mendexk/main.c
+++ b/Build/source/texk/mendexk/main.c
@@ -3,6 +3,7 @@
#include <string.h>
#include <kpathsea/config.h>
+#include <kpathsea/tex-file.h>
#include <ptexenc/ptexenc.h>
#include "mendex.h"
@@ -233,24 +234,22 @@ int main(int argc, char **argv)
if (i==-1) sprintf(indfile,"%s.ind",idxfile[0]);
}
- if (logfile[0]=='\0') {
- if (idxcount-fsti>0) {
- for (i=strlen(idxfile[0]);i>=0;i--) {
- if (idxfile[0][i]=='.') {
- strncpy(logfile,idxfile[0],i);
- sprintf(&logfile[i],".ilg");
- break;
- }
+ if ((logfile[0] == '\0') && (idxcount-fsti > 0)) {
+ for (i=strlen(idxfile[0]);i>=0;i--) {
+ if (idxfile[0][i]=='.') {
+ strncpy(logfile,idxfile[0],i);
+ sprintf(&logfile[i],".ilg");
+ break;
}
- if (i==-1) sprintf(logfile,"%s.ilg",idxfile[0]);
- efp=fopen(logfile,"w");
}
- else {
- efp=stderr;
- strcpy(logfile,"stderr");
+ if (i==-1) sprintf(logfile,"%s.ilg",idxfile[0]);
}
+ if ((logfile[0] != '\0') && kpse_out_name_ok(logfile))
+ efp=fopen(logfile,"w");
+ if(efp == NULL) {
+ efp=stderr;
+ strcpy(logfile,"stderr");
}
- else efp=fopen(logfile,"w");
if (strcmp(argv[0],"makeindex")==0) {
verb_printf(efp,"This is Not `MAKEINDEX\', But `MENDEX\' %s (%s).\n",
diff --git a/Build/source/texk/mendexk/pageread.c b/Build/source/texk/mendexk/pageread.c
index 41c65de14c1..8b16e892d7a 100644
--- a/Build/source/texk/mendexk/pageread.c
+++ b/Build/source/texk/mendexk/pageread.c
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
+#include <kpathsea/tex-file.h>
#include "mendex.h"
/* checking last page */
@@ -20,7 +21,10 @@ int lastpage(const char *filename)
}
if (i==-1) sprintf(logfile,"%s.log",filename);
- fp=fopen(logfile,"r");
+ if(kpse_in_name_ok(logfile))
+ fp=fopen(logfile,"r");
+ else
+ fp=NULL;
if (fp==NULL) {
fprintf(stderr,"No log file, %s.\n",logfile);
exit(0);
diff --git a/Build/source/texk/mendexk/styfile.c b/Build/source/texk/mendexk/styfile.c
index ccc2db238c9..f7d990e2790 100644
--- a/Build/source/texk/mendexk/styfile.c
+++ b/Build/source/texk/mendexk/styfile.c
@@ -3,6 +3,7 @@
#include <string.h>
#include <kpathsea/config.h>
+#include <kpathsea/tex-file.h>
#include <ptexenc/ptexenc.h>
#include "mendex.h"
@@ -10,7 +11,6 @@
#ifdef KPATHSEA
#include "kp.h"
-extern KpathseaSupportInfo kp_ist;
#endif
FILE *fp;
@@ -32,7 +32,10 @@ void styread(const char *filename)
#ifdef KPATHSEA
filename = KP_find_file(&kp_ist,filename);
#endif
- fp=nkf_open(filename,"r");
+ if(kpse_in_name_ok(filename))
+ fp=nkf_open(filename,"r");
+ else
+ fp=NULL;
if (fp==NULL) {
fprintf(stderr,"%s does not exist.\n",filename);
exit(0);