[Lldb-commits] [PATCH] D105779: RFC: [lldb] Fix editline unicode on Linux

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 13 02:15:20 PDT 2021


teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!



================
Comment at: lldb/tools/driver/Driver.cpp:872
+  ::setlocale(LC_ALL, "");
+  ::setlocale(LC_CTYPE, "");
+
----------------
jankratochvil wrote:
> teemperor wrote:
> > I don't think we need this if we set `LC_ALL`?
> Originally I have just copy-pasted it. But when testing it more now I think it makes some sense:
> ```
> #include <locale.h>
> #include <stdio.h>
> #include <wctype.h>
> int main(void) {
>   printf("setlocale(LC_ALL  )=%s\n",setlocale(LC_ALL  ,""));
>   printf("iswprint(0x17e)=%d\n",iswprint(0x17e));
>   printf("setlocale(LC_CTYPE):%s\n",setlocale(LC_CTYPE,""));
>   printf("iswprint(0x17e)=%d\n",iswprint(0x17e));
>   return 0;
> }
> $ LANG=C LC_NAME=foobar LC_CTYPE=en_US.UTF-8 ./setlocale
> setlocale(LC_ALL  )=(null)
> iswprint(0x17e)=0
> setlocale(LC_CTYPE):en_US.UTF-8
> iswprint(0x17e)=1
> ```
> Because: [[ https://pubs.opengroup.org/onlinepubs/009695399/functions/setlocale.html | Setting all of the categories of the locale of the process is similar to successively setting each individual category of the locale of the process, except that all error checking is done before any actions are performed. ]]
Good point, didn't think of that case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105779/new/

https://reviews.llvm.org/D105779



More information about the lldb-commits mailing list