lcn2 / calc

C-style arbitrary precision calculator
http://www.isthe.com/chongo/tech/comp/calc/index.html
Other
357 stars 51 forks source link

Properly handle multi-line strings and newline returned by readline() #139

Closed gromit1811 closed 9 months ago

gromit1811 commented 9 months ago

Fix for #138

According to https://lists.gnu.org/archive/html/bug-readline/2024-01/msg00000.html it's OK for readline() to return multi-line strings and/or newlines in case of bracketed paste (enabled by default since readline 8.1) and also in other situations even though its documentation explicitly states the opposite. So we need to handle this properly in calc instead of just using the first line and dropping the rest: Split the string returned by readline() into lines and return line by line with each invocation of hist_getline(), each possbily adding a terminating newline.

lcn2 commented 9 months ago

Thank you very much, @gromit1811 for dong the research and taking the time to do this pull request.

We will begin testing this pull request via the master branch. Thanks again!