diff options
author | Karl Berry <karl@freefriends.org> | 2017-02-15 22:52:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-02-15 22:52:41 +0000 |
commit | 70090e3ff9ef701f4712fbf70b7d9d93b6fd23d7 (patch) | |
tree | 9b74c1bf86f887bc3b71df29bc82d9f3d8939444 /Build/source/texk/dvisvgm/dvisvgm-src/libs | |
parent | e1d7bddac7d75ef6bb337f709e67cbd35a6b1e09 (diff) |
locale portability patch from Martin; autoreconf
git-svn-id: svn://tug.org/texlive/trunk@43238 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/libs')
7 files changed, 83 insertions, 65 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.am b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.am index 2864abed4bf..41ecdbadbdd 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.am +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.am @@ -14,6 +14,8 @@ libfontforge_a_SOURCES = \ fontforge/edgelist2.h \ fontforge/encoding.c \ fontforge/encoding.h \ + fontforge/fflocale.c \ + fontforge/fflocale.h \ fontforge/fontforge-config.h \ fontforge/fontforge.h \ fontforge/fontforgevw.h \ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.in b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.in index 6dd50061ca7..ef286840abd 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.in +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/Makefile.in @@ -125,12 +125,12 @@ am_libfontforge_a_OBJECTS = fontforge/alphabet.$(OBJEXT) \ fontforge/asmfpst.$(OBJEXT) fontforge/autohint.$(OBJEXT) \ fontforge/char.$(OBJEXT) fontforge/cjk.$(OBJEXT) \ fontforge/cvundoes.$(OBJEXT) fontforge/dumppfa.$(OBJEXT) \ - fontforge/encoding.$(OBJEXT) fontforge/fvfonts.$(OBJEXT) \ - fontforge/gwwiconv.$(OBJEXT) fontforge/lookups.$(OBJEXT) \ - fontforge/macbinary.$(OBJEXT) fontforge/macenc.$(OBJEXT) \ - fontforge/mathconstants.$(OBJEXT) fontforge/memory.$(OBJEXT) \ - fontforge/mm.$(OBJEXT) fontforge/namelist.$(OBJEXT) \ - fontforge/nouiutil.$(OBJEXT) \ + fontforge/encoding.$(OBJEXT) fontforge/fflocale.$(OBJEXT) \ + fontforge/fvfonts.$(OBJEXT) fontforge/gwwiconv.$(OBJEXT) \ + fontforge/lookups.$(OBJEXT) fontforge/macbinary.$(OBJEXT) \ + fontforge/macenc.$(OBJEXT) fontforge/mathconstants.$(OBJEXT) \ + fontforge/memory.$(OBJEXT) fontforge/mm.$(OBJEXT) \ + fontforge/namelist.$(OBJEXT) fontforge/nouiutil.$(OBJEXT) \ fontforge/nowakowskittfinstr.$(OBJEXT) \ fontforge/parsepfa.$(OBJEXT) fontforge/parsettf.$(OBJEXT) \ fontforge/parsettfatt.$(OBJEXT) fontforge/psread.$(OBJEXT) \ @@ -394,6 +394,8 @@ libfontforge_a_SOURCES = \ fontforge/edgelist2.h \ fontforge/encoding.c \ fontforge/encoding.h \ + fontforge/fflocale.c \ + fontforge/fflocale.h \ fontforge/fontforge-config.h \ fontforge/fontforge.h \ fontforge/fontforgevw.h \ @@ -520,6 +522,8 @@ fontforge/dumppfa.$(OBJEXT): fontforge/$(am__dirstamp) \ fontforge/$(DEPDIR)/$(am__dirstamp) fontforge/encoding.$(OBJEXT): fontforge/$(am__dirstamp) \ fontforge/$(DEPDIR)/$(am__dirstamp) +fontforge/fflocale.$(OBJEXT): fontforge/$(am__dirstamp) \ + fontforge/$(DEPDIR)/$(am__dirstamp) fontforge/fvfonts.$(OBJEXT): fontforge/$(am__dirstamp) \ fontforge/$(DEPDIR)/$(am__dirstamp) fontforge/gwwiconv.$(OBJEXT): fontforge/$(am__dirstamp) \ @@ -621,6 +625,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@fontforge/$(DEPDIR)/cvundoes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@fontforge/$(DEPDIR)/dumppfa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@fontforge/$(DEPDIR)/encoding.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@fontforge/$(DEPDIR)/fflocale.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@fontforge/$(DEPDIR)/fvfonts.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@fontforge/$(DEPDIR)/gwwiconv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@fontforge/$(DEPDIR)/lookups.Po@am__quote@ diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/fflocale.c b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/fflocale.c new file mode 100644 index 00000000000..3912686b5e8 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/fflocale.c @@ -0,0 +1,44 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "fflocale.h" + +void switch_to_c_locale(ff_locale_t * tmplocale_p, ff_locale_t * oldlocale_p) { +#ifdef HAVE_USELOCALE + *tmplocale_p = newlocale(LC_NUMERIC_MASK, "C", NULL); + if (*tmplocale_p == NULL) + fprintf(stderr, "Failed to create temporary locale.\n"); + else if ((*oldlocale_p = uselocale(*tmplocale_p)) == NULL) { + fprintf(stderr, "Failed to change locale.\n"); + freelocale(*tmplocale_p); *tmplocale_p = NULL; + } +#else + *tmplocale_p = setlocale(LC_NUMERIC, "C"); + if (*tmplocale_p) + *oldlocale_p = strdup(*tmplocale_p); + else { + *oldlocale_p = NULL; + fprintf(stderr, "Failed to change locale.\n"); + } +#endif +} + +void switch_to_old_locale(ff_locale_t * tmplocale_p, ff_locale_t * oldlocale_p) { +#ifdef HAVE_USELOCALE + if (*oldlocale_p) + uselocale(*oldlocale_p); + else + uselocale(LC_GLOBAL_LOCALE); + *oldlocale_p = NULL; // This ends the lifecycle of the temporary old locale storage. + if (*tmplocale_p) { + freelocale(*tmplocale_p); + *tmplocale_p = NULL; + } +#else + if (*oldlocale_p) { + setlocale(LC_NUMERIC, *oldlocale_p); + free(*oldlocale_p); + *oldlocale_p = NULL; + } +#endif +} diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/fflocale.h b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/fflocale.h new file mode 100644 index 00000000000..51bcd83d147 --- /dev/null +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/fflocale.h @@ -0,0 +1,23 @@ +#ifndef FFLOCALE_H +#define FFLOCALE_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <locale.h> +#ifdef HAVE_XLOCALE_H +#include <xlocale.h> +#endif + +#ifdef HAVE_USELOCALE +typedef locale_t ff_locale_t; +#else +typedef char* ff_locale_t; +#endif // HAVE_USELOCALE + +void switch_to_c_locale(ff_locale_t *tmplocale_p, ff_locale_t *oldlocale_p); +void switch_to_old_locale(ff_locale_t *tmplocale_p, ff_locale_t *oldlocale_p); + +#endif /* FFLOCALE_H */ + diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/sfd.c b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/sfd.c index 53671118138..1f6ca428f93 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/sfd.c +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/sfd.c @@ -4646,7 +4646,7 @@ static SplineFont *SFD_Read(char *filename,FILE *sfd, int fromdir) { } if ( sfd==NULL ) return( NULL ); - locale_t tmplocale; locale_t oldlocale; // Declare temporary locale storage. + ff_locale_t tmplocale, oldlocale; // Declare temporary locale storage. switch_to_c_locale(&tmplocale, &oldlocale); // Switch to the C locale temporarily and cache the old locale. ff_progress_change_stages(2); if ( (version = SFDStartsCorrectly(sfd,tok))!=-1 ) diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/splinefont.h b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/splinefont.h index 6ecf7996506..09945f456d8 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/splinefont.h +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/splinefont.h @@ -33,15 +33,12 @@ #include <basics.h> #include <dlist.h> #include "configure-fontforge.h" +#include "fflocale.h" #ifdef HAVE_ICONV # include <iconv.h> #else # include <gwwiconv.h> #endif -#include <locale.h> -#ifdef HAVE_XLOCALE_H -#include <xlocale.h> -#endif #include <gnetwork.h> #ifdef FONTFORGE_CONFIG_USE_DOUBLE @@ -2554,57 +2551,4 @@ char * upper_case(const char * input); #include "ustring.h" -#ifdef _WIN32 -#define BAD_LOCALE_HACK -typedef char* locale_t; -#define LC_GLOBAL_LOCALE ((locale_t)-1) -#define LC_ALL_MASK LC_ALL -#define LC_COLLATE_MASK LC_COLLATE -#define LC_CTYPE_MASK LC_CTYPE -#define LC_MONETARY_MASK LC_MONETARY -#define LC_NUMERIC_MASK LC_NUMERIC -#define LC_TIME_MASK LC_TIME -#endif - -static inline void switch_to_c_locale(locale_t * tmplocale_p, locale_t * oldlocale_p) { -#ifndef BAD_LOCALE_HACK - *tmplocale_p = newlocale(LC_NUMERIC_MASK, "C", NULL); - if (*tmplocale_p == NULL) fprintf(stderr, "Failed to create temporary locale.\n"); - else if ((*oldlocale_p = uselocale(*tmplocale_p)) == NULL) { - fprintf(stderr, "Failed to change locale.\n"); - freelocale(*tmplocale_p); *tmplocale_p = NULL; - } -#else - // Yes, it is dirty. But so is an operating system that doesn't support threaded locales. - *oldlocale_p = (locale_t)copy(setlocale(LC_NUMERIC_MASK, "C")); - if (*oldlocale_p == NULL) fprintf(stderr, "Failed to change locale.\n"); -#endif -} - -static inline void switch_to_old_locale(locale_t * tmplocale_p, locale_t * oldlocale_p) { -#ifndef BAD_LOCALE_HACK - if (*oldlocale_p != NULL) { uselocale(*oldlocale_p); } else { uselocale(LC_GLOBAL_LOCALE); } - *oldlocale_p = NULL; // This ends the lifecycle of the temporary old locale storage. - if (*tmplocale_p != NULL) { freelocale(*tmplocale_p); *tmplocale_p = NULL; } -#else - if (*oldlocale_p != NULL) { - setlocale(LC_NUMERIC_MASK, (char*)(*oldlocale_p)); - free((char*)(*oldlocale_p)); - *oldlocale_p = NULL; - } -#endif -} - -#if 0 -#define DECLARE_TEMP_LOCALE() char oldloc[25]; -#define SWITCH_TO_C_LOCALE() strncpy( oldloc,setlocale(LC_NUMERIC,NULL),24 ); oldloc[24]='\0'; setlocale(LC_NUMERIC,"C"); -#define SWITCH_TO_OLD_LOCALE() setlocale(LC_NUMERIC,oldloc); -#else -#define DECLARE_TEMP_LOCALE() locale_t tmplocale; locale_t oldlocale; // Declare temporary locale storage. -#define SWITCH_TO_C_LOCALE() switch_to_c_locale(&tmplocale, &oldlocale); // Switch to the C locale temporarily and cache the old locale. -#define SWITCH_TO_OLD_LOCALE() switch_to_old_locale(&tmplocale, &oldlocale); // Switch to the cached locale. -#endif - - - #endif diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/tottf.c b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/tottf.c index e3257c1fc38..57c61c0cc24 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/tottf.c +++ b/Build/source/texk/dvisvgm/dvisvgm-src/libs/ff-woff/fontforge/tottf.c @@ -5925,7 +5925,7 @@ int _WriteTTFFont(FILE *ttf,SplineFont *sf,enum fontformat format, short_too_long_warned = 0; // This is a static variable defined for putshort. /* TrueType probably doesn't need this, but OpenType does for floats in dictionaries */ - locale_t tmplocale; locale_t oldlocale; // Declare temporary locale storage. + ff_locale_t tmplocale, oldlocale; // Declare temporary locale storage. switch_to_c_locale(&tmplocale, &oldlocale); // Switch to the C locale temporarily and cache the old locale. if ( format==ff_otfcid || format== ff_cffcid ) { |