* include/freetype/internal/ftdebug.h, src/base/ftdebug.c: modified
the debug sub-system initialization. trace levels can now be specified
within the "FT2_DEBUG" environment variable. See the comments within
"ftdebug.c" for more details
* include/freetype/internal/fttrace.h: new file to define the trace
levels used for debugging. it is used both to define enums and
toggle names for FT2_DEBUG
* src/base/ftobjs.c, src/base/ftstream.c: FT_Assert renamed to
FT_ASSERT
* include/freetype/internal/ftextend.h, src/base/ftextend.c,
src/base/Jamfile, src/base/rules.mk: removing "ftextend" from the
library, since it is now completely obsolete..
diff --git a/src/base/Jamfile b/src/base/Jamfile
index a310914..5c2f5a6 100644
--- a/src/base/Jamfile
+++ b/src/base/Jamfile
@@ -10,7 +10,7 @@
if $(FT2_MULTI)
{
- _sources = ftcalc ftextend ftlist ftobjs ftstream ftoutln ftnames fttrigon
+ _sources = ftcalc ftlist ftobjs ftstream ftoutln ftnames fttrigon
ftdbgmem ;
}
else
diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c
index 6a3fc49..ea4033a 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -45,12 +45,7 @@
#include FT_INTERNAL_DEBUG_H
-#ifdef FT_DEBUG_LEVEL_TRACE
- char ft_trace_levels[trace_max];
-#endif
-
-
-#if defined( FT_DEBUG_LEVEL_ERROR ) || defined( FT_DEBUG_LEVEL_TRACE )
+#if defined( FT_DEBUG_LEVEL_ERROR )
#include <stdarg.h>
@@ -83,36 +78,123 @@
exit( EXIT_FAILURE );
}
+#endif /* FT_DEBUG_LEVEL_ERROR */
+
+
#ifdef FT_DEBUG_LEVEL_TRACE
- FT_EXPORT_DEF( void )
- FT_SetTraceLevel( FT_Trace component,
- char level )
+ /* array of trace levels, initialized to 0 */
+ int ft_trace_levels[ trace_count ];
+
+ /* define array of trace toggle names */
+#define FT_TRACE_DEF(x) #x ,
+
+ static const char* ft_trace_toggles[ trace_count+1 ] =
+ {
+#include FT_INTERNAL_TRACE_H
+ NULL
+ };
+
+#undef FT_TRACE_DEF
+
+
+
+ /************************************************************************
+ *
+ * initialize the tracing sub-system, this is done by retrieving the
+ * value of the "FT2_DEBUG" environment variable. It must be a list of
+ * toggles, separated by spaces, ';' or ':' for example:
+ *
+ * "any=3 memory=6 stream=5"
+ *
+ * will request that all levels be set to 3, except the trace level for
+ * the memory and stream components which are respectively set to 6 and 5
+ *
+ * see the file <freetype/internal/fttrace.h> for details of the available
+ * toggle names.
+ *
+ * the level is between 0 and 6, where 0 is quiet (except in important
+ * runtime errors), and 6 is _very_ verbose
+ */
+
+ FT_BASE_DEF( void )
+ ft_debug_init( void )
{
- if ( component >= trace_max )
- return;
-
- /* if component is `trace_any', change _all_ levels at once */
- if ( component == trace_any )
+ const char* ft2_debug = getenv( "FT2_DEBUG" );
+
+ if ( ft2_debug )
{
- int n;
-
-
- for ( n = trace_any; n < trace_max; n++ )
- ft_trace_levels[n] = level;
+ const char* p = ft2_debug;
+ const char* q;
+
+ for ( ; *p; p++ )
+ {
+ /* skip leading whitespace and separators */
+ if ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' || *p == '=' )
+ continue;
+
+ /* read toggle name, followed by '=' */
+ q = p;
+ while ( *p && *p != '=' )
+ p++;
+
+ if ( *p == '=' && p > q )
+ {
+ int n, i, len = p - q;
+ int level = -1, found = -1;
+
+ for ( n = 0; n < trace_count; n++ )
+ {
+ const char* toggle = ft_trace_toggles[n];
+
+ for ( i = 0; i < len; i++ )
+ {
+ if ( toggle[i] != q[i] )
+ break;
+ }
+
+ if ( i == len && toggle[i] == 0 )
+ {
+ found = n;
+ break;
+ }
+ }
+
+ /* read level */
+ p++;
+ if ( *p )
+ {
+ level = *p++ - '0';
+ if ( level < 0 || level > 6 )
+ level = -1;
+ }
+
+ if ( found >= 0 && level >= 0 )
+ {
+ if ( found == trace_any )
+ {
+ /* special case for "any" */
+ for ( n = 0; n < trace_count; n++ )
+ ft_trace_levels[n] = level;
+ }
+ else
+ ft_trace_levels[ found ] = level;
+ }
+ }
+ }
}
- else /* otherwise, only change individual component */
- ft_trace_levels[component] = level;
}
-#endif /* FT_DEBUG_LEVEL_TRACE */
+#else /* !FT_DEBUG_LEVEL_TRACE */
-#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
+ FT_BASE_DEF( void )
+ ft_debut_init( void )
+ {
+ /* nothing */
+ }
-
- /* ANSI C doesn't allow empty files, so we insert a dummy symbol */
- extern const int ft_debug_dummy;
+#endif /* !FT_DEBUG_LEVEL_TRACE */
/* END */
diff --git a/src/base/ftextend.c b/src/base/ftextend.c
deleted file mode 100644
index cafb284..0000000
--- a/src/base/ftextend.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/***************************************************************************/
-/* */
-/* ftextend.c */
-/* */
-/* FreeType extensions implementation (body). */
-/* */
-/* Copyright 1996-2001 by */
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */
-/* */
-/* This file is part of the FreeType project, and may only be used, */
-/* modified, and distributed under the terms of the FreeType project */
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
-/* this file you indicate that you have read the license and */
-/* understand and accept it fully. */
-/* */
-/***************************************************************************/
-
- /*************************************************************************/
- /* */
- /* This is an updated version of the extension component, now located */
- /* in the main library's source directory. It allows the dynamic */
- /* registration/use of various face object extensions through a simple */
- /* API. */
- /* */
- /*************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_EXTEND_H
-#include FT_INTERNAL_DEBUG_H
-
-
- /*************************************************************************/
- /* */
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
- /* messages during execution. */
- /* */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_extend
-
-
- typedef struct FT_Extension_Registry_
- {
- FT_Int num_extensions;
- FT_Long cur_offset;
- FT_Extension_Class classes[FT_MAX_EXTENSIONS];
-
- } FT_Extension_Registry;
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Init_Extensions */
- /* */
- /* <Description> */
- /* Initializes the extension component. */
- /* */
- /* <InOut> */
- /* driver :: A handle to the driver object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- FT_LOCAL_DEF FT_Error
- FT_Init_Extensions( FT_Driver driver )
- {
- FT_Error error;
- FT_Memory memory;
- FT_Extension_Registry* registry;
-
-
- memory = driver->root.library->memory;
- if ( ALLOC( registry, sizeof ( *registry ) ) )
- return error;
-
- registry->num_extensions = 0;
- registry->cur_offset = 0;
- driver->extensions = registry;
-
- FT_TRACE2(( "FT_Init_Extensions: success\n" ));
-
- return FT_Err_Ok;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Done_Extensions */
- /* */
- /* <Description> */
- /* Finalizes the extension component. */
- /* */
- /* <InOut> */
- /* driver :: A handle to the driver object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- FT_LOCAL_DEF FT_Error
- FT_Done_Extensions( FT_Driver driver )
- {
- FT_Memory memory = driver->root.memory;
-
-
- FREE( driver->extensions );
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftextend.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Register_Extension( FT_Driver driver,
- FT_Extension_Class* clazz )
- {
- FT_Extension_Registry* registry;
-
-
- if ( !driver )
- return FT_Err_Invalid_Driver_Handle;
-
- if ( !clazz )
- return FT_Err_Invalid_Argument;
-
- registry = (FT_Extension_Registry*)driver->extensions;
- if ( registry )
- {
- FT_Int n = registry->num_extensions;
- FT_Extension_Class* cur = registry->classes + n;
-
-
- if ( n >= FT_MAX_EXTENSIONS )
- return FT_Err_Too_Many_Extensions;
-
- *cur = *clazz;
-
- cur->offset = registry->cur_offset;
-
- registry->num_extensions++;
- registry->cur_offset +=
- ( cur->size + FT_ALIGNMENT - 1 ) & -FT_ALIGNMENT;
-
- FT_TRACE1(( "FT_Register_Extension: `%s' successfully registered\n",
- cur->id ));
- }
-
- return FT_Err_Ok;
- }
-
-
- /* documentation is in ftextend.h */
-
- FT_EXPORT_DEF( void* )
- FT_Get_Extension( FT_Face face,
- const char* extension_id,
- void** extension_interface )
- {
- FT_Extension_Registry* registry;
-
-
- if ( !face || !extension_id || !extension_interface )
- return 0;
-
- registry = (FT_Extension_Registry*)face->driver->extensions;
- if ( registry && face->extensions )
- {
- FT_Extension_Class* cur = registry->classes;
- FT_Extension_Class* limit = cur + registry->num_extensions;
-
-
- for ( ; cur < limit; cur++ )
- if ( strcmp( cur->id, extension_id ) == 0 )
- {
- *extension_interface = cur->interface;
-
- FT_TRACE1(( "FT_Get_Extension: got `%s'\n", extension_id ));
-
- return (void*)((char*)face->extensions + cur->offset);
- }
- }
-
- /* could not find the extension id */
-
- FT_ERROR(( "FT_Get_Extension: couldn't find `%s'\n", extension_id ));
-
- *extension_interface = 0;
-
- return 0;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Destroy_Extensions */
- /* */
- /* <Description> */
- /* Destroys all extensions within a face object. */
- /* */
- /* <InOut> */
- /* face :: A handle to the face object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Called by the face object destructor. */
- /* */
- FT_LOCAL_DEF FT_Error
- FT_Destroy_Extensions( FT_Face face )
- {
- FT_Extension_Registry* registry;
- FT_Memory memory;
-
-
- registry = (FT_Extension_Registry*)face->driver->extensions;
- if ( registry && face->extensions )
- {
- FT_Extension_Class* cur = registry->classes;
- FT_Extension_Class* limit = cur + registry->num_extensions;
-
-
- for ( ; cur < limit; cur++ )
- {
- char* ext = (char*)face->extensions + cur->offset;
-
- if ( cur->finalize )
- cur->finalize( ext, face );
- }
-
- memory = face->driver->root.memory;
- FREE( face->extensions );
- }
-
- return FT_Err_Ok;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Create_Extensions */
- /* */
- /* <Description> */
- /* Creates an extension object within a face object for all */
- /* registered extensions. */
- /* */
- /* <InOut> */
- /* face :: A handle to the face object. */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* Called by the face object constructor. */
- /* */
- FT_LOCAL_DEF FT_Error
- FT_Create_Extensions( FT_Face face )
- {
- FT_Extension_Registry* registry;
- FT_Memory memory;
- FT_Error error;
-
-
- face->extensions = 0;
-
- /* load extensions registry; exit successfully if none is there */
-
- registry = (FT_Extension_Registry*)face->driver->extensions;
- if ( !registry )
- return FT_Err_Ok;
-
- memory = face->driver->root.memory;
- if ( ALLOC( face->extensions, registry->cur_offset ) )
- return error;
-
- {
- FT_Extension_Class* cur = registry->classes;
- FT_Extension_Class* limit = cur + registry->num_extensions;
-
-
- for ( ; cur < limit; cur++ )
- {
- char* ext = (char*)face->extensions + cur->offset;
-
- if ( cur->init )
- {
- error = cur->init( ext, face );
- if ( error )
- break;
- }
- }
- }
-
- return error;
- }
-
-
-/* END */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 21a6be0..1b78c9d 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -57,7 +57,7 @@
FT_Long size,
void* *P )
{
- FT_Assert( P != 0 );
+ FT_ASSERT( P != 0 );
if ( size > 0 )
{
@@ -94,7 +94,7 @@
void* Q;
- FT_Assert( P != 0 );
+ FT_ASSERT( P != 0 );
/* if the original pointer is NULL, call FT_Alloc() */
if ( !*P )
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index 96683a2..3fc40f9 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -201,7 +201,7 @@
/* check for nested frame access */
- FT_Assert( stream && stream->cursor == 0 );
+ FT_ASSERT( stream && stream->cursor == 0 );
if ( stream->read )
{
@@ -265,7 +265,7 @@
/* gracefully; however, stream.cursor is really set to 0 by the */
/* FT_Access_Frame() call, and this is not an error. */
/* */
- FT_Assert( stream );
+ FT_ASSERT( stream );
if ( stream->read )
{
@@ -285,7 +285,7 @@
FT_Char result;
- FT_Assert( stream && stream->cursor );
+ FT_ASSERT( stream && stream->cursor );
result = 0;
if ( stream->cursor < stream->limit )
@@ -302,7 +302,7 @@
FT_Short result;
- FT_Assert( stream && stream->cursor );
+ FT_ASSERT( stream && stream->cursor );
result = 0;
p = stream->cursor;
@@ -321,7 +321,7 @@
FT_Short result;
- FT_Assert( stream && stream->cursor );
+ FT_ASSERT( stream && stream->cursor );
result = 0;
p = stream->cursor;
@@ -340,7 +340,7 @@
FT_Long result;
- FT_Assert( stream && stream->cursor );
+ FT_ASSERT( stream && stream->cursor );
result = 0;
p = stream->cursor;
@@ -358,7 +358,7 @@
FT_Long result;
- FT_Assert( stream && stream->cursor );
+ FT_ASSERT( stream && stream->cursor );
result = 0;
p = stream->cursor;
@@ -376,7 +376,7 @@
FT_Long result;
- FT_Assert( stream && stream->cursor );
+ FT_ASSERT( stream && stream->cursor );
result = 0;
p = stream->cursor;
@@ -394,7 +394,7 @@
FT_Byte result = 0;
- FT_Assert( stream );
+ FT_ASSERT( stream );
*error = FT_Err_Ok;
@@ -433,7 +433,7 @@
FT_Short result = 0;
- FT_Assert( stream );
+ FT_ASSERT( stream );
*error = FT_Err_Ok;
@@ -480,7 +480,7 @@
FT_Short result = 0;
- FT_Assert( stream );
+ FT_ASSERT( stream );
*error = FT_Err_Ok;
@@ -527,7 +527,7 @@
FT_Long result = 0;
- FT_Assert( stream );
+ FT_ASSERT( stream );
*error = FT_Err_Ok;
@@ -574,7 +574,7 @@
FT_Long result = 0;
- FT_Assert( stream );
+ FT_ASSERT( stream );
*error = FT_Err_Ok;
@@ -621,7 +621,7 @@
FT_Long result = 0;
- FT_Assert( stream );
+ FT_ASSERT( stream );
*error = FT_Err_Ok;
diff --git a/src/base/rules.mk b/src/base/rules.mk
index 8c3bbd4..2c6df87 100644
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -34,7 +34,6 @@
#
BASE_SRC := $(BASE_)ftcalc.c \
$(BASE_)fttrigon.c \
- $(BASE_)ftextend.c \
$(BASE_)ftlist.c \
$(BASE_)ftobjs.c \
$(BASE_)ftstream.c \