From 7bd6e577d9e9ef7278d3d0506ca98b3b2a1c8c85 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 25 Oct 2025 08:30:13 +0200 Subject: [PATCH] Remove obsolete uses of LC_CTYPE These are obsolete as of c8001b5023a (encoding: use UTF-8 everywhere, 2025-10-18). The only place where we still read the user's LC_CTYPE is in libc::wcwidth(), but that's kind of a regression -- we should always be using a UTF-8 LC_CTYPE if possible -- which will be fixed by a following commit. --- doc_src/language.rst | 7 +------ share/functions/__fish_set_locale.fish | 8 -------- share/tools/web_config/webconfig.py | 19 ++++--------------- src/env_dispatch.rs | 3 +-- 4 files changed, 6 insertions(+), 31 deletions(-) diff --git a/doc_src/language.rst b/doc_src/language.rst index c6b6bd870..f2b6aa7d8 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -1563,7 +1563,7 @@ You can change the settings of fish by changing the values of certain variables. .. describe:: Locale Variables - The locale variables :envvar:`LANG`, :envvar:`LC_ALL`, :envvar:`LC_COLLATE`, :envvar:`LC_CTYPE`, :envvar:`LC_MESSAGES`, :envvar:`LC_MONETARY`, :envvar:`LC_NUMERIC`, and :envvar:`LANG` set the language option for the shell and subprograms. See the section :ref:`Locale variables ` for more information. + The locale variables :envvar:`LANG`, :envvar:`LC_ALL`, :envvar:`LC_COLLATE`, :envvar:`LC_MESSAGES`, :envvar:`LC_MONETARY`, :envvar:`LC_NUMERIC`, and :envvar:`LANG` set the language option for the shell and subprograms. See the section :ref:`Locale variables ` for more information. .. describe:: Color variables @@ -1842,11 +1842,6 @@ The "locale" of a program is its set of language and regional settings that depe This determines the rules about equivalence of cases and alphabetical ordering: collation. -.. envvar:: LC_CTYPE - - This determines classification rules, like if the type of character is an alpha, digit, and so on. - Most importantly, it defines the text *encoding* - which numbers map to which characters. On modern systems, this should typically be something ending in "UTF-8". - .. envvar:: LC_MESSAGES ``LC_MESSAGES`` determines the language in which messages are diisplayed. diff --git a/share/functions/__fish_set_locale.fish b/share/functions/__fish_set_locale.fish index 47d1621fd..a2e092860 100644 --- a/share/functions/__fish_set_locale.fish +++ b/share/functions/__fish_set_locale.fish @@ -69,12 +69,4 @@ function __fish_set_locale end <$f end end - - # If we really cannot get anything, at least set character encoding to UTF-8. - for locale_var in $LOCALE_VARS LC_ALL - if set -q $locale_var - return 0 - end - end - set -gx LC_CTYPE en_US.UTF-8 end diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 4a8f9e2b1..496fb5cab 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -114,23 +114,12 @@ def is_chromeos_garcon(): def run_fish_cmd(text): - # Ensure that fish is using UTF-8. - ctype = os.environ.get("LC_ALL", os.environ.get("LC_CTYPE", os.environ.get("LANG"))) - env = None - if ctype is None or re.search(r"\.utf-?8$", ctype, flags=re.I) is None: - # override LC_CTYPE with en_US.UTF-8 - # We're assuming this locale exists. - # Fish makes the same assumption in config.fish - env = os.environ.copy() - env.update(LC_CTYPE="en_US.UTF-8", LANG="en_US.UTF-8") - print("$ " + text) p = subprocess.Popen( [FISH_BIN_PATH], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=env, ) out, err = p.communicate(text.encode("utf-8")) out = out.decode("utf-8", "replace") @@ -1272,13 +1261,13 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): # In some cases it'll give us the encoding as well, # ("application/json;charset=utf-8") # but we don't currently care. - ctype = self.headers["content-type"].split(";")[0] + content_type = self.headers["content-type"].split(";")[0] - if ctype == "application/x-www-form-urlencoded": + if content_type == "application/x-www-form-urlencoded": length = int(self.headers["content-length"]) url_str = self.rfile.read(length).decode("utf-8") postvars = parse_qs(url_str, keep_blank_values=1) - elif ctype == "application/json": + elif content_type == "application/json": length = int(self.headers["content-length"]) # This used to use the provided encoding, but we use utf-8 # all around the place and nobody has ever complained. @@ -1288,7 +1277,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): # If that happens to anyone we expect bug reports. url_str = self.rfile.read(length).decode("utf-8") postvars = json.loads(url_str) - elif ctype == "multipart/form-data": + elif content_type == "multipart/form-data": # This used to be a thing, as far as I could find there's # no use anymore, but let's keep an error around just in case. return self.send_error(500) diff --git a/src/env_dispatch.rs b/src/env_dispatch.rs index bc03cf765..6fbaffaf4 100644 --- a/src/env_dispatch.rs +++ b/src/env_dispatch.rs @@ -24,12 +24,11 @@ /// List of all locale environment variable names that might trigger (re)initializing of the locale /// subsystem. These are only the variables we're possibly interested in. -const LOCALE_VARIABLES: [&wstr; 9] = [ +const LOCALE_VARIABLES: [&wstr; 8] = [ L!("LANG"), L!("LANGUAGE"), L!("LC_ALL"), L!("LC_COLLATE"), - L!("LC_CTYPE"), L!("LC_MESSAGES"), L!("LC_NUMERIC"), L!("LC_TIME"),