From c87fec0299533fee9b20505a4955c7f2f5c5bed7 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Wed, 9 Aug 2017 07:45:12 +0200 Subject: [PATCH] [psnames] Really fix issue #49949. We now use a separate preprocessor macro to handle both definition and declaration of the glyph name arrays. * src/psnames/psmodule.c (DEFINE_PS_TABLE_DATA): New macro. * src/tools/glnames.py (StringTable::dump, StringTable::dump_sublist): Use `DEFINE_PS_TABLE_DATA'. (dump_encoding): Ditto. (main): Use `wb' mode for writing the output file, which works on Windows also. * src/psnames/pstables.h: Regenerated. --- ChangeLog | 19 ++++++++++++++++++- src/psnames/psmodule.c | 13 +++++++++++++ src/psnames/pstables.h | 36 ++++++++++++++++++------------------ src/tools/glnames.py | 26 +++++++++++++------------- 4 files changed, 62 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c648549f..c512808d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2017-08-08 Werner Lemberg + + [psnames] Really fix issue #49949. + + We now use a separate preprocessor macro to handle both definition + and declaration of the glyph name arrays. + + * src/psnames/psmodule.c (DEFINE_PS_TABLE_DATA): New macro. + + * src/tools/glnames.py (StringTable::dump, + StringTable::dump_sublist): Use `DEFINE_PS_TABLE_DATA'. + (dump_encoding): Ditto. + (main): Use `wb' mode for writing the output file, which works on + Windows also. + + * src/psnames/pstables.h: Regenerated. + 2017-08-08 Alexei Podtelezhnikov [smooth] Harmony LCD rendering. @@ -25,7 +42,7 @@ * src/sftnt/ttpost.c (format): Use otspec-compliant versions. -2017-06-27 Werner Lemberg +2017-08-05 Werner Lemberg [truetype] Integer overflow. diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c index 3ff8cb911..44ba9ec6a 100644 --- a/src/psnames/psmodule.c +++ b/src/psnames/psmodule.c @@ -23,8 +23,21 @@ #include "psmodule.h" + /* + * The file `pstables.h' with its arrays and its function + * `ft_get_adobe_glyph_index' is useful for other projects also (for + * example, `pdfium' is using it). However, if used as a C++ header, + * including it in two different source files makes it necessary to use + * `extern const' for the declaration of its arrays, otherwise the data + * would be duplicated as mandated by the C++ standard. + * + * For this reason, we use `DEFINE_PS_TABLES' to guard the function + * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array + * declarations and definitions. + */ #include "pstables.h" #define DEFINE_PS_TABLES +#define DEFINE_PS_TABLES_DATA #include "pstables.h" #include "psnamerr.h" diff --git a/src/psnames/pstables.h b/src/psnames/pstables.h index e0f5e3080..2a2b717d8 100644 --- a/src/psnames/pstables.h +++ b/src/psnames/pstables.h @@ -19,7 +19,7 @@ /* This file has been generated automatically -- do not edit! */ -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -27,7 +27,7 @@ #endif #endif const char ft_standard_glyph_names[3696] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { '.','n','u','l','l', 0, @@ -451,7 +451,7 @@ 'R','o','m','a','n', 0, 'S','e','m','i','b','o','l','d', 0, } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; @@ -459,7 +459,7 @@ /* Values are offsets into the `ft_standard_glyph_names' table */ -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -467,7 +467,7 @@ #endif #endif const short ft_mac_names[FT_NUM_MAC_NAMES] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { 253, 0, 6, 261, 267, 274, 283, 294, 301, 309, 758, 330, 340, 351, @@ -490,7 +490,7 @@ 1270,1313,1323,1171,1290,1332,1211,1235,1276, 169, 175, 182, 189, 200, 209, 218, 225, 232, 239, 246 } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; @@ -498,7 +498,7 @@ /* Values are offsets into the `ft_standard_glyph_names' table */ -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -506,7 +506,7 @@ #endif #endif const short ft_sid_names[FT_NUM_SID_NAMES] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { 253, 261, 267, 274, 283, 294, 301, 309, 319, 330, 340, 351, 360, 365, @@ -538,12 +538,12 @@ 3418,3430,3442,3454,3471,3483,3498,3506,3518,3530,3542,3559,3574,3586, 3597,3612,3620,3628,3636,3644,3650,3655,3660,3666,3673,3681,3687 } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; /* the following are indices into the SID name table */ -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -551,7 +551,7 @@ #endif #endif const unsigned short t1_standard_encoding[256] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -571,12 +571,12 @@ 0,138, 0,139, 0, 0, 0, 0,140,141,142,143, 0, 0, 0, 0, 0,144, 0, 0, 0,145, 0, 0,146,147,148,149, 0, 0, 0, 0 } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; /* the following are indices into the SID name table */ -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -584,7 +584,7 @@ #endif #endif const unsigned short t1_expert_encoding[256] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -604,7 +604,7 @@ 347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362, 363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378 } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; @@ -619,7 +619,7 @@ #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -627,7 +627,7 @@ #endif #endif const unsigned char ft_adobe_glyph_list[55997L] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { 0, 52, 0,106, 2,167, 3, 63, 4,220, 6,125, 9,143, 10, 23, @@ -4131,7 +4131,7 @@ 182,117, 2,218,167,218,178,232,233,242,225,231,225,238, 97,128, 48, 90,235,225,244,225,235,225,238, 97,128, 48,186 } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; diff --git a/src/tools/glnames.py b/src/tools/glnames.py index 9ed158862..3270eebb3 100644 --- a/src/tools/glnames.py +++ b/src/tools/glnames.py @@ -4920,7 +4920,7 @@ class StringTable: def dump( self, file ): write = file.write - write( "#ifndef DEFINE_PS_TABLES\n" ) + write( "#ifndef DEFINE_PS_TABLES_DATA\n" ) write( "#ifdef __cplusplus\n" ) write( ' extern "C"\n' ) write( "#else\n" ) @@ -4929,7 +4929,7 @@ class StringTable: write( "#endif\n" ) write( " const char " + self.master_table + "[" + repr( self.total ) + "]\n" ) - write( "#ifdef DEFINE_PS_TABLES\n" ) + write( "#ifdef DEFINE_PS_TABLES_DATA\n" ) write( " =\n" ) write( " {\n" ) @@ -4941,7 +4941,7 @@ class StringTable: write( line ) write( " }\n" ) - write( "#endif /* DEFINE_PS_TABLES */\n" ) + write( "#endif /* DEFINE_PS_TABLES_DATA */\n" ) write( " ;\n\n\n" ) def dump_sublist( self, file, table_name, macro_name, sublist ): @@ -4950,7 +4950,7 @@ class StringTable: write( " /* Values are offsets into the `" + self.master_table + "' table */\n\n" ) - write( "#ifndef DEFINE_PS_TABLES\n" ) + write( "#ifndef DEFINE_PS_TABLES_DATA\n" ) write( "#ifdef __cplusplus\n" ) write( ' extern "C"\n' ) write( "#else\n" ) @@ -4959,7 +4959,7 @@ class StringTable: write( "#endif\n" ) write( " const short " + table_name + "[" + macro_name + "]\n" ) - write( "#ifdef DEFINE_PS_TABLES\n" ) + write( "#ifdef DEFINE_PS_TABLES_DATA\n" ) write( " =\n" ) write( " {\n" ) @@ -4979,7 +4979,7 @@ class StringTable: write( line ) write( "\n" ) write( " }\n" ) - write( "#endif /* DEFINE_PS_TABLES */\n" ) + write( "#endif /* DEFINE_PS_TABLES_DATA */\n" ) write( " ;\n\n\n" ) @@ -5213,7 +5213,7 @@ def dump_encoding( file, encoding_name, encoding_list ): write = file.write write( " /* the following are indices into the SID name table */\n" ) - write( "#ifndef DEFINE_PS_TABLES\n" ) + write( "#ifndef DEFINE_PS_TABLES_DATA\n" ) write( "#ifdef __cplusplus\n" ) write( ' extern "C"\n' ) write( "#else\n" ) @@ -5222,7 +5222,7 @@ def dump_encoding( file, encoding_name, encoding_list ): write( "#endif\n" ) write( " const unsigned short " + encoding_name + "[" + repr( len( encoding_list ) ) + "]\n" ) - write( "#ifdef DEFINE_PS_TABLES\n" ) + write( "#ifdef DEFINE_PS_TABLES_DATA\n" ) write( " =\n" ) write( " {\n" ) @@ -5241,14 +5241,14 @@ def dump_encoding( file, encoding_name, encoding_list ): write( line ) write( "\n" ) write( " }\n" ) - write( "#endif /* DEFINE_PS_TABLES */\n" ) + write( "#endif /* DEFINE_PS_TABLES_DATA */\n" ) write( " ;\n\n\n" ) def dump_array( the_array, write, array_name ): """dumps a given encoding""" - write( "#ifndef DEFINE_PS_TABLES\n" ) + write( "#ifndef DEFINE_PS_TABLES_DATA\n" ) write( "#ifdef __cplusplus\n" ) write( ' extern "C"\n' ) write( "#else\n" ) @@ -5257,7 +5257,7 @@ def dump_array( the_array, write, array_name ): write( "#endif\n" ) write( " const unsigned char " + array_name + "[" + repr( len( the_array ) ) + "L]\n" ) - write( "#ifdef DEFINE_PS_TABLES\n" ) + write( "#ifdef DEFINE_PS_TABLES_DATA\n" ) write( " =\n" ) write( " {\n" ) @@ -5282,7 +5282,7 @@ def dump_array( the_array, write, array_name ): write( line ) write( "\n" ) write( " }\n" ) - write( "#endif /* DEFINE_PS_TABLES */\n" ) + write( "#endif /* DEFINE_PS_TABLES_DATA */\n" ) write( " ;\n\n\n" ) @@ -5293,7 +5293,7 @@ def main(): print __doc__ % sys.argv[0] sys.exit( 1 ) - file = open( sys.argv[1], "w\n" ) + file = open( sys.argv[1], "wb" ) write = file.write count_sid = len( sid_standard_names )