Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions inflection/src/inflection/dialog/CommonConceptFactoryImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ static std::pair<SpeakableString, SpeakableString> getDefaultList(const ::inflec

UErrorCode status = U_ZERO_ERROR;
UListFormatter* listFmt = ulistfmt_openForType(language.getName().c_str(), type, ULISTFMT_WIDTH_WIDE, &status);
::inflection::util::Finally finally([listFmt]() noexcept {
auto cleanup = [listFmt]() noexcept {
ulistfmt_close(listFmt);
});
};
::inflection::util::Finally<decltype(cleanup)> finally(cleanup);
::inflection::exception::ICUException::throwOnFailure(status);
auto listSize = ulistfmt_format(listFmt, reinterpret_cast<const UChar *const *>(twoItems ? list2Items : listItems), nullptr, twoItems ? list2ItemsSize : listItemsSize,
(UChar *)&(formatResult[0]), int32_t(formatResult.length()), &status);
Expand Down Expand Up @@ -83,9 +84,10 @@ CommonConceptFactoryImpl::CommonConceptFactoryImpl(const ::inflection::util::ULo
{
auto status = U_ZERO_ERROR;
auto localeData = ulocdata_open(language.getName().c_str(), &status);
::inflection::util::Finally finally([localeData]() noexcept {
auto cleanup = [localeData]() noexcept {
ulocdata_close(localeData);
});
};
::inflection::util::Finally<decltype(cleanup)> finally(cleanup);
::inflection::exception::ICUException::throwOnFailure(status);
startQuote = getQuote(localeData, ULOCDATA_QUOTATION_START);
endQuote = getQuote(localeData, ULOCDATA_QUOTATION_END);
Expand Down
5 changes: 3 additions & 2 deletions inflection/tools/buildDictionary/InflectionDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,13 @@ Inflector_InflectionDictionary* InflectionDictionary::readXML(const ::inflection

xmlDocPtr xmlDoc = nullptr;
{
::inflection::util::Finally finally([&xmlDoc]() noexcept {
auto cleanup = [&xmlDoc]() noexcept {
if (xmlDoc != nullptr) {
xmlFreeDoc(xmlDoc);
}
xmlCleanupParser();
});
};
::inflection::util::Finally<decltype(cleanup)> finally(cleanup);
::std::u16string resourceName = inflection::util::StringUtils::to_u16string(source);
::inflection::util::MemoryMappedFile mMapFile(resourceName);
xmlDoc = xmlParseMemory(mMapFile.getData(), int32_t(mMapFile.getSize()));
Expand Down
2 changes: 1 addition & 1 deletion inflection/tools/buildTokDictionary/buildTokDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int main(int argc, const char * const argv[]) {
}

if (errorCount == 0) {
::inflection::dictionary::metadata::MarisaTrie trie(stringToIntegerMap);
::inflection::dictionary::metadata::MarisaTrie<int32_t> trie(stringToIntegerMap);
out.write(inflection::tokenizer::trie::SerializedTrie::MAGIC_MARKER, sizeof(inflection::tokenizer::trie::SerializedTrie::MAGIC_MARKER));
out.write(reinterpret_cast<const char*>(&inflection::tokenizer::trie::SerializedTrie::VERSION), sizeof(inflection::tokenizer::trie::SerializedTrie::VERSION));
out.write(reinterpret_cast<const char*>(&ENDIANNESS_MARKER), sizeof(ENDIANNESS_MARKER));
Expand Down
Loading