* src/tools/apinames.c: Formatting, minor edits.
This commit is contained in:
parent
47ca5cb69d
commit
983a87c6ec
|
@ -1,3 +1,7 @@
|
||||||
|
2019-06-16 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
|
* src/tools/apinames.c: Formatting, minor edits.
|
||||||
|
|
||||||
2019-06-16 Werner Lemberg <wl@gnu.org>
|
2019-06-16 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
[autofit] Disable hinting if no blue zones are available (#56450).
|
[autofit] Disable hinting if no blue zones are available (#56450).
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
* accepted if you are using GCC for compilation (and probably by
|
* accepted if you are using GCC for compilation (and probably by
|
||||||
* other compilers too).
|
* 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.
|
* This code is explicitly placed into the public domain.
|
||||||
*
|
*
|
||||||
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#define LINEBUFF_SIZE 1024
|
#define LINEBUFF_SIZE 1024
|
||||||
|
|
||||||
|
|
||||||
typedef enum OutputFormat_
|
typedef enum OutputFormat_
|
||||||
{
|
{
|
||||||
OUTPUT_LIST = 0, /* output the list of names, one per line */
|
OUTPUT_LIST = 0, /* output the list of names, one per line */
|
||||||
|
@ -53,10 +54,12 @@ typedef struct NameRec_
|
||||||
|
|
||||||
} NameRec, *Name;
|
} NameRec, *Name;
|
||||||
|
|
||||||
|
|
||||||
static Name the_names;
|
static Name the_names;
|
||||||
static int num_names;
|
static int num_names;
|
||||||
static int max_names;
|
static int max_names;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
names_add( const char* name,
|
names_add( const char* name,
|
||||||
const char* end )
|
const char* end )
|
||||||
|
@ -65,12 +68,14 @@ names_add( const char* name,
|
||||||
int nn, len;
|
int nn, len;
|
||||||
Name nm;
|
Name nm;
|
||||||
|
|
||||||
|
|
||||||
if ( end <= name )
|
if ( end <= name )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* compute hash value */
|
/* compute hash value */
|
||||||
len = (int)( end - name );
|
len = (int)( end - name );
|
||||||
h = 0;
|
h = 0;
|
||||||
|
|
||||||
for ( nn = 0; nn < len; nn++ )
|
for ( nn = 0; nn < len; nn++ )
|
||||||
h = h * 33 + name[nn];
|
h = h * 33 + name[nn];
|
||||||
|
|
||||||
|
@ -116,6 +121,7 @@ name_compare( const void* name1,
|
||||||
return strcmp( n1->name, n2->name );
|
return strcmp( n1->name, n2->name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
names_sort( void )
|
names_sort( void )
|
||||||
{
|
{
|
||||||
|
@ -140,8 +146,10 @@ names_dump( FILE* out,
|
||||||
|
|
||||||
fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
|
fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
|
||||||
fprintf( out, "EXPORTS\n" );
|
fprintf( out, "EXPORTS\n" );
|
||||||
|
|
||||||
for ( nn = 0; nn < num_names; nn++ )
|
for ( nn = 0; nn < num_names; nn++ )
|
||||||
fprintf( out, " %s\n", the_names[nn].name );
|
fprintf( out, " %s\n", the_names[nn].name );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTPUT_BORLAND_DEF:
|
case OUTPUT_BORLAND_DEF:
|
||||||
|
@ -150,8 +158,10 @@ names_dump( FILE* out,
|
||||||
|
|
||||||
fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
|
fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
|
||||||
fprintf( out, "EXPORTS\n" );
|
fprintf( out, "EXPORTS\n" );
|
||||||
|
|
||||||
for ( nn = 0; nn < num_names; nn++ )
|
for ( nn = 0; nn < num_names; nn++ )
|
||||||
fprintf( out, " _%s\n", the_names[nn].name );
|
fprintf( out, " _%s\n", the_names[nn].name );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTPUT_WATCOM_LBC:
|
case OUTPUT_WATCOM_LBC:
|
||||||
|
@ -167,7 +177,7 @@ names_dump( FILE* out,
|
||||||
exit( 4 );
|
exit( 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we must omit the .dll suffix from the library name */
|
/* we must omit the `.dll' suffix from the library name */
|
||||||
dot = strchr( dll_name, '.' );
|
dot = strchr( dll_name, '.' );
|
||||||
if ( dot )
|
if ( dot )
|
||||||
{
|
{
|
||||||
|
@ -184,39 +194,41 @@ names_dump( FILE* out,
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( nn = 0; nn < num_names; nn++ )
|
for ( nn = 0; nn < num_names; nn++ )
|
||||||
fprintf( out, "++_%s.%s.%s\n", the_names[nn].name, dll_name,
|
fprintf( out, "++_%s.%s.%s\n",
|
||||||
the_names[nn].name );
|
the_names[nn].name, dll_name, the_names[nn].name );
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTPUT_NETWARE_IMP:
|
case OUTPUT_NETWARE_IMP:
|
||||||
{
|
|
||||||
if ( dll_name )
|
if ( dll_name )
|
||||||
fprintf( out, " (%s)\n", dll_name );
|
fprintf( out, " (%s)\n", dll_name );
|
||||||
|
|
||||||
for ( nn = 0; nn < num_names - 1; nn++ )
|
for ( nn = 0; nn < num_names - 1; nn++ )
|
||||||
fprintf( out, " %s,\n", the_names[nn].name );
|
fprintf( out, " %s,\n", the_names[nn].name );
|
||||||
fprintf( out, " %s\n", the_names[num_names - 1].name );
|
fprintf( out, " %s\n", the_names[num_names - 1].name );
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OUTPUT_GNU_VERMAP:
|
case OUTPUT_GNU_VERMAP:
|
||||||
{
|
|
||||||
fprintf( out, "{\n\tglobal:\n" );
|
fprintf( out, "{\n\tglobal:\n" );
|
||||||
|
|
||||||
for ( nn = 0; nn < num_names; nn++ )
|
for ( nn = 0; nn < num_names; nn++ )
|
||||||
fprintf( out, "\t\t%s;\n", the_names[nn].name );
|
fprintf( out, "\t\t%s;\n", the_names[nn].name );
|
||||||
|
|
||||||
fprintf( out, "\tlocal:\n\t\t*;\n};\n" );
|
fprintf( out, "\tlocal:\n\t\t*;\n};\n" );
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* LIST */
|
default: /* LIST */
|
||||||
for ( nn = 0; nn < num_names; nn++ )
|
for ( nn = 0; nn < num_names; nn++ )
|
||||||
fprintf( out, "%s\n", the_names[nn].name );
|
fprintf( out, "%s\n", the_names[nn].name );
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* states of the line parser */
|
/* states of the line parser */
|
||||||
|
|
||||||
typedef enum State_
|
typedef enum State_
|
||||||
|
@ -226,31 +238,36 @@ typedef enum State_
|
||||||
|
|
||||||
} State;
|
} State;
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
read_header_file( FILE* file, int verbose )
|
read_header_file( FILE* file,
|
||||||
|
int verbose )
|
||||||
{
|
{
|
||||||
static char buff[LINEBUFF_SIZE + 1];
|
static char buff[LINEBUFF_SIZE + 1];
|
||||||
State state = STATE_START;
|
State state = STATE_START;
|
||||||
|
|
||||||
|
|
||||||
while ( !feof( file ) )
|
while ( !feof( file ) )
|
||||||
{
|
{
|
||||||
char* p;
|
char* p;
|
||||||
|
|
||||||
|
|
||||||
if ( !fgets( buff, LINEBUFF_SIZE, file ) )
|
if ( !fgets( buff, LINEBUFF_SIZE, file ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
p = buff;
|
p = buff;
|
||||||
|
|
||||||
while ( *p && (*p == ' ' || *p == '\\') ) /* skip leading whitespace */
|
/* skip leading whitespace */
|
||||||
|
while ( *p && ( *p == ' ' || *p == '\\' ) )
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
if ( *p == '\n' || *p == '\r' ) /* skip empty lines */
|
/* skip empty lines */
|
||||||
|
if ( *p == '\n' || *p == '\r' )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch ( state )
|
switch ( state )
|
||||||
{
|
{
|
||||||
case STATE_START:
|
case STATE_START:
|
||||||
{
|
|
||||||
if ( memcmp( p, "FT_EXPORT(", 10 ) != 0 )
|
if ( memcmp( p, "FT_EXPORT(", 10 ) != 0 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -271,22 +288,23 @@ read_header_file( FILE* file, int verbose )
|
||||||
|
|
||||||
state = STATE_TYPE;
|
state = STATE_TYPE;
|
||||||
|
|
||||||
/* sometimes, the name is just after the FT_EXPORT(...), so
|
/*
|
||||||
* skip whitespace, and fall-through if we find an alphanumeric
|
* Sometimes, the name is just after `FT_EXPORT(...)', so skip
|
||||||
* character
|
* whitespace and fall-through if we find an alphanumeric character.
|
||||||
*/
|
*/
|
||||||
while ( *p == ' ' || *p == '\t' )
|
while ( *p == ' ' || *p == '\t' )
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
if ( !isalpha( *p ) )
|
if ( !isalpha( *p ) )
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
|
|
||||||
case STATE_TYPE:
|
case STATE_TYPE:
|
||||||
{
|
{
|
||||||
char* name = p;
|
char* name = p;
|
||||||
|
|
||||||
|
|
||||||
while ( isalnum( *p ) || *p == '_' )
|
while ( isalnum( *p ) || *p == '_' )
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
|
@ -300,6 +318,7 @@ read_header_file( FILE* file, int verbose )
|
||||||
|
|
||||||
state = STATE_START;
|
state = STATE_START;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -308,7 +327,7 @@ read_header_file( FILE* file, int verbose )
|
||||||
|
|
||||||
NextLine:
|
NextLine:
|
||||||
;
|
;
|
||||||
}
|
} /* end of while loop */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -318,35 +337,38 @@ static void
|
||||||
usage( void )
|
usage( void )
|
||||||
{
|
{
|
||||||
static const char* const format =
|
static const char* const format =
|
||||||
"%s %s: extract FreeType API names from header files\n\n"
|
"%s %s: extract FreeType API names from header files\n"
|
||||||
"this program is used to extract the list of public FreeType API\n"
|
"\n"
|
||||||
"functions. It receives the list of header files as argument and\n"
|
"This program extracts the list of public FreeType API functions.\n"
|
||||||
"generates a sorted list of unique identifiers\n\n"
|
"It receives a list of header files as an argument and\n"
|
||||||
|
"generates a sorted list of unique identifiers in various formats.\n"
|
||||||
"usage: %s header1 [options] [header2 ...]\n\n"
|
"\n"
|
||||||
|
"usage: %s header1 [options] [header2 ...]\n"
|
||||||
"options: - : parse the content of stdin, ignore arguments\n"
|
"\n"
|
||||||
" -v : verbose mode, output sent to standard error\n"
|
"options: - parse the contents of stdin, ignore arguments\n"
|
||||||
" -oFILE : write output to FILE instead of standard output\n"
|
" -v verbose mode, output sent to standard error\n"
|
||||||
" -dNAME : indicate DLL file name, 'freetype.dll' by default\n"
|
" -oFILE write output to FILE instead of standard output\n"
|
||||||
" -w : output .DEF file for Visual C++ and Mingw\n"
|
" -dNAME indicate DLL file name, 'freetype.dll' by default\n"
|
||||||
" -wB : output .DEF file for Borland C++\n"
|
" -w output .DEF file for Visual C++ and Mingw\n"
|
||||||
" -wW : output Watcom Linker Response File\n"
|
" -wB output .DEF file for Borland C++\n"
|
||||||
" -wN : output NetWare Import File\n"
|
" -wW output Watcom Linker Response File\n"
|
||||||
" -wL : output version map for GNU or Solaris linker\n"
|
" -wN output NetWare Import File\n"
|
||||||
|
" -wL output version map for GNU or Solaris linker\n"
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
fprintf( stderr,
|
fprintf( stderr,
|
||||||
format,
|
format,
|
||||||
PROGRAM_NAME,
|
PROGRAM_NAME,
|
||||||
PROGRAM_VERSION,
|
PROGRAM_VERSION,
|
||||||
PROGRAM_NAME
|
PROGRAM_NAME );
|
||||||
);
|
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, const char* const* argv )
|
int
|
||||||
|
main( int argc,
|
||||||
|
const char* const* argv )
|
||||||
{
|
{
|
||||||
int from_stdin = 0;
|
int from_stdin = 0;
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
|
@ -354,18 +376,21 @@ int main( int argc, const char* const* argv )
|
||||||
FILE* out = stdout;
|
FILE* out = stdout;
|
||||||
const char* library_name = NULL;
|
const char* library_name = NULL;
|
||||||
|
|
||||||
|
|
||||||
if ( argc < 2 )
|
if ( argc < 2 )
|
||||||
usage();
|
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] == '-' )
|
while ( argc > 1 && argv[1][0] == '-' )
|
||||||
{
|
{
|
||||||
const char* arg = argv[1];
|
const char* arg = argv[1];
|
||||||
|
|
||||||
|
|
||||||
switch ( arg[1] )
|
switch ( arg[1] )
|
||||||
{
|
{
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
|
@ -387,6 +412,7 @@ int main( int argc, const char* const* argv )
|
||||||
fprintf( stderr, "could not open '%s' for writing\n", arg );
|
fprintf( stderr, "could not open '%s' for writing\n", arg );
|
||||||
exit( 3 );
|
exit( 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
|
@ -403,10 +429,12 @@ int main( int argc, const char* const* argv )
|
||||||
arg += 2;
|
arg += 2;
|
||||||
|
|
||||||
library_name = arg;
|
library_name = arg;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
format = OUTPUT_WINDOWS_DEF;
|
format = OUTPUT_WINDOWS_DEF;
|
||||||
|
|
||||||
switch ( arg[2] )
|
switch ( arg[2] )
|
||||||
{
|
{
|
||||||
case 'B':
|
case 'B':
|
||||||
|
@ -431,10 +459,12 @@ int main( int argc, const char* const* argv )
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
from_stdin = 1;
|
from_stdin = 1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -443,18 +473,18 @@ int main( int argc, const char* const* argv )
|
||||||
|
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
}
|
|
||||||
|
} /* end of while loop */
|
||||||
|
|
||||||
if ( from_stdin )
|
if ( from_stdin )
|
||||||
{
|
|
||||||
read_header_file( stdin, verbose );
|
read_header_file( stdin, verbose );
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for ( --argc, argv++; argc > 0; argc--, argv++ )
|
for ( --argc, argv++; argc > 0; argc--, argv++ )
|
||||||
{
|
{
|
||||||
FILE* file = fopen( argv[0], "rb" );
|
FILE* file = fopen( argv[0], "rb" );
|
||||||
|
|
||||||
|
|
||||||
if ( !file )
|
if ( !file )
|
||||||
fprintf( stderr, "unable to open '%s'\n", argv[0] );
|
fprintf( stderr, "unable to open '%s'\n", argv[0] );
|
||||||
else
|
else
|
||||||
|
@ -469,7 +499,7 @@ int main( int argc, const char* const* argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( num_names == 0 )
|
if ( num_names == 0 )
|
||||||
panic( "could not find exported functions !!\n" );
|
panic( "could not find exported functions\n" );
|
||||||
|
|
||||||
names_sort();
|
names_sort();
|
||||||
names_dump( out, format, library_name );
|
names_dump( out, format, library_name );
|
||||||
|
@ -479,3 +509,6 @@ int main( int argc, const char* const* argv )
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* END */
|
||||||
|
|
Loading…
Reference in New Issue