1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
From 9b1736cc9ad620fef7d386e12ed52aab73319cef Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 25 Dec 2014 16:56:20 +0100
Subject: [PATCH] Revert "ash: make ${#var} unicode-aware"
This reverts commit e9ab07c211b283c0f798628858eaaef93a4893aa.
---
shell/ash.c | 39 +++++++++++++--------------------------
1 file changed, 13 insertions(+), 26 deletions(-)
diff --git a/shell/ash.c b/shell/ash.c
index 90fb00f..337d63d 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -2128,22 +2128,6 @@ lookupvar(const char *name)
return NULL;
}
-static void reinit_unicode_for_ash(void)
-{
- /* Unicode support should be activated even if LANG is set
- * _during_ shell execution, not only if it was set when
- * shell was started. Therefore, re-check LANG every time:
- */
- if (ENABLE_FEATURE_CHECK_UNICODE_IN_ENV
- || ENABLE_UNICODE_USING_LOCALE
- ) {
- const char *s = lookupvar("LC_ALL");
- if (!s) s = lookupvar("LC_CTYPE");
- if (!s) s = lookupvar("LANG");
- reinit_unicode(s);
- }
-}
-
/*
* Search the environment of a builtin command.
*/
@@ -6829,15 +6813,7 @@ evalvar(char *p, int flags, struct strlist *var_str_list)
varunset(p, var, 0, 0);
if (subtype == VSLENGTH) {
- ssize_t n = varlen;
- if (n > 0) {
- reinit_unicode_for_ash();
- if (unicode_status == UNICODE_ON) {
- const char *val = lookupvar(var);
- n = unicode_strlen(val);
- }
- }
- cvtnum(n > 0 ? n : 0);
+ cvtnum(varlen > 0 ? varlen : 0);
goto record;
}
@@ -9696,7 +9672,18 @@ preadfd(void)
# if ENABLE_FEATURE_TAB_COMPLETION
line_input_state->path_lookup = pathval();
# endif
- reinit_unicode_for_ash();
+ /* Unicode support should be activated even if LANG is set
+ * _during_ shell execution, not only if it was set when
+ * shell was started. Therefore, re-check LANG every time:
+ */
+ if (ENABLE_FEATURE_CHECK_UNICODE_IN_ENV
+ || ENABLE_UNICODE_USING_LOCALE
+ ) {
+ const char *s = lookupvar("LC_ALL");
+ if (!s) s = lookupvar("LC_CTYPE");
+ if (!s) s = lookupvar("LANG");
+ reinit_unicode(s);
+ }
nr = read_line_input(line_input_state, cmdedit_prompt, buf, IBUFSIZ, timeout);
if (nr == 0) {
/* Ctrl+C pressed */
--
2.2.1
|