From 2999eed8b9dcef62db9d8a4e85219eb2775945b3 Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Thu, 10 Apr 2025 22:57:03 +0200 Subject: [PATCH] Berry 'readline' when a line is exactly 98 characters (#23276) --- CHANGELOG.md | 1 + lib/libesp32/berry_tasmota/src/be_port.cpp | 6 +++--- lib/libesp32_lvgl/lv_haspmota/src/embedded/lv_haspmota.be | 3 ++- .../lv_haspmota/src/solidify/solidified_lv_haspmota.h | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87cede085..eab4a5dd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file. ### Fixed - INA226 driver fixes (#23197) - TLS increase timeout and fix crash (#23249) +- Berry `readline` when a line is exactly 98 characters ### Removed diff --git a/lib/libesp32/berry_tasmota/src/be_port.cpp b/lib/libesp32/berry_tasmota/src/be_port.cpp index db40e153f..c07200b2d 100644 --- a/lib/libesp32/berry_tasmota/src/be_port.cpp +++ b/lib/libesp32/berry_tasmota/src/be_port.cpp @@ -315,11 +315,11 @@ char* be_fgets(void *hfile, void *buffer, int size) uint8_t * buf = (uint8_t*) buffer; if (hfile != nullptr && buffer != nullptr && size > 0) { File * f_ptr = (File*) hfile; - int ret = f_ptr->readBytesUntil('\n', buf, size - 2); - // Serial.printf("be_fgets ret=%d\n", ret); + int ret = f_ptr->readBytesUntil('\n', buf, size - 1); + // Serial.printf("be_fgets size=%d ret=%d\n", size, ret); if (ret >= 0) { buf[ret] = 0; // add string terminator - if (ret > 0 && ret < size - 2) { + if (ret < size - 1) { buf[ret] = '\n'; buf[ret+1] = 0; } diff --git a/lib/libesp32_lvgl/lv_haspmota/src/embedded/lv_haspmota.be b/lib/libesp32_lvgl/lv_haspmota/src/embedded/lv_haspmota.be index 14099e5d2..d6b53e11d 100644 --- a/lib/libesp32_lvgl/lv_haspmota/src/embedded/lv_haspmota.be +++ b/lib/libesp32_lvgl/lv_haspmota/src/embedded/lv_haspmota.be @@ -2970,7 +2970,8 @@ class HASPmota while f.tell() < f.size() # while we're not at the end of the file var line = f.readline() - if (size(line) == 0) || (line[0] == '#') # skip empty lines and lines starting with '#' + # if size is '1', the line is considered as empty because it's a '\n' character + if (size(line) <= 1) || (line[0] == '#') # skip empty lines and lines starting with '#' continue end diff --git a/lib/libesp32_lvgl/lv_haspmota/src/solidify/solidified_lv_haspmota.h b/lib/libesp32_lvgl/lv_haspmota/src/solidify/solidified_lv_haspmota.h index f83d2e671..f52d570d3 100644 --- a/lib/libesp32_lvgl/lv_haspmota/src/solidify/solidified_lv_haspmota.h +++ b/lib/libesp32_lvgl/lv_haspmota/src/solidify/solidified_lv_haspmota.h @@ -11947,7 +11947,7 @@ be_local_class(lvh_page, be_str_weak(lvh_page) ); extern const bclass be_class_HASPmota; -// compact class 'HASPmota' ktab size: 124, total: 197 (saved 584 bytes) +// compact class 'HASPmota' ktab size: 124, total: 198 (saved 592 bytes) static const bvalue be_ktab_class_HASPmota[124] = { /* K0 */ be_nested_str_weak(global), /* K1 */ be_nested_str_weak(introspect), @@ -12667,7 +12667,7 @@ be_local_closure(class_HASPmota__load, /* name */ 0x6018000C, // 000D GETGBL R6 G12 0x5C1C0A00, // 000E MOVE R7 R5 0x7C180200, // 000F CALL R6 1 - 0x1C180D06, // 0010 EQ R6 R6 K6 + 0x18180D20, // 0010 LE R6 R6 K32 0x741A0002, // 0011 JMPT R6 #0015 0x94180B06, // 0012 GETIDX R6 R5 K6 0x1C180D39, // 0013 EQ R6 R6 K57