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

@@ -2060,3 +2060,20 @@ scoped_lock::scoped_lock(pthread_mutex_t &mutex) : lock_obj(&mutex), locked(fals
scoped_lock::~scoped_lock() {
if (locked) this->unlock();
}
wcstokenizer::wcstokenizer(const wcstring &s, const wcstring &separator) : sep(separator) {
buffer = wcsdup(s.c_str());
str = buffer;
state = NULL;
}
bool wcstokenizer::next(wcstring &result) {
wchar_t *tmp = wcstok(str, sep.c_str(), &state);
str = NULL;
if (tmp) result = tmp;
return tmp != NULL;
}
wcstokenizer::~wcstokenizer() {
free(buffer);
}