summaryrefslogtreecommitdiff
path: root/freetype/src/tools/apinames.c
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2019-11-26 14:39:02 +0000
committerChris Liddell <chris.liddell@artifex.com>2019-11-26 17:51:31 +0000
commit79ac3f84060fbd5447219264ab0bcf89c7caa2cf (patch)
treeeb80c656c8302f91fc140e4a23db608ef207ba0d /freetype/src/tools/apinames.c
parent36cbd382b160ee4951d1911f85a4fa0723dd8db3 (diff)
downloadghostpdl-79ac3f84060fbd5447219264ab0bcf89c7caa2cf.tar.gz
Update Freetype to 2.4.10
Plus makefile updates to support it Bug 701288: Handle SEAC ligature glyph metrics correctly. As originally intended, a Type 1 SEAC charstring would be used for an accented glyph (like an a-caron, or u-umlaut) where the advance with of the SEAC glyph is the same as that of the 'base' glyph ('a' or 'u'). It this case, it is not uncommon for the SEAC to skip using an (H)SBW op code and rely on the one from the base glyph. But out of spec fonts also use SEAC glyphs ligature glyphs (like 'oe' or 'fi'), and in those cases the overall advance width is greater than that of the 'base' glyph. In this case, we have to allow for the SEAC glyph having included an (H)SBW and if it has, retain those values, rather than those from the base glyph. Rename file and make file change to match Avoids file name clash with freetype 2.4.10 Work around a change in the zlib API for 1.2.11 where it's used in the Freetype/zlib interface debugging code.
Diffstat (limited to 'freetype/src/tools/apinames.c')
-rw-r--r--freetype/src/tools/apinames.c441
1 files changed, 237 insertions, 204 deletions
diff --git a/freetype/src/tools/apinames.c b/freetype/src/tools/apinames.c
index 06c326043..aeecf88d2 100644
--- a/freetype/src/tools/apinames.c
+++ b/freetype/src/tools/apinames.c
@@ -10,7 +10,7 @@
* accepted if you are using GCC for compilation (and probably by
* other compilers too).
*
- * Author: David Turner, 2005, 2006, 2008-2013, 2015
+ * Author: FreeType team, 2005-2019
*
* This code is explicitly placed into the public domain.
*
@@ -26,6 +26,7 @@
#define LINEBUFF_SIZE 1024
+
typedef enum OutputFormat_
{
OUTPUT_LIST = 0, /* output the list of names, one per line */
@@ -53,10 +54,12 @@ typedef struct NameRec_
} NameRec, *Name;
+
static Name the_names;
static int num_names;
static int max_names;
+
static void
names_add( const char* name,
const char* end )
@@ -65,14 +68,16 @@ names_add( const char* name,
int nn, len;
Name nm;
+
if ( end <= name )
return;
/* compute hash value */
- len = (int)(end - name);
+ len = (int)( end - name );
h = 0;
+
for ( nn = 0; nn < len; nn++ )
- h = h*33 + name[nn];
+ h = h * 33 + name[nn];
/* check for an pre-existing name */
for ( nn = 0; nn < num_names; nn++ )
@@ -88,7 +93,7 @@ names_add( const char* name,
/* add new name */
if ( num_names >= max_names )
{
- max_names += (max_names >> 1) + 4;
+ max_names += ( max_names >> 1 ) + 4;
the_names = (NameRec*)realloc( the_names,
sizeof ( the_names[0] ) * max_names );
if ( !the_names )
@@ -97,7 +102,7 @@ names_add( const char* name,
nm = &the_names[num_names++];
nm->hash = h;
- nm->name = (char*)malloc( len+1 );
+ nm->name = (char*)malloc( len + 1 );
if ( !nm->name )
panic( "not enough memory" );
@@ -116,6 +121,7 @@ name_compare( const void* name1,
return strcmp( n1->name, n2->name );
}
+
static void
names_sort( void )
{
@@ -134,87 +140,93 @@ names_dump( FILE* out,
switch ( format )
{
- case OUTPUT_WINDOWS_DEF:
- if ( dll_name )
- fprintf( out, "LIBRARY %s\n", dll_name );
-
- fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
- fprintf( out, "EXPORTS\n" );
- for ( nn = 0; nn < num_names; nn++ )
- fprintf( out, " %s\n", the_names[nn].name );
- break;
+ case OUTPUT_WINDOWS_DEF:
+ if ( dll_name )
+ fprintf( out, "LIBRARY %s\n", dll_name );
- case OUTPUT_BORLAND_DEF:
- if ( dll_name )
- fprintf( out, "LIBRARY %s\n", dll_name );
-
- fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
- fprintf( out, "EXPORTS\n" );
- for ( nn = 0; nn < num_names; nn++ )
- fprintf( out, " _%s\n", the_names[nn].name );
- break;
-
- case OUTPUT_WATCOM_LBC:
- {
- const char* dot;
- char temp[512];
+ fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
+ fprintf( out, "EXPORTS\n" );
+ for ( nn = 0; nn < num_names; nn++ )
+ fprintf( out, " %s\n", the_names[nn].name );
- if ( !dll_name )
- {
- fprintf( stderr,
- "you must provide a DLL name with the -d option!\n" );
- exit( 4 );
- }
+ break;
- /* we must omit the .dll suffix from the library name */
- dot = strchr( dll_name, '.' );
- if ( dot )
- {
- int len = dot - dll_name;
+ case OUTPUT_BORLAND_DEF:
+ if ( dll_name )
+ fprintf( out, "LIBRARY %s\n", dll_name );
+ fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
+ fprintf( out, "EXPORTS\n" );
- if ( len > (int)( sizeof ( temp ) - 1 ) )
- len = sizeof ( temp ) - 1;
+ for ( nn = 0; nn < num_names; nn++ )
+ fprintf( out, " _%s\n", the_names[nn].name );
- memcpy( temp, dll_name, len );
- temp[len] = 0;
+ break;
- dll_name = (const char*)temp;
- }
+ case OUTPUT_WATCOM_LBC:
+ {
+ const char* dot;
+ char temp[512];
- for ( nn = 0; nn < num_names; nn++ )
- fprintf( out, "++_%s.%s.%s\n", the_names[nn].name, dll_name,
- the_names[nn].name );
- }
- break;
- case OUTPUT_NETWARE_IMP:
+ if ( !dll_name )
{
- if ( dll_name )
- fprintf( out, " (%s)\n", dll_name );
- for ( nn = 0; nn < num_names - 1; nn++ )
- fprintf( out, " %s,\n", the_names[nn].name );
- fprintf( out, " %s\n", the_names[num_names - 1].name );
+ fprintf( stderr,
+ "you must provide a DLL name with the -d option!\n" );
+ exit( 4 );
}
- break;
- case OUTPUT_GNU_VERMAP:
+ /* we must omit the `.dll' suffix from the library name */
+ dot = strchr( dll_name, '.' );
+ if ( dot )
{
- fprintf( out, "{\n\tglobal:\n" );
- for ( nn = 0; nn < num_names; nn++ )
- fprintf( out, "\t\t%s;\n", the_names[nn].name );
- fprintf( out, "\tlocal:\n\t\t*;\n};\n" );
+ int len = dot - dll_name;
+
+
+ if ( len > (int)( sizeof ( temp ) - 1 ) )
+ len = sizeof ( temp ) - 1;
+
+ memcpy( temp, dll_name, len );
+ temp[len] = 0;
+
+ dll_name = (const char*)temp;
}
- break;
- default: /* LIST */
for ( nn = 0; nn < num_names; nn++ )
- fprintf( out, "%s\n", the_names[nn].name );
- }
-}
+ fprintf( out, "++_%s.%s.%s\n",
+ the_names[nn].name, dll_name, the_names[nn].name );
+ }
+
+ break;
+
+ case OUTPUT_NETWARE_IMP:
+ if ( dll_name )
+ fprintf( out, " (%s)\n", dll_name );
+
+ for ( nn = 0; nn < num_names - 1; nn++ )
+ fprintf( out, " %s,\n", the_names[nn].name );
+ fprintf( out, " %s\n", the_names[num_names - 1].name );
+
+ break;
+
+ case OUTPUT_GNU_VERMAP:
+ fprintf( out, "{\n\tglobal:\n" );
+ for ( nn = 0; nn < num_names; nn++ )
+ fprintf( out, "\t\t%s;\n", the_names[nn].name );
+ fprintf( out, "\tlocal:\n\t\t*;\n};\n" );
+
+ break;
+
+ default: /* LIST */
+ for ( nn = 0; nn < num_names; nn++ )
+ fprintf( out, "%s\n", the_names[nn].name );
+
+ break;
+ }
+}
/* states of the line parser */
@@ -226,89 +238,96 @@ typedef enum State_
} State;
+
static int
-read_header_file( FILE* file, int verbose )
+read_header_file( FILE* file,
+ int verbose )
{
static char buff[LINEBUFF_SIZE + 1];
State state = STATE_START;
+
while ( !feof( file ) )
{
char* p;
+
if ( !fgets( buff, LINEBUFF_SIZE, file ) )
break;
p = buff;
- while ( *p && (*p == ' ' || *p == '\\') ) /* skip leading whitespace */
+ /* skip leading whitespace */
+ while ( *p && ( *p == ' ' || *p == '\\' ) )
p++;
- if ( *p == '\n' || *p == '\r' ) /* skip empty lines */
+ /* skip empty lines */
+ if ( *p == '\n' || *p == '\r' )
continue;
switch ( state )
{
- case STATE_START:
+ case STATE_START:
+ if ( memcmp( p, "FT_EXPORT(", 10 ) != 0 )
+ break;
+
+ p += 10;
+ for (;;)
+ {
+ if ( *p == 0 || *p == '\n' || *p == '\r' )
+ goto NextLine;
+
+ if ( *p == ')' )
{
- if ( memcmp( p, "FT_EXPORT(", 10 ) != 0 )
- break;
-
- p += 10;
- for (;;)
- {
- if ( *p == 0 || *p == '\n' || *p == '\r' )
- goto NextLine;
-
- if ( *p == ')' )
- {
- p++;
- break;
- }
-
- p++;
- }
-
- state = STATE_TYPE;
-
- /* sometimes, the name is just after the FT_EXPORT(...), so
- * skip whitespace, and fall-through if we find an alphanumeric
- * character
- */
- while ( *p == ' ' || *p == '\t' )
- p++;
-
- if ( !isalpha(*p) )
- break;
+ p++;
+ break;
}
- /* fall-through */
- case STATE_TYPE:
- {
- char* name = p;
+ p++;
+ }
- while ( isalnum(*p) || *p == '_' )
- p++;
+ state = STATE_TYPE;
+
+ /*
+ * Sometimes, the name is just after `FT_EXPORT(...)', so skip
+ * whitespace and fall-through if we find an alphanumeric character.
+ */
+ while ( *p == ' ' || *p == '\t' )
+ p++;
+
+ if ( !isalpha( *p ) )
+ break;
+
+ /* fall-through */
+
+ case STATE_TYPE:
+ {
+ char* name = p;
- if ( p > name )
- {
- if ( verbose )
- fprintf( stderr, ">>> %.*s\n", (int)(p - name), name );
- names_add( name, p );
- }
+ while ( isalnum( *p ) || *p == '_' )
+ p++;
- state = STATE_START;
+ if ( p > name )
+ {
+ if ( verbose )
+ fprintf( stderr, ">>> %.*s\n", (int)( p - name ), name );
+
+ names_add( name, p );
}
- break;
- default:
- ;
+ state = STATE_START;
+ }
+
+ break;
+
+ default:
+ ;
}
- NextLine:
+NextLine:
;
- }
+ } /* end of while loop */
return 0;
}
@@ -318,143 +337,154 @@ static void
usage( void )
{
static const char* const format =
- "%s %s: extract FreeType API names from header files\n\n"
- "this program is used to extract the list of public FreeType API\n"
- "functions. It receives the list of header files as argument and\n"
- "generates a sorted list of unique identifiers\n\n"
-
- "usage: %s header1 [options] [header2 ...]\n\n"
-
- "options: - : parse the content of stdin, ignore arguments\n"
- " -v : verbose mode, output sent to standard error\n"
- " -oFILE : write output to FILE instead of standard output\n"
- " -dNAME : indicate DLL file name, 'freetype.dll' by default\n"
- " -w : output .DEF file for Visual C++ and Mingw\n"
- " -wB : output .DEF file for Borland C++\n"
- " -wW : output Watcom Linker Response File\n"
- " -wN : output NetWare Import File\n"
- " -wL : output version map for GNU or Solaris linker\n"
- "\n";
+ "%s %s: extract FreeType API names from header files\n"
+ "\n"
+ "This program extracts the list of public FreeType API functions.\n"
+ "It receives a list of header files as an argument and\n"
+ "generates a sorted list of unique identifiers in various formats.\n"
+ "\n"
+ "usage: %s header1 [options] [header2 ...]\n"
+ "\n"
+ "options: - parse the contents of stdin, ignore arguments\n"
+ " -v verbose mode, output sent to standard error\n"
+ " -oFILE write output to FILE instead of standard output\n"
+ " -dNAME indicate DLL file name, 'freetype.dll' by default\n"
+ " -w output .DEF file for Visual C++ and Mingw\n"
+ " -wB output .DEF file for Borland C++\n"
+ " -wW output Watcom Linker Response File\n"
+ " -wN output NetWare Import File\n"
+ " -wL output version map for GNU or Solaris linker\n"
+ "\n";
fprintf( stderr,
format,
PROGRAM_NAME,
PROGRAM_VERSION,
- PROGRAM_NAME
- );
- exit(1);
+ PROGRAM_NAME );
+
+ exit( 1 );
}
-int main( int argc, const char* const* argv )
+int
+main( int argc,
+ const char* const* argv )
{
- int from_stdin = 0;
- int verbose = 0;
- OutputFormat format = OUTPUT_LIST; /* the default */
- FILE* out = stdout;
+ int from_stdin = 0;
+ int verbose = 0;
+ OutputFormat format = OUTPUT_LIST; /* the default */
+ FILE* out = stdout;
const char* library_name = NULL;
+
if ( argc < 2 )
usage();
- /* '-' used as a single argument means read source file from stdin */
+ /* `-' used as a single argument means read source file from stdin */
while ( argc > 1 && argv[1][0] == '-' )
{
const char* arg = argv[1];
+
switch ( arg[1] )
{
- case 'v':
- verbose = 1;
- break;
+ case 'v':
+ verbose = 1;
- case 'o':
- if ( arg[2] == 0 )
- {
- if ( argc < 2 )
- usage();
+ break;
- arg = argv[2];
- argv++;
- argc--;
- }
- else
- arg += 2;
+ case 'o':
+ if ( arg[2] == 0 )
+ {
+ if ( argc < 2 )
+ usage();
- out = fopen( arg, "wt" );
- if ( !out )
- {
- fprintf( stderr, "could not open '%s' for writing\n", argv[2] );
- exit(3);
- }
- break;
+ arg = argv[2];
+ argv++;
+ argc--;
+ }
+ else
+ arg += 2;
- case 'd':
- if ( arg[2] == 0 )
- {
- if ( argc < 2 )
- usage();
+ out = fopen( arg, "wt" );
+ if ( !out )
+ {
+ fprintf( stderr, "could not open '%s' for writing\n", arg );
+ exit( 3 );
+ }
- arg = argv[2];
- argv++;
- argc--;
- }
- else
- arg += 2;
+ break;
- library_name = arg;
- break;
+ case 'd':
+ if ( arg[2] == 0 )
+ {
+ if ( argc < 2 )
+ usage();
- case 'w':
- format = OUTPUT_WINDOWS_DEF;
- switch ( arg[2] )
- {
- case 'B':
- format = OUTPUT_BORLAND_DEF;
- break;
+ arg = argv[2];
+ argv++;
+ argc--;
+ }
+ else
+ arg += 2;
+
+ library_name = arg;
+
+ break;
- case 'W':
- format = OUTPUT_WATCOM_LBC;
- break;
+ case 'w':
+ format = OUTPUT_WINDOWS_DEF;
- case 'N':
- format = OUTPUT_NETWARE_IMP;
- break;
+ switch ( arg[2] )
+ {
+ case 'B':
+ format = OUTPUT_BORLAND_DEF;
+ break;
- case 'L':
- format = OUTPUT_GNU_VERMAP;
- break;
+ case 'W':
+ format = OUTPUT_WATCOM_LBC;
+ break;
- case 0:
- break;
+ case 'N':
+ format = OUTPUT_NETWARE_IMP;
+ break;
- default:
- usage();
- }
+ case 'L':
+ format = OUTPUT_GNU_VERMAP;
break;
case 0:
- from_stdin = 1;
break;
default:
usage();
+ }
+
+ break;
+
+ case 0:
+ from_stdin = 1;
+
+ break;
+
+ default:
+ usage();
}
argc--;
argv++;
- }
+
+ } /* end of while loop */
if ( from_stdin )
- {
read_header_file( stdin, verbose );
- }
else
{
for ( --argc, argv++; argc > 0; argc--, argv++ )
{
FILE* file = fopen( argv[0], "rb" );
+
if ( !file )
fprintf( stderr, "unable to open '%s'\n", argv[0] );
else
@@ -469,7 +499,7 @@ int main( int argc, const char* const* argv )
}
if ( num_names == 0 )
- panic( "could not find exported functions !!\n" );
+ panic( "could not find exported functions\n" );
names_sort();
names_dump( out, format, library_name );
@@ -479,3 +509,6 @@ int main( int argc, const char* const* argv )
return 0;
}
+
+
+/* END */