From b828d5bfa936ea94615c3c98d4cc99ca9711e771 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Thu, 8 Mar 2018 12:05:37 +0700 Subject: [PATCH] Only use dirname_r and basename_r if on macOS 10.12 Not only do we test for the presence of these functions at runtime, but we do not use them at all, when building with the 10.11 SDK (or earlier). This is because if we had to support building with an earlier SDK it is not enough to declare the prototypes, we also need to add the symbols as weak to the linker options. Not using the functions does not remove crucial functionality. --- Frameworks/regexp/src/format_string.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Frameworks/regexp/src/format_string.cc b/Frameworks/regexp/src/format_string.cc index ea4cb674..f7285e84 100644 --- a/Frameworks/regexp/src/format_string.cc +++ b/Frameworks/regexp/src/format_string.cc @@ -291,16 +291,20 @@ struct expand_visitor : boost::static_visitor value = format_number(value); if(v.change & parser::transform::kDuration) value = format_duration(value); - if(v.change & parser::transform::kDirname) + +#if defined(MAC_OS_X_VERSION_10_12) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12) + if(dirname_r != nullptr && (v.change & parser::transform::kDirname)) { char buf[MAXPATHLEN]; value = dirname_r(value.c_str(), buf) ?: value; } - if(v.change & parser::transform::kBasename) + + if(basename_r != nullptr && (v.change & parser::transform::kBasename)) { char buf[MAXPATHLEN]; value = basename_r(value.c_str(), buf) ?: value; } +#endif res += value; } }