File 3071-stdlib-Short-circuit-shell-prompt_width-calls-done-b.patch of Package erlang

From de45fd193b601cb520e9eb002c14d07c933ef03d Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 17 Apr 2024 09:34:05 +0200
Subject: [PATCH] stdlib: Short-circuit shell:prompt_width calls done by
 user_drv

---
 lib/stdlib/src/shell.erl | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/stdlib/src/shell.erl b/lib/stdlib/src/shell.erl
index 7037e730c5..3554b4c40b 100644
--- a/lib/stdlib/src/shell.erl
+++ b/lib/stdlib/src/shell.erl
@@ -1908,7 +1908,16 @@ Equivalent to `prompt_width/2` with `Encoding` set to the encoding used by
 
 -spec prompt_width(unicode:chardata()) -> non_neg_integer().
 prompt_width(String) ->
-    Encoding = proplists:get_value(encoding, io:getopts(user)),
+    Encoding =
+        case whereis(user_drv) =:= self() of
+            %% When in JCL mode edlin can be called by
+            %% user_drv, which in turn calls this function.
+            %% Since JCL is very rudimentary we can assume
+            %% that it uses latin1.
+            true -> latin1;
+            false ->
+                proplists:get_value(encoding, io:getopts(user))
+        end,
     prompt_width(String, Encoding).
 
 -spec prompt_width(unicode:chardata(), unicode | latin1) -> non_neg_integer().
-- 
2.35.3

openSUSE Build Service is sponsored by