Use weak linking of wcsdup and wcscasecmp on OS X

Fixes https://github.com/fish-shell/fish-shell/issues/240
This commit is contained in:
ridiculousfish
2012-07-20 14:33:08 -07:00
parent cf9bfe9e66
commit 966bbd476f
5 changed files with 99 additions and 72 deletions

View File

@@ -209,7 +209,20 @@ int wcwidth( wchar_t c );
#endif
#ifndef HAVE_WCSDUP
/** On OS X, use weak linking for wcsdup and wcscasecmp. Weak linking allows you to call the function only if it exists at runtime. You can detect it by testing the function pointer against NULL. To avoid making the callers do that, redefine wcsdup to wcsdup_use_weak, and likewise with wcscasecmp. This lets us use the same binary on SnowLeopard (10.6) and Lion+ (10.7), even though these functions only exist on 10.7+.
On other platforms, use what's detected at build time.
*/
#if __APPLE__ && __DARWIN_C_LEVEL >= 200809L
wchar_t *wcsdup_use_weak(const wchar_t *);
int wcscasecmp_use_weak(const wchar_t *, const wchar_t *);
#define wcsdup(a) wcsdup_use_weak((a))
#define wcscasecmp(a, b) wcscasecmp_use_weak((a), (b))
#else
#ifndef HAVE_WCSDUP
/**
Create a duplicate string. Wide string version of strdup. Will
@@ -217,18 +230,9 @@ int wcwidth( wchar_t c );
*/
wchar_t *wcsdup(const wchar_t *in);
#endif
#endif
#ifndef HAVE_WCSLEN
/**
Fallback for wcsen. Returns the length of the specified string.
*/
size_t wcslen(const wchar_t *in);
#endif
#ifndef HAVE_WCSCASECMP
#ifndef HAVE_WCSCASECMP
/**
Case insensitive string compare function. Wide string version of
strcasecmp.
@@ -242,8 +246,20 @@ size_t wcslen(const wchar_t *in);
*/
int wcscasecmp( const wchar_t *a, const wchar_t *b );
#endif
#endif //__APPLE__
#ifndef HAVE_WCSLEN
/**
Fallback for wclsen. Returns the length of the specified string.
*/
size_t wcslen(const wchar_t *in);
#endif
#ifndef HAVE_WCSNCASECMP
/**