Skip to content

Commit

Permalink
Fix empty lines not being processed (#916)
Browse files Browse the repository at this point in the history
As described in #661, Planck has a bug where an empty line after a
backslash is not processed and so does not produce the correct output (a
newline character). This was due to the fact a newline by itself appears
to the REPL as an empty string. This commit detects that and processes
it properly. This fixes #661.
  • Loading branch information
pyrmont authored and mfikes committed Apr 24, 2019
1 parent 62adb3e commit b6a41a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. This change

### Fixed
- Switch `strncpy` to `memcpy` to avoid GCC warning
- Backslash return return should produce "\n" ([661](https://github.com/planck-repl/planck/issues/661))

## [2.22.0] - 2019-04-06
### Added
Expand Down
10 changes: 7 additions & 3 deletions planck-c/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,14 @@ void run_cmdline_loop(repl_t *repl) {

// If the input is small process each line separately here
// so that things like brace highlighting work properly.
// But for large input, let process line more efficiently
// handle the input.
// But for large input, let process_line() more efficiently
// handle the input. The initial case is for a new line (the
// new itself is not part of input_line).
bool break_out = false;
if (strlen(input_line) < 16384) {
if (repl->input != NULL & strlen(input_line) == 0) {
repl->indent_space_count = 0;
break_out = process_line(repl, input_line, false);
} else if (strlen(input_line) < 16384) {
char *tokenize = strdup(input_line);
char *saveptr;
char *token = strtok_r(tokenize, "\n", &saveptr);
Expand Down

0 comments on commit b6a41a4

Please sign in to comment.