aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--FishsFish.xcodeproj/project.pbxproj24
-rw-r--r--common.cpp17
-rw-r--r--common.h21
-rw-r--r--fallback.cpp69
-rw-r--r--fallback.h40
5 files changed, 99 insertions, 72 deletions
diff --git a/FishsFish.xcodeproj/project.pbxproj b/FishsFish.xcodeproj/project.pbxproj
index 27d8c23e..b9c7ca6a 100644
--- a/FishsFish.xcodeproj/project.pbxproj
+++ b/FishsFish.xcodeproj/project.pbxproj
@@ -1075,7 +1075,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = NO;
EXECUTABLE_NAME = fish_launcher;
GCC_DYNAMIC_NO_PIC = NO;
@@ -1086,7 +1085,6 @@
);
GCC_WARN_UNINITIALIZED_AUTOS = YES;
INFOPLIST_FILE = osx/Info.plist;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = fish;
WRAPPER_EXTENSION = app;
};
@@ -1096,14 +1094,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EXECUTABLE_NAME = fish_launcher;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
INFOPLIST_FILE = osx/Info.plist;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = fish;
WRAPPER_EXTENSION = app;
};
@@ -1113,12 +1109,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -1127,12 +1121,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -1141,7 +1133,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
@@ -1150,7 +1141,6 @@
"$(inherited)",
);
GCC_WARN_UNINITIALIZED_AUTOS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -1159,12 +1149,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -1173,7 +1161,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
@@ -1182,7 +1169,6 @@
"$(inherited)",
);
GCC_WARN_UNINITIALIZED_AUTOS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -1191,12 +1177,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -1205,12 +1189,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = fish;
};
name = Debug;
@@ -1219,12 +1201,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = fish;
};
name = Release;
@@ -1233,7 +1213,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
@@ -1242,7 +1221,6 @@
"$(inherited)",
);
GCC_WARN_UNINITIALIZED_AUTOS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -1251,12 +1229,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
- MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
diff --git a/common.cpp b/common.cpp
index 3d98b7e4..9b443989 100644
--- a/common.cpp
+++ b/common.cpp
@@ -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);
+}
diff --git a/common.h b/common.h
index 7c5ab03f..4f85d0d6 100644
--- a/common.h
+++ b/common.h
@@ -486,28 +486,15 @@ public:
~scoped_lock();
};
+/* Wrapper around wcstok */
class wcstokenizer {
wchar_t *buffer, *str, *state;
const wcstring sep;
public:
- wcstokenizer(const wcstring &s, const wcstring &separator) : sep(separator) {
- wchar_t *wcsdup(const wchar_t *s);
- buffer = wcsdup(s.c_str());
- str = buffer;
- state = NULL;
- }
-
- bool next(wcstring &result) {
- wchar_t *tmp = wcstok(str, sep.c_str(), &state);
- str = NULL;
- if (tmp) result = tmp;
- return tmp != NULL;
- }
-
- ~wcstokenizer() {
- free(buffer);
- }
+ wcstokenizer(const wcstring &s, const wcstring &separator);
+ bool next(wcstring &result);
+ ~wcstokenizer();
};
/**
diff --git a/fallback.cpp b/fallback.cpp
index abfe5cee..50954ab0 100644
--- a/fallback.cpp
+++ b/fallback.cpp
@@ -803,8 +803,9 @@ wchar_t *wcstok(wchar_t *wcs, const wchar_t *delim, wchar_t **save_ptr)
#endif
-#ifndef HAVE_WCSDUP
-wchar_t *wcsdup( const wchar_t *in )
+/* Fallback implementations of wcsdup and wcscasecmp. On systems where these are not needed (e.g. building on Linux) these should end up just being stripped, as they are static functions that are not referenced in this file.
+*/
+static wchar_t *wcsdup_fallback(const wchar_t *in)
{
size_t len=wcslen(in);
wchar_t *out = (wchar_t *)malloc( sizeof( wchar_t)*(len+1));
@@ -815,23 +816,9 @@ wchar_t *wcsdup( const wchar_t *in )
memcpy( out, in, sizeof( wchar_t)*(len+1));
return out;
-
}
-#endif
-#ifndef HAVE_WCSLEN
-size_t wcslen(const wchar_t *in)
-{
- const wchar_t *end=in;
- while( *end )
- end++;
- return end-in;
-}
-#endif
-
-
-#ifndef HAVE_WCSCASECMP
-int wcscasecmp( const wchar_t *a, const wchar_t *b )
+int wcscasecmp_fallback( const wchar_t *a, const wchar_t *b )
{
if( *a == 0 )
{
@@ -845,11 +832,55 @@ int wcscasecmp( const wchar_t *a, const wchar_t *b )
if( diff != 0 )
return diff;
else
- return wcscasecmp( a+1,b+1);
+ return wcscasecmp_fallback( a+1,b+1);
}
-#endif
+#if __APPLE__ && __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);
+ return wcsdup_fallback(a);
+}
+
+int wcscasecmp_use_weak(const wchar_t *a, const wchar_t *b)
+{
+ if (wcscasecmp != NULL)
+ return (wcscasecmp)(a, b);
+ return wcscasecmp_fallback(a, b);
+}
+
+#else //__APPLE__
+
+ #ifndef HAVE_WCSDUP
+wchar_t *wcsdup( const wchar_t *in )
+{
+ return wcsdup_fallback(in);
+
+}
+ #endif
+
+
+ #ifndef HAVE_WCSCASECMP
+int wcscasecmp( const wchar_t *a, const wchar_t *b )
+{
+ return wcscasecmp_fallback(a, b);
+}
+ #endif
+#endif //__APPLE__
+
+#ifndef HAVE_WCSLEN
+size_t wcslen(const wchar_t *in)
+{
+ const wchar_t *end=in;
+ while( *end )
+ end++;
+ return end-in;
+}
+#endif
+
#ifndef HAVE_WCSNCASECMP
int wcsncasecmp( const wchar_t *a, const wchar_t *b, int count )
{
diff --git a/fallback.h b/fallback.h
index 7a1a9dc7..de809564 100644
--- a/fallback.h
+++ b/fallback.h
@@ -209,26 +209,30 @@ int wcwidth( wchar_t c );
#endif
-#ifndef HAVE_WCSDUP
-/**
- Create a duplicate string. Wide string version of strdup. Will
- automatically exit if out of memory.
-*/
-wchar_t *wcsdup(const wchar_t *in);
+/** 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+.
-#endif
+ 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_WCSLEN
+ #ifndef HAVE_WCSDUP
/**
- Fallback for wcsen. Returns the length of the specified string.
+ Create a duplicate string. Wide string version of strdup. Will
+ automatically exit if out of memory.
*/
-size_t wcslen(const wchar_t *in);
+wchar_t *wcsdup(const wchar_t *in);
-#endif
+ #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
/**