Przeglądaj źródła

fix CRLF handling (closes #3)

Oliver Fabel 1 rok temu
rodzic
commit
c0d6c6edeb
2 zmienionych plików z 8 dodań i 12 usunięć
  1. 4 0
      CHANGELOG.md
  2. 4 12
      upython_repl.c

+ 4 - 0
CHANGELOG.md

@@ -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

+ 4 - 12
upython_repl.c

@@ -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 {
@@ -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);