Fixed ASCII folding for non-foldable non-ASCII characters
Problem: Add an object, name it using cyrilic, Slice, click Export: the proposed name is mangled. Affects all platforms, 2.2.0 was fine.
Cause: It is mangled during ASCII folding, which was broken with 28c0880
when it was generalized to be used from the fuzzy matcher.
fold_to_ascii(wchar_t c, char *out) relies on narrowing char = wchar_t assignment, the old one used std::back_insert_iterator<std::wstring>.
It is thus unable to leave a character alone even when it should (it should, right?).
Solution:
1. Typed the fold_to_ascii function so it works on wchar_t only, which should mimic the old behaviour.
2. Changed the respective call in fts_fuzzy_match.h. That function also works with wide char C-strings.
Cleanup:
1. Removed the unused fold_utf8_to_ascii(const char *src) overload to avoid code duplication.
2. Untemplated the fold_to_ascii(wchar_t c, std::back_insert_iterator<std::wstring>& out) function, it was never called with a different type.
3. The function is now static in ASCIIFolding.cpp, nobody else needs to know.
This commit is contained in:
parent
1f5ac7d2f7
commit
78a3d8b63e
3 changed files with 17 additions and 29 deletions
|
@ -116,10 +116,10 @@ namespace fts {
|
|||
int num_matched = std::tolower(*pattern) == std::tolower(*str) ? 1 : 0;
|
||||
bool folded_match = false;
|
||||
if (! num_matched) {
|
||||
char tmp[4];
|
||||
char *end = Slic3r::fold_to_ascii(*str, tmp);
|
||||
char *c = tmp;
|
||||
for (const wchar_t* d = pattern; c != end && *d != 0 && wchar_t(std::tolower(*c)) == std::tolower(*d); ++c, ++d);
|
||||
wchar_t tmp[4];
|
||||
wchar_t *end = Slic3r::fold_to_ascii(*str, tmp);
|
||||
wchar_t *c = tmp;
|
||||
for (const wchar_t* d = pattern; c != end && *d != 0 && std::towlower(*c) == std::towlower(*d); ++c, ++d);
|
||||
if (c == end) {
|
||||
folded_match = true;
|
||||
num_matched = end - tmp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue