From: <sv...@op...> - 2024-12-26 19:11:42
|
Author: manx Date: Thu Dec 26 20:11:29 2024 New Revision: 22608 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22608 Log: [Fix] mpt/base/detect_quirks.hpp: Add MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE for older Apple Clang. See <https://github.com/fink/fink-distributions/issues/1202>. Modified: trunk/OpenMPT/common/mptString.h trunk/OpenMPT/soundlib/Dlsbank.cpp trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/src/mpt/base/detect_quirks.hpp trunk/OpenMPT/src/mpt/io_file_adapter/fileadapter.hpp trunk/OpenMPT/src/mpt/library/library.hpp Modified: trunk/OpenMPT/common/mptString.h ============================================================================== --- trunk/OpenMPT/common/mptString.h Thu Dec 26 20:04:41 2024 (r22607) +++ trunk/OpenMPT/common/mptString.h Thu Dec 26 20:11:29 2024 (r22608) @@ -430,7 +430,11 @@ std::optional<mpt::common_encoding> charset = mpt::optional_encoding_from_codepage(codepage); if(charset.has_value()) { +#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE) + result = mpt::transcode<mpt::ustring>(*charset, std::forward<Tsrc>(str)); +#else result = mpt::transcode<mpt::ustring>(charset.value(), std::forward<Tsrc>(str)); +#endif } else if(mpt::has_codepage(static_cast<UINT>(codepage))) { result = mpt::transcode<mpt::ustring>(static_cast<UINT>(codepage), std::forward<Tsrc>(str)); @@ -441,7 +445,11 @@ return result; #else // !MPT_OS_WINDOWS std::optional<mpt::common_encoding> charset = mpt::optional_encoding_from_codepage(codepage); +#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE) return charset.has_value() ? mpt::transcode<mpt::ustring>(charset.value(), std::forward<Tsrc>(str)) : mpt::transcode<mpt::ustring>(std::forward<Tencoding>(fallback), std::forward<Tsrc>(str)); +#else + return charset.has_value() ? mpt::transcode<mpt::ustring>(*charset, std::forward<Tsrc>(str)) : mpt::transcode<mpt::ustring>(std::forward<Tencoding>(fallback), std::forward<Tsrc>(str)); +#endif #endif // MPT_OS_WINDOWS } Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Dlsbank.cpp Thu Dec 26 20:04:41 2024 (r22607) +++ trunk/OpenMPT/soundlib/Dlsbank.cpp Thu Dec 26 20:11:29 2024 (r22608) @@ -1423,7 +1423,13 @@ uint32 nInsDef; if(file.GetOptionalFileName()) + { +#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE) + m_szFileName = *(file.GetOptionalFileName()); +#else m_szFileName = file.GetOptionalFileName().value(); +#endif + } file.Rewind(); if(!file.CanRead(256)) Modified: trunk/OpenMPT/soundlib/Load_mod.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp Thu Dec 26 20:04:41 2024 (r22607) +++ trunk/OpenMPT/soundlib/Load_mod.cpp Thu Dec 26 20:11:29 2024 (r22608) @@ -712,7 +712,11 @@ FileReader amData; if(file.GetOptionalFileName()) { +#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE) + mpt::PathString filename = *(file.GetOptionalFileName()); +#else mpt::PathString filename = file.GetOptionalFileName().value(); +#endif // Find instrument definition file const mpt::PathString exts[] = {P_(".nt"), P_(".NT"), P_(".as"), P_(".AS")}; for(const auto &ext : exts) Modified: trunk/OpenMPT/src/mpt/base/detect_quirks.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/base/detect_quirks.hpp Thu Dec 26 20:04:41 2024 (r22607) +++ trunk/OpenMPT/src/mpt/base/detect_quirks.hpp Thu Dec 26 20:11:29 2024 (r22608) @@ -355,4 +355,20 @@ +#if MPT_OS_MACOSX_OR_IOS +#if defined(TARGET_OS_OSX) +#if TARGET_OS_OSX +#if !defined(MAC_OS_X_VERSION_10_14) +#define MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE +#else +#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14) +#define MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE +#endif +#endif +#endif +#endif +#endif + + + #endif // MPT_BASE_DETECT_QUIRKS_HPP Modified: trunk/OpenMPT/src/mpt/io_file_adapter/fileadapter.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/io_file_adapter/fileadapter.hpp Thu Dec 26 20:04:41 2024 (r22607) +++ trunk/OpenMPT/src/mpt/io_file_adapter/fileadapter.hpp Thu Dec 26 20:11:29 2024 (r22608) @@ -135,7 +135,11 @@ m_Filename = tempName; m_IsTempFile = true; } else { +#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE) + m_Filename = *(file.GetOptionalFileName()); +#else m_Filename = file.GetOptionalFileName().value(); +#endif } } catch (const std::runtime_error &) { m_Filename = mpt::os_path{}; Modified: trunk/OpenMPT/src/mpt/library/library.hpp ============================================================================== --- trunk/OpenMPT/src/mpt/library/library.hpp Thu Dec 26 20:04:41 2024 (r22607) +++ trunk/OpenMPT/src/mpt/library/library.hpp Thu Dec 26 20:11:29 2024 (r22608) @@ -187,7 +187,11 @@ if (!optionalfilename) { return std::nullopt; } +#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE) + mpt::native_path & filename = *optionalfilename; +#else mpt::native_path & filename = optionalfilename.value(); +#endif if (filename.empty()) { return std::nullopt; } @@ -351,7 +355,11 @@ if (!optionalfilename) { return std::nullopt; } +#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE) + mpt::native_path & filename = *optionalfilename; +#else mpt::native_path & filename = optionalfilename.value(); +#endif if (filename.empty()) { return std::nullopt; } @@ -405,7 +413,11 @@ if (!optionalfilename) { return std::nullopt; } +#if defined(MPT_LIBCXX_QUIRK_NO_OPTIONAL_VALUE) + mpt::native_path & filename = *optionalfilename; +#else mpt::native_path & filename = optionalfilename.value(); +#endif if (filename.empty()) { return std::nullopt; } |