summaryrefslogtreecommitdiff
path: root/Build/source/texk/makejvf
diff options
context:
space:
mode:
authorHironobu Yamashita <h.y.acetaminophen@gmail.com>2019-02-23 22:34:30 +0000
committerHironobu Yamashita <h.y.acetaminophen@gmail.com>2019-02-23 22:34:30 +0000
commit389adc225b81ce6f44e82455cd7ec72402c2ed13 (patch)
tree3fa3a637208d652c9294ac3ac87f223379c2b730 /Build/source/texk/makejvf
parent86ffc22eba4103f3f056180b2eb16e078d76bb90 (diff)
makejvf: forbid invalid usages
git-svn-id: svn://tug.org/texlive/trunk@50106 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/makejvf')
-rw-r--r--Build/source/texk/makejvf/ChangeLog11
-rw-r--r--Build/source/texk/makejvf/main.c95
-rw-r--r--Build/source/texk/makejvf/tfmread.c13
-rw-r--r--Build/source/texk/makejvf/version.h2
4 files changed, 85 insertions, 36 deletions
diff --git a/Build/source/texk/makejvf/ChangeLog b/Build/source/texk/makejvf/ChangeLog
index d600c26fba7..4afdb6139c3 100644
--- a/Build/source/texk/makejvf/ChangeLog
+++ b/Build/source/texk/makejvf/ChangeLog
@@ -1,3 +1,14 @@
+2019-02-23 Hironobu Yamashita <h.y.acetaminophen@gmail.com>
+
+ * main.c, tfmread.c: Forbid invalid usages.
+ - Make sure the output TFM does not have the same
+ basename as the input TFM.
+ - Options -J, -U, -3, -H are useless in non-UCS mode,
+ throw a warning and ignore.
+ - Options -J and -U cannot be used at the same time,
+ throw an error.
+ * version.h: Bump version.
+
2019-02-19 Hironobu Yamashita <h.y.acetaminophen@gmail.com>
* tfmread.c, tool.c: Avoid compiler warnings for fgetc().
diff --git a/Build/source/texk/makejvf/main.c b/Build/source/texk/makejvf/main.c
index 86c0a0d6202..ade05cf4bf3 100644
--- a/Build/source/texk/makejvf/main.c
+++ b/Build/source/texk/makejvf/main.c
@@ -27,7 +27,6 @@ int main(int argc, char ** argv)
while ((c = getopt (argc, argv, "k:K:Ca:b:mu:3J:U:Hiet:")) != -1)
switch (c) {
-
case 'k':
kanatume = atoi(optarg);
break;
@@ -111,25 +110,78 @@ int main(int argc, char ** argv)
exit(0);
}
- atfmname = xmalloc(strlen(argv[optind])+4);
- strcpy(atfmname, argv[optind]);
-
- {
- const char *p = xbasename(argv[optind]);
- vfname = xmalloc(strlen(p)+4);
- strcpy(vfname, p);
- }
- if (FILESTRCASEEQ(&vfname[strlen(vfname)-4], ".tfm")) {
- vfname[strlen(vfname)-4] = '\0';
+ atfmname = xstrdup(argv[optind]);
+ if (FILESTRCASEEQ(&atfmname[strlen(atfmname)-4], ".tfm")) {
+ atfmname[strlen(atfmname)-4] = '\0';
}
+
+ const char *atfmname_base = xbasename(atfmname);
+ vfname = xmalloc(strlen(atfmname_base)+4);
+ strcpy(vfname, atfmname_base);
strcat(vfname,".vf");
vtfmname = xstrdup(argv[optind+1]);
if (FILESTRCASEEQ(&vtfmname[strlen(vtfmname)-4], ".tfm")) {
vtfmname[strlen(vtfmname)-4] = '\0';
}
+ if (FILESTRCASEEQ(&vtfmname[0], &atfmname_base[0])) {
+ fprintf(stderr,"Invalid usage: input TFM and output TFM must be different.\n");
+ exit(100);
+ }
- tfmget(atfmname);
+ if (kanatfm) {
+ if (FILESTRCASEEQ(&kanatfm[strlen(kanatfm)-4], ".tfm")) {
+ kanatfm[strlen(kanatfm)-4] = '\0';
+ }
+ if (FILESTRCASEEQ(&kanatfm[0], &atfmname_base[0])) {
+ fprintf(stderr,"Invalid usage: input TFM and output TFM must be different.\n");
+ exit(100);
+ }
+ }
+
+ if (!ucs) {
+ if (jistfm) {
+ fprintf(stderr,"[Warning] Option -J invalid in non-UCS mode, ignored.\n");
+ jistfm = NULL;
+ }
+ if (ucsqtfm) {
+ fprintf(stderr,"[Warning] Option -U invalid in non-UCS mode, ignored.\n");
+ ucsqtfm = NULL;
+ }
+ if (useset3) {
+ fprintf(stderr,"[Warning] Option -3 invalid in non-UCS mode, ignored.\n");
+ useset3 = 0;
+ }
+ if (hankana) {
+ fprintf(stderr,"[Warning] Option -H invalid in non-UCS mode, ignored.\n");
+ hankana = 0;
+ }
+ }
+
+ if (jistfm && ucsqtfm) {
+ fprintf(stderr,"Options -J and -U at the same time? I'm confused.\n");
+ exit(100);
+ }
+
+ if (jistfm) {
+ if (FILESTRCASEEQ(&jistfm[strlen(jistfm)-4], ".tfm")) {
+ jistfm[strlen(jistfm)-4] = '\0';
+ }
+ if (FILESTRCASEEQ(&jistfm[0], &atfmname_base[0])) {
+ fprintf(stderr,"Invalid usage: input TFM and output TFM must be different.\n");
+ exit(100);
+ }
+ }
+
+ if (ucsqtfm) {
+ if (FILESTRCASEEQ(&ucsqtfm[strlen(ucsqtfm)-4], ".tfm")) {
+ ucsqtfm[strlen(ucsqtfm)-4] = '\0';
+ }
+ if (FILESTRCASEEQ(&ucsqtfm[0], &atfmname_base[0])) {
+ fprintf(stderr,"Invalid usage: input TFM and output TFM must be different.\n");
+ exit(100);
+ }
+ }
if (usertable) {
get_usertable(usertable);
@@ -144,6 +196,8 @@ int main(int argc, char ** argv)
exit(101);
}
+ tfmget(atfmname);
+
vfp = vfopen(vfname);
pstfm_nt=1; /* initialize */
@@ -164,9 +218,6 @@ int main(int argc, char ** argv)
vfclose(vfp);
if (kanatfm) {
- if (FILESTRCASEEQ(&kanatfm[strlen(kanatfm)-4], ".tfm")) {
- kanatfm[strlen(kanatfm)-4] = '\0';
- }
maketfm(kanatfm);
pstfm_nt=1; /* already done*/
}
@@ -174,19 +225,9 @@ int main(int argc, char ** argv)
maketfm(vtfmname);
pstfm_nt=1; /* already done*/
- if (jistfm) {
- if (FILESTRCASEEQ(&jistfm[strlen(jistfm)-4], ".tfm")) {
- jistfm[strlen(jistfm)-4] = '\0';
- }
- maketfm(jistfm);
- }
+ if (jistfm) maketfm(jistfm);
- if (ucsqtfm) {
- if (FILESTRCASEEQ(&ucsqtfm[strlen(ucsqtfm)-4], ".tfm")) {
- ucsqtfm[strlen(ucsqtfm)-4] = '\0';
- }
- maketfm(ucsqtfm);
- }
+ if (ucsqtfm) maketfm(ucsqtfm);
exit(0);
}
diff --git a/Build/source/texk/makejvf/tfmread.c b/Build/source/texk/makejvf/tfmread.c
index 275ecd9164b..cf825cc28dc 100644
--- a/Build/source/texk/makejvf/tfmread.c
+++ b/Build/source/texk/makejvf/tfmread.c
@@ -93,20 +93,17 @@ int jfmread(int kcode)
int tfmget(char *name)
{
- char nbuff[1024];
+ char *nbuff;
FILE *fp;
- if (strlen(name) >= 1020) { /* <buffer size> - ".tfm" */
- fprintf(stderr,"Too long input file name.\n");
- exit(1);
- }
+ nbuff = xmalloc(strlen(name)+4);
strcpy(nbuff,name);
+ strcat(nbuff,".tfm");
fp = fopen(nbuff,"rb");
if (fp == NULL) {
- strcat(nbuff,".tfm");
- fp = fopen(nbuff,"rb");
+ fp = fopen(name,"rb"); /* just in case ... */
if (fp == NULL) {
- fprintf(stderr,"%s is not found.\n",name);
+ fprintf(stderr,"Cannot open %s for input.\n",nbuff);
exit(1);
}
}
diff --git a/Build/source/texk/makejvf/version.h b/Build/source/texk/makejvf/version.h
index 68357020e2e..c5d7003f67c 100644
--- a/Build/source/texk/makejvf/version.h
+++ b/Build/source/texk/makejvf/version.h
@@ -1,2 +1,2 @@
-#define VERSION "20190210"
+#define VERSION "20190223"
#define BUG_ADDRESS "issue@texjp.org"