Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/core/libedit/src/readline.patch
1070 views
1
I don't understand why, but I had to make a small change in order to get
2
control+d to work properly with Python + WASI. For some reason
3
e->el_tty.t_c[TS_IO] is just all zeros, whereas e->el_tty.t_c[EX_IO] is
4
interesting. Reading all the code (!), it makes way more sense to me
5
to consider e->el_tty.t_c[EX_IO] rather than e->el_tty.t_c[TS_IO].
6
Maybe this is just a decades old bug in libedit, and people usually use
7
readline, so they don't notice. I don't know.
8
9
I found that using e->el_tty.t_c[EX_IO][C_EOF] led to a lot of problems in
10
various states as well after revamping our IO and refactoring code. I'm
11
now just hardcoding the number 4, which seems to work very well in all cases for us.
12
13
--- readline-orig.c 2022-07-20 16:28:37.000000000 -0700
14
+++ readline.c 2022-07-20 16:49:05.000000000 -0700
15
@@ -2112,7 +2112,7 @@
16
el_set(e, EL_UNBUFFERED, 1);
17
if (buf == NULL || count-- <= 0)
18
return;
19
- if (count == 0 && buf[0] == e->el_tty.t_c[TS_IO][C_EOF])
20
+ if (count == 0 && buf[0] == 4)
21
done = 1;
22
if (buf[count] == '\n' || buf[count] == '\r')
23
done = 2;
24
25