aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/fallback.cpp
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-05-18 17:46:13 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-05-19 18:42:34 -0700
commit46be5ac468db923bd3d19c55638b723aa760cd4e (patch)
tree44726156923b2243b946e11101242e543656de76 /src/fallback.cpp
parent30ea7cc3f8a5d56ad30dc749ea374363c15f312a (diff)
make fish buildable on OS X Snow Leopard
I noticed that the `test_convert()` function was randomly failing when run on OS X Snow Leopard. I tracked it down to the `mbrtowc()` function on that OS being broken. Explicitly testing for UTF-8 prefixes that identify a sequence longer than four bytes (which the Unicode standard made illegal long ago) keeps us from having encoding errors on those OS's. This also makes the errors reported by the `test_convert()` function actually useful and readable. Lastly, it makes it possible to build fish on OS X Snow Leopard.
Diffstat (limited to 'src/fallback.cpp')
-rw-r--r--src/fallback.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/fallback.cpp b/src/fallback.cpp
index 7a829124..96fa417b 100644
--- a/src/fallback.cpp
+++ b/src/fallback.cpp
@@ -131,7 +131,8 @@ __attribute__((unused)) static int wcsncasecmp_fallback(const wchar_t *a, const
return wcsncasecmp_fallback(a + 1, b + 1, count - 1);
}
-#if __APPLE__ && __DARWIN_C_LEVEL >= 200809L
+#if __APPLE__
+#if __DARWIN_C_LEVEL >= 200809L
// Note parens avoid the macro expansion.
wchar_t *wcsdup_use_weak(const wchar_t *a) {
if (&wcsdup != NULL) return (wcsdup)(a);
@@ -147,8 +148,12 @@ 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);
}
-
-#endif //__APPLE__
+#else // __DARWIN_C_LEVEL >= 200809L
+wchar_t *wcsdup(const wchar_t *in) { return wcsdup_fallback(in); }
+int wcscasecmp(const wchar_t *a, const wchar_t *b) { return wcscasecmp_fallback(a, b); }
+int wcsncasecmp(const wchar_t *a, const wchar_t *b, size_t n) { return wcsncasecmp_fallback(a, b, n); }
+#endif // __DARWIN_C_LEVEL >= 200809L
+#endif // __APPLE__
#ifndef HAVE_WCSNDUP
wchar_t *wcsndup(const wchar_t *in, size_t c) {