diff --git a/MODULE.bazel b/MODULE.bazel index a83316024..e6e82c5a4 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -7,7 +7,7 @@ module( bazel_dep(name = "aspect_bazel_lib", version = "2.22.5") bazel_dep(name = "aspect_rules_js", version = "3.2.2") -bazel_dep(name = "darts-clone", version = "0.32h") +bazel_dep(name = "darts-clone", version = "0.32h.bcr.1") bazel_dep(name = "googletest", version = "1.17.0.bcr.2", dev_dependency = True) bazel_dep(name = "marisa-trie", version = "0.3.1.bcr.2") bazel_dep(name = "node_addon_api", version = "8.9.0") @@ -30,13 +30,6 @@ single_version_override( version = "2.0.3", ) -single_version_override( - module_name = "darts-clone", - patches = ["//patches:darts-clone-opencc.patch"], - patch_strip = 1, - version = "0.32h", -) - # Windows x64 node.lib import library for Zig/MinGW addon linking. node-addon-api # comes from BCR (above) and the Node C headers come from the rules_nodejs Node # toolchain (below); this import library is available from neither. diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index c7969595d..f0543d285 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -75,8 +75,8 @@ "https://bcr.bazel.build/modules/bazel_skylib/1.9.0/source.json": "7ad77c1e8c1b84222d9b3f3cae016a76639435744c19330b0b37c0a3c9da7dc0", "https://bcr.bazel.build/modules/buildozer/8.5.1/MODULE.bazel": "a35d9561b3fc5b18797c330793e99e3b834a473d5fbd3d7d7634aafc9bdb6f8f", "https://bcr.bazel.build/modules/buildozer/8.5.1/source.json": "e3386e6ff4529f2442800dee47ad28d3e6487f36a1f75ae39ae56c70f0cd2fbd", - "https://bcr.bazel.build/modules/darts-clone/0.32h/MODULE.bazel": "ba209b6cfb1a70f4fad4c9c0aa5204ae4b1dcc3c0bcc95a7bf93ec3df0546296", - "https://bcr.bazel.build/modules/darts-clone/0.32h/source.json": "49b56b7949dd1efe3c99b4d08a739683bba35299f1c103be0dd76b21b30a8913", + "https://bcr.bazel.build/modules/darts-clone/0.32h.bcr.1/MODULE.bazel": "348f81ae7e268eddcd7bc3afc7b0eb2db9463ace8cd13d66d1d93e00f472eb0e", + "https://bcr.bazel.build/modules/darts-clone/0.32h.bcr.1/source.json": "2f63a2d747b3c5e722b0b8127cf1b3b36277b126dde171f13aa025a5a343d466", "https://bcr.bazel.build/modules/gawk/5.3.2.bcr.1/MODULE.bazel": "cdf8cbe5ee750db04b78878c9633cc76e80dcf4416cbe982ac3a9222f80713c8", "https://bcr.bazel.build/modules/gawk/5.3.2.bcr.3/MODULE.bazel": "f1b7bb2dd53e8f2ef984b39485ec8a44e9076dda5c4b8efd2fb4c6a6e856a31d", "https://bcr.bazel.build/modules/gawk/5.3.2.bcr.3/source.json": "ebe931bfe362e4b41e59ee00a528db6074157ff2ced92eb9e970acab2e1089c9", diff --git a/patches/darts-clone-opencc.patch b/patches/darts-clone-opencc.patch deleted file mode 100644 index 7dfc87fe2..000000000 --- a/patches/darts-clone-opencc.patch +++ /dev/null @@ -1,142 +0,0 @@ -diff --git a/MODULE.bazel b/MODULE.bazel ---- a/MODULE.bazel -+++ b/MODULE.bazel -@@ -6,4 +6,4 @@ - compatibility_level = 0, - ) - --bazel_dep(name = "rules_cc", version = "0.2.17") -+bazel_dep(name = "rules_cc", version = "0.2.20") -diff --git a/include/darts.h b/include/darts.h ---- a/include/darts.h -+++ b/include/darts.h -@@ -2,6 +2,7 @@ - #define DARTS_H_ - - #include -+#include - #include - #include - -@@ -173,6 +174,14 @@ - array_ = static_cast(ptr); - size_ = size; - } -+ void copy_array(const void* ptr, std::size_t num_bytes) { -+ clear(); -+ const std::size_t extra_padding = num_bytes % unit_size() == 0 ? 0 : 1; -+ size_ = num_bytes / unit_size() + extra_padding; -+ buf_ = new unit_type[size_]; -+ std::memcpy(buf_, ptr, num_bytes); -+ array_ = buf_; -+ } - // array() returns a pointer to the array of units. - const void *array() const { - return array_; -@@ -314,6 +323,8 @@ - // updates `node_pos' and `key_pos' after each transition. - inline value_type traverse(const key_type *key, std::size_t &node_pos, - std::size_t &key_pos, std::size_t length = 0) const; -+ -+ bool validate(value_type max_value_limit = -1) const; - - private: - typedef Details::uchar_type uchar_type; -@@ -451,6 +462,29 @@ - } - std::fclose(file); - return 0; -+} -+ -+template -+bool DoubleArrayImpl::validate(value_type max_value_limit) const { -+ if (size_ == 0 || array_ == NULL) { -+ return false; -+ } -+ if (array_[0].label() != '\0' || array_[0].has_leaf() || -+ array_[0].offset() == 0 || ((0 ^ array_[0].offset()) | 0xFF) >= size_) { -+ return false; -+ } -+ for (std::size_t i = 1; i < size_; ++i) { -+ if (array_[i].label() <= 0xFF) { -+ if (((i ^ array_[i].offset()) | 0xFF) >= size_) { -+ return false; -+ } -+ } else if (max_value_limit >= 0) { -+ if (array_[i].value() >= max_value_limit) { -+ return false; -+ } -+ } -+ } -+ return true; - } - - template -@@ -910,7 +944,7 @@ - - num_ones_ = 0; - for (std::size_t i = 0; i < units_.size(); ++i) { -- ranks_[i] = num_ones_; -+ ranks_[i] = static_cast(num_ones_); - num_ones_ += pop_count(units_[i]); - } - } -@@ -1832,7 +1866,7 @@ - - inline id_type DoubleArrayBuilder::find_valid_offset(id_type id) const { - if (extras_head_ >= units_.size()) { -- return units_.size() | (id & LOWER_MASK); -+ return static_cast(units_.size()) | (id & LOWER_MASK); - } - - id_type unfixed_id = extras_head_; -@@ -1844,7 +1878,7 @@ - unfixed_id = extras(unfixed_id).next(); - } while (unfixed_id != extras_head_); - -- return units_.size() | (id & LOWER_MASK); -+ return static_cast(units_.size()) | (id & LOWER_MASK); - } - - inline bool DoubleArrayBuilder::is_valid_offset(id_type id, -@@ -1875,7 +1909,7 @@ - if (id == extras_head_) { - extras_head_ = extras(id).next(); - if (extras_head_ == id) { -- extras_head_ = units_.size(); -+ extras_head_ = static_cast(units_.size()); - } - } - extras(extras(id).prev()).set_next(extras(id).next()); -@@ -1884,8 +1918,8 @@ - } - - inline void DoubleArrayBuilder::expand_units() { -- id_type src_num_units = units_.size(); -- id_type src_num_blocks = num_blocks(); -+ id_type src_num_units = static_cast(units_.size()); -+ id_type src_num_blocks = static_cast(num_blocks()); - - id_type dest_num_units = src_num_units + BLOCK_SIZE; - id_type dest_num_blocks = src_num_blocks + 1; -@@ -1897,7 +1931,7 @@ - units_.resize(dest_num_units); - - if (dest_num_blocks > NUM_EXTRA_BLOCKS) { -- for (std::size_t id = src_num_units; id < dest_num_units; ++id) { -+ for (id_type id = src_num_units; id < dest_num_units; ++id) { - extras(id).set_is_used(false); - extras(id).set_is_fixed(false); - } -@@ -1921,9 +1955,9 @@ - inline void DoubleArrayBuilder::fix_all_blocks() { - id_type begin = 0; - if (num_blocks() > NUM_EXTRA_BLOCKS) { -- begin = num_blocks() - NUM_EXTRA_BLOCKS; -+ begin = static_cast(num_blocks()) - NUM_EXTRA_BLOCKS; - } -- id_type end = num_blocks(); -+ id_type end = static_cast(num_blocks()); - - for (id_type block_id = begin; block_id != end; ++block_id) { - fix_block(block_id);