SHA256
1
0
forked from pool/transfig
transfig/transfig-3.2.8.dif

164 lines
4.3 KiB
Plaintext

---
configure | 2 +-
fig2dev/dev/genps.c | 32 ++++++++++++++++++++++----------
fig2dev/dev/genpstex.c | 8 ++++++--
fig2dev/fig2ps2tex.csh | 2 +-
fig2dev/lib/getopt.c | 9 +++++++++
transfig/transfig.c | 2 ++
6 files changed, 41 insertions(+), 14 deletions(-)
--- configure
+++ configure 2021-02-12 08:54:37.958704809 +0000
@@ -4015,7 +4015,7 @@ main ()
int dynamic_array[ni.number];
dynamic_array[ni.number - 1] = 543;
-
+ free(ia);
// work around unused variable warnings
return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
|| dynamic_array[ni.number - 1] != 543);
--- fig2dev/dev/genps.c
+++ fig2dev/dev/genps.c 2021-02-12 09:13:56.896176342 +0000
@@ -56,6 +56,7 @@
#include <pwd.h>
#endif
#include <locale.h>
+#include <langinfo.h>
#include "fig2dev.h" /* includes bool.h and object.h */
//#include "object.h" /* NUMSHADES, NUMTINTS */
@@ -958,9 +959,10 @@ genps_start(F_compound *objects)
fprintf(tfp, "%s\n", SPLINE_PS);
#ifdef I18N
if (support_i18n && iso_text_exist(objects)) {
- char *libdir, *locale;
- char localefile_buf[128];
- char *localefile = localefile_buf;
+ char *libdir, *locale, *codeset;
+ char *localefile = NULL;
+ size_t llen;
+ int ret;
FILE *fp;
libdir = getenv("FIG2DEV_LIBDIR");
#ifdef I18N_DATADIR
@@ -968,19 +970,30 @@ genps_start(F_compound *objects)
libdir = I18N_DATADIR;
#endif
locale = setlocale(LC_CTYPE, NULL);
+ llen = strcspn(locale, ".@");
+ codeset = nl_langinfo(CODESET);
if (locale == NULL) {
fprintf(stderr,
"fig2dev: LANG not defined; assuming C locale\n");
locale = "C";
}
- if (strlen(libdir) + strlen(locale) + 5 > sizeof localefile_buf)
- localefile = malloc(strlen(libdir) + strlen(locale) + 5);
- if (localefile != NULL) {
- sprintf(localefile, "%s/%s.ps", libdir, locale);
+ retry:
+ ret = asprintf(&localefile, "%s/%s.ps", libdir, locale);
+ if (ret > 0) {
/* get filename like
``/usr/local/lib/fig2dev/japanese.ps'' */
fp = fopen(localefile, "rb");
if (fp == NULL) {
+ if (strlen(locale) != llen) {
+ free(localefile);
+ locale[llen] = '\0';
+ goto retry;
+ }
+ if (codeset && locale != codeset) {
+ free(localefile);
+ locale = codeset;
+ goto retry;
+ }
fprintf(stderr, "fig2dev: can not open file: %s\n",
localefile);
} else {
@@ -998,11 +1011,10 @@ genps_start(F_compound *objects)
"The output might be broken.\n",
localefile);
}
- fclose(fp);
+ fclose(fp);
}
- }
- if (localefile != localefile_buf)
free(localefile);
+ }
}
#endif /* I18N */
--- fig2dev/dev/genpstex.c
+++ fig2dev/dev/genpstex.c 2021-02-12 09:17:16.360300734 +0000
@@ -46,6 +46,7 @@
#include <stdio.h>
#include <string.h>
+#include <sys/stat.h>
#include "fig2dev.h"
#include "object.h"
@@ -62,10 +63,13 @@ extern void
genps_spline(F_spline *s),
genlatex_option(char opt, char *optarg),
genlatex_text(F_text *t),
- genps_text(F_text *t);
+ genps_text(F_text *t),
+ genpdf_option(char opt, char *optarg),
+ genpdf_start(F_compound *objects);
extern int
genlatex_end(void),
- genps_end(void);
+ genps_end(void),
+ genpdf_end(void);
extern void genpdf_option(char opt, char *optarg); /* genpdf.c */
extern void genpdf_start(F_compound *objects); /* genpdf.c */
--- fig2dev/fig2ps2tex.csh
+++ fig2dev/fig2ps2tex.csh 2021-02-12 08:54:37.954704887 +0000
@@ -22,7 +22,7 @@
# 2016-07-07 Thomas Loimer
# * use here-document, instead of echo
#
-
+set echo_style = bsd
set bbox = `grep "^%%BoundingBox:" $1`
set xsp = `echo "3k $bbox[4] $bbox[2] - 72 / p" | dc`
--- fig2dev/lib/getopt.c
+++ fig2dev/lib/getopt.c 2021-02-12 08:54:37.954704887 +0000
@@ -42,6 +42,7 @@
#define EMSG ""
#define ENDARGS "--"
+#ifndef __GLIBC__
/*
* get option letter from argument vector
*/
@@ -88,3 +89,11 @@ getopt(int nargc, char **nargv, const ch
}
return optc; /* dump back option letter */
}
+#else
+#include <unistd.h>
+int
+fig_getopt(int nargc, char * const nargv[], const char *ostr)
+{
+ return getopt(nargc, nargv, ostr);
+}
+#endif
--- transfig/transfig.c
+++ transfig/transfig.c 2021-02-12 08:54:37.954704887 +0000
@@ -26,6 +26,8 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#include "transfig.h"
extern void sysmv(char *file); /* sys.c */