Properly handle multi-line strings and newline returned by readline() #139
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.