From b440828b6c74b663b3438248974d1cafcb4bdcc6 Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Thu, 6 Jan 2011 12:24:43 +0900 Subject: use cpp-macro PLATFORM_PATH_SEPARATOR instead of raw ascii slash --- builds/unix/ftconfig.in | 20 ++++++++++++++++++++ include/freetype/config/ftconfig.h | 19 +++++++++++++++++++ src/base/ftrfork.c | 19 +++++++++++++------ 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in index 4c81187e5..85bde304a 100644 --- a/builds/unix/ftconfig.in +++ b/builds/unix/ftconfig.in @@ -167,6 +167,26 @@ FT_BEGIN_HEADER #endif + /*************************************************************************/ + /* */ + /* Pathname separator used by resource-fork accessor & ft_basename() */ + /* */ + +#ifdef PLATFORM_PATH_SEPARATOR + /* explicitly defined, do nothing */ +#elif defined( __DOS__ ) || defined( __OS2__ ) || defined( _WIN32 ) || \ + defined( __SYMBIAN32__ ) +#define PLATFORM_PATH_SEPARATOR "\\" +#elif defined( FT_MACINTOSH ) && !defined( __MACH__ ) +#define PLATFORM_PATH_SEPARATOR ":" +#elif defined( __riscos__ ) || defined( VMS ) +#define PLATFORM_PATH_SEPARATOR "." +#else +#define PLATFORM_PATH_SEPARATOR "/" +#endif + + + /* Fix compiler warning with sgi compiler */ #if defined( __sgi ) && !defined( __GNUC__ ) #if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 ) diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h index cbe30f268..de7d654a2 100644 --- a/include/freetype/config/ftconfig.h +++ b/include/freetype/config/ftconfig.h @@ -145,6 +145,25 @@ FT_BEGIN_HEADER #endif + /*************************************************************************/ + /* */ + /* Pathname separator used by resource-fork accessor & ft_basename() */ + /* */ + +#ifdef PLATFORM_PATH_SEPARATOR + /* explicitly defined, do nothing */ +#elif defined( __DOS__ ) || defined( __OS2__ ) || defined( _WIN32 ) || \ + defined( __SYMBIAN32__ ) +#define PLATFORM_PATH_SEPARATOR "\\" +#elif defined( FT_MACINTOSH ) && !defined( __MACH__ ) +#define PLATFORM_PATH_SEPARATOR ":" +#elif defined( __riscos__ ) || defined( VMS ) +#define PLATFORM_PATH_SEPARATOR "." +#else +#define PLATFORM_PATH_SEPARATOR "/" +#endif + + /*************************************************************************/ /* */ /*
*/ diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c index b01ecb9f9..819aa01af 100644 --- a/src/base/ftrfork.c +++ b/src/base/ftrfork.c @@ -544,7 +544,8 @@ return error; FT_MEM_COPY( newpath, base_file_name, base_file_len ); - FT_MEM_COPY( newpath + base_file_len, "/rsrc", 6 ); + FT_MEM_COPY( newpath + base_file_len, + PLATFORM_PATH_SEPARATOR "rsrc", 6 ); *result_file_name = newpath; *result_offset = 0; @@ -580,7 +581,9 @@ return error; FT_MEM_COPY( newpath, base_file_name, base_file_len ); - FT_MEM_COPY( newpath + base_file_len, "/..namedfork/rsrc", 18 ); + FT_MEM_COPY( newpath + base_file_len, + PLATFORM_PATH_SEPARATOR "..namedfork" + PLATFORM_PATH_SEPARATOR "rsrc", 18 ); *result_file_name = newpath; *result_offset = 0; @@ -605,7 +608,8 @@ memory = library->memory; newpath = raccess_make_file_name( memory, base_file_name, - "resource.frk/" ); + "resource.frk" + PLATFORM_PATH_SEPARATOR ); if ( !newpath ) return FT_Err_Out_Of_Memory; @@ -631,7 +635,9 @@ memory = library->memory; - newpath = raccess_make_file_name( memory, base_file_name, ".resource/" ); + newpath = raccess_make_file_name( memory, base_file_name, + ".resource" + PLATFORM_PATH_SEPARATOR ); if ( !newpath ) return FT_Err_Out_Of_Memory; @@ -690,7 +696,8 @@ memory = library->memory; newpath = raccess_make_file_name( memory, base_file_name, - ".AppleDouble/" ); + ".AppleDouble" + PLATFORM_PATH_SEPARATOR ); if ( !newpath ) return FT_Err_Out_Of_Memory; @@ -815,7 +822,7 @@ if ( FT_ALLOC( new_name, new_length + 1 ) ) return NULL; - tmp = ft_strrchr( original_name, '/' ); + tmp = ft_strrchr( original_name, PLATFORM_PATH_SEPARATOR[0] ); if ( tmp ) { ft_strncpy( new_name, original_name, tmp - original_name + 1 ); -- cgit v1.2.1