mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Fix for failing to weak link wcsncasecmp - binary dies on SnowLeopard
This commit is contained in:
parent
7d9b0a00e4
commit
77ec902ca7
2 changed files with 33 additions and 19 deletions
48
fallback.cpp
48
fallback.cpp
|
@ -817,7 +817,7 @@ static wchar_t *wcsdup_fallback(const wchar_t *in)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wcscasecmp_fallback(const wchar_t *a, const wchar_t *b)
|
static int wcscasecmp_fallback(const wchar_t *a, const wchar_t *b)
|
||||||
{
|
{
|
||||||
if (*a == 0)
|
if (*a == 0)
|
||||||
{
|
{
|
||||||
|
@ -834,6 +834,26 @@ int wcscasecmp_fallback(const wchar_t *a, const wchar_t *b)
|
||||||
return wcscasecmp_fallback(a+1,b+1);
|
return wcscasecmp_fallback(a+1,b+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int wcsncasecmp_fallback(const wchar_t *a, const wchar_t *b, size_t count)
|
||||||
|
{
|
||||||
|
if (count == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (*a == 0)
|
||||||
|
{
|
||||||
|
return (*b==0)?0:-1;
|
||||||
|
}
|
||||||
|
else if (*b == 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int diff = towlower(*a)-towlower(*b);
|
||||||
|
if (diff != 0)
|
||||||
|
return diff;
|
||||||
|
else
|
||||||
|
return wcsncasecmp_fallback(a+1,b+1, count-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if __APPLE__ && __DARWIN_C_LEVEL >= 200809L
|
#if __APPLE__ && __DARWIN_C_LEVEL >= 200809L
|
||||||
/* Note parens avoid the macro expansion */
|
/* Note parens avoid the macro expansion */
|
||||||
|
@ -851,6 +871,13 @@ int wcscasecmp_use_weak(const wchar_t *a, const wchar_t *b)
|
||||||
return wcscasecmp_fallback(a, b);
|
return wcscasecmp_fallback(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wcsncasecmp_use_weak(const wchar_t *s1, const wchar_t *s2, size_t n)
|
||||||
|
{
|
||||||
|
if (wcsncasecmp != NULL)
|
||||||
|
return (wcsncasecmp)(s1, s2, n);
|
||||||
|
return wcsncasecmp_fallback(s1, s2, n);
|
||||||
|
}
|
||||||
|
|
||||||
#else //__APPLE__
|
#else //__APPLE__
|
||||||
|
|
||||||
#ifndef HAVE_WCSDUP
|
#ifndef HAVE_WCSDUP
|
||||||
|
@ -881,24 +908,9 @@ size_t wcslen(const wchar_t *in)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_WCSNCASECMP
|
#ifndef HAVE_WCSNCASECMP
|
||||||
int wcsncasecmp(const wchar_t *a, const wchar_t *b, int count)
|
int wcsncasecmp(const wchar_t *a, const wchar_t *b, size_t count)
|
||||||
{
|
{
|
||||||
if (count == 0)
|
return wcsncasecmp_fallback(a, b, count);
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (*a == 0)
|
|
||||||
{
|
|
||||||
return (*b==0)?0:-1;
|
|
||||||
}
|
|
||||||
else if (*b == 0)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
int diff = towlower(*a)-towlower(*b);
|
|
||||||
if (diff != 0)
|
|
||||||
return diff;
|
|
||||||
else
|
|
||||||
return wcsncasecmp(a+1,b+1, count-1);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -217,8 +217,10 @@ int wcwidth(wchar_t c);
|
||||||
#if __APPLE__ && __DARWIN_C_LEVEL >= 200809L
|
#if __APPLE__ && __DARWIN_C_LEVEL >= 200809L
|
||||||
wchar_t *wcsdup_use_weak(const wchar_t *);
|
wchar_t *wcsdup_use_weak(const wchar_t *);
|
||||||
int wcscasecmp_use_weak(const wchar_t *, const wchar_t *);
|
int wcscasecmp_use_weak(const wchar_t *, const wchar_t *);
|
||||||
|
int wcsncasecmp_use_weak(const wchar_t *s1, const wchar_t *s2, size_t n);
|
||||||
#define wcsdup(a) wcsdup_use_weak((a))
|
#define wcsdup(a) wcsdup_use_weak((a))
|
||||||
#define wcscasecmp(a, b) wcscasecmp_use_weak((a), (b))
|
#define wcscasecmp(a, b) wcscasecmp_use_weak((a), (b))
|
||||||
|
#define wcsncasecmp(a, b, c) wcsncasecmp_use_weak((a), (b), (c))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -273,7 +275,7 @@ size_t wcslen(const wchar_t *in);
|
||||||
fish and guaranteed to be a sane, english word. Using wcsncasecmp on
|
fish and guaranteed to be a sane, english word. Using wcsncasecmp on
|
||||||
a user-supplied string should be considered a bug.
|
a user-supplied string should be considered a bug.
|
||||||
*/
|
*/
|
||||||
int wcsncasecmp(const wchar_t *a, const wchar_t *b, int count);
|
int wcsncasecmp(const wchar_t *a, const wchar_t *b, size_t count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a newly allocated wide character string wich is a copy of
|
Returns a newly allocated wide character string wich is a copy of
|
||||||
|
|
Loading…
Reference in a new issue