diff options
author | Kurtis Rader <krader@skepticism.us> | 2016-05-18 17:46:13 -0700 |
---|---|---|
committer | Kurtis Rader <krader@skepticism.us> | 2016-05-19 18:42:34 -0700 |
commit | 46be5ac468db923bd3d19c55638b723aa760cd4e (patch) | |
tree | 44726156923b2243b946e11101242e543656de76 /src/wutil.cpp | |
parent | 30ea7cc3f8a5d56ad30dc749ea374363c15f312a (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/wutil.cpp')
-rw-r--r-- | src/wutil.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wutil.cpp b/src/wutil.cpp index 4299956a..9f975fab 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -343,7 +343,13 @@ wchar_t *wrealpath(const wcstring &pathname, wchar_t *resolved_path) { res = wcsdup(wide_res.c_str()); } +#if __APPLE__ && __DARWIN_C_LEVEL < 200809L + // OS X Snow Leopard is broken with respect to the dynamically allocated buffer returned by + // realpath(). It's not dynamically allocated so attempting to free that buffer triggers a + // malloc/free error. Thus we don't attempt the free in this case. +#else free(narrow_res); +#endif return res; } |