From 2694f59d794984128456c4b219ceda0a53a4c0a6 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 12 Mar 2025 11:14:19 +0100 Subject: [PATCH] Sync with Xcode Signed-off-by: Simon Rozman --- UnitTests/UnitTests.xcodeproj/project.pbxproj | 138 +++++++++++++----- UnitTests/string.cpp | 12 +- include/stdex/string.hpp | 60 +++++--- 3 files changed, 144 insertions(+), 66 deletions(-) diff --git a/UnitTests/UnitTests.xcodeproj/project.pbxproj b/UnitTests/UnitTests.xcodeproj/project.pbxproj index b7086f2da..6305d13d2 100644 --- a/UnitTests/UnitTests.xcodeproj/project.pbxproj +++ b/UnitTests/UnitTests.xcodeproj/project.pbxproj @@ -17,20 +17,20 @@ F421D4802B750EAE004ECBB0 /* trees.c in Sources */ = {isa = PBXBuildFile; fileRef = F421D4792B750EAE004ECBB0 /* trees.c */; settings = {COMPILER_FLAGS = "-w"; }; }; F421D4812B750EAE004ECBB0 /* inftrees.c in Sources */ = {isa = PBXBuildFile; fileRef = F421D47A2B750EAE004ECBB0 /* inftrees.c */; settings = {COMPILER_FLAGS = "-w"; }; }; F421D4822B750EAE004ECBB0 /* uncompr.c in Sources */ = {isa = PBXBuildFile; fileRef = F421D47B2B750EAE004ECBB0 /* uncompr.c */; settings = {COMPILER_FLAGS = "-w"; }; }; - F421D4832B7511FA004ECBB0 /* hash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F437AA902AC1BB64001E2230 /* hash.cpp */; }; - F421D4842B7514B5004ECBB0 /* math.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F4E2AB059300044EDC0 /* math.cpp */; }; - F421D4852B751551004ECBB0 /* parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F562AB08E690044EDC0 /* parser.cpp */; }; - F421D4862B751707004ECBB0 /* pool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4CCA3B72B73B940007B857B /* pool.cpp */; }; - F421D4872B751739004ECBB0 /* ring.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F592AB08E690044EDC0 /* ring.cpp */; }; - F421D4882B751774004ECBB0 /* sgml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F582AB08E690044EDC0 /* sgml.cpp */; }; - F421D4892B751777004ECBB0 /* stream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F5A2AB08E690044EDC0 /* stream.cpp */; }; - F421D48A2B75177B004ECBB0 /* string.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4CCA3B82B73D2E2007B857B /* string.cpp */; }; - F421D48B2B75177E004ECBB0 /* unicode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F572AB08E690044EDC0 /* unicode.cpp */; }; - F421D48C2B751780004ECBB0 /* watchdog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4CCA3B62B73B912007B857B /* watchdog.cpp */; }; - F421D48D2B751783004ECBB0 /* zlib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F421D46B2B750BFD004ECBB0 /* zlib.cpp */; }; - F4481A1A2C73427600CED93B /* langid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4481A192C73427600CED93B /* langid.cpp */; }; - F4C07F522AB059580044EDC0 /* pch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F512AB059580044EDC0 /* pch.cpp */; }; - F4C07F552AB05B5B0044EDC0 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F542AB05B5B0044EDC0 /* main.cpp */; }; + F44DE97F2D818A9F007E4ECC /* math.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F4E2AB059300044EDC0 /* math.cpp */; }; + F44DE9802D818A9F007E4ECC /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F542AB05B5B0044EDC0 /* main.cpp */; }; + F44DE9812D818A9F007E4ECC /* ring.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F592AB08E690044EDC0 /* ring.cpp */; }; + F44DE9822D818A9F007E4ECC /* hash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F437AA902AC1BB64001E2230 /* hash.cpp */; }; + F44DE9832D818A9F007E4ECC /* sgml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F582AB08E690044EDC0 /* sgml.cpp */; }; + F44DE9842D818A9F007E4ECC /* pool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4CCA3B72B73B940007B857B /* pool.cpp */; }; + F44DE9852D818A9F007E4ECC /* watchdog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4CCA3B62B73B912007B857B /* watchdog.cpp */; }; + F44DE9862D818A9F007E4ECC /* stream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F5A2AB08E690044EDC0 /* stream.cpp */; }; + F44DE9872D818A9F007E4ECC /* langid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4481A192C73427600CED93B /* langid.cpp */; }; + F44DE9882D818A9F007E4ECC /* pch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F512AB059580044EDC0 /* pch.cpp */; }; + F44DE9892D818A9F007E4ECC /* string.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4CCA3B82B73D2E2007B857B /* string.cpp */; }; + F44DE98A2D818A9F007E4ECC /* zlib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F421D46B2B750BFD004ECBB0 /* zlib.cpp */; }; + F44DE98B2D818A9F007E4ECC /* unicode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F572AB08E690044EDC0 /* unicode.cpp */; }; + F44DE98C2D818A9F007E4ECC /* parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4C07F562AB08E690044EDC0 /* parser.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -48,11 +48,9 @@ /* Begin PBXFileReference section */ F4213D172ABB14C600F72674 /* vector_queue.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = vector_queue.hpp; path = ../include/stdex/vector_queue.hpp; sourceTree = ""; }; F4213D182ABB14C600F72674 /* base64.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = base64.hpp; path = ../include/stdex/base64.hpp; sourceTree = ""; }; - F4213D192ABB14C600F72674 /* chrono.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = chrono.hpp; path = ../include/stdex/chrono.hpp; sourceTree = ""; }; F4213D1A2ABB14C600F72674 /* exception.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = exception.hpp; path = ../include/stdex/exception.hpp; sourceTree = ""; }; F4213D1B2ABB14C600F72674 /* idrec.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = idrec.hpp; path = ../include/stdex/idrec.hpp; sourceTree = ""; }; F4213D1C2ABB14C600F72674 /* compat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = compat.hpp; path = ../include/stdex/compat.hpp; sourceTree = ""; }; - F4213D1D2ABB14C600F72674 /* errno.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = errno.hpp; path = ../include/stdex/errno.hpp; sourceTree = ""; }; F4213D1E2ABB14C600F72674 /* progress.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = progress.hpp; path = ../include/stdex/progress.hpp; sourceTree = ""; }; F4213D1F2ABB14C600F72674 /* stream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = stream.hpp; path = ../include/stdex/stream.hpp; sourceTree = ""; }; F4213D202ABB14C600F72674 /* memory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = memory.hpp; path = ../include/stdex/memory.hpp; sourceTree = ""; }; @@ -68,7 +66,7 @@ F4213D2A2ABB14C600F72674 /* sgml_unicode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = sgml_unicode.hpp; path = ../include/stdex/sgml_unicode.hpp; sourceTree = ""; }; F4213D2B2ABB14C600F72674 /* sgml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = sgml.hpp; path = ../include/stdex/sgml.hpp; sourceTree = ""; }; F4213D2C2ABB14C600F72674 /* system.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = system.hpp; path = ../include/stdex/system.hpp; sourceTree = ""; }; - F421D46B2B750BFD004ECBB0 /* zlib.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = zlib.cpp; sourceTree = ""; }; + F421D46B2B750BFD004ECBB0 /* zlib.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = zlib.cpp; sourceTree = ""; }; F421D46F2B750E0F004ECBB0 /* adler32.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = adler32.c; sourceTree = ""; }; F421D4712B750E18004ECBB0 /* compress.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = compress.c; sourceTree = ""; }; F421D4732B750E21004ECBB0 /* crc32.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = crc32.c; sourceTree = ""; }; @@ -79,22 +77,54 @@ F421D4792B750EAE004ECBB0 /* trees.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = trees.c; sourceTree = ""; }; F421D47A2B750EAE004ECBB0 /* inftrees.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = inftrees.c; sourceTree = ""; }; F421D47B2B750EAE004ECBB0 /* uncompr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = uncompr.c; sourceTree = ""; }; - F437AA902AC1BB64001E2230 /* hash.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = hash.cpp; sourceTree = ""; }; + F437AA902AC1BB64001E2230 /* hash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hash.cpp; sourceTree = ""; }; F4481A192C73427600CED93B /* langid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = langid.cpp; sourceTree = ""; }; + F44DE94A2D818A48007E4ECC /* watchdog.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = watchdog.hpp; path = ../include/stdex/watchdog.hpp; sourceTree = ""; }; + F44DE94C2D818A48007E4ECC /* sys_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = sys_info.hpp; path = ../include/stdex/sys_info.hpp; sourceTree = ""; }; + F44DE94D2D818A48007E4ECC /* langid.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = langid.hpp; path = ../include/stdex/langid.hpp; sourceTree = ""; }; + F44DE94E2D818A48007E4ECC /* base64.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = base64.hpp; path = ../include/stdex/base64.hpp; sourceTree = ""; }; + F44DE94F2D818A48007E4ECC /* curl.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = curl.hpp; path = ../include/stdex/curl.hpp; sourceTree = ""; }; + F44DE9512D818A48007E4ECC /* scoped_executor.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = scoped_executor.hpp; path = ../include/stdex/scoped_executor.hpp; sourceTree = ""; }; + F44DE9522D818A48007E4ECC /* windows.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = windows.h; path = ../include/stdex/windows.h; sourceTree = ""; }; + F44DE9532D818A48007E4ECC /* zlib.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = zlib.hpp; path = ../include/stdex/zlib.hpp; sourceTree = ""; }; + F44DE9542D818A48007E4ECC /* unicode.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = unicode.hpp; path = ../include/stdex/unicode.hpp; sourceTree = ""; }; + F44DE9552D818A48007E4ECC /* minisign.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = minisign.hpp; path = ../include/stdex/minisign.hpp; sourceTree = ""; }; + F44DE9572D818A48007E4ECC /* math.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = math.hpp; path = ../include/stdex/math.hpp; sourceTree = ""; }; + F44DE9582D818A48007E4ECC /* parser.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = parser.hpp; path = ../include/stdex/parser.hpp; sourceTree = ""; }; + F44DE9592D818A48007E4ECC /* ring.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = ring.hpp; path = ../include/stdex/ring.hpp; sourceTree = ""; }; + F44DE95A2D818A48007E4ECC /* spinlock.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = spinlock.hpp; path = ../include/stdex/spinlock.hpp; sourceTree = ""; }; + F44DE95B2D818A49007E4ECC /* string.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = string.hpp; path = ../include/stdex/string.hpp; sourceTree = ""; }; + F44DE95C2D818A49007E4ECC /* hash.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = hash.hpp; path = ../include/stdex/hash.hpp; sourceTree = ""; }; + F44DE95D2D818A49007E4ECC /* wav.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = wav.hpp; path = ../include/stdex/wav.hpp; sourceTree = ""; }; + F44DE95E2D818A49007E4ECC /* endian.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = endian.hpp; path = ../include/stdex/endian.hpp; sourceTree = ""; }; + F44DE95F2D818A49007E4ECC /* html.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = html.hpp; path = ../include/stdex/html.hpp; sourceTree = ""; }; + F44DE9602D818A49007E4ECC /* hex.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = hex.hpp; path = ../include/stdex/hex.hpp; sourceTree = ""; }; + F44DE9622D818A49007E4ECC /* socket.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = socket.hpp; path = ../include/stdex/socket.hpp; sourceTree = ""; }; + F44DE9642D818A49007E4ECC /* assert.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = assert.hpp; path = ../include/stdex/assert.hpp; sourceTree = ""; }; + F44DE9662D818A49007E4ECC /* exception.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = exception.hpp; path = ../include/stdex/exception.hpp; sourceTree = ""; }; + F44DE9672D818A49007E4ECC /* debug.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = debug.hpp; path = ../include/stdex/debug.hpp; sourceTree = ""; }; + F44DE9682D818A49007E4ECC /* sgml.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = sgml.hpp; path = ../include/stdex/sgml.hpp; sourceTree = ""; }; + F44DE9692D818A49007E4ECC /* chrono.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = chrono.hpp; path = ../include/stdex/chrono.hpp; sourceTree = ""; }; + F44DE96A2D818A49007E4ECC /* uuid.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = uuid.hpp; path = ../include/stdex/uuid.hpp; sourceTree = ""; }; + F44DE96B2D818A49007E4ECC /* locale.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = locale.hpp; path = ../include/stdex/locale.hpp; sourceTree = ""; }; + F44DE96C2D818A4A007E4ECC /* pool.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = pool.hpp; path = ../include/stdex/pool.hpp; sourceTree = ""; }; + F44DE96D2D818A4A007E4ECC /* compat.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = compat.hpp; path = ../include/stdex/compat.hpp; sourceTree = ""; }; + F44DE96F2D818A4A007E4ECC /* interval.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = interval.hpp; path = ../include/stdex/interval.hpp; sourceTree = ""; }; + F44DE9702D818A4A007E4ECC /* idrec.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = idrec.hpp; path = ../include/stdex/idrec.hpp; sourceTree = ""; }; + F4C07F502AB059580044EDC0 /* pch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pch.hpp; sourceTree = ""; }; F4B7FBDC2AAF49BC00C6BE9F /* UnitTests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = UnitTests; sourceTree = BUILT_PRODUCTS_DIR; }; F4C07F4E2AB059300044EDC0 /* math.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = math.cpp; sourceTree = ""; }; - F4C07F502AB059580044EDC0 /* pch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pch.hpp; sourceTree = ""; }; F4C07F512AB059580044EDC0 /* pch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pch.cpp; sourceTree = ""; }; F4C07F532AB05A240044EDC0 /* compat.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = compat.hpp; sourceTree = ""; }; - F4C07F542AB05B5B0044EDC0 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + F4C07F542AB05B5B0044EDC0 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; F4C07F562AB08E690044EDC0 /* parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parser.cpp; sourceTree = ""; }; F4C07F572AB08E690044EDC0 /* unicode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unicode.cpp; sourceTree = ""; }; F4C07F582AB08E690044EDC0 /* sgml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sgml.cpp; sourceTree = ""; }; F4C07F592AB08E690044EDC0 /* ring.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ring.cpp; sourceTree = ""; }; F4C07F5A2AB08E690044EDC0 /* stream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stream.cpp; sourceTree = ""; }; - F4CCA3B62B73B912007B857B /* watchdog.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = watchdog.cpp; sourceTree = ""; }; - F4CCA3B72B73B940007B857B /* pool.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = pool.cpp; sourceTree = ""; }; - F4CCA3B82B73D2E2007B857B /* string.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = string.cpp; sourceTree = ""; }; + F4CCA3B62B73B912007B857B /* watchdog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = watchdog.cpp; sourceTree = ""; }; + F4CCA3B72B73B940007B857B /* pool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pool.cpp; sourceTree = ""; }; + F4CCA3B82B73D2E2007B857B /* string.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = string.cpp; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -111,11 +141,41 @@ F4213D162ABB14AA00F72674 /* stdex */ = { isa = PBXGroup; children = ( + F44DE9642D818A49007E4ECC /* assert.hpp */, F4213D182ABB14C600F72674 /* base64.hpp */, - F4213D192ABB14C600F72674 /* chrono.hpp */, F4213D1C2ABB14C600F72674 /* compat.hpp */, + F44DE94F2D818A48007E4ECC /* curl.hpp */, + F44DE9672D818A49007E4ECC /* debug.hpp */, F4213D272ABB14C600F72674 /* endian.hpp */, - F4213D1D2ABB14C600F72674 /* errno.hpp */, + F44DE94E2D818A48007E4ECC /* base64.hpp */, + F44DE9662D818A49007E4ECC /* exception.hpp */, + F44DE9692D818A49007E4ECC /* chrono.hpp */, + F44DE95C2D818A49007E4ECC /* hash.hpp */, + F44DE9602D818A49007E4ECC /* hex.hpp */, + F44DE96D2D818A4A007E4ECC /* compat.hpp */, + F44DE95F2D818A49007E4ECC /* html.hpp */, + F44DE9702D818A4A007E4ECC /* idrec.hpp */, + F44DE95E2D818A49007E4ECC /* endian.hpp */, + F44DE96F2D818A4A007E4ECC /* interval.hpp */, + F44DE94D2D818A48007E4ECC /* langid.hpp */, + F44DE96B2D818A49007E4ECC /* locale.hpp */, + F44DE9572D818A48007E4ECC /* math.hpp */, + F44DE9552D818A48007E4ECC /* minisign.hpp */, + F44DE9582D818A48007E4ECC /* parser.hpp */, + F44DE96C2D818A4A007E4ECC /* pool.hpp */, + F44DE9592D818A48007E4ECC /* ring.hpp */, + F44DE9512D818A48007E4ECC /* scoped_executor.hpp */, + F44DE9682D818A49007E4ECC /* sgml.hpp */, + F44DE9622D818A49007E4ECC /* socket.hpp */, + F44DE95A2D818A48007E4ECC /* spinlock.hpp */, + F44DE95B2D818A49007E4ECC /* string.hpp */, + F44DE94C2D818A48007E4ECC /* sys_info.hpp */, + F44DE9542D818A48007E4ECC /* unicode.hpp */, + F44DE96A2D818A49007E4ECC /* uuid.hpp */, + F44DE94A2D818A48007E4ECC /* watchdog.hpp */, + F44DE95D2D818A49007E4ECC /* wav.hpp */, + F44DE9522D818A48007E4ECC /* windows.h */, + F44DE9532D818A48007E4ECC /* zlib.hpp */, F4213D1A2ABB14C600F72674 /* exception.hpp */, F4213D262ABB14C600F72674 /* hex.hpp */, F4213D1B2ABB14C600F72674 /* idrec.hpp */, @@ -245,29 +305,29 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - F421D4892B751777004ECBB0 /* stream.cpp in Sources */, - F421D48B2B75177E004ECBB0 /* unicode.cpp in Sources */, + F44DE98A2D818A9F007E4ECC /* zlib.cpp in Sources */, + F44DE9812D818A9F007E4ECC /* ring.cpp in Sources */, F421D47F2B750EAE004ECBB0 /* zutil.c in Sources */, - F4C07F552AB05B5B0044EDC0 /* main.cpp in Sources */, - F421D4882B751774004ECBB0 /* sgml.cpp in Sources */, - F4C07F522AB059580044EDC0 /* pch.cpp in Sources */, - F421D4862B751707004ECBB0 /* pool.cpp in Sources */, + F44DE97F2D818A9F007E4ECC /* math.cpp in Sources */, + F44DE9862D818A9F007E4ECC /* stream.cpp in Sources */, F421D4802B750EAE004ECBB0 /* trees.c in Sources */, - F421D48D2B751783004ECBB0 /* zlib.cpp in Sources */, + F44DE9852D818A9F007E4ECC /* watchdog.cpp in Sources */, + F44DE9802D818A9F007E4ECC /* main.cpp in Sources */, + F44DE98B2D818A9F007E4ECC /* unicode.cpp in Sources */, F421D47D2B750EAE004ECBB0 /* deflate.c in Sources */, - F4481A1A2C73427600CED93B /* langid.cpp in Sources */, + F44DE9832D818A9F007E4ECC /* sgml.cpp in Sources */, + F44DE9882D818A9F007E4ECC /* pch.cpp in Sources */, + F44DE98C2D818A9F007E4ECC /* parser.cpp in Sources */, F421D4702B750E0F004ECBB0 /* adler32.c in Sources */, F421D4822B750EAE004ECBB0 /* uncompr.c in Sources */, F421D4742B750E21004ECBB0 /* crc32.c in Sources */, F421D47E2B750EAE004ECBB0 /* inffast.c in Sources */, F421D4722B750E18004ECBB0 /* compress.c in Sources */, - F421D4872B751739004ECBB0 /* ring.cpp in Sources */, - F421D4852B751551004ECBB0 /* parser.cpp in Sources */, F421D4812B750EAE004ECBB0 /* inftrees.c in Sources */, - F421D4842B7514B5004ECBB0 /* math.cpp in Sources */, - F421D4832B7511FA004ECBB0 /* hash.cpp in Sources */, - F421D48A2B75177B004ECBB0 /* string.cpp in Sources */, - F421D48C2B751780004ECBB0 /* watchdog.cpp in Sources */, + F44DE9842D818A9F007E4ECC /* pool.cpp in Sources */, + F44DE9872D818A9F007E4ECC /* langid.cpp in Sources */, + F44DE9822D818A9F007E4ECC /* hash.cpp in Sources */, + F44DE9892D818A9F007E4ECC /* string.cpp in Sources */, F421D47C2B750EAE004ECBB0 /* inflate.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/UnitTests/string.cpp b/UnitTests/string.cpp index 6973a32a2..52a1985c4 100644 --- a/UnitTests/string.cpp +++ b/UnitTests/string.cpp @@ -1,4 +1,4 @@ -/* +/* SPDX-License-Identifier: MIT Copyright © 2023-2025 Amebis */ @@ -60,13 +60,15 @@ namespace UnitTests { wchar_t buf[8]; - Assert::IsTrue(stdex::snprintf(buf, _countof(buf), L"This is %ls.", locale, L"a test") == 8); - Assert::IsTrue(stdex::strncmp(L"This is a test.", buf, _countof(buf)) == 0); + size_t n = stdex::snprintf(buf, _countof(buf), L"This is %ls.", locale, L"a test"); + Assert::IsTrue(n <= _countof(buf)); + Assert::IsTrue(stdex::strncmp(L"This is a test.", buf, n) == 0); } { char buf[8]; - Assert::IsTrue(stdex::snprintf(buf, _countof(buf), "This is %s.", locale, "a test") == 8); - Assert::IsTrue(stdex::strncmp("This is a test.", buf, _countof(buf)) == 0); + size_t n = stdex::snprintf(buf, _countof(buf), "This is %s.", locale, "a test"); + Assert::IsTrue(n <= _countof(buf)); + Assert::IsTrue(stdex::strncmp("This is a test.", buf, n) == 0); } } } diff --git a/include/stdex/string.hpp b/include/stdex/string.hpp index a2d129d2d..92bc9d828 100644 --- a/include/stdex/string.hpp +++ b/include/stdex/string.hpp @@ -14,7 +14,9 @@ #include #include #include +#ifdef _WIN32 #include +#endif #ifdef __APPLE__ #include #endif @@ -888,8 +890,9 @@ namespace stdex { stdex_assert(str1); stdex_assert(str2); - size_t i; T1 a; T2 b; - for (i = 0; (a = str1[i]) | (b = str2[i]); ++i) { + size_t i; + unsigned int a, b; + for (i = 0; (a = static_cast(str1[i])) | (b = static_cast(str2[i])); ++i) { if (a > b) return +1; if (a < b) return -1; } @@ -912,8 +915,9 @@ namespace stdex { stdex_assert(str1 || !count); stdex_assert(str2 || !count); - size_t i; T1 a; T2 b; - for (i = 0; i < count && ((a = str1[i]) | (b = str2[i])); ++i) { + size_t i; + unsigned int a, b; + for (i = 0; i < count && ((a = static_cast(str1[i])) | (b = static_cast(str2[i]))); ++i) { if (a > b) return +1; if (a < b) return -1; } @@ -940,9 +944,10 @@ namespace stdex stdex_assert(str1 || !count1); stdex_assert(str2 || !count2); size_t i; + unsigned int a, b; for (i = 0; i < count1 && i < count2; ++i) { - auto a = str1[i]; - auto b = str2[i]; + a = static_cast(str1[i]); + b = static_cast(str2[i]); if (!a && !b) return 0; if (a > b) return +1; if (a < b) return -1; @@ -984,7 +989,8 @@ namespace stdex { stdex_assert(str1 || !count1); stdex_assert(str2 || !count2); - size_t i, j, j_next; utf32_t a, b; + size_t i, j, j_next; + utf32_t a, b; for (i = 0, j = 0; i < count1 && j < count2; ++i, j = j_next) { a = str1[i]; if (!a) @@ -1176,9 +1182,10 @@ namespace stdex stdex_assert(str1); stdex_assert(str2); size_t i; + unsigned int a, b; for (i = 0; ; ++i) { - auto a = tolower(str1[i]); - auto b = tolower(str2[i]); + a = static_cast(tolower(str1[i])); + b = static_cast(tolower(str2[i])); if (!a && !b) return 0; if (a > b) return +1; if (a < b) return -1; @@ -1200,11 +1207,12 @@ namespace stdex stdex_assert(str1); stdex_assert(str2); size_t i; + unsigned int a, b; const auto& ctype1 = std::use_facet>(locale); const auto& ctype2 = std::use_facet>(locale); for (i = 0;; ++i) { - auto a = ctype1.tolower(str1[i]); - auto b = ctype2.tolower(str2[i]); + a = static_cast(ctype1.tolower(str1[i])); + b = static_cast(ctype2.tolower(str2[i])); if (!a && !b) return 0; if (a > b) return +1; if (a < b) return -1; @@ -1226,9 +1234,10 @@ namespace stdex stdex_assert(str1 || !count); stdex_assert(str2 || !count); size_t i; + unsigned int a, b; for (i = 0; i < count; ++i) { - auto a = tolower(str1[i]); - auto b = tolower(str2[i]); + a = static_cast(tolower(str1[i])); + b = static_cast(tolower(str2[i])); if (!a && !b) return 0; if (a > b) return +1; if (a < b) return -1; @@ -1254,11 +1263,12 @@ namespace stdex stdex_assert(str1 || !count); stdex_assert(str2 || !count); size_t i; + unsigned int a, b; const auto& ctype1 = std::use_facet>(locale); const auto& ctype2 = std::use_facet>(locale); for (i = 0; i < count; ++i) { - auto a = ctype1.tolower(str1[i]); - auto b = ctype2.tolower(str2[i]); + a = static_cast(ctype1.tolower(str1[i])); + b = static_cast(ctype2.tolower(str2[i])); if (!a && !b) return 0; if (a > b) return +1; if (a < b) return -1; @@ -1286,9 +1296,10 @@ namespace stdex stdex_assert(str1 || !count1); stdex_assert(str2 || !count2); size_t i; + unsigned int a, b; for (i = 0; i < count1 && i < count2; ++i) { - auto a = tolower(str1[i]); - auto b = tolower(str2[i]); + a = static_cast(tolower(str1[i])); + b = static_cast(tolower(str2[i])); if (!a && !b) return 0; if (a > b) return +1; if (a < b) return -1; @@ -1318,11 +1329,12 @@ namespace stdex stdex_assert(str1 || !count1); stdex_assert(str2 || !count2); size_t i; + unsigned int a, b; const auto& ctype1 = std::use_facet>(locale); const auto& ctype2 = std::use_facet>(locale); for (i = 0; i < count1 && i < count2; ++i) { - auto a = ctype1.tolower(str1[i]); - auto b = ctype2.tolower(str2[i]); + a = static_cast(ctype1.tolower(str1[i])); + b = static_cast(ctype2.tolower(str2[i])); if (!a && !b) return 0; if (a > b) return +1; if (a < b) return -1; @@ -1691,7 +1703,9 @@ namespace stdex for (size_t j = 0, i = 0; ; ++j, ++i) { // strcpy has no knowledge, how big the dst buffer is, but we know, we won't be writing more than strlen(src) + 1 characters into it. // Code Analysis somehow doesn't work this out from the code and the dst SAL above, and reports a false-positive warning. +#ifdef _MSC_VER #pragma warning(suppress: 6386) +#endif if ((dst[j] = (is_surrogate_pair(&src[i]) ? surrogate_pair_to_ucs4(&src[i++]) : static_cast(src[i]))) == 0) return j; } @@ -2734,16 +2748,18 @@ namespace stdex /// /// Formats string using `printf()`. /// - /// \param[out] str Output string + /// \param[out] str Output string. When this function returns inline size_t snprintf(_Out_z_cap_(capacity) T* str, _In_ size_t capacity, _In_z_ _Printf_format_string_params_(2) const T* format, _In_opt_ locale_t locale, ...) { + if (!capacity) _Unlikely_ + return 0; va_list arg; va_start(arg, locale); int count = vsnprintf(str, capacity, format, locale, arg); @@ -2763,7 +2779,7 @@ namespace stdex return capacity; #else switch (errno) { - case EOVERFLOW: return capacity; + case EOVERFLOW: return capacity - 1; case EINVAL: throw std::invalid_argument("invalid snprintf arguments"); case EILSEQ: throw std::runtime_error("encoding error"); default: throw std::runtime_error("failed to format string");