004-busybox-1.23.0-ash.patch 845 B

12345678910111213141516171819202122232425262728293031323334
  1. --- busybox-1.23.0/shell/ash.c
  2. +++ busybox-1.23.0-ash/shell/ash.c
  3. @@ -6746,6 +6746,14 @@ varvalue(char *name, int varflags, int f
  4. len = strlen(p);
  5. if (!(subtype == VSPLUS || subtype == VSLENGTH))
  6. memtodest(p, len, syntax, quotes);
  7. +#if ENABLE_UNICODE_SUPPORT
  8. + if (subtype == VSLENGTH && len > 0) {
  9. + reinit_unicode_for_ash();
  10. + if (unicode_status == UNICODE_ON) {
  11. + len = unicode_strlen(p);
  12. + }
  13. + }
  14. +#endif
  15. return len;
  16. }
  17. @@ -6829,15 +6837,7 @@ evalvar(char *p, int flags, struct strli
  18. varunset(p, var, 0, 0);
  19. if (subtype == VSLENGTH) {
  20. - ssize_t n = varlen;
  21. - if (n > 0) {
  22. - reinit_unicode_for_ash();
  23. - if (unicode_status == UNICODE_ON) {
  24. - const char *val = lookupvar(var);
  25. - n = unicode_strlen(val);
  26. - }
  27. - }
  28. - cvtnum(n > 0 ? n : 0);
  29. + cvtnum(varlen > 0 ? varlen : 0);
  30. goto record;
  31. }