diff options
author | suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> | 2011-01-06 18:34:36 +0900 |
---|---|---|
committer | suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp> | 2011-01-10 00:43:40 +0900 |
commit | f6af979d2e5e1a6e859c8acce38849306eb23cee (patch) | |
tree | 3b8d4e9f5a6b19d364d10bb9e2079585de299144 | |
parent | dfaf70a056063aae74c6197e1e55bb8bb577a36b (diff) | |
download | freetype2-f6af979d2e5e1a6e859c8acce38849306eb23cee.tar.gz |
introduce ft_basename(): if libgen.h is available, it is a macro to system basename()
-rw-r--r-- | builds/unix/configure.raw | 2 | ||||
-rw-r--r-- | builds/unix/ftconfig.in | 1 | ||||
-rw-r--r-- | include/freetype/internal/ftobjs.h | 8 | ||||
-rw-r--r-- | src/base/ftobjs.c | 21 |
4 files changed, 31 insertions, 1 deletions
diff --git a/builds/unix/configure.raw b/builds/unix/configure.raw index cb10ef481..6e4c1c287 100644 --- a/builds/unix/configure.raw +++ b/builds/unix/configure.raw @@ -111,7 +111,7 @@ esac # checks for header files AC_HEADER_STDC -AC_CHECK_HEADERS([fcntl.h unistd.h]) +AC_CHECK_HEADERS([fcntl.h unistd.h libgen.h]) # checks for typedefs, structures, and compiler characteristics diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in index 680fc7f2d..3bb68fb82 100644 --- a/builds/unix/ftconfig.in +++ b/builds/unix/ftconfig.in @@ -60,6 +60,7 @@ FT_BEGIN_HEADER #undef HAVE_UNISTD_H #undef HAVE_FCNTL_H #undef HAVE_STDINT_H +#undef HAVE_LIBGEN_H /* There are systems (like the Texas Instruments 'C54x) where a `char' */ diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h index 670eb78a8..4cffb1318 100644 --- a/include/freetype/internal/ftobjs.h +++ b/include/freetype/internal/ftobjs.h @@ -108,6 +108,14 @@ FT_BEGIN_HEADER #define ft_isalpha( x ) ( ft_isupper( x ) || ft_islower( x ) ) #define ft_isalnum( x ) ( ft_isdigit( x ) || ft_isalpha( x ) ) +#ifdef HAVE_LIBGEN_H +#include <libgen.h> +#define ft_basename( p ) basename( ( p ) ) +#else + FT_BASE( char* ) + ft_basename( char* path ); +#endif + /*************************************************************************/ /*************************************************************************/ diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 6b01f43d5..afe299501 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1226,6 +1226,27 @@ } +#ifndef HAVE_LIBGEN_H + FT_BASE_DEF( char* ) + ft_basename( char* pathname ) + { + char* c; + + + c = pathname + ft_strlen( pathname ); + + /* skip trailing separator */ + while ( pathname < c && *c == PLATFORM_DIR_SEPARATOR[0] ) + c--; + + while ( pathname < c && *(c-1) != PLATFORM_DIR_SEPARATOR[0] ) + c--; + + return c; + } +#endif + + #ifdef FT_CONFIG_OPTION_MAC_FONTS /* The behavior here is very similar to that in base/ftmac.c, but it */ |