Skip to content

catini: fix file truncation by replacing FileReadLine with FileRead-based line assembly#49

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-catini-file-display
Open

catini: fix file truncation by replacing FileReadLine with FileRead-based line assembly#49
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-catini-file-display

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 27, 2026

catini was silently truncating INI files mid-read on the STM32 target because the embedded FS's FileReadLine (fgets-like) returns NULL prematurely. cat uses FileRead (fread-like) and displays files correctly.

Changes

  • commands/catini/catini.c
    • Replace Dmod_FileReadLine loop with a Dmod_FileRead chunk-loop that manually assembles lines, adding a second heap-allocated read buffer (256 B) — mirrors the proven pattern in cat.c
    • Skip \r characters to correctly handle \r\n line endings
    • Pass lines to print_highlighted_line without trailing \n; every branch now appends \n after VT100_RESET, so the reset escape always precedes the newline instead of appearing at the start of the next line
Before (buggy):  "PI1\n\033[0m"          → \033[0m at start of next line
After  (fixed):  "PI1\033[0m\n"          → \033[0m before newline, every line type

Copilot AI linked an issue May 27, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix incorrect file display in catini catini: fix file truncation by replacing FileReadLine with FileRead-based line assembly May 27, 2026
Copilot AI requested a review from JohnAmadis May 27, 2026 15:23
@JohnAmadis JohnAmadis marked this pull request as ready for review May 27, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ucinanie pliku w catini

2 participants