swiftlang / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.29k stars 1.13k forks source link

[CoreFoundation] Replace use of strlcpy/strlcat with our own functions. #5113

Closed al45tair closed 1 month ago

al45tair commented 1 month ago

These can use strlcpy and strlcat if we have them, but we mustn't go defining strlcpy or strlcat because (a) those names are reserved, and (b) doing so without explicitly testing for their presence runs the risk of build failures from trying to define them when they already exist.

rdar://137567627

al45tair commented 1 month ago

@swift-ci Please test Linux platform

al45tair commented 1 month ago

@swift-ci Please test Windows platform

parkera commented 1 month ago

We need the Windows build to pass, though...

parkera commented 1 month ago
C:/Users/swift-ci/jenkins/workspace/swift-corelibs-foundation-PR-windows/swift-corelibs-foundation/Sources/CoreFoundation/internalInclude/CoreFoundation_Prefix.h(203,68): error: function-like macro '__GLIBC_PREREQ' is not defined
  203 | #if TARGET_OS_MAC || TARGET_OS_WASI || (defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 38))
      |                                                                    ^
al45tair commented 1 month ago

Oops, yes, that's wrong. Will fix and re-spin the tests.

al45tair commented 1 month ago

@swift-ci Please test Linux platform

al45tair commented 1 month ago

@swift-ci Please test Windows platform

al45tair commented 1 month ago

Hopefully fixed that one. That'll teach me to try to be clever and use the nice macro (the problem being that, of course, you can't use function macros in an expression if they're undefined, even after testing whether they're defined and doing an &&).

al45tair commented 1 month ago

@swift-ci Please test Windows platform