Skip to content

Commit

Permalink
fix CRLF handling (closes #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofabel committed Oct 5, 2024
1 parent f7e95ab commit c0d6c6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Only the root logger is supported, so no `getLogger` function.
* Logs directly to the log output, so no output in the REPL.

### Fixed

* [#3](https://github.com/ofabel/mp-flipper/issues/3): Proper `CR` and `LF` handling in the REPL:

## [1.4.0] - 2024-09-29

### Added
Expand Down
16 changes: 4 additions & 12 deletions upython_repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ void upython_repl_execute(Cli* cli) {
uint8_t* buffer = malloc(sizeof(uint8_t));

bool exit = false;
bool wait_for_lf = false;

// REPL loop
do {
Expand Down Expand Up @@ -306,20 +305,13 @@ void upython_repl_execute(Cli* cli) {
break;
}

// wait for line feed character
if(character == CliSymbolAsciiCR) {
wait_for_lf = true;

continue;
}

// skip if we don't wait for line feed
if(!wait_for_lf && character == CliSymbolAsciiLF) {
// skip line feed
if(character == CliSymbolAsciiLF) {
continue;
}

// handle line feed
if(wait_for_lf && character == CliSymbolAsciiLF) {
// handle carriage return
if(character == CliSymbolAsciiCR) {
furi_string_push_back(context->code, '\n');
furi_string_cat(context->code, context->line);
furi_string_trim(context->code);
Expand Down

0 comments on commit c0d6c6e

Please sign in to comment.