summaryrefslogtreecommitdiff
path: root/src/locale/collation.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-10-31 09:01:34 +1100
committerjacqueline <me@jacqueline.id.au>2023-10-31 09:01:34 +1100
commit4cc5fa4c9c324c18908a7786358c7f6cac8a7f82 (patch)
tree76ed59e88579a909bb5118941e55c148de0e6086 /src/locale/collation.cpp
parentb58c08150853b8055093dc116d407ffd543f8ec8 (diff)
downloadtangara-fw-4cc5fa4c9c324c18908a7786358c7f6cac8a7f82.tar.gz
Store the current collator in the database
Diffstat (limited to 'src/locale/collation.cpp')
-rw-r--r--src/locale/collation.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/locale/collation.cpp b/src/locale/collation.cpp
index f5e8272a..2d787b5a 100644
--- a/src/locale/collation.cpp
+++ b/src/locale/collation.cpp
@@ -58,19 +58,26 @@ auto GLibCollator::create() -> GLibCollator* {
return nullptr;
}
+ // We reserve the first 8 bytes of the partition for an identifier / name.
+ // Copy it out, then crop the rest of the region so that the LC_COLLATE parser
+ // doesn't see it.
+ std::string name{static_cast<const char*>(region)};
+ region = static_cast<const std::byte*>(region) + 8;
+
auto data = std::make_unique<locale_data_t>();
- if (!parse_locale_data(region, partition->size, data.get())) {
+ if (!parse_locale_data(region, partition->size - 8, data.get())) {
ESP_LOGE(kTag, "parsing locale data failed");
esp_partition_munmap(handle);
return nullptr;
}
- return new GLibCollator(handle, std::move(data));
+ return new GLibCollator(name, handle, std::move(data));
}
-GLibCollator::GLibCollator(const esp_partition_mmap_handle_t handle,
+GLibCollator::GLibCollator(const std::string& name,
+ const esp_partition_mmap_handle_t handle,
std::unique_ptr<locale_data_t> locale)
- : handle_(handle), locale_data_(std::move(locale)) {}
+ : name_(name), handle_(handle), locale_data_(std::move(locale)) {}
GLibCollator::~GLibCollator() {
esp_partition_munmap(handle_);