================
@@ -978,8 +978,14 @@ void Editline::DisplayCompletions(
       break;
 
     fprintf(editline.m_output_file, "More (Y/n/a): ");
-    char reply = 'n';
-    int got_char = el_getc(editline.m_editline, &reply);
+    // The type for the output and the type for the parameter are different,
+    // to allow interoperability with older versions of libedit. The container
+    // for the reply must be as wide as what our implementation is using,
+    // but libedit may use a narrower type depending on the build
+    // configuration.
+    EditLineGetCharType reply = L'n';
+    int got_char = el_wgetc(editline.m_editline,
----------------
kevinfrei wrote:

el_wgetc is #defined to el_getc if there's no wchar_t support (it's not at all 
consistent in this file, but I wanted to targeted fix for the crash). The core 
problem is actually with the #if code below the comment in the header:
```
#if LLDB_EDITLINE_USE_WCHAR || defined(EL_CLIENTDATA) || LLDB_HAVE_EL_RFUNC_T
using EditLineGetCharType = wchar_t;
#else
using EditLineGetCharType = char;
#endif
```

We set EditLineGetCharType to wchar_t, *even if you are building with 
`LLDB_EDITLINE_USE_WCHAR=0`* with newer versions of libedit (the ones that 
define EL_CLIENTDATA) so the function that reads a character (called from 
within libedit) is always reading a wchar_t *and writing it to the buffer 
that's backed by `&reply`*.

https://github.com/llvm/llvm-project/pull/75388
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to