cstring_readline() fix for readonly string - #38
Merged
Merged
Conversation
Add a component case that passes a non-empty readonly cstring to cstring_readline() for an empty line and for immediate EOF. The clear must return CSTRING_RC_READONLY, leave the payload in place, and leave the stream unconsumed.
Describe the cstring_readline() truncate check in CHANGES.md and NEWS.md, set Doxyfile PROJECT_NUMBER to 4.0.19, and date the cstring.core.c banner.
mwsis
approved these changes
Oct 3, 2026
synesissoftware
added a commit
that referenced
this pull request
Oct 4, 2026
* squash-commit (test.performance.cstring_readline) * date * portability * test(cstring): use auto_buffer in borrowed_fixed_assign harness Replace per-iteration std::vector arenas with stlsoft::auto_buffer (512 stack elements) so sizes ≤256 avoid a heap alloc in the timed path; rename scenario_borrowed_fixed to scenario_borrowed_fixed_assign to match the measured operation. * (fix(performance tests): `scenario_borrowed_fixed_assign()` all anchor values calculated consistently * feature(performance tests): added `scenario_borrowed_fixed_construct()` * fix(cstring): silence GCC free-nonheap-object in the perf harness GCC 15 with -Werror flags an inlined stlsoft::auto_buffer destructor as freeing its internal buffer. Suppress -Wfree-nonheap-object on test.performance.cstring; the destructor deallocates external storage only. * misc * Internal refac (#35) * misc * chore(internal): removed `CSTRING_USE_WINAPI_` and now discriminate on `_WIN32` * chore(internal): simplified includes * refactor(cstring): centralise CSTRING_ASSERT in internal.h Define CSTRING_ASSERT once in src/internal.h, with <assert.h>, and drop the copies in cstring.core.c and cstring.vector.c. Vector call sites use that macro in place of CSTRING_VECTOR_ASSERT. dllmain.c includes internal.h. * fix * misc * `cstring_readline()` fix for readonly string (#38) * dependencies * misc * test(cstring): show readline ignoring a failed readonly clear Add a component case that passes a non-empty readonly cstring to cstring_readline() for an empty line and for immediate EOF. The clear must return CSTRING_RC_READONLY, leave the payload in place, and leave the stream unconsumed. * docs(cstring): record the 4.0.19 readonly readline clear Describe the cstring_readline() truncate check in CHANGES.md and NEWS.md, set Doxyfile PROJECT_NUMBER to 4.0.19, and date the cstring.core.c banner. * fix: `cstring_readline()` (#37) * dependencies * chore(tests): canonicalised form * refactoring(tests): canonicalised form * tests(readline): more test cases * refactor(readline): canonicalising tests * fix(scripts): drop --verbosity from non-automated runners Example, performance, and scratch runners do not take --verbosity and do not pass it to the programs they launch. Each program is invoked with no extra arguments. Unit and component runners still accept the flag and forward it. Apply the same change to the cstring runners and to the cmake-helpers templates they are copied from. * fix(cstring): count the newline in cstring_readline() numRead Count every character read from the stream in numRead, including the terminating newline. A CRLF's CR is still counted and still stripped from the string. Previously that newline was omitted, so a line containing only LF reported zero. Add single-line LF and CRLF component cases and align the existing numRead expectations. Record the correction as 4.0.19. * chore(tests): simplified form(s) * fix(cstring): treat CR, LF, and CRLF as cstring_readline terminators Count every character read for the line in numRead, including the terminator, and do not store CR or LF. A lone CR, including CR at end of stream, ends the line with CSTRING_RC_SUCCESS and pushes the following character back. Add single-line LF, CRLF, and CR component cases. An embedded CR now splits a cstring_vector_readLines line. Record the correction as 4.0.19. * tests(readline): more test cases * tests(readline): more test cases * test(cstring): close readline temp files before reopen xtests::temp_file creates its Windows file with an exclusive handle and leaves that handle open. The readline component tests then fopen the same path, which Windows rejects as a sharing violation. Pass CloseOnOpen so the creating handle is closed before fopen. Drop the local argc == 0 guard, which skipped the suite on every normal invocation. * fix * fix * test(cstring): shorten test directories and name cases in `TEST_` form (#39) * test(cstring): shorten test directories and name cases in TEST_ form Shorten test directories to the subject under test/<kind>/, and name each CMake target test.<kind>.<subject>. Spell every case TEST_ in shouting snake case, keeping each API or type in its real spelling, and switch assertions to the terse xTests API. - Drop empty cases and unused temp-file names; - Rename **auto_buffer** to **cstring.borrowed**; - Use `size_t` in the performance programs; - Run CI on the **directories** branch. * docs(cstring): complete the 4.0.19 release notes Record post-4.0.18 behaviour and tests in **CHANGES.md** and **NEWS.md**; Cover zero-size realloc frees and the readline performance suite; borrowed-fixed scenarios, and shortened test directories with `TEST_` names; * chore(tests): refactored * release * test(cstring): add a C unit suite and shorten example and test names (#40) Add **test.unit.cstring** as a C port of **test.unit.cstring.cxx**, and shorten example and unit-test directories to the subject. Document memory contracts, allocators, and a default-use sketch in **README.md**, and note 5.x SSO, vector-owned payloads, and a macOS dylib in **TODO.md**. Record the split in **FAQ.md**, **NEWS.md**, and **CHANGES.md**.
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.
No description provided.