# Text ASCII Helpers, View Splitting, and Bounded Growth Task ID: M-TEXT-02 Phase: P1 Status: APPROVED Contracts: C-01, C-05, C-13 ## 1. Context and baseline `src/Text/module.cmake` declares zero dependencies. `include/Void/Text/Str.hpp` currently uses `std::isspace`/`std::tolower`/`std::toupper`/`std::isalpha`/`std::isdigit`/`std::isalnum` without an explicit locale-free ASCII byte contract (`0..127` classified, bytes `>= 128` preserved unchanged) and lacks overflow/output-bounded splitting, replacing, repeating, and joining utilities. ## 2. Deliverables - Extended `include/Void/Text/Str.hpp` adding `constexpr noexcept` ASCII-only classifiers, `trim_*_ascii`, `to_lower_ascii`/`to_upper_ascii`, and `iequals_ascii`. - New `include/Void/Text/Bounded.hpp` defining `Void::Text::{TextLimits, TextError, EmptyParts, split_views, replace_bounded, repeat_bounded, join_bounded}` and re-exporting ASCII helpers. - Tests in `tests/standalone/Text/Str.cpp` and `tests/standalone/Text/Bounded.cpp`. ## 3. Exact files and interfaces - `include/Void/Text/Str.hpp`: keep all 1.x `Void::Str` signatures intact; add `is_ascii_*`, `to_*_ascii_char`, `trim_{left,right,}_ascii`, `to_{lower,upper}_ascii`, `is_{alpha,digit,alnum}_ascii`, `iequals_ascii`. - `include/Void/Text/Bounded.hpp`: `TextLimits` (`max_input=16MiB`, `max_output=16MiB`, `max_parts=65536`), `TextError`, `split_views`, `replace_bounded`, `repeat_bounded`, `join_bounded`. ## 4. Edge cases - High bytes `0x80..0xFF` and multi-byte UTF-8 sequences preserved untouched by ASCII trim/case helpers; embedded NUL bytes preserved. - Empty delimiter/needle rejected with `TextError::Code::invalid_rule`; oversized input/parts/output rejected BEFORE allocating; `SIZE_MAX` count*size multiplication rejected with `TextError::Code::overflow`; shrinking `replace_bounded` verified cleanly. ## 5. Acceptance criteria - `Str*` and `Bounded*` tests plus full `Text;Testing` suite pass under `-DVOID_WARNINGS_AS_ERRORS=ON` without Unicode linkage. ## 6. Verification commands ```sh dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-p1-text -G Ninja -DVOID_ENABLED_MODULES="Text;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-p1-text && /tmp/void-p1-text/tests/VoidTests --filter "Str*|Bounded*" && ctest --test-dir /tmp/void-p1-text --output-on-failure --timeout 60' ```