You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
zstr: enforce single C-string spelling, drop char* / const char* arms
The codebase's `Zstr` typedef (`const char *`) is now the only spelling
for C-strings -- bare `char *` and `const char *` are forbidden
everywhere, including inside `_Generic` dispatch arms. The old
exception that allowed `char *` / `const char *` arms (so string
literals could match) is replaced by enabling `-Wwrite-strings`
(gcc/clang/clang-cl) and `/Zc:strictStrings` (msvc/clang-cl) in
`common_c_args`. Under those flags string literals carry type
`const char *` (= `Zstr`), which lets `_Generic((literal), Zstr: ...)`
match literals directly without a bare `char *` arm.
Convention + header updates:
* `CODING-CONVENTIONS.md` Naming + `_Generic` sections: forbid `char *`
/ `const char *` anywhere; rewrite the path-dispatch skeleton to
`Str *` + `Zstr` arms only; add a "Compiler flags" section
documenting the mandatory strict-string flags.
* `Misra/Std/Zstr.h` header comment: drop the old exception clause;
define `Cstr` as the `(Zstr, size)` naming-suffix (not a type).
_Generic dispatch sweep:
* Every existing string `_Generic` macro across `Misra/Parsers/*.h`,
`Misra/Sys/*.h`, `Misra/Std/File.h`, etc. loses its `char *` arm,
has its `const char *` arm renamed to `Zstr`, and uses `(Zstr)` casts
inside arm bodies. The `((Str *)(p))->data` field reach is replaced
with the public `StrBegin((Str *)(p))` accessor.
* `const Str *` arms removed -- per the canonical "Path dispatch:
`Str *`, `Zstr`" rule.
Source-tree spelling cleanup:
* Bulk-rename `const char *` -> `Zstr` and bare `char *` -> `Zstr`
(where it's a string, not a byte buffer or kernel-boundary signature)
across `Include/`, `Source/`, `Tests/`, `Bin/`.
* Pre-existing byte-arithmetic `const char *` parameters (e.g.
`insert_range_into_vec`'s `item_data`, `vec_const_ptr_at`'s return)
converted to `const u8 *` per the existing "Raw byte buffers use
`u8 *`" rule. Caller pointer-sign warnings fixed with `(const u8 *)`
casts.
* Cascading callsites where `path.data` (typed `char *`) was passed to
macros that now dispatch on `Str *` / `Zstr` only -- callers pass
`&path` instead so the `Str *` arm matches.
Family refactors (per "Cstr / Zstr / unsuffixed-Str" canonical pattern):
* `StrIndexOf`, `StrContains`, `StrStartsWith`, `StrEndsWith`,
`StrReplace` (5 families in `Std/Container/Str/Ops.h`): the three
public PascalCase functions per family are moved to snake_case
backends in a new `Std/Container/Str/Private.h`. Replaced with a
single PascalCase macro dispatching via `MISRA_OVERLOAD` (arg count
for Cstr) + `_Generic` (Str * vs Zstr).
* `StrInsert` / `StrMustInsert` (`Std/Container/Str/Insert.h`):
unified into a single overloaded macro of the same shape.
Compiler behaviour empirically verified on GCC and Clang. MSVC and
clang-cl behaviour follows the documented `/Zc:strictStrings` flag;
CI will confirm.
Build clean (0 errors, 0 warnings); meson test 104/104 passing.
0 commit comments