summaryrefslogtreecommitdiff
path: root/package/busybox/patches/004-busybox-1.23.0-ash.patch
blob: fb494aa251f03f32e9d6e549036be5a182659b13 (plain)
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
--- busybox-1.23.0/shell/ash.c
+++ busybox-1.23.0-ash/shell/ash.c
@@ -6746,6 +6746,14 @@ varvalue(char *name, int varflags, int f
 		len = strlen(p);
 		if (!(subtype == VSPLUS || subtype == VSLENGTH))
 			memtodest(p, len, syntax, quotes);
+#if ENABLE_UNICODE_SUPPORT
+		if (subtype == VSLENGTH && len > 0) {
+			reinit_unicode_for_ash();
+			if (unicode_status == UNICODE_ON) {
+				len = unicode_strlen(p);
+			}
+		}
+#endif
 		return len;
 	}
 
@@ -6829,15 +6837,7 @@ evalvar(char *p, int flags, struct strli
 		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;
 	}