libmongocrypt-helper 1.7.4.0.1002 → 1.11.0.0.1001
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +40 -5
- data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +29 -24
- data/ext/libmongocrypt/libmongocrypt/CODEOWNERS +1 -4
- data/ext/libmongocrypt/libmongocrypt/Earthfile +522 -0
- data/ext/libmongocrypt/libmongocrypt/README.md +36 -40
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/CMakeLists.txt +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Driver.snk +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/AssemblyInfo.cs +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Binary.cs +16 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClientFactory.cs +8 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +35 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/LibraryLoader.cs +81 -44
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/MongoDB.Libmongocrypt.csproj +2 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/MongoDB.Libmongocrypt.Test.csproj +2 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test32/MongoDB.Libmongocrypt.Test32.csproj +2 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/README.md +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +22 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.config +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.sh +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/build.gradle.kts +28 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/java/com/mongodb/crypt/benchmark/BenchmarkRunner.java +217 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/resources/keyDocument.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +22 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.properties +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew +154 -108
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew.bat +7 -18
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/settings.gradle.kts +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPI.java +41 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPIHelper.java +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CipherCallback.java +27 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptImpl.java +34 -19
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoExplicitEncryptOptions.java +6 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/jni-config.json +180 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/reflect-config.json +134 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +50 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/{python/test/data/fle2-find-range-explicit → java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2}/int32/rangeopts.json +3 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +4 -771
- data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +86 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +41 -20
- data/ext/libmongocrypt/libmongocrypt/bindings/python/RELEASE.rst +6 -24
- data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +4 -13
- data/ext/libmongocrypt/libmongocrypt/bindings/python/hatch_build.py +36 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/libmongocrypt-version.txt +1 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/__init__.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/auto_encrypter.py +61 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/credentials.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/explicit_encrypter.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/state_machine.py +149 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/auto_encrypter.py +2 -46
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binary.py +14 -17
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +232 -296
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +6 -31
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/credentials.py +2 -121
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/crypto.py +31 -20
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/errors.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +2 -233
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +168 -254
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/options.py +265 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/state_machine.py +2 -141
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/auto_encrypter.py +61 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/credentials.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/explicit_encrypter.py +156 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/state_machine.py +149 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pyproject.toml +118 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +97 -61
- data/ext/libmongocrypt/libmongocrypt/bindings/python/requirements-test.txt +7 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/requirements.txt +4 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/sbom.json +76 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/strip_header.py +6 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/python/synchro.py +64 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +2 -10
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/collection-info.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/command.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/encrypted-payload.json +21 -21
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-command-reply.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-field-config-map.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/rangeopts.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-azure.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document-gcp.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-document.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/key-filter.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/list-collections-filter.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-command.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/mongocryptd-reply.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/schema-map.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/performance/keyDocument.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/performance/perf_test.py +165 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_binding.py +8 -12
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_crypto.py +9 -11
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +991 -343
- data/ext/libmongocrypt/libmongocrypt/bindings/python/update-sbom.sh +14 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/FetchMongoC.cmake +19 -1
- data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +31 -6
- data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +20 -227
- data/ext/libmongocrypt/libmongocrypt/cmake/Patch.cmake +54 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
- data/ext/libmongocrypt/libmongocrypt/doc/img/cli-icon.png +0 -0
- data/ext/libmongocrypt/libmongocrypt/doc/img/reference-targets.png +0 -0
- data/ext/libmongocrypt/libmongocrypt/doc/releasing.md +153 -0
- data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
- data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version.py +61 -28
- data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version_selftest.sh +73 -0
- data/ext/libmongocrypt/libmongocrypt/etc/cyclonedx.sbom.json +108 -0
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +15 -24
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +66 -54
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +14 -23
- data/ext/libmongocrypt/libmongocrypt/etc/fle2v2_aead_generate_tests.py +32 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format-all.sh +12 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format.sh +16 -0
- data/ext/libmongocrypt/libmongocrypt/etc/install-package.sh +48 -0
- data/ext/libmongocrypt/libmongocrypt/etc/libbson-remove-GCC-diagnostic-pragma.patch +27 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-alpine-arm-fix.patch +17 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
- data/ext/libmongocrypt/libmongocrypt/etc/packager.py +120 -91
- data/ext/libmongocrypt/libmongocrypt/etc/purls.txt +14 -0
- data/ext/libmongocrypt/libmongocrypt/etc/repo_config.yaml +56 -0
- data/ext/libmongocrypt/libmongocrypt/etc/silk-create-asset-group.sh +70 -0
- data/ext/libmongocrypt/libmongocrypt/etc/ssdlc_compliance_report.md +37 -0
- data/ext/libmongocrypt/libmongocrypt/etc/third_party_vulnerabilities.md +42 -0
- data/ext/libmongocrypt/libmongocrypt/integrating.md +18 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/CMakeLists.txt +11 -3
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_gcp_request.c +1 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer.c +17 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer_private.h +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_request.c +211 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_response.c +163 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_tag_type_private.h +2 -1
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_request.h +17 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message/kms_kmip_response.h +6 -0
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_port.c +3 -2
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request.c +4 -2
- data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.c +2 -2
- data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kmip_reader_writer.c +23 -2
- data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +381 -436
- data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +162 -227
- data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +183 -248
- data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +33 -55
- data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +175 -205
- data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +10 -21
- data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +44 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +4 -8
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +351 -463
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +59 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +21 -11
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +175 -99
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +69 -70
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +445 -439
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +41 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +11 -18
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +135 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +109 -126
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +103 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +28 -31
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +173 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +106 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +130 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +36 -44
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +382 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +237 -278
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +133 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +67 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +437 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +454 -325
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common-private.h +69 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +182 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +23 -31
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2-private.h +85 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2.c +142 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +104 -231
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +8 -7
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +56 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +520 -580
- data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +47 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +67 -76
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +201 -190
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +55 -42
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +809 -558
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +177 -201
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +54 -53
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +188 -240
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +43 -35
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +484 -337
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +36 -71
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +111 -164
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +87 -65
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +153 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +66 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +141 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +37 -55
- data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +11 -11
- data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +27 -32
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +461 -499
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +256 -334
- data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +4 -5
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +196 -231
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +56 -79
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +411 -530
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +116 -131
- data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +17 -26
- data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +1 -9
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +31 -48
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +55 -131
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +442 -565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +28 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +11 -17
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +104 -132
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +16 -24
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +110 -93
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +26 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +220 -273
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +13 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +110 -204
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1145 -1567
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +510 -476
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2775 -2697
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +189 -184
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +990 -1139
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +23 -24
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +44 -58
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +21 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +167 -181
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +42 -44
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +292 -272
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +70 -110
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +1010 -1033
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +27 -44
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +349 -402
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +127 -120
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1692 -1611
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +35 -67
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +49 -83
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +31 -36
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1923 -1479
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +124 -107
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +925 -419
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +99 -122
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +3 -8
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +92 -119
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +19 -29
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +136 -176
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +11 -21
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +98 -136
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +924 -1339
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +199 -313
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +83 -79
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +64 -73
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +8 -16
- data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +57 -87
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/bypassQueryAnalysis/payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd-to-mongocryptd.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/cmd-to-mongocryptd.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/cmd.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/collinfo.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/encrypted-field-map.json +24 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/encrypted-payload-pattern.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/simple/mongocryptd-reply.json +62 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/cmd-to-mongocryptd.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/cmd.json +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/mongocryptd-reply.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/payload.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/missing-key-id/collinfo.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/collinfo.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/encrypted-payload.json +4 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/collinfo.json +63 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-field-config-map.json +61 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload-range-v2.json +37 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/collinfo.json +64 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload-range-v2.json +105 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/cmd.json +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/collinfo.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-field-config-map.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-payload.json +23 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/collinfo.json +15 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-field-config-map.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload-range-v2.json +104 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +60 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +67 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/collinfo.json +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +5 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/mongocryptd-reply.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/cmd.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +58 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/cmd.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +132 -132
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +71 -71
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +61 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/mongocryptd-reply.json +55 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +15 -15
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-field-map.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-payload.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/mongocryptd-reply.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-payload.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneRangeV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/decrypt-response.txt +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/encrypt-response.txt +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/kms-azure/oauth-response.txt +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/encrypted-payload.json +62 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/find/mongocryptd-reply.json +69 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/no-trimFactor/insert/mongocryptd-reply.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_decimal128.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_double.cstruct +8637 -7958
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int32.cstruct +5522 -1382
- data/ext/libmongocrypt/libmongocrypt/test/data/range-edge-generation/edges_int64.cstruct +5042 -1262
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_decimal128_precision.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_double_precision.cstruct +2 -2
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int32.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-min-cover/mincover_int64.cstruct +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/encrypted-payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-find-int32/mongocryptd-reply.json +58 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/encrypted-field-map.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/auto-insert-int32/mongocryptd-reply.json +45 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32/expected.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32/to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32-defaults/expected.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-find-int32-defaults/to-encrypt.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-double/expected.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-int32/expected.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/range-sends-cryptoParams/explicit-insert-int32-defaults/expected.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/README.md +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/aes-ctr.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-fixed.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-generated.json +38 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-decrypt.json +35 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/mcgrew.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/nist.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +25 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +25 -0
- data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +279 -323
- data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +8 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +6 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +221 -283
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +60 -73
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +78 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +129 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +248 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +467 -414
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +248 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +141 -159
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev-v2.c +338 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +238 -176
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +373 -474
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +421 -388
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +974 -825
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +499 -481
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +312 -148
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +249 -213
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +632 -808
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +22 -2
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +168 -189
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +187 -211
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +118 -37
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +210 -233
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +185 -220
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cleanup.c +374 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +410 -445
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +798 -812
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +142 -135
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +70 -71
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +394 -846
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +159 -183
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +870 -1045
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +5183 -4717
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +1093 -1178
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +348 -420
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +23 -30
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +98 -111
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +49 -52
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +770 -920
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +354 -407
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +197 -245
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +705 -368
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +50 -61
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +85 -100
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +1073 -690
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-opts.c +42 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +381 -451
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +55 -67
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +7 -10
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +879 -918
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +119 -169
- data/ext/libmongocrypt/libmongocrypt/test/test-named-kms-providers.c +2381 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/HELP.autogen +3 -1
- data/ext/libmongocrypt/libmongocrypt/test/util/README.md +1 -0
- data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +512 -559
- data/ext/libmongocrypt/libmongocrypt/test/util/make_includes.py +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/util/util.c +771 -882
- data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
- data/lib/libmongocrypt_helper/version.rb +2 -2
- metadata +245 -111
- checksums.yaml.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +0 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +0 -81
- data/ext/libmongocrypt/libmongocrypt/bindings/node/LICENSE +0 -201
- data/ext/libmongocrypt/libmongocrypt/bindings/node/binding.gyp +0 -79
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/README.hbs +0 -44
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +0 -39
- data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +0 -515
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +0 -420
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/buffer_pool.js +0 -123
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +0 -699
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +0 -100
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/cryptoCallbacks.js +0 -87
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +0 -42
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/mongocryptdManager.js +0 -66
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +0 -487
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +0 -16051
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +0 -81
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +0 -929
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.h +0 -114
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +0 -953
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/buffer_pool.test.js +0 -91
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +0 -701
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +0 -284
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/README.md +0 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/cmd.json +0 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/collection-info.json +0 -37
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document-nested.json +0 -8
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encrypted-document.json +0 -11
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/encryptedFields.json +0 -30
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key-document.json +0 -32
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/key1-document.json +0 -30
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/data/mongocryptd-reply.json +0 -18
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +0 -48
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +0 -59
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +0 -29
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +0 -331
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/mongodb_reporter.js +0 -325
- data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +0 -84
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +0 -12
- data/ext/libmongocrypt/libmongocrypt/debian/build_snapshot.sh +0 -79
- data/ext/libmongocrypt/libmongocrypt/debian/changelog +0 -105
- data/ext/libmongocrypt/libmongocrypt/debian/compat +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/control +0 -41
- data/ext/libmongocrypt/libmongocrypt/debian/copyright +0 -129
- data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +0 -23
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.dirs +0 -2
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt-dev.install +0 -5
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.dirs +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/libmongocrypt0.install +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/rules +0 -46
- data/ext/libmongocrypt/libmongocrypt/debian/source/format +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/source/lintian-overrides +0 -3
- data/ext/libmongocrypt/libmongocrypt/debian/source/options +0 -1
- data/ext/libmongocrypt/libmongocrypt/debian/watch +0 -3
- data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
- data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/mongocryptd-reply.json +0 -72
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +0 -109
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +0 -70
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +0 -8
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +0 -33
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/key-filter.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/{java/mongocrypt/src/test/resources/fle2-find-range-explicit → python/test/data/fle2-find-rangePreview-explicit}/int32/rangeopts.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/{test/data/fle2-find-range-explicit/int32-nominmax → bindings/python/test/data/fle2-find-rangePreview-explicit/int32}/value-to-encrypt.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/{bindings/node/test/data/kms-decrypt-reply.txt → test/data/kms-aws/decrypt-response.txt} +0 -0
- /data/ext/libmongocrypt/libmongocrypt/{bindings/node/test/data/kms-encrypt-reply.txt → test/data/kms-aws/encrypt-response.txt} +0 -0
- /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/decrypt-response.txt +0 -0
- /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/encrypt-response.txt +0 -0
- /data/ext/libmongocrypt/libmongocrypt/test/data/{gcp-auth → kms-gcp}/oauth-response.txt +0 -0
@@ -1,17 +1,17 @@
|
|
1
1
|
#ifndef MONGOCRYPT_STR_PRIVATE_H
|
2
2
|
#define MONGOCRYPT_STR_PRIVATE_H
|
3
3
|
|
4
|
-
#include "./user-check.h"
|
5
4
|
#include "./macros.h"
|
5
|
+
#include "./user-check.h"
|
6
6
|
|
7
|
-
#include <stdlib.h>
|
8
|
-
#include <string.h>
|
9
7
|
#include <assert.h>
|
10
|
-
#include <stddef.h>
|
11
|
-
#include <stdio.h>
|
12
8
|
#include <inttypes.h>
|
13
9
|
#include <limits.h> /* INT_MAX */
|
14
10
|
#include <stdbool.h>
|
11
|
+
#include <stddef.h>
|
12
|
+
#include <stdio.h>
|
13
|
+
#include <stdlib.h>
|
14
|
+
#include <string.h>
|
15
15
|
|
16
16
|
#if defined(MLIB_HAVE_STRINGS_H)
|
17
17
|
#include <strings.h> /* For strncasecmp. */
|
@@ -31,18 +31,18 @@ MLIB_C_LINKAGE_BEGIN
|
|
31
31
|
* @ref mstr object, OR returned from @ref mstrv_view_cstr.
|
32
32
|
*/
|
33
33
|
typedef struct mstr_view {
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
34
|
+
/**
|
35
|
+
* @brief Pointer to the beginning of the code unit array.
|
36
|
+
*
|
37
|
+
* @note DO NOT MODIFY
|
38
|
+
*/
|
39
|
+
const char *data;
|
40
|
+
/**
|
41
|
+
* @brief Length of the pointed-to code unit array
|
42
|
+
*
|
43
|
+
* @note DO NOT MODIFY
|
44
|
+
*/
|
45
|
+
size_t len;
|
46
46
|
} mstr_view;
|
47
47
|
|
48
48
|
/**
|
@@ -71,26 +71,27 @@ typedef struct mstr_view {
|
|
71
71
|
* Passing or returning an `mstr_view` is non-owning.
|
72
72
|
*/
|
73
73
|
typedef struct mstr {
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
74
|
+
union {
|
75
|
+
struct {
|
76
|
+
/**
|
77
|
+
* @brief Pointer to the beginning of the code unit array.
|
78
|
+
*
|
79
|
+
* @note DO NOT MODIFY
|
80
|
+
*/
|
81
|
+
const char *data;
|
82
|
+
/**
|
83
|
+
* @brief Length of the pointed-to code unit array
|
84
|
+
*
|
85
|
+
* @note DO NOT MODIFY
|
86
|
+
*/
|
87
|
+
size_t len;
|
88
|
+
};
|
89
|
+
|
90
|
+
/**
|
91
|
+
* @brief A non-owning `mstr_view` of the string
|
92
|
+
*/
|
93
|
+
mstr_view view;
|
94
|
+
};
|
94
95
|
} mstr;
|
95
96
|
|
96
97
|
/**
|
@@ -100,42 +101,42 @@ typedef struct mstr {
|
|
100
101
|
* be used as an @ref mstr by accessing the @ref mstr_mut::mstr member.
|
101
102
|
*/
|
102
103
|
typedef struct mstr_mut {
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
104
|
+
union {
|
105
|
+
struct {
|
106
|
+
/**
|
107
|
+
* @brief Pointer to the beginning of the mutable code unit array.
|
108
|
+
*
|
109
|
+
* @note DO NOT MODIFY THE POINTER VALUE. Only modify the pointed-to
|
110
|
+
* characters.
|
111
|
+
*/
|
112
|
+
char *data;
|
113
|
+
/**
|
114
|
+
* @brief Length of the pointed-to code unit array.
|
115
|
+
*
|
116
|
+
* @note DO NOT MODIFY
|
117
|
+
*/
|
118
|
+
size_t len;
|
119
|
+
};
|
120
|
+
/// Convert the mutable string to an immutable string
|
121
|
+
struct mstr mstr;
|
122
|
+
/// Convert the mutable string to an immutable string view
|
123
|
+
mstr_view view;
|
124
|
+
};
|
124
125
|
} mstr_mut;
|
125
126
|
|
126
127
|
/**
|
127
128
|
* @brief A null @ref mstr
|
128
129
|
*/
|
129
|
-
#define MSTR_NULL (MLIB_INIT
|
130
|
+
#define MSTR_NULL (MLIB_INIT(mstr){{{NULL, 0}}})
|
130
131
|
/**
|
131
132
|
* @brief A null @ref mstr_view
|
132
133
|
*/
|
133
|
-
#define MSTRV_NULL (MLIB_INIT
|
134
|
+
#define MSTRV_NULL (MLIB_INIT(mstr_view){NULL, 0})
|
134
135
|
|
135
136
|
/**
|
136
137
|
* @brief Create an @ref mstr_view that views the given string literal
|
137
138
|
*/
|
138
|
-
#define mstrv_lit(String) (mstrv_view_data
|
139
|
+
#define mstrv_lit(String) (mstrv_view_data(String "", (sizeof String) - 1))
|
139
140
|
|
140
141
|
/**
|
141
142
|
* @brief Create a new mutable code-unit array of the given length,
|
@@ -149,16 +150,14 @@ typedef struct mstr_mut {
|
|
149
150
|
* @note The @ref mstr_mut::mstr member MUST eventually be given to
|
150
151
|
* @ref mstr_free().
|
151
152
|
*/
|
152
|
-
static inline mstr_mut
|
153
|
-
mstr_new (size_t len)
|
154
|
-
{
|
153
|
+
static inline mstr_mut mstr_new(size_t len) {
|
155
154
|
#ifndef __clang_analyzer__
|
156
|
-
|
157
|
-
|
155
|
+
assert(len < SIZE_MAX);
|
156
|
+
return MLIB_INIT(mstr_mut){{{(char *)calloc(1, len + 1), len}}};
|
158
157
|
#else
|
159
|
-
|
160
|
-
|
161
|
-
|
158
|
+
// Clang-analyzer is smart enough to see the calloc(), but not smart enough
|
159
|
+
// to link it to the free() in mstr_free()
|
160
|
+
return MLIB_INIT(mstr_mut){};
|
162
161
|
#endif
|
163
162
|
}
|
164
163
|
|
@@ -169,10 +168,8 @@ mstr_new (size_t len)
|
|
169
168
|
* @param len The length of the character array, in code units
|
170
169
|
* @return mstr_view A non-owning string.
|
171
170
|
*/
|
172
|
-
static inline mstr_view
|
173
|
-
|
174
|
-
{
|
175
|
-
return MLIB_INIT (mstr_view){s, len};
|
171
|
+
static inline mstr_view mstrv_view_data(const char *s, size_t len) {
|
172
|
+
return MLIB_INIT(mstr_view){s, len};
|
176
173
|
}
|
177
174
|
|
178
175
|
/**
|
@@ -182,10 +179,8 @@ mstrv_view_data (const char *s, size_t len)
|
|
182
179
|
* @param s A pointer to a null-terminated character array
|
183
180
|
* @return mstr_view A view of the pointed-to string
|
184
181
|
*/
|
185
|
-
static inline mstr_view
|
186
|
-
|
187
|
-
{
|
188
|
-
return mstrv_view_data (s, strlen (s));
|
182
|
+
static inline mstr_view mstrv_view_cstr(const char *s) {
|
183
|
+
return mstrv_view_data(s, strlen(s));
|
189
184
|
}
|
190
185
|
|
191
186
|
/**
|
@@ -198,12 +193,10 @@ mstrv_view_cstr (const char *s)
|
|
198
193
|
*
|
199
194
|
* @note The resulting string will be null-terminated.
|
200
195
|
*/
|
201
|
-
static inline mstr
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
memcpy (r.data, s, len);
|
206
|
-
return r.mstr;
|
196
|
+
static inline mstr mstr_copy_data(const char *s, size_t len) {
|
197
|
+
mstr_mut r = mstr_new(len);
|
198
|
+
memcpy(r.data, s, len);
|
199
|
+
return r.mstr;
|
207
200
|
}
|
208
201
|
|
209
202
|
/**
|
@@ -212,10 +205,8 @@ mstr_copy_data (const char *s, size_t len)
|
|
212
205
|
* @param s A pointer to a null-terminated character array
|
213
206
|
* @return mstr A new string copied from the pointed-to string
|
214
207
|
*/
|
215
|
-
static inline mstr
|
216
|
-
|
217
|
-
{
|
218
|
-
return mstr_copy_data (s, strlen (s));
|
208
|
+
static inline mstr mstr_copy_cstr(const char *s) {
|
209
|
+
return mstr_copy_data(s, strlen(s));
|
219
210
|
}
|
220
211
|
|
221
212
|
/**
|
@@ -224,10 +215,8 @@ mstr_copy_cstr (const char *s)
|
|
224
215
|
* @param s A string view to copy from
|
225
216
|
* @return mstr A new string copied from the given view
|
226
217
|
*/
|
227
|
-
static inline mstr
|
228
|
-
|
229
|
-
{
|
230
|
-
return mstr_copy_data (s.data, s.len);
|
218
|
+
static inline mstr mstr_copy(mstr_view s) {
|
219
|
+
return mstr_copy_data(s.data, s.len);
|
231
220
|
}
|
232
221
|
|
233
222
|
/**
|
@@ -235,10 +224,8 @@ mstr_copy (mstr_view s)
|
|
235
224
|
*
|
236
225
|
* @param s The string to free
|
237
226
|
*/
|
238
|
-
static inline void
|
239
|
-
|
240
|
-
{
|
241
|
-
free ((char *) s.data);
|
227
|
+
static inline void mstr_free(mstr s) {
|
228
|
+
free((char *)s.data);
|
242
229
|
}
|
243
230
|
|
244
231
|
/**
|
@@ -248,24 +235,22 @@ mstr_free (mstr s)
|
|
248
235
|
* @param s The @ref mstr_mut to update
|
249
236
|
* @param new_len The new length of the string
|
250
237
|
*/
|
251
|
-
static inline void
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
} else {
|
257
|
-
const size_t old_len = s->len;
|
238
|
+
static inline void mstrm_resize(mstr_mut *s, size_t new_len) {
|
239
|
+
if (new_len <= s->len) {
|
240
|
+
s->len = new_len;
|
241
|
+
} else {
|
242
|
+
const size_t old_len = s->len;
|
258
243
|
#ifndef __clang_analyzer__
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
244
|
+
// Clang-analyzer is smart enough to see the calloc(), but not smart
|
245
|
+
// enough to link it to the free() in mstr_free()
|
246
|
+
assert(new_len < SIZE_MAX);
|
247
|
+
s->data = (char *)realloc((char *)s->data, new_len + 1);
|
263
248
|
#endif
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
249
|
+
s->len = new_len;
|
250
|
+
assert(new_len >= old_len);
|
251
|
+
memset(s->data + old_len, 0, new_len - old_len);
|
252
|
+
}
|
253
|
+
s->data[new_len] = (char)0;
|
269
254
|
}
|
270
255
|
|
271
256
|
/**
|
@@ -294,11 +279,9 @@ mstrm_resize (mstr_mut *s, size_t new_len)
|
|
294
279
|
* mstr_assign(&s, convert_to_uppercase(s.view));
|
295
280
|
* ```
|
296
281
|
*/
|
297
|
-
static inline void
|
298
|
-
|
299
|
-
|
300
|
-
mstr_free (*s);
|
301
|
-
*s = from;
|
282
|
+
static inline void mstr_assign(mstr *s, mstr from) {
|
283
|
+
mstr_free(*s);
|
284
|
+
*s = from;
|
302
285
|
}
|
303
286
|
|
304
287
|
/**
|
@@ -310,31 +293,28 @@ mstr_assign (mstr *s, mstr from)
|
|
310
293
|
* @return int The zero-based index of the first instance of `needle` in
|
311
294
|
* `given`, or -1 if no substring is found.
|
312
295
|
*/
|
313
|
-
static inline int
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
(void) 0;
|
336
|
-
}
|
337
|
-
return -1;
|
296
|
+
static inline int mstr_find(mstr_view given, mstr_view needle) {
|
297
|
+
const char *const scan_end = given.data + given.len;
|
298
|
+
const char *const needle_end = needle.data + needle.len;
|
299
|
+
for (const char *scan = given.data; scan != scan_end; ++scan) {
|
300
|
+
size_t remain = (size_t)(scan_end - scan);
|
301
|
+
if (remain < needle.len) {
|
302
|
+
break;
|
303
|
+
}
|
304
|
+
const char *subscan = scan;
|
305
|
+
for (const char *nscan = needle.data; nscan != needle_end; ++nscan, ++subscan) {
|
306
|
+
if (*nscan == *subscan) {
|
307
|
+
continue;
|
308
|
+
} else {
|
309
|
+
goto skip;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
// Got through the whole loop of scanning the needle
|
313
|
+
return (int)(scan - given.data);
|
314
|
+
skip:
|
315
|
+
(void)0;
|
316
|
+
}
|
317
|
+
return -1;
|
338
318
|
}
|
339
319
|
|
340
320
|
/**
|
@@ -346,30 +326,27 @@ mstr_find (mstr_view given, mstr_view needle)
|
|
346
326
|
* @return int The zero-based index of the last instance of `needle` in
|
347
327
|
* `given`, or -1 if no substring is found.
|
348
328
|
*/
|
349
|
-
static inline int
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
(void) 0;
|
371
|
-
}
|
372
|
-
return -1;
|
329
|
+
static inline int mstr_rfind(mstr_view given, mstr_view needle) {
|
330
|
+
if (needle.len > given.len) {
|
331
|
+
return -1;
|
332
|
+
}
|
333
|
+
const char *scan = given.data + given.len - needle.len;
|
334
|
+
const char *const needle_end = needle.data + needle.len;
|
335
|
+
for (; scan >= given.data; --scan) {
|
336
|
+
const char *subscan = scan;
|
337
|
+
for (const char *nscan = needle.data; nscan != needle_end; ++nscan, ++subscan) {
|
338
|
+
if (*nscan == *subscan) {
|
339
|
+
continue;
|
340
|
+
} else {
|
341
|
+
goto skip;
|
342
|
+
}
|
343
|
+
}
|
344
|
+
// Got through the whole loop of scanning the needle
|
345
|
+
return (int)(scan - given.data);
|
346
|
+
skip:
|
347
|
+
(void)0;
|
348
|
+
}
|
349
|
+
return -1;
|
373
350
|
}
|
374
351
|
|
375
352
|
/**
|
@@ -382,47 +359,41 @@ mstr_rfind (mstr_view given, mstr_view needle)
|
|
382
359
|
* @param insert The string to insert at `at`.
|
383
360
|
* @return mstr A new string that is the result of the splice
|
384
361
|
*/
|
385
|
-
static inline mstr
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
memcpy (p, s.data + at + del_count, s.len - at - del_count);
|
407
|
-
return ret.mstr;
|
362
|
+
static inline mstr mstr_splice(mstr_view s, size_t at, size_t del_count, mstr_view insert) {
|
363
|
+
assert(at <= s.len);
|
364
|
+
const size_t remain = s.len - at;
|
365
|
+
if (del_count > remain) {
|
366
|
+
del_count = remain;
|
367
|
+
}
|
368
|
+
/* at this point, it is absolutely necessary that del_count <= s.len */
|
369
|
+
assert(s.len - del_count <= SIZE_MAX - insert.len);
|
370
|
+
const size_t new_size = s.len - del_count + insert.len;
|
371
|
+
mstr_mut ret = mstr_new(new_size);
|
372
|
+
char *p = ret.data;
|
373
|
+
memcpy(p, s.data, at);
|
374
|
+
p += at;
|
375
|
+
if (insert.data) {
|
376
|
+
memcpy(p, insert.data, insert.len);
|
377
|
+
p += insert.len;
|
378
|
+
}
|
379
|
+
/* 'at <= s.len' was already asserted earlier */
|
380
|
+
assert(s.len - at >= del_count);
|
381
|
+
memcpy(p, s.data + at + del_count, s.len - at - del_count);
|
382
|
+
return ret.mstr;
|
408
383
|
}
|
409
384
|
|
410
385
|
/**
|
411
386
|
* @brief Append the given suffix to the given string
|
412
387
|
*/
|
413
|
-
static inline mstr
|
414
|
-
|
415
|
-
{
|
416
|
-
return mstr_splice (s, s.len, 0, suffix);
|
388
|
+
static inline mstr mstr_append(mstr_view s, mstr_view suffix) {
|
389
|
+
return mstr_splice(s, s.len, 0, suffix);
|
417
390
|
}
|
418
391
|
|
419
392
|
/**
|
420
393
|
* @brief Prepend the given prefix to the given string
|
421
394
|
*/
|
422
|
-
static inline mstr
|
423
|
-
|
424
|
-
{
|
425
|
-
return mstr_splice (s, 0, 0, prefix);
|
395
|
+
static inline mstr mstr_prepend(mstr_view s, mstr_view prefix) {
|
396
|
+
return mstr_splice(s, 0, 0, prefix);
|
426
397
|
}
|
427
398
|
|
428
399
|
/**
|
@@ -433,10 +404,8 @@ mstr_prepend (mstr_view s, mstr_view prefix)
|
|
433
404
|
* @param infix The string to insert into `s`
|
434
405
|
* @return mstr A new string with `infix` inserted
|
435
406
|
*/
|
436
|
-
static inline mstr
|
437
|
-
|
438
|
-
{
|
439
|
-
return mstr_splice (s, at, 0, infix);
|
407
|
+
static inline mstr mstr_insert(mstr_view s, size_t at, mstr_view infix) {
|
408
|
+
return mstr_splice(s, at, 0, infix);
|
440
409
|
}
|
441
410
|
|
442
411
|
/**
|
@@ -447,29 +416,23 @@ mstr_insert (mstr_view s, size_t at, mstr_view infix)
|
|
447
416
|
* @param count The number of characters to remove
|
448
417
|
* @return mstr A new string with the deletion result.
|
449
418
|
*/
|
450
|
-
static inline mstr
|
451
|
-
|
452
|
-
{
|
453
|
-
return mstr_splice (s, at, count, mstrv_view_cstr (""));
|
419
|
+
static inline mstr mstr_erase(mstr_view s, size_t at, size_t count) {
|
420
|
+
return mstr_splice(s, at, count, mstrv_view_cstr(""));
|
454
421
|
}
|
455
422
|
|
456
423
|
/**
|
457
424
|
* @brief Erase `len` characters from the beginning of the string
|
458
425
|
*/
|
459
|
-
static inline mstr
|
460
|
-
|
461
|
-
{
|
462
|
-
return mstr_erase (s, 0, len);
|
426
|
+
static inline mstr mstr_remove_prefix(mstr_view s, size_t len) {
|
427
|
+
return mstr_erase(s, 0, len);
|
463
428
|
}
|
464
429
|
|
465
430
|
/**
|
466
431
|
* @brief Erase `len` characters from the end of the string
|
467
432
|
*/
|
468
|
-
static inline mstr
|
469
|
-
|
470
|
-
|
471
|
-
assert (s.len >= len);
|
472
|
-
return mstr_erase (s, s.len - len, len);
|
433
|
+
static inline mstr mstr_remove_suffix(mstr_view s, size_t len) {
|
434
|
+
assert(s.len >= len);
|
435
|
+
return mstr_erase(s, s.len - len, len);
|
473
436
|
}
|
474
437
|
|
475
438
|
/**
|
@@ -481,17 +444,15 @@ mstr_remove_suffix (mstr_view s, size_t len)
|
|
481
444
|
* remaining length.
|
482
445
|
* @return mstr A new string that is a substring of `s`
|
483
446
|
*/
|
484
|
-
static inline mstr
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
memcpy (r.data, s.data + at, len);
|
494
|
-
return r.mstr;
|
447
|
+
static inline mstr mstr_substr(mstr_view s, size_t at, size_t len) {
|
448
|
+
assert(at <= s.len);
|
449
|
+
const size_t remain = s.len - at;
|
450
|
+
if (len > remain) {
|
451
|
+
len = remain;
|
452
|
+
}
|
453
|
+
mstr_mut r = mstr_new(len);
|
454
|
+
memcpy(r.data, s.data + at, len);
|
455
|
+
return r.mstr;
|
495
456
|
}
|
496
457
|
|
497
458
|
/**
|
@@ -503,36 +464,30 @@ mstr_substr (mstr_view s, size_t at, size_t len)
|
|
503
464
|
* remaining length.
|
504
465
|
* @return mstr_view A view of `s`.
|
505
466
|
*/
|
506
|
-
static inline mstr_view
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
}
|
514
|
-
return mstrv_view_data (s.data + at, len);
|
467
|
+
static inline mstr_view mstrv_subview(mstr_view s, size_t at, size_t len) {
|
468
|
+
assert(at <= s.len);
|
469
|
+
const size_t remain = s.len - at;
|
470
|
+
if (len > remain) {
|
471
|
+
len = remain;
|
472
|
+
}
|
473
|
+
return mstrv_view_data(s.data + at, len);
|
515
474
|
}
|
516
475
|
|
517
476
|
/**
|
518
477
|
* @brief Obtain a view of another string by removing `len` characters from the
|
519
478
|
* front
|
520
479
|
*/
|
521
|
-
static inline mstr_view
|
522
|
-
|
523
|
-
{
|
524
|
-
return mstrv_subview (s, len, s.len);
|
480
|
+
static inline mstr_view mstrv_remove_prefix(mstr_view s, size_t len) {
|
481
|
+
return mstrv_subview(s, len, s.len);
|
525
482
|
}
|
526
483
|
|
527
484
|
/**
|
528
485
|
* @brief Obtain a view of another string by removing `len` characters from the
|
529
486
|
* end.
|
530
487
|
*/
|
531
|
-
static inline mstr_view
|
532
|
-
|
533
|
-
|
534
|
-
assert (s.len >= len);
|
535
|
-
return mstrv_subview (s, 0, s.len - len);
|
488
|
+
static inline mstr_view mstrv_remove_suffix(mstr_view s, size_t len) {
|
489
|
+
assert(s.len >= len);
|
490
|
+
return mstrv_subview(s, 0, s.len - len);
|
536
491
|
}
|
537
492
|
|
538
493
|
/**
|
@@ -542,11 +497,9 @@ mstrv_remove_suffix (mstr_view s, size_t len)
|
|
542
497
|
* @param new_len The new length of the string
|
543
498
|
* @return mstr A new string copied from the beginning of `s`
|
544
499
|
*/
|
545
|
-
static inline mstr
|
546
|
-
|
547
|
-
|
548
|
-
assert (new_len <= s.len);
|
549
|
-
return mstr_remove_suffix (s, s.len - new_len);
|
500
|
+
static inline mstr mstr_trunc(mstr_view s, size_t new_len) {
|
501
|
+
assert(new_len <= s.len);
|
502
|
+
return mstr_remove_suffix(s, s.len - new_len);
|
550
503
|
}
|
551
504
|
|
552
505
|
/**
|
@@ -560,134 +513,113 @@ mstr_trunc (mstr_view s, size_t new_len)
|
|
560
513
|
*
|
561
514
|
* @note If `find` is empty, returns a copy of `string`
|
562
515
|
*/
|
563
|
-
static inline mstr
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
// Advance our position by how many chars we skipped and how many we
|
590
|
-
// inserted
|
591
|
-
whence += (size_t) pos + subst.len;
|
592
|
-
}
|
593
|
-
return ret;
|
516
|
+
static inline mstr mstr_replace(const mstr_view string, const mstr_view find, const mstr_view subst) {
|
517
|
+
if (find.len == 0) {
|
518
|
+
// Finding an empty string would loop forever
|
519
|
+
return mstr_copy(string);
|
520
|
+
}
|
521
|
+
// First copy the string
|
522
|
+
mstr ret = mstr_copy(string);
|
523
|
+
// Keep an index of how far we have processed
|
524
|
+
size_t whence = 0;
|
525
|
+
for (;;) {
|
526
|
+
// Chop off the front that has already been processed
|
527
|
+
mstr_view tail = mstrv_subview(ret.view, whence, SIZE_MAX);
|
528
|
+
// Find where in that tail is the next needle
|
529
|
+
int pos = mstr_find(tail, find);
|
530
|
+
if (pos == -1) {
|
531
|
+
// We're done
|
532
|
+
break;
|
533
|
+
}
|
534
|
+
// Do the replacement
|
535
|
+
assert(whence <= SIZE_MAX - (size_t)pos);
|
536
|
+
mstr_assign(&ret, mstr_splice(ret.view, (size_t)pos + whence, find.len, subst));
|
537
|
+
// Advance our position by how many chars we skipped and how many we
|
538
|
+
// inserted
|
539
|
+
whence += (size_t)pos + subst.len;
|
540
|
+
}
|
541
|
+
return ret;
|
594
542
|
}
|
595
543
|
|
596
544
|
/**
|
597
545
|
* @brief Determine whether two strings are equivalent.
|
598
546
|
*/
|
599
|
-
static inline bool
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
}
|
605
|
-
return memcmp (left.data, right.data, left.len) == 0;
|
547
|
+
static inline bool mstr_eq(mstr_view left, mstr_view right) {
|
548
|
+
if (left.len != right.len) {
|
549
|
+
return false;
|
550
|
+
}
|
551
|
+
return memcmp(left.data, right.data, left.len) == 0;
|
606
552
|
}
|
607
553
|
|
608
554
|
/**
|
609
555
|
* @brief Determine whether two strings are equivalent ignoring case.
|
610
556
|
*/
|
611
|
-
static inline bool
|
612
|
-
mstr_eq_ignore_case (mstr_view left, mstr_view right)
|
613
|
-
{
|
557
|
+
static inline bool mstr_eq_ignore_case(mstr_view left, mstr_view right) {
|
614
558
|
#ifdef _WIN32
|
615
559
|
#define _mstr_strncasecmp _strnicmp
|
616
560
|
#else
|
617
561
|
#define _mstr_strncasecmp strncasecmp
|
618
562
|
#endif
|
619
563
|
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
564
|
+
if (left.len != right.len) {
|
565
|
+
return false;
|
566
|
+
}
|
567
|
+
return _mstr_strncasecmp(left.data, right.data, left.len) == 0;
|
624
568
|
#undef _mstr_strncasecmp
|
625
569
|
}
|
626
570
|
|
627
571
|
/// Determine whether the given character is an printable ASCII codepoint
|
628
|
-
static inline bool
|
629
|
-
|
630
|
-
{
|
631
|
-
return (c >= ' ' && c <= '~');
|
572
|
+
static inline bool mstr_is_printable(char c) {
|
573
|
+
return (c >= ' ' && c <= '~');
|
632
574
|
}
|
633
575
|
|
634
576
|
/// Write the given string to `out`, rendering non-printable characters as hex
|
635
577
|
/// escapes
|
636
|
-
static inline void
|
637
|
-
|
638
|
-
{
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
}
|
645
|
-
}
|
646
|
-
}
|
647
|
-
|
648
|
-
static inline void
|
649
|
-
_mstr_assert_fail_ (mstr_view left,
|
650
|
-
const char *predicate,
|
651
|
-
mstr_view right,
|
652
|
-
const char *file,
|
653
|
-
int line)
|
654
|
-
{
|
655
|
-
fprintf (stderr, "%s:%d: ASSERTION FAILED: \"", file, line);
|
656
|
-
_mstr_write_str_repr_ (stderr, left);
|
657
|
-
fprintf (stderr, "\" %s \"", predicate);
|
658
|
-
_mstr_write_str_repr_ (stderr, right);
|
659
|
-
fprintf (stderr, "\"\n");
|
660
|
-
abort ();
|
578
|
+
static inline void _mstr_write_str_repr_(FILE *out, mstr_view s) {
|
579
|
+
for (const char *it = s.data; it != s.data + s.len; ++it) {
|
580
|
+
if (mstr_is_printable(*it)) {
|
581
|
+
fputc(*it, out);
|
582
|
+
} else {
|
583
|
+
fprintf(out, "\\x%.2x", (unsigned)(unsigned char)*it);
|
584
|
+
}
|
585
|
+
}
|
661
586
|
}
|
662
587
|
|
663
588
|
static inline void
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
589
|
+
_mstr_assert_fail_(mstr_view left, const char *predicate, mstr_view right, const char *file, int line) {
|
590
|
+
fprintf(stderr, "%s:%d: ASSERTION FAILED: \"", file, line);
|
591
|
+
_mstr_write_str_repr_(stderr, left);
|
592
|
+
fprintf(stderr, "\" %s \"", predicate);
|
593
|
+
_mstr_write_str_repr_(stderr, right);
|
594
|
+
fprintf(stderr, "\"\n");
|
595
|
+
abort();
|
596
|
+
}
|
597
|
+
|
598
|
+
static inline void _mstr_assert_(mstr_view left,
|
599
|
+
mstr_view right,
|
600
|
+
bool (*pred)(mstr_view left, mstr_view right),
|
601
|
+
bool B,
|
602
|
+
const char *pred_str,
|
603
|
+
const char *file,
|
604
|
+
int line) {
|
605
|
+
if (pred(left, right) != B) {
|
606
|
+
mstr pstr = mstr_copy_cstr(pred_str);
|
607
|
+
if (!B) {
|
608
|
+
mstr_assign(&pstr, mstr_prepend(pstr.view, mstrv_lit("not ")));
|
609
|
+
}
|
610
|
+
_mstr_assert_fail_(left, pstr.data, right, file, line);
|
611
|
+
}
|
612
|
+
}
|
613
|
+
|
614
|
+
#define MSTR_ASSERT(Bool, Left, Pred, Right) \
|
615
|
+
(_mstr_assert_((Left), (Right), mstr_##Pred, (Bool), #Pred, __FILE__, __LINE__))
|
684
616
|
|
685
617
|
/**
|
686
618
|
* @brief Assert that two strings are equivalent.
|
687
619
|
*
|
688
620
|
* Prints and error message and aborts if they are not
|
689
621
|
*/
|
690
|
-
#define MSTR_ASSERT_EQ(Left, Right) MSTR_ASSERT
|
622
|
+
#define MSTR_ASSERT_EQ(Left, Right) MSTR_ASSERT(true, Left, eq, Right)
|
691
623
|
|
692
624
|
/**
|
693
625
|
* @brief Determine whether the given string contains the given substring
|
@@ -697,113 +629,88 @@ _mstr_assert_ (mstr_view left,
|
|
697
629
|
* @return true If `given` contains at least one occurrence of `needle`
|
698
630
|
* @return false Otherwise
|
699
631
|
*/
|
700
|
-
static inline bool
|
701
|
-
|
702
|
-
{
|
703
|
-
return mstr_find (given, needle) >= 0;
|
632
|
+
static inline bool mstr_contains(mstr_view given, mstr_view needle) {
|
633
|
+
return mstr_find(given, needle) >= 0;
|
704
634
|
}
|
705
635
|
|
706
636
|
/**
|
707
637
|
* @brief Determine whether `given` starts with `prefix`
|
708
638
|
*/
|
709
|
-
static inline bool
|
710
|
-
|
711
|
-
|
712
|
-
given = mstrv_subview (given, 0, prefix.len);
|
713
|
-
return mstr_eq (given, prefix);
|
639
|
+
static inline bool mstr_starts_with(mstr_view given, mstr_view prefix) {
|
640
|
+
given = mstrv_subview(given, 0, prefix.len);
|
641
|
+
return mstr_eq(given, prefix);
|
714
642
|
}
|
715
643
|
|
716
644
|
/**
|
717
645
|
* @brief Determine whether `given` ends with `suffix`
|
718
646
|
*/
|
719
|
-
static inline bool
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
given = mstrv_subview (given, given.len - suffix.len, SIZE_MAX);
|
726
|
-
return mstr_eq (given, suffix);
|
647
|
+
static inline bool mstr_ends_with(mstr_view given, mstr_view suffix) {
|
648
|
+
if (suffix.len > given.len) {
|
649
|
+
return false;
|
650
|
+
}
|
651
|
+
given = mstrv_subview(given, given.len - suffix.len, SIZE_MAX);
|
652
|
+
return mstr_eq(given, suffix);
|
727
653
|
}
|
728
654
|
|
729
655
|
/// Compound in-place version of @ref mstr_splice
|
730
|
-
static inline void
|
731
|
-
|
732
|
-
{
|
733
|
-
mstr_assign (s, mstr_splice (s->view, at, del_count, insert));
|
656
|
+
static inline void mstr_inplace_splice(mstr *s, size_t at, size_t del_count, mstr_view insert) {
|
657
|
+
mstr_assign(s, mstr_splice(s->view, at, del_count, insert));
|
734
658
|
}
|
735
659
|
|
736
660
|
/// Compound in-place version of @ref mstr_append
|
737
|
-
static inline void
|
738
|
-
|
739
|
-
{
|
740
|
-
mstr_assign (s, mstr_append (s->view, suffix));
|
661
|
+
static inline void mstr_inplace_append(mstr *s, mstr_view suffix) {
|
662
|
+
mstr_assign(s, mstr_append(s->view, suffix));
|
741
663
|
}
|
742
664
|
|
743
665
|
/// Compound in-place version of @ref mstr_prepend
|
744
|
-
static inline void
|
745
|
-
|
746
|
-
{
|
747
|
-
mstr_assign (s, mstr_prepend (s->view, prefix));
|
666
|
+
static inline void mstr_inplace_prepend(mstr *s, mstr_view prefix) {
|
667
|
+
mstr_assign(s, mstr_prepend(s->view, prefix));
|
748
668
|
}
|
749
669
|
|
750
670
|
/// Compound in-place version of @ref mstr_insert
|
751
|
-
static inline void
|
752
|
-
|
753
|
-
{
|
754
|
-
mstr_assign (s, mstr_insert (s->view, at, infix));
|
671
|
+
static inline void mstr_inplace_insert(mstr *s, size_t at, mstr_view infix) {
|
672
|
+
mstr_assign(s, mstr_insert(s->view, at, infix));
|
755
673
|
}
|
756
674
|
|
757
675
|
/// Compound in-place version of @ref mstr_erase
|
758
|
-
static inline void
|
759
|
-
|
760
|
-
{
|
761
|
-
mstr_assign (s, mstr_erase (s->view, at, count));
|
676
|
+
static inline void mstr_inplace_erase(mstr *s, size_t at, size_t count) {
|
677
|
+
mstr_assign(s, mstr_erase(s->view, at, count));
|
762
678
|
}
|
763
679
|
|
764
680
|
/// Compound in-place version of @ref mstr_remove_prefix
|
765
|
-
static inline void
|
766
|
-
|
767
|
-
{
|
768
|
-
mstr_assign (s, mstr_remove_prefix (s->view, len));
|
681
|
+
static inline void mstr_inplace_remove_prefix(mstr *s, size_t len) {
|
682
|
+
mstr_assign(s, mstr_remove_prefix(s->view, len));
|
769
683
|
}
|
770
684
|
|
771
685
|
/// Compound in-place version of @ref mstr_remove_suffix
|
772
|
-
static inline void
|
773
|
-
|
774
|
-
{
|
775
|
-
mstr_assign (s, mstr_remove_suffix (s->view, len));
|
686
|
+
static inline void mstr_inplace_remove_suffix(mstr *s, size_t len) {
|
687
|
+
mstr_assign(s, mstr_remove_suffix(s->view, len));
|
776
688
|
}
|
777
689
|
|
778
690
|
/// Compound in-place version of @ref mstr_substr
|
779
|
-
static inline void
|
780
|
-
|
781
|
-
{
|
782
|
-
mstr_assign (s, mstr_substr (s->view, at, count));
|
691
|
+
static inline void mstr_inplace_substr(mstr *s, size_t at, size_t count) {
|
692
|
+
mstr_assign(s, mstr_substr(s->view, at, count));
|
783
693
|
}
|
784
694
|
|
785
695
|
/// Compound in-place version of @ref mstr_trunc
|
786
|
-
static inline void
|
787
|
-
|
788
|
-
{
|
789
|
-
mstr_assign (s, mstr_trunc (s->view, new_len));
|
696
|
+
static inline void mstr_inplace_trunc(mstr *s, size_t new_len) {
|
697
|
+
mstr_assign(s, mstr_trunc(s->view, new_len));
|
790
698
|
}
|
791
699
|
|
792
700
|
/// Compound in-place version of @ref mstr_replace
|
793
|
-
static inline void
|
794
|
-
|
795
|
-
{
|
796
|
-
mstr_assign (s, mstr_replace (s->view, find, subst));
|
701
|
+
static inline void mstr_inplace_replace(mstr *s, mstr_view find, mstr_view subst) {
|
702
|
+
mstr_assign(s, mstr_replace(s->view, find, subst));
|
797
703
|
}
|
798
704
|
|
799
705
|
#ifdef _WIN32
|
800
706
|
#include "./windows-lean.h"
|
707
|
+
|
801
708
|
/**
|
802
709
|
* @brief The result type of mstr_win32_widen
|
803
710
|
*/
|
804
711
|
typedef struct mstr_widen_result {
|
805
|
-
|
806
|
-
|
712
|
+
wchar_t *wstring;
|
713
|
+
int error;
|
807
714
|
} mstr_widen_result;
|
808
715
|
|
809
716
|
/**
|
@@ -814,29 +721,25 @@ typedef struct mstr_widen_result {
|
|
814
721
|
*
|
815
722
|
* @note The returned @ref mstr_widen_result::wstring must be given to free()
|
816
723
|
*/
|
817
|
-
static inline mstr_widen_result
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
int got_length = MultiByteToWideChar (
|
829
|
-
CP_UTF8, MB_ERR_INVALID_CHARS, str.data, (int) str.len, ret, length + 1);
|
830
|
-
assert (got_length == length);
|
831
|
-
return MLIB_INIT (mstr_widen_result){ret, 0};
|
724
|
+
static inline mstr_widen_result mstr_win32_widen(mstr_view str) {
|
725
|
+
assert(str.len <= INT_MAX);
|
726
|
+
int length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data, (int)str.len, NULL, 0);
|
727
|
+
if (length == 0 && str.len != 0) {
|
728
|
+
return MLIB_INIT(mstr_widen_result){NULL, (int)GetLastError()};
|
729
|
+
}
|
730
|
+
wchar_t *ret = (wchar_t *)calloc(length + 1, sizeof(wchar_t));
|
731
|
+
assert(length < INT_MAX);
|
732
|
+
int got_length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data, (int)str.len, ret, length + 1);
|
733
|
+
assert(got_length == length);
|
734
|
+
return MLIB_INIT(mstr_widen_result){ret, 0};
|
832
735
|
}
|
833
736
|
|
834
737
|
/**
|
835
738
|
* @brief The result type of mstr_win32_narrow
|
836
739
|
*/
|
837
740
|
typedef struct mstr_narrow_result {
|
838
|
-
|
839
|
-
|
741
|
+
mstr string;
|
742
|
+
int error;
|
840
743
|
} mstr_narrow_result;
|
841
744
|
|
842
745
|
/**
|
@@ -849,102 +752,87 @@ typedef struct mstr_narrow_result {
|
|
849
752
|
* @note The returned @ref mstr_narrow_result::string must be freed with
|
850
753
|
* mstr_free()
|
851
754
|
*/
|
852
|
-
static inline mstr_narrow_result
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
NULL,
|
865
|
-
NULL);
|
866
|
-
if (length == 0 && wstring[0] != 0) {
|
867
|
-
return MLIB_INIT (mstr_narrow_result){MSTR_NULL, (int) GetLastError ()};
|
868
|
-
}
|
869
|
-
// Allocate a new string, not including the null terminator
|
870
|
-
mstr_mut ret = mstr_new ((size_t) (length - 1));
|
871
|
-
int got_len = WideCharToMultiByte (CP_UTF8,
|
755
|
+
static inline mstr_narrow_result mstr_win32_narrow(const wchar_t *wstring) {
|
756
|
+
// Some older versions of MinGW fail to include the WC_ERR_INVALID_CHARS
|
757
|
+
// flag, so we will specify it manually:
|
758
|
+
DWORD wcflags = 0x80; // WC_ERR_INVALID_CHARS
|
759
|
+
int length =
|
760
|
+
WideCharToMultiByte(CP_UTF8, wcflags, wstring, -1 /* wstring is null-terminated */, NULL, 0, NULL, NULL);
|
761
|
+
if (length == 0 && wstring[0] != 0) {
|
762
|
+
return MLIB_INIT(mstr_narrow_result){MSTR_NULL, (int)GetLastError()};
|
763
|
+
}
|
764
|
+
// Allocate a new string, not including the null terminator
|
765
|
+
mstr_mut ret = mstr_new((size_t)(length - 1));
|
766
|
+
int got_len = WideCharToMultiByte(CP_UTF8,
|
872
767
|
wcflags,
|
873
768
|
wstring,
|
874
769
|
-1,
|
875
770
|
ret.data,
|
876
771
|
// Plus one byte for the NUL
|
877
|
-
(int)
|
772
|
+
(int)(ret.len + 1),
|
878
773
|
NULL,
|
879
774
|
NULL);
|
880
|
-
|
881
|
-
|
775
|
+
assert(length == got_len);
|
776
|
+
return MLIB_INIT(mstr_narrow_result){ret.mstr, 0};
|
882
777
|
}
|
883
778
|
#endif
|
884
779
|
|
885
780
|
/// Iteration state for string splitting
|
886
781
|
struct _mstr_split_iter_ {
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
782
|
+
/// What hasn't been parsed yet
|
783
|
+
mstr_view remaining;
|
784
|
+
/// The string that we split on
|
785
|
+
mstr_view splitter;
|
786
|
+
/// The current part
|
787
|
+
mstr_view part;
|
788
|
+
/// A once-var for the inner loop. Set to 1 by iter_next, then decremented
|
789
|
+
int once;
|
790
|
+
/// The loop state. Starts at zero. Set to one when we part the final split.
|
791
|
+
/// Set to two to break out of the loop.
|
792
|
+
int state;
|
898
793
|
};
|
899
794
|
|
900
795
|
/// Hidden function to advance a string-split iterator
|
901
|
-
static inline void
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
}
|
930
|
-
// Prime the inner "loop" to execute once
|
931
|
-
iter->once = 1;
|
796
|
+
static inline void _mstr_split_iter_next_(struct _mstr_split_iter_ *iter) {
|
797
|
+
if (iter->once == 1) {
|
798
|
+
// We only get here if the loop body hit a 'break', skipping the decrement
|
799
|
+
// of the 'once'. Break out of the whole loop, as the user expects.
|
800
|
+
iter->state = 2;
|
801
|
+
return;
|
802
|
+
}
|
803
|
+
if (iter->state == 1) {
|
804
|
+
// We just completed the final loop pass.
|
805
|
+
iter->state = 2;
|
806
|
+
return;
|
807
|
+
}
|
808
|
+
// Find the next occurence of the token
|
809
|
+
const int pos = mstr_find(iter->remaining, iter->splitter);
|
810
|
+
if (pos < 0) {
|
811
|
+
// There are no more occurences. yield the remaining string
|
812
|
+
iter->part = iter->remaining;
|
813
|
+
iter->remaining = mstrv_subview(iter->remaining, iter->remaining.len, 0);
|
814
|
+
// Set state to 1 to break on the next pass
|
815
|
+
iter->state = 1;
|
816
|
+
} else {
|
817
|
+
// Advance our parts:
|
818
|
+
iter->part = mstrv_subview(iter->remaining, 0, (size_t)pos);
|
819
|
+
assert(iter->splitter.len <= SIZE_MAX - (size_t)pos);
|
820
|
+
iter->remaining = mstrv_subview(iter->remaining, (size_t)pos + iter->splitter.len, SIZE_MAX);
|
821
|
+
}
|
822
|
+
// Prime the inner "loop" to execute once
|
823
|
+
iter->once = 1;
|
932
824
|
}
|
933
825
|
|
934
826
|
/// init a new split iterator
|
935
|
-
static inline struct _mstr_split_iter_
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
_mstr_split_iter_next_ (&iter);
|
940
|
-
return iter;
|
827
|
+
static inline struct _mstr_split_iter_ _mstr_split_iter_begin_(mstr_view str, mstr_view split) {
|
828
|
+
struct _mstr_split_iter_ iter = {str, split};
|
829
|
+
_mstr_split_iter_next_(&iter);
|
830
|
+
return iter;
|
941
831
|
}
|
942
832
|
|
943
833
|
/// Check whether we are done iterating
|
944
|
-
static inline bool
|
945
|
-
|
946
|
-
{
|
947
|
-
return iter->state == 2;
|
834
|
+
static inline bool _mstr_split_iter_done_(struct _mstr_split_iter_ *iter) {
|
835
|
+
return iter->state == 2;
|
948
836
|
}
|
949
837
|
|
950
838
|
// clang-format off
|
@@ -961,18 +849,16 @@ _mstr_split_iter_done_ (struct _mstr_split_iter_ *iter)
|
|
961
849
|
for (mstr_view const LineVar = _iter_var_.part; \
|
962
850
|
_iter_var_.once; \
|
963
851
|
--_iter_var_.once)
|
852
|
+
|
964
853
|
// clang-format on
|
965
854
|
|
966
855
|
/**
|
967
856
|
* @brief Equivalent to strlen(), but has a constexpr annotation.
|
968
857
|
*/
|
969
|
-
static mlib_constexpr_fn size_t
|
970
|
-
|
971
|
-
{
|
972
|
-
|
973
|
-
for (; *s; ++r, ++s) {
|
974
|
-
}
|
975
|
-
return r;
|
858
|
+
static mlib_constexpr_fn size_t mlib_strlen(const char *s) {
|
859
|
+
size_t r = 0;
|
860
|
+
for (; *s; ++r, ++s) {}
|
861
|
+
return r;
|
976
862
|
}
|
977
863
|
|
978
864
|
/**
|
@@ -991,36 +877,31 @@ mlib_strlen (const char *s)
|
|
991
877
|
* @note Characters beyond (dst + R) are unmodified. dst[R] is guaranteed to
|
992
878
|
* be a null terminator.
|
993
879
|
*/
|
994
|
-
static mlib_constexpr_fn size_t
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
}
|
1020
|
-
// "dst" now points past the final character we copied (if any), and is still
|
1021
|
-
// in-bounds. This will be the null terminator.
|
1022
|
-
*dst = 0;
|
1023
|
-
return ncopied;
|
880
|
+
static mlib_constexpr_fn size_t mlib_strnmcopy(char *dst, size_t dst_bufsize, const char *src, size_t src_bufsize) {
|
881
|
+
// No empty destination, since we *must* write a null terminator:
|
882
|
+
assert(dst_bufsize > 0);
|
883
|
+
// The maximum number of characters in the dest is one less than the buffer
|
884
|
+
// size, since we need room for the null terminator:
|
885
|
+
const size_t dstlen = dst_bufsize - 1u;
|
886
|
+
// The actual maximum number of characters we can copy is the less of the
|
887
|
+
// source length and the dest length:
|
888
|
+
const size_t minlen = dstlen < src_bufsize ? dstlen : src_bufsize;
|
889
|
+
// Track what we copy:
|
890
|
+
size_t ncopied = 0;
|
891
|
+
while (ncopied != minlen // Stop if we hit our character limit
|
892
|
+
&& *src != 0 // Or if we hit the null terminator in the source
|
893
|
+
) {
|
894
|
+
// Copy:
|
895
|
+
*dst = *src;
|
896
|
+
// Advance:
|
897
|
+
++dst;
|
898
|
+
++src;
|
899
|
+
++ncopied;
|
900
|
+
}
|
901
|
+
// "dst" now points past the final character we copied (if any), and is still
|
902
|
+
// in-bounds. This will be the null terminator.
|
903
|
+
*dst = 0;
|
904
|
+
return ncopied;
|
1024
905
|
}
|
1025
906
|
|
1026
907
|
MLIB_C_LINKAGE_END
|