[Repo Assist] improve: add l_buf_push_char and fix l_str_replace size guard#146
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
Conversation
- Add l_buf_push_char(L_Buf *, char) — missing single-character append helper (thin wrapper over l_buf_push), with declaration in the core L_Buf API section and implementation adjacent to the other l_buf_* functions. - Add early-return guard in l_str_replace: when find.len > s.len the previous while (pos <= s.len - find.len) condition relied on a size_t wrap-around to eventually exit. Although C unsigned arithmetic is defined, the intent is clearer with an explicit check. CI: Linux gcc+clang PASS (1515/1513 assertions). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
38 tasks
26 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist.\n\n## Summary\n\nTwo small improvements to
l_os.h:\n\n### 1.l_buf_push_char— new single-character append helper\n\nL_Bufhadl_buf_push(raw bytes),l_buf_push_str,l_buf_push_cstr, andl_buf_push_int, but no helper for appending a single character. Building output character-by-character required a local variable and al_buf_push(&b, &c, 1)call. The new helper is a trivial inline wrapper:\n\nc\nl_buf_push_char(&buf, '"'); // instead of: char q='"'; l_buf_push(&buf, &q, 1);\n\n\n### 2.l_str_replace— explicit size guard\n\nWhenfind.len > s.len, the previous loop conditionwhile (pos <= s.len - find.len)produced asize_twrap-around. While correct (l_str_find returns -1 immediately), the intent was obscured. An explicit early return makes it clear:\n\nc\nif (find.len > s.len) return l_str_dup(a, s);\n\n\n## Test Status\n\n| Platform | Build | Test |\n|:---|:---:|:---:|\n| Linux (gcc) | ✅ | ✅ 1515 assertions |\n| Linux (clang) | ✅ | ✅ 1513 assertions |\n\nARM/AArch64 not available in this runner; changes are platform-independent.