From 5c56fa0e6f3d43746b50a5b2cf2fc79af3bf6336 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sat, 14 Jan 2023 09:09:15 +0100 Subject: [PATCH] Remove str2wcs special case for MB_CUR_MAX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This meant we didn't actually do our weird en/decoding scheme for e.g. a C locale, which meant that, when you then switch to a proper locale the previous variables were broken. I don't know how to test this automatically - none of my attempts seem to ever *fail* with the old code, here's what you'd do manually: - Run fish with an actual C locale (LC_ALL=C fish_allow_singlebyte_locale=1 fish) - `set -gx foo 💩` - `set -e LC_ALL` - `echo $foo` outputs "💩" if it works and "ð⏎" if it's broken. Fixes #2613 --- src/common.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index baee97a62..a1cc7c63c 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -303,16 +303,6 @@ static wcstring str2wcs_internal(const char *in, const size_t in_len) { wcstring result; result.reserve(in_len); - // In the unlikely event that MB_CUR_MAX is 1, then we are just going to append. - if (MB_CUR_MAX == 1) { - size_t in_pos = 0; - while (in_pos < in_len) { - result.push_back(static_cast(in[in_pos])); - in_pos++; - } - return result; - } - size_t in_pos = 0; mbstate_t state = {}; while (in_pos < in_len) {