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.
This commit is contained in:
Allan Odgaard
2018-03-08 12:05:37 +07:00
parent c9cc0c266d
commit b828d5bfa9

View File

@@ -291,16 +291,20 @@ struct expand_visitor : boost::static_visitor<void>
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;
}
}