summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/makejvf/ChangeLog18
-rw-r--r--Build/source/texk/makejvf/main.c112
-rwxr-xr-xBuild/source/texk/makejvf/makejvf.test7
-rw-r--r--Build/source/texk/makejvf/tfmread.c16
-rw-r--r--Build/source/texk/makejvf/tool.c1
5 files changed, 74 insertions, 80 deletions
diff --git a/Build/source/texk/makejvf/ChangeLog b/Build/source/texk/makejvf/ChangeLog
index 05fc0d1bdc7..1e21373edfa 100644
--- a/Build/source/texk/makejvf/ChangeLog
+++ b/Build/source/texk/makejvf/ChangeLog
@@ -1,3 +1,21 @@
+2012-09-04 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * main.c: Use xmalloc() and xstrdup(). Use getopt() to parse
+ options, avoiding segmentation fault for missing parameters.
+ * tfmread.c: Use xmalloc().
+ * makejvf.test: Test options '-k0 -a abc'.
+
+2012-09-02 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ Remove W32TeX/TL diffs (from Akira).
+ * main.c: Use "sjis" file encoding.
+ Use kpse_find_file() to locate AFM file.
+ Use FILESTRCASEEQ() and xbasename().
+
+2012-08-23 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * tool.c: Drop useless '#include <strings.h>'.
+
2012-07-01 Peter Breitenlohner <peb@mppmu.mpg.de>
* tfmread.c: Use fopen() mode "rb" for TFM file.
diff --git a/Build/source/texk/makejvf/main.c b/Build/source/texk/makejvf/main.c
index baa96c39798..5a38a0bf907 100644
--- a/Build/source/texk/makejvf/main.c
+++ b/Build/source/texk/makejvf/main.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
-#include <kpathsea/config.h>
+#include <kpathsea/kpathsea.h>
#include <ptexenc/ptexenc.h>
#include "makejvf.h"
#include "uniblock.h"
@@ -15,71 +15,55 @@ long ucs=0;
int main(int argc, char ** argv)
{
int i,j,ib;
+ int c;
long ch;
- set_enc_string(NULL, "EUC");
- if (argc < 3) {
- usage();
- exit(0);
- }
+ kpse_set_program_name(argv[0], "makejvf");
+ set_enc_string("sjis", "euc");
+
+ while ((c = getopt (argc, argv, "k:K:Ca:b:mu:3J:U:Hi")) != -1)
+ switch (c) {
- argv++;
- for (;**argv=='-';argv++) {
- switch ((*argv)[1]) {
case 'k':
- if ((*argv)[2]!='\0') {
- kanatume = atoi(&(*argv)[2]);
- }
- else {
- kanatume = atoi(*(++argv));
- }
+ kanatume = atoi(optarg);
break;
case 'K':
- if ((*argv)[2]!='\0') {
- kanatfm = strdup(&(*argv)[2]);
- }
- else {
- kanatfm = strdup(*(++argv));
- }
+ kanatfm = xstrdup(optarg);
break;
case 'C':
chotai=1;
break;
case 'a':
- if ((*argv)[2]!='\0') {
- afmname = strdup(&(*argv)[2]);
- }
- else {
- afmname = strdup(*(++argv));
+ afmname = xstrdup(optarg);
+ {
+ char *fpath = kpse_find_file(afmname, kpse_afm_format, 0);
+ if (fpath) {
+ afp = fopen(fpath, "r");
+ free(fpath);
+ }
}
- if ((afp = fopen(afmname,"r"))==NULL) {
+ if (!afp) {
fprintf(stderr,"no AFM file, %s.\n",afmname);
exit(100);
}
break;
case 'b':
- if ((*argv)[2]!='\0') {
- baseshift = atoi(&(*argv)[2]);
- }
- else {
- baseshift = atoi(*(++argv));
- }
+ baseshift = atoi(optarg);
break;
case 'm':
minute=1;
break;
case 'u':
- argv++;
- if (!strcmp(*argv,"gb"))
+ if (!strcmp(optarg, "gb"))
ucs = ENTRY_G;
- else if (!strcmp(*argv,"cns"))
+ else if (!strcmp(optarg, "cns"))
ucs = ENTRY_C;
- else if (!strcmp(*argv,"jisq"))
+ else if (!strcmp(optarg, "jisq"))
ucs = ENTRY_JQ;
- else if (!strcmp(*argv,"jis"))
+ else if (!strcmp(optarg, "jis"))
ucs = ENTRY_J;
- else if (!strcmp(*argv,"ks"))
+ else if (!strcmp(optarg, "ks"))
ucs = ENTRY_K;
else {
fprintf(stderr,"Charset is not set\n");
@@ -90,21 +74,10 @@ int main(int argc, char ** argv)
useset3=1;
break;
case 'J':
- if ((*argv)[2]!='\0') {
- jistfm = strdup(&(*argv)[2]);
- }
- else {
- jistfm = strdup(*(++argv));
- }
+ jistfm = xstrdup(optarg);
break;
case 'U':
- if ((*argv)[2]!='\0') {
- ucsqtfm = strdup(&(*argv)[2]);
- }
- else {
- ucsqtfm = strdup(*(++argv));
- }
- break;
+ ucsqtfm = xstrdup(optarg);
case 'H':
hankana=1;
break;
@@ -115,33 +88,32 @@ int main(int argc, char ** argv)
usage();
exit(0);
}
- }
if (kanatume>=0 && !afp) {
fprintf(stderr,"No AFM file for kanatume.\n");
exit(100);
}
- atfmname = malloc(strlen(*argv)+4);
- strcpy(atfmname,*argv);
+ if (argc - optind != 2) {
+ usage();
+ exit(0);
+ }
- vfname = malloc(strlen(*argv)+4);
- strcpy(vfname,*argv);
- for (i = strlen(vfname)-1 ; i >= 0 ; i--) {
- if (vfname[i] == '/') {
- vfname = &vfname[i+1];
- break;
- }
+ 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 (!strcmp(&vfname[strlen(vfname)-4],".tfm")) {
+ if (FILESTRCASEEQ(&vfname[strlen(vfname)-4], ".tfm")) {
vfname[strlen(vfname)-4] = '\0';
}
strcat(vfname,".vf");
- argv++;
-
- vtfmname = strdup(*argv);
- if (!strcmp(&vtfmname[strlen(vtfmname)-4],".tfm")) {
+ vtfmname = xstrdup(argv[optind+1]);
+ if (FILESTRCASEEQ(&vtfmname[strlen(vtfmname)-4], ".tfm")) {
vtfmname[strlen(vtfmname)-4] = '\0';
}
@@ -150,21 +122,21 @@ int main(int argc, char ** argv)
maketfm(vtfmname);
if (kanatfm) {
- if (!strcmp(&kanatfm[strlen(kanatfm)-4],".tfm")) {
+ if (FILESTRCASEEQ(&kanatfm[strlen(kanatfm)-4], ".tfm")) {
kanatfm[strlen(kanatfm)-4] = '\0';
}
maketfm(kanatfm);
}
if (jistfm) {
- if (!strcmp(&jistfm[strlen(jistfm)-4],".tfm")) {
+ if (FILESTRCASEEQ(&jistfm[strlen(jistfm)-4], ".tfm")) {
jistfm[strlen(jistfm)-4] = '\0';
}
maketfm(jistfm);
}
if (ucsqtfm) {
- if (!strcmp(&ucsqtfm[strlen(ucsqtfm)-4],".tfm")) {
+ if (FILESTRCASEEQ(&ucsqtfm[strlen(ucsqtfm)-4], ".tfm")) {
ucsqtfm[strlen(ucsqtfm)-4] = '\0';
}
maketfm(ucsqtfm);
diff --git a/Build/source/texk/makejvf/makejvf.test b/Build/source/texk/makejvf/makejvf.test
index f09e48b28a5..e6111cb6296 100755
--- a/Build/source/texk/makejvf/makejvf.test
+++ b/Build/source/texk/makejvf/makejvf.test
@@ -1,6 +1,6 @@
#! /bin/sh
-# Copyright (C) 2010 Peter Breitenlohner <tex-live@tug.org>
+# Copyright (C) 2010-2012 Peter Breitenlohner <tex-live@tug.org>
# You may freely use, modify and/or distribute this file.
./makejvf $srcdir/tests/min10.tfm rml && \
@@ -13,3 +13,8 @@ cmp $srcdir/tests/min10.vf min10.vf || :
cmp $srcdir/tests/tmin10.vf tmin10.vf || :
+TEXMFCNF=$srcdir/../kpathsea \
+ ./makejvf -k0 -a abc && exit 1
+
+exit 0
+
diff --git a/Build/source/texk/makejvf/tfmread.c b/Build/source/texk/makejvf/tfmread.c
index 40323a73c63..f9046c0aeb4 100644
--- a/Build/source/texk/makejvf/tfmread.c
+++ b/Build/source/texk/makejvf/tfmread.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
-#include <kpathsea/config.h>
+#include <kpathsea/kpathsea.h>
#include "makejvf.h"
int nt,unit,zh,zw,jfm_id;
@@ -72,32 +72,32 @@ int tfmidx(FILE *fp)
ng = ufpair(fp);
np = ufpair(fp);
- header = malloc(lh*4);
+ header = xmalloc(lh*4);
for (i = 0 ; i < lh*4 ; i++) {
header[i] = fgetc(fp);
}
- char_type = malloc(nt*4);
+ char_type = xmalloc(nt*4);
for (i = 0 ; i < nt*4 ; i++) {
char_type[i] = fgetc(fp);
}
- char_info = malloc((ec+1)*4);
+ char_info = xmalloc((ec+1)*4);
for (i = 0 ; i < (ec+1)*4 ; i++) {
char_info[i] = fgetc(fp);
}
- width = malloc(nw*sizeof(int));
+ width = xmalloc(nw*sizeof(int));
for (i = 0 ; i < nw ; i++) {
width[i] = fquad(fp);
}
- height = malloc(nh*sizeof(int));
+ height = xmalloc(nh*sizeof(int));
for (i = 0 ; i < nh ; i++) {
height[i] = fquad(fp);
}
- depth = malloc(nd*sizeof(int));
+ depth = xmalloc(nd*sizeof(int));
for (i = 0 ; i < nd ; i++) {
depth[i] = fquad(fp);
}
fseek(fp,(ni+nl+nk+ng)*4,SEEK_CUR);
- param = malloc(np*sizeof(int));
+ param = xmalloc(np*sizeof(int));
for (i = 0 ; i < np ; i++) {
param[i] = fquad(fp);
}
diff --git a/Build/source/texk/makejvf/tool.c b/Build/source/texk/makejvf/tool.c
index eed34c78959..c99e8b9a03f 100644
--- a/Build/source/texk/makejvf/tool.c
+++ b/Build/source/texk/makejvf/tool.c
@@ -1,5 +1,4 @@
#include <stdio.h>
-#include <strings.h>
#include <math.h>
#include <kpathsea/config.h>