Zstr
Description
Read-only NUL-terminated C string – the project name for a const char *. Zstr is the canonical C-string type in the codebase for declarations, parameters, return types, and fields. -Wwrite-strings (gcc/clang) types string literals as const char * (= Zstr) and rejects char *p = "literal".
_Generic dispatch has one carve-out: every arm matching Zstr also has a char * synonym arm with the same body. MSVC’s C _Generic follows the C standard, which types string literals as char[N] decaying to char *; /Zc:strictStrings is a C++-only flag with no effect in C mode. Inlining both arms at every dispatch site is what keeps the codebase portable to MSVC. See CODING-CONVENTIONS.md for the canonical shape.
Cstr is not a type but a naming-suffix for the (Zstr, size) form – a non-NUL-terminated view, or a NUL-terminated string truncated at an explicit length. See StrStartsWith for the canonical Cstr / Zstr / unsuffixed-Str overload family.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Std.h:28:
#include <Misra/Std/Prng.h>
#include <Misra/Std/Utility.h>
#include <Misra/Std/Zstr.h>
#if FEATURE_ALLOC_ARENA- In
Zstr.h:35:
/// canonical Cstr / Zstr / unsuffixed-Str overload family.
typedef const char *Zstr;
typedef Vec(Zstr) Zstrs;
///
- In
Zstr.h:46:
///
/// TAGS: Zstr, Length
size ZstrLen(Zstr str);
///
- In
Zstr.h:58:
///
/// TAGS: Zstr, Comparison
i32 ZstrCompare(Zstr s1, Zstr s2);
///
- In
Zstr.h:76:
/// TAGS: Zstr, Hash, Ops
///
u64 zstr_hash(const Zstr *key, u32 size);
///
- In
Zstr.h:97:
/// TAGS: Zstr, Compare, Ops
///
i32 zstr_compare(const Zstr *a, const Zstr *b, u32 size);
///
- In
Zstr.h:107:
///
/// TAGS: Zstr, Comparison
i32 ZstrCompareN(Zstr s1, Zstr s2, size n);
///
- In
Zstr.h:118:
///
/// TAGS: Zstr, Comparison, IgnoreCase
i32 ZstrCompareIgnoreCase(Zstr s1, Zstr s2);
///
- In
Zstr.h:128:
///
/// TAGS: Zstr, Comparison, IgnoreCase
i32 ZstrCompareNIgnoreCase(Zstr s1, Zstr s2, size n);
///
- In
Zstr.h:137:
///
/// TAGS: Zstr, Search
Zstr ZstrFindChar(Zstr str, char ch);
///
- In
Zstr.h:146:
///
/// TAGS: Zstr, Search
Zstr ZstrFindSubstring(Zstr haystack, Zstr needle);
///
- In
Zstr.h:155:
///
/// TAGS: Zstr, Search
Zstr ZstrFindSubstringN(Zstr haystack, Zstr needle, size needle_len);
///
- In
Zstr.h:167:
///
/// TAGS: Zstr, Allocation
Zstr zstr_dup_n(Zstr src, size n, Allocator *alloc);
#define ZstrDupN(...) OVERLOAD(ZstrDupN, __VA_ARGS__)
#define ZstrDupN_2(src, n) zstr_dup_n((src), (n), MisraScope)- In
Zstr.h:181:
///
/// TAGS: Zstr, Allocation
Zstr zstr_dup(Zstr src, Allocator *alloc);
#define ZstrDup(...) OVERLOAD(ZstrDup, __VA_ARGS__)
#define ZstrDup_1(src) zstr_dup((src), MisraScope)- In
Zstr.h:227:
///
/// TAGS: Zstr, Parse, Escape
char ZstrProcessEscape(Zstr *str);
///
- In
Zstr.h:241:
///
/// TAGS: Zstr, Parse, Integer
i64 ZstrToI64(Zstr s, Zstr *endptr);
///
- In
Zstr.h:253:
///
/// TAGS: Zstr, Parse, Float
f64 ZstrToF64(Zstr s, Zstr *endptr);
#endif // MISRA_STD_ZSTR_H
- In
ArgParse.h:45:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
ArgParse.h:59:
typedef enum ArgKind {
ARG_KIND_INVALID = 0, // unknown target type -- registration fails
ARG_KIND_ZSTR, // `Zstr *` / `char **`
ARG_KIND_STR, // `Str *`
ARG_KIND_BOOL, // `bool *`
- In
ArgParse.h:115:
///
typedef struct ArgSpec {
Zstr short_name; // "-l" or NULL; ignored for positionals
Zstr long_name; // "--listen" for options; metavar (e.g. "hostname") for positionals
Zstr help; // one-line description for `--help`
- In
ArgParse.h:116:
typedef struct ArgSpec {
Zstr short_name; // "-l" or NULL; ignored for positionals
Zstr long_name; // "--listen" for options; metavar (e.g. "hostname") for positionals
Zstr help; // one-line description for `--help`
ArgRole role;- In
ArgParse.h:117:
Zstr short_name; // "-l" or NULL; ignored for positionals
Zstr long_name; // "--listen" for options; metavar (e.g. "hostname") for positionals
Zstr help; // one-line description for `--help`
ArgRole role;
ArgKind kind;- In
ArgParse.h:139:
typedef struct ArgParse {
Allocator *alloc;
Zstr name;
Zstr about;
ArgSpecs specs;- In
ArgParse.h:140:
Allocator *alloc;
Zstr name;
Zstr about;
ArgSpecs specs;
File *out;- In
ArgParse.h:213:
/// TAGS: ArgParse, Register, Internal
///
void arg_register(ArgParse *self, ArgRole role, Zstr short_name, Zstr long_name, Zstr help, ArgTarget target);
///
- In
ArgParse.h:234:
_Generic( \
(t), \
Zstr *: ((ArgTarget) {ARG_KIND_ZSTR, (void *)(t)}), \
char **: ((ArgTarget) {ARG_KIND_ZSTR, (void *)(t)}), \
Str *: ((ArgTarget) {ARG_KIND_STR, (void *)(t)}), \
- In
File.h:16:
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
File.h:78:
/// TAGS: File, Open, API
///
File file_open(Zstr path, Zstr mode);
#define FileOpen(path, mode) \
_Generic( \- In
File.h:82:
_Generic( \
(path), \
Str *: file_open((Zstr)StrBegin((Str *)(path)), (mode)), \
Zstr: file_open((Zstr)(path), (mode)), \
char *: file_open((Zstr)(path), (mode)) \
- In
File.h:83:
(path), \
Str *: file_open((Zstr)StrBegin((Str *)(path)), (mode)), \
Zstr: file_open((Zstr)(path), (mode)), \
char *: file_open((Zstr)(path), (mode)) \
)- In
File.h:84:
Str *: file_open((Zstr)StrBegin((Str *)(path)), (mode)), \
Zstr: file_open((Zstr)(path), (mode)), \
char *: file_open((Zstr)(path), (mode)) \
)- In
File.h:200:
/// TAGS: File, Read
///
i64 file_read_and_close_to_buf(Zstr path, Buf *out);
i64 file_read_and_close_to_str(Zstr path, Str *out);
#define FileReadAndClose(path, out) \- In
File.h:201:
///
i64 file_read_and_close_to_buf(Zstr path, Buf *out);
i64 file_read_and_close_to_str(Zstr path, Str *out);
#define FileReadAndClose(path, out) \
_Generic( \- In
File.h:207:
Buf *: _Generic( \
(path), \
Str *: file_read_and_close_to_buf((Zstr)StrBegin((Str *)(path)), (Buf *)(out)), \
Zstr: file_read_and_close_to_buf((Zstr)(path), (Buf *)(out)), \
char *: file_read_and_close_to_buf((Zstr)(path), (Buf *)(out)) \
- In
File.h:208:
(path), \
Str *: file_read_and_close_to_buf((Zstr)StrBegin((Str *)(path)), (Buf *)(out)), \
Zstr: file_read_and_close_to_buf((Zstr)(path), (Buf *)(out)), \
char *: file_read_and_close_to_buf((Zstr)(path), (Buf *)(out)) \
), \
- In
File.h:209:
Str *: file_read_and_close_to_buf((Zstr)StrBegin((Str *)(path)), (Buf *)(out)), \
Zstr: file_read_and_close_to_buf((Zstr)(path), (Buf *)(out)), \
char *: file_read_and_close_to_buf((Zstr)(path), (Buf *)(out)) \
), \
Str *: _Generic( \
- In
File.h:213:
Str *: _Generic( \
(path), \
Str *: file_read_and_close_to_str((Zstr)StrBegin((Str *)(path)), (Str *)(out)), \
Zstr: file_read_and_close_to_str((Zstr)(path), (Str *)(out)), \
char *: file_read_and_close_to_str((Zstr)(path), (Str *)(out)) \
- In
File.h:214:
(path), \
Str *: file_read_and_close_to_str((Zstr)StrBegin((Str *)(path)), (Str *)(out)), \
Zstr: file_read_and_close_to_str((Zstr)(path), (Str *)(out)), \
char *: file_read_and_close_to_str((Zstr)(path), (Str *)(out)) \
) \
- In
File.h:215:
Str *: file_read_and_close_to_str((Zstr)StrBegin((Str *)(path)), (Str *)(out)), \
Zstr: file_read_and_close_to_str((Zstr)(path), (Str *)(out)), \
char *: file_read_and_close_to_str((Zstr)(path), (Str *)(out)) \
) \
)- In
File.h:249:
/// TAGS: File, Write
///
i64 file_write_and_close_from_buf(Zstr path, const Buf *in);
i64 file_write_and_close_from_str(Zstr path, const Str *in);
i64 file_write_and_close_from_bytes(Zstr path, const void *buf, u64 n);- In
File.h:250:
///
i64 file_write_and_close_from_buf(Zstr path, const Buf *in);
i64 file_write_and_close_from_str(Zstr path, const Str *in);
i64 file_write_and_close_from_bytes(Zstr path, const void *buf, u64 n);
#define FileWriteAndClose(...) OVERLOAD(FileWriteAndClose, __VA_ARGS__)- In
File.h:251:
i64 file_write_and_close_from_buf(Zstr path, const Buf *in);
i64 file_write_and_close_from_str(Zstr path, const Str *in);
i64 file_write_and_close_from_bytes(Zstr path, const void *buf, u64 n);
#define FileWriteAndClose(...) OVERLOAD(FileWriteAndClose, __VA_ARGS__)
#define FileWriteAndClose_2(path, container) \- In
File.h:258:
Buf *: _Generic( \
(path), \
Str *: file_write_and_close_from_buf((Zstr)StrBegin((Str *)(path)), (const Buf *)(container)), \
Zstr: file_write_and_close_from_buf((Zstr)(path), (const Buf *)(container)), \
char *: file_write_and_close_from_buf((Zstr)(path), (const Buf *)(container)) \
- In
File.h:259:
(path), \
Str *: file_write_and_close_from_buf((Zstr)StrBegin((Str *)(path)), (const Buf *)(container)), \
Zstr: file_write_and_close_from_buf((Zstr)(path), (const Buf *)(container)), \
char *: file_write_and_close_from_buf((Zstr)(path), (const Buf *)(container)) \
), \
- In
File.h:260:
Str *: file_write_and_close_from_buf((Zstr)StrBegin((Str *)(path)), (const Buf *)(container)), \
Zstr: file_write_and_close_from_buf((Zstr)(path), (const Buf *)(container)), \
char *: file_write_and_close_from_buf((Zstr)(path), (const Buf *)(container)) \
), \
Str *: _Generic( \
- In
File.h:264:
Str *: _Generic( \
(path), \
Str *: file_write_and_close_from_str((Zstr)StrBegin((Str *)(path)), (const Str *)(container)), \
Zstr: file_write_and_close_from_str((Zstr)(path), (const Str *)(container)), \
char *: file_write_and_close_from_str((Zstr)(path), (const Str *)(container)) \
- In
File.h:265:
(path), \
Str *: file_write_and_close_from_str((Zstr)StrBegin((Str *)(path)), (const Str *)(container)), \
Zstr: file_write_and_close_from_str((Zstr)(path), (const Str *)(container)), \
char *: file_write_and_close_from_str((Zstr)(path), (const Str *)(container)) \
) \
- In
File.h:266:
Str *: file_write_and_close_from_str((Zstr)StrBegin((Str *)(path)), (const Str *)(container)), \
Zstr: file_write_and_close_from_str((Zstr)(path), (const Str *)(container)), \
char *: file_write_and_close_from_str((Zstr)(path), (const Str *)(container)) \
) \
)- In
File.h:272:
_Generic( \
(path), \
Str *: file_write_and_close_from_bytes((Zstr)StrBegin((Str *)(path)), (buf), (n)), \
Zstr: file_write_and_close_from_bytes((Zstr)(path), (buf), (n)), \
char *: file_write_and_close_from_bytes((Zstr)(path), (buf), (n)) \
- In
File.h:273:
(path), \
Str *: file_write_and_close_from_bytes((Zstr)StrBegin((Str *)(path)), (buf), (n)), \
Zstr: file_write_and_close_from_bytes((Zstr)(path), (buf), (n)), \
char *: file_write_and_close_from_bytes((Zstr)(path), (buf), (n)) \
)- In
File.h:274:
Str *: file_write_and_close_from_bytes((Zstr)StrBegin((Str *)(path)), (buf), (n)), \
Zstr: file_write_and_close_from_bytes((Zstr)(path), (buf), (n)), \
char *: file_write_and_close_from_bytes((Zstr)(path), (buf), (n)) \
)- In
Log.h:249:
/// TAGS: Log, Write, Diagnostics, Backtrace, IO
///
void LogWrite(LogMessageType type, Zstr tag, u64 line, Zstr msg);
#endif // MISRA_STD_LOG_H
- In
Io.h:18:
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/DateTime.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/File.h>
#include <Misra/Types.h>- In
Io.h:115:
/// TAGS: I/O, Callback, Generic
///
typedef Zstr (*TypeSpecificReader)(Zstr i, FmtInfo *fmt_info, void *data);
///
- In
Io.h:304:
DateTime: TO_TYPE_SPECIFIC_IO(DateTime, &(x)), \
IOFMT_FLOAT_CASE_(x, &(x)) IOFMT_INT_CASE_(x, &(x)) IOFMT_BITVEC_CASE_(x, &(x)) IOFMT_USER_CASE_(x, &(x)) \
Zstr: TO_TYPE_SPECIFIC_IO(Zstr, &(x)), \
char *: TO_TYPE_SPECIFIC_IO(Zstr, &(x)), \
unsigned char: TO_TYPE_SPECIFIC_IO(u8, &(x)), \
- In
Io.h:305:
IOFMT_FLOAT_CASE_(x, &(x)) IOFMT_INT_CASE_(x, &(x)) IOFMT_BITVEC_CASE_(x, &(x)) IOFMT_USER_CASE_(x, &(x)) \
Zstr: TO_TYPE_SPECIFIC_IO(Zstr, &(x)), \
char *: TO_TYPE_SPECIFIC_IO(Zstr, &(x)), \
unsigned char: TO_TYPE_SPECIFIC_IO(u8, &(x)), \
unsigned short: TO_TYPE_SPECIFIC_IO(u16, &(x)), \
- In
Io.h:330:
DateTime: TO_TYPE_SPECIFIC_IO(DateTime, (void *)&(x)), \
IOFMT_FLOAT_CASE_(x, (void *)&(x)) IOFMT_INT_CASE_(x, (void *)&(x)) IOFMT_BITVEC_CASE_(x, (void *)&(x)) \
IOFMT_USER_CASE_(x, (void *)&(x)) Zstr: TO_TYPE_SPECIFIC_IO(Zstr, (void *)&(x)), \
char *: TO_TYPE_SPECIFIC_IO(Zstr, (void *)&(x)), \
unsigned char: TO_TYPE_SPECIFIC_IO(u8, (void *)&(x)), \
- In
Io.h:331:
IOFMT_FLOAT_CASE_(x, (void *)&(x)) IOFMT_INT_CASE_(x, (void *)&(x)) IOFMT_BITVEC_CASE_(x, (void *)&(x)) \
IOFMT_USER_CASE_(x, (void *)&(x)) Zstr: TO_TYPE_SPECIFIC_IO(Zstr, (void *)&(x)), \
char *: TO_TYPE_SPECIFIC_IO(Zstr, (void *)&(x)), \
unsigned char: TO_TYPE_SPECIFIC_IO(u8, (void *)&(x)), \
unsigned short: TO_TYPE_SPECIFIC_IO(u16, (void *)&(x)), \
- In
Io.h:574:
TypeSpecificIO *UNPL(argv) = &(varr)[0]; \
u64 UNPL(argc) = sizeof(varr) / sizeof(TypeSpecificIO); \
Zstr UNPL(out) = str_read_fmt((input), (fmtstr), UNPL(argv), UNPL(argc) - 1); \
if (UNPL(out)) \
(input) = UNPL(out); \
- In
Io.h:747:
bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
bool _write_Zstr(Str *o, FmtInfo *fmt_info, Zstr *s);
bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg);
bool _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);- In
Io.h:761:
#endif
Zstr _read_Str(Zstr i, FmtInfo *fmt_info, Str *s);
Zstr _read_Buf(Zstr i, FmtInfo *fmt_info, Buf *b);
Zstr _read_DateTime(Zstr i, FmtInfo *fmt_info, DateTime *dt);- In
Io.h:762:
Zstr _read_Str(Zstr i, FmtInfo *fmt_info, Str *s);
Zstr _read_Buf(Zstr i, FmtInfo *fmt_info, Buf *b);
Zstr _read_DateTime(Zstr i, FmtInfo *fmt_info, DateTime *dt);
Zstr _read_u8(Zstr i, FmtInfo *fmt_info, u8 *v);- In
Io.h:763:
Zstr _read_Str(Zstr i, FmtInfo *fmt_info, Str *s);
Zstr _read_Buf(Zstr i, FmtInfo *fmt_info, Buf *b);
Zstr _read_DateTime(Zstr i, FmtInfo *fmt_info, DateTime *dt);
Zstr _read_u8(Zstr i, FmtInfo *fmt_info, u8 *v);
Zstr _read_u16(Zstr i, FmtInfo *fmt_info, u16 *v);- In
Io.h:764:
Zstr _read_Buf(Zstr i, FmtInfo *fmt_info, Buf *b);
Zstr _read_DateTime(Zstr i, FmtInfo *fmt_info, DateTime *dt);
Zstr _read_u8(Zstr i, FmtInfo *fmt_info, u8 *v);
Zstr _read_u16(Zstr i, FmtInfo *fmt_info, u16 *v);
Zstr _read_u32(Zstr i, FmtInfo *fmt_info, u32 *v);- In
Io.h:765:
Zstr _read_DateTime(Zstr i, FmtInfo *fmt_info, DateTime *dt);
Zstr _read_u8(Zstr i, FmtInfo *fmt_info, u8 *v);
Zstr _read_u16(Zstr i, FmtInfo *fmt_info, u16 *v);
Zstr _read_u32(Zstr i, FmtInfo *fmt_info, u32 *v);
Zstr _read_u64(Zstr i, FmtInfo *fmt_info, u64 *v);- In
Io.h:766:
Zstr _read_u8(Zstr i, FmtInfo *fmt_info, u8 *v);
Zstr _read_u16(Zstr i, FmtInfo *fmt_info, u16 *v);
Zstr _read_u32(Zstr i, FmtInfo *fmt_info, u32 *v);
Zstr _read_u64(Zstr i, FmtInfo *fmt_info, u64 *v);
Zstr _read_i8(Zstr i, FmtInfo *fmt_info, i8 *v);- In
Io.h:767:
Zstr _read_u16(Zstr i, FmtInfo *fmt_info, u16 *v);
Zstr _read_u32(Zstr i, FmtInfo *fmt_info, u32 *v);
Zstr _read_u64(Zstr i, FmtInfo *fmt_info, u64 *v);
Zstr _read_i8(Zstr i, FmtInfo *fmt_info, i8 *v);
Zstr _read_i16(Zstr i, FmtInfo *fmt_info, i16 *v);- In
Io.h:768:
Zstr _read_u32(Zstr i, FmtInfo *fmt_info, u32 *v);
Zstr _read_u64(Zstr i, FmtInfo *fmt_info, u64 *v);
Zstr _read_i8(Zstr i, FmtInfo *fmt_info, i8 *v);
Zstr _read_i16(Zstr i, FmtInfo *fmt_info, i16 *v);
Zstr _read_i32(Zstr i, FmtInfo *fmt_info, i32 *v);- In
Io.h:769:
Zstr _read_u64(Zstr i, FmtInfo *fmt_info, u64 *v);
Zstr _read_i8(Zstr i, FmtInfo *fmt_info, i8 *v);
Zstr _read_i16(Zstr i, FmtInfo *fmt_info, i16 *v);
Zstr _read_i32(Zstr i, FmtInfo *fmt_info, i32 *v);
Zstr _read_i64(Zstr i, FmtInfo *fmt_info, i64 *v);- In
Io.h:770:
Zstr _read_i8(Zstr i, FmtInfo *fmt_info, i8 *v);
Zstr _read_i16(Zstr i, FmtInfo *fmt_info, i16 *v);
Zstr _read_i32(Zstr i, FmtInfo *fmt_info, i32 *v);
Zstr _read_i64(Zstr i, FmtInfo *fmt_info, i64 *v);
Zstr _read_Zstr(Zstr i, FmtInfo *fmt_info, Zstr *v);- In
Io.h:771:
Zstr _read_i16(Zstr i, FmtInfo *fmt_info, i16 *v);
Zstr _read_i32(Zstr i, FmtInfo *fmt_info, i32 *v);
Zstr _read_i64(Zstr i, FmtInfo *fmt_info, i64 *v);
Zstr _read_Zstr(Zstr i, FmtInfo *fmt_info, Zstr *v);
Zstr _read_ZstrAlloc(Zstr i, FmtInfo *fmt_info, ZstrIOArg *arg);- In
Io.h:772:
Zstr _read_i32(Zstr i, FmtInfo *fmt_info, i32 *v);
Zstr _read_i64(Zstr i, FmtInfo *fmt_info, i64 *v);
Zstr _read_Zstr(Zstr i, FmtInfo *fmt_info, Zstr *v);
Zstr _read_ZstrAlloc(Zstr i, FmtInfo *fmt_info, ZstrIOArg *arg);
Zstr _read_f32(Zstr i, FmtInfo *fmt_info, f32 *v);- In
Io.h:773:
Zstr _read_i64(Zstr i, FmtInfo *fmt_info, i64 *v);
Zstr _read_Zstr(Zstr i, FmtInfo *fmt_info, Zstr *v);
Zstr _read_ZstrAlloc(Zstr i, FmtInfo *fmt_info, ZstrIOArg *arg);
Zstr _read_f32(Zstr i, FmtInfo *fmt_info, f32 *v);
Zstr _read_f64(Zstr i, FmtInfo *fmt_info, f64 *v);- In
Io.h:774:
Zstr _read_Zstr(Zstr i, FmtInfo *fmt_info, Zstr *v);
Zstr _read_ZstrAlloc(Zstr i, FmtInfo *fmt_info, ZstrIOArg *arg);
Zstr _read_f32(Zstr i, FmtInfo *fmt_info, f32 *v);
Zstr _read_f64(Zstr i, FmtInfo *fmt_info, f64 *v);
#if FEATURE_FLOAT- In
Io.h:775:
Zstr _read_ZstrAlloc(Zstr i, FmtInfo *fmt_info, ZstrIOArg *arg);
Zstr _read_f32(Zstr i, FmtInfo *fmt_info, f32 *v);
Zstr _read_f64(Zstr i, FmtInfo *fmt_info, f64 *v);
#if FEATURE_FLOAT
Zstr _read_Float(Zstr i, FmtInfo *fmt_info, Float *value);- In
Io.h:777:
Zstr _read_f64(Zstr i, FmtInfo *fmt_info, f64 *v);
#if FEATURE_FLOAT
Zstr _read_Float(Zstr i, FmtInfo *fmt_info, Float *value);
#endif
#if FEATURE_BITVEC- In
Io.h:780:
#endif
#if FEATURE_BITVEC
Zstr _read_BitVec(Zstr i, FmtInfo *fmt_info, BitVec *bv);
#endif
#if FEATURE_INT- In
Io.h:783:
#endif
#if FEATURE_INT
Zstr _read_Int(Zstr i, FmtInfo *fmt_info, Int *value);
#endif- In
Io.h:826:
/// TAGS: Buf, Read, Format, I/O
///
bool buf_read_fmt(BufIter *iter, Zstr fmtstr, TypeSpecificIO *argv, u64 argc);
///
- In
Io.h:844:
/// TAGS: Buf, Append, Format, I/O
///
bool buf_append_fmt(Buf *out, Zstr fmtstr, TypeSpecificIO *argv, u64 argc);
///
- In
Io.h:860:
/// TAGS: Buf, Write, Format, I/O
///
bool buf_write_fmt(Buf *out, Zstr fmtstr, TypeSpecificIO *argv, u64 argc);
///
- In
Io.h:877:
/// TAGS: Buf, Patch, Format, I/O
///
bool buf_patch_fmt(Buf *out, size offset, Zstr fmtstr, TypeSpecificIO *argv, u64 argc);
///
- In
StrIter.h:15:
#include <Misra/Std/Container/Vec/Type.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Utility/Iter.h>
#include <Misra/Types.h>- In
Buf.h:16:
#include <Misra/Std/Memory.h>
#include <Misra/Std/Utility/Iter.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
Buf.h:405:
/// TAGS: Buf, Read, Zstr, String
///
static inline Zstr BufReadZstr(BufIter *c) {
Zstr s = (Zstr)(c->data + c->pos);
while (c->pos < c->length && c->data[c->pos] != 0) {- In
Buf.h:406:
///
static inline Zstr BufReadZstr(BufIter *c) {
Zstr s = (Zstr)(c->data + c->pos);
while (c->pos < c->length && c->data[c->pos] != 0) {
c->pos++;- In
Buf.h:595:
/// TAGS: Buf, Write, Zstr, String
///
static inline bool BufWriteZstr(Buf *b, Zstr s) {
while (*s) {
if (!VecPushBackR(b, (u8)*s)) {- In
Convert.h:85:
/// TAGS: Float, Convert, Parse, Decimal
///
bool float_try_from_str_zstr(Float *out, Zstr text);
bool float_try_from_str_str(Float *out, const Str *text);
#define FloatTryFromStr(out, text) \- In
Convert.h:88:
bool float_try_from_str_str(Float *out, const Str *text);
#define FloatTryFromStr(out, text) \
_Generic((text), Str *: float_try_from_str_str, Zstr: float_try_from_str_zstr, char *: float_try_from_str_zstr)( \
(out), \
(text) \- In
Convert.h:104:
/// TAGS: Float, Convert, String
///
Float float_from_str_zstr(Zstr text, Allocator *alloc);
Float float_from_str_str(const Str *text, Allocator *alloc);
#define FloatFromStr(...) OVERLOAD(FloatFromStr, __VA_ARGS__)- In
Convert.h:108:
#define FloatFromStr(...) OVERLOAD(FloatFromStr, __VA_ARGS__)
#define FloatFromStr_1(text) \
_Generic((text), Str *: float_from_str_str, Zstr: float_from_str_zstr, char *: float_from_str_zstr)( \
(text), \
MisraScope \- In
Convert.h:113:
)
#define FloatFromStr_2(text, alloc) \
_Generic((text), Str *: float_from_str_str, Zstr: float_from_str_zstr, char *: float_from_str_zstr)( \
(text), \
ALLOCATOR_OF(alloc) \- In
Pattern.h:12:
#include "Type.h"
#include <Misra/Std/Container/Str/Type.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
Pattern.h:256:
/// TAGS: BitVec, Pattern, Regex, Match
///
bool bitvec_regex_match_zstr(BitVec *bv, Zstr pattern);
bool bitvec_regex_match_str(BitVec *bv, const Str *pattern);
#define BitVecRegexMatch(bv, pattern) \- In
Pattern.h:259:
bool bitvec_regex_match_str(BitVec *bv, const Str *pattern);
#define BitVecRegexMatch(bv, pattern) \
_Generic((pattern), Str *: bitvec_regex_match_str, Zstr: bitvec_regex_match_zstr, char *: bitvec_regex_match_zstr)( \
(bv), \
(pattern) \- In
Convert.h:58:
/// TAGS: BitVec, Convert, String, Allocator
///
bool bitvec_try_from_str_zstr(BitVec *out, Zstr str, Allocator *alloc);
bool bitvec_try_from_str_str(BitVec *out, const Str *str, Allocator *alloc);
#define BitVecTryFromStr(...) OVERLOAD(BitVecTryFromStr, __VA_ARGS__)- In
Convert.h:62:
#define BitVecTryFromStr(...) OVERLOAD(BitVecTryFromStr, __VA_ARGS__)
#define BitVecTryFromStr_2(out, str) \
_Generic((str), Str *: bitvec_try_from_str_str, Zstr: bitvec_try_from_str_zstr, char *: bitvec_try_from_str_zstr)( \
(out), \
(str), \- In
Convert.h:68:
)
#define BitVecTryFromStr_3(out, str, alloc) \
_Generic((str), Str *: bitvec_try_from_str_str, Zstr: bitvec_try_from_str_zstr, char *: bitvec_try_from_str_zstr)( \
(out), \
(str), \- In
Convert.h:85:
/// TAGS: BitVec, Convert, String, Allocator
///
BitVec bitvec_from_str_zstr(Zstr str, Allocator *alloc);
BitVec bitvec_from_str_str(const Str *str, Allocator *alloc);
#define BitVecFromStr(...) OVERLOAD(BitVecFromStr, __VA_ARGS__)- In
Convert.h:89:
#define BitVecFromStr(...) OVERLOAD(BitVecFromStr, __VA_ARGS__)
#define BitVecFromStr_1(str) \
_Generic((str), Str *: bitvec_from_str_str, Zstr: bitvec_from_str_zstr, char *: bitvec_from_str_zstr)( \
(str), \
MisraScope \- In
Convert.h:94:
)
#define BitVecFromStr_2(str, alloc) \
_Generic((str), Str *: bitvec_from_str_str, Zstr: bitvec_from_str_zstr, char *: bitvec_from_str_zstr)( \
(str), \
ALLOCATOR_OF(alloc) \- In
Convert.h:182:
/// TAGS: Int, Convert, Parse, Radix
///
bool int_try_from_str_radix_zstr(Int *out, Zstr digits, u8 radix);
bool int_try_from_str_radix_str(Int *out, const Str *digits, u8 radix);
#define IntTryFromStrRadix(out, digits, radix) \- In
Convert.h:185:
bool int_try_from_str_radix_str(Int *out, const Str *digits, u8 radix);
#define IntTryFromStrRadix(out, digits, radix) \
_Generic((digits), Str *: int_try_from_str_radix_str, Zstr: int_try_from_str_radix_zstr, char *: int_try_from_str_radix_zstr)( \
(out), \
(digits), \- In
Convert.h:202:
/// TAGS: Int, Convert, Radix, String
///
Int int_from_str_radix_zstr(Zstr digits, u8 radix, Allocator *alloc);
Int int_from_str_radix_str(const Str *digits, u8 radix, Allocator *alloc);
#define IntFromStrRadix(...) OVERLOAD(IntFromStrRadix, __VA_ARGS__)- In
Convert.h:206:
#define IntFromStrRadix(...) OVERLOAD(IntFromStrRadix, __VA_ARGS__)
#define IntFromStrRadix_2(digits, radix) \
_Generic((digits), Str *: int_from_str_radix_str, Zstr: int_from_str_radix_zstr, char *: int_from_str_radix_zstr)( \
(digits), \
(radix), \- In
Convert.h:212:
)
#define IntFromStrRadix_3(digits, radix, alloc) \
_Generic((digits), Str *: int_from_str_radix_str, Zstr: int_from_str_radix_zstr, char *: int_from_str_radix_zstr)( \
(digits), \
(radix), \- In
Convert.h:258:
/// TAGS: Int, Convert, Parse, Decimal
///
bool int_try_from_str_zstr(Int *out, Zstr decimal);
bool int_try_from_str_str(Int *out, const Str *decimal);
#define IntTryFromStr(out, decimal) \- In
Convert.h:261:
bool int_try_from_str_str(Int *out, const Str *decimal);
#define IntTryFromStr(out, decimal) \
_Generic((decimal), Str *: int_try_from_str_str, Zstr: int_try_from_str_zstr, char *: int_try_from_str_zstr)( \
(out), \
(decimal) \- In
Convert.h:277:
/// TAGS: Int, Convert, String
///
Int int_from_str_zstr(Zstr decimal, Allocator *alloc);
Int int_from_str_str(const Str *decimal, Allocator *alloc);
#define IntFromStr(...) OVERLOAD(IntFromStr, __VA_ARGS__)- In
Convert.h:281:
#define IntFromStr(...) OVERLOAD(IntFromStr, __VA_ARGS__)
#define IntFromStr_1(decimal) \
_Generic((decimal), Str *: int_from_str_str, Zstr: int_from_str_zstr, char *: int_from_str_zstr)( \
(decimal), \
MisraScope \- In
Convert.h:286:
)
#define IntFromStr_2(decimal, alloc) \
_Generic((decimal), Str *: int_from_str_str, Zstr: int_from_str_zstr, char *: int_from_str_zstr)( \
(decimal), \
ALLOCATOR_OF(alloc) \- In
Convert.h:329:
/// TAGS: Int, Convert, Parse, Binary
///
bool int_try_from_binary_zstr(Int *out, Zstr binary);
bool int_try_from_binary_str(Int *out, const Str *binary);
#define IntTryFromBinary(out, binary) \- In
Convert.h:332:
bool int_try_from_binary_str(Int *out, const Str *binary);
#define IntTryFromBinary(out, binary) \
_Generic((binary), Str *: int_try_from_binary_str, Zstr: int_try_from_binary_zstr, char *: int_try_from_binary_zstr)( \
(out), \
(binary) \- In
Convert.h:348:
/// TAGS: Int, Convert, Binary
///
Int int_from_binary_zstr(Zstr binary, Allocator *alloc);
Int int_from_binary_str(const Str *binary, Allocator *alloc);
#define IntFromBinary(...) OVERLOAD(IntFromBinary, __VA_ARGS__)- In
Convert.h:352:
#define IntFromBinary(...) OVERLOAD(IntFromBinary, __VA_ARGS__)
#define IntFromBinary_1(binary) \
_Generic((binary), Str *: int_from_binary_str, Zstr: int_from_binary_zstr, char *: int_from_binary_zstr)( \
(binary), \
MisraScope \- In
Convert.h:357:
)
#define IntFromBinary_2(binary, alloc) \
_Generic((binary), Str *: int_from_binary_str, Zstr: int_from_binary_zstr, char *: int_from_binary_zstr)( \
(binary), \
ALLOCATOR_OF(alloc) \- In
Convert.h:400:
/// TAGS: Int, Convert, Parse, Octal
///
bool int_try_from_oct_str_zstr(Int *out, Zstr octal);
bool int_try_from_oct_str_str(Int *out, const Str *octal);
#define IntTryFromOctStr(out, octal) \- In
Convert.h:403:
bool int_try_from_oct_str_str(Int *out, const Str *octal);
#define IntTryFromOctStr(out, octal) \
_Generic((octal), Str *: int_try_from_oct_str_str, Zstr: int_try_from_oct_str_zstr, char *: int_try_from_oct_str_zstr)( \
(out), \
(octal) \- In
Convert.h:419:
/// TAGS: Int, Convert, Oct
///
Int int_from_oct_str_zstr(Zstr octal, Allocator *alloc);
Int int_from_oct_str_str(const Str *octal, Allocator *alloc);
#define IntFromOctStr(...) OVERLOAD(IntFromOctStr, __VA_ARGS__)- In
Convert.h:423:
#define IntFromOctStr(...) OVERLOAD(IntFromOctStr, __VA_ARGS__)
#define IntFromOctStr_1(octal) \
_Generic((octal), Str *: int_from_oct_str_str, Zstr: int_from_oct_str_zstr, char *: int_from_oct_str_zstr)( \
(octal), \
MisraScope \- In
Convert.h:428:
)
#define IntFromOctStr_2(octal, alloc) \
_Generic((octal), Str *: int_from_oct_str_str, Zstr: int_from_oct_str_zstr, char *: int_from_oct_str_zstr)( \
(octal), \
ALLOCATOR_OF(alloc) \- In
Convert.h:473:
/// TAGS: Int, Convert, Parse, Hex
///
bool int_try_from_hex_str_zstr(Int *out, Zstr hex);
bool int_try_from_hex_str_str(Int *out, const Str *hex);
#define IntTryFromHexStr(out, hex) \- In
Convert.h:476:
bool int_try_from_hex_str_str(Int *out, const Str *hex);
#define IntTryFromHexStr(out, hex) \
_Generic((hex), Str *: int_try_from_hex_str_str, Zstr: int_try_from_hex_str_zstr, char *: int_try_from_hex_str_zstr)( \
(out), \
(hex) \- In
Convert.h:492:
/// TAGS: Int, Convert, Hex
///
Int int_from_hex_str_zstr(Zstr hex, Allocator *alloc);
Int int_from_hex_str_str(const Str *hex, Allocator *alloc);
#define IntFromHexStr(...) OVERLOAD(IntFromHexStr, __VA_ARGS__)- In
Convert.h:496:
#define IntFromHexStr(...) OVERLOAD(IntFromHexStr, __VA_ARGS__)
#define IntFromHexStr_1(hex) \
_Generic((hex), Str *: int_from_hex_str_str, Zstr: int_from_hex_str_zstr, char *: int_from_hex_str_zstr)( \
(hex), \
MisraScope \- In
Convert.h:501:
)
#define IntFromHexStr_2(hex, alloc) \
_Generic((hex), Str *: int_from_hex_str_str, Zstr: int_from_hex_str_zstr, char *: int_from_hex_str_zstr)( \
(hex), \
ALLOCATOR_OF(alloc) \- In
Init.h:13:
#include "Type.h"
#include <Misra/Std/Memory.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Vec/Type.h>- In
Init.h:41:
/// TAGS: Str, Init, Cstr
///
bool str_try_init_from_cstr(Str *out, Zstr cstr, size len, Allocator *alloc);
///
- In
Init.h:60:
/// TAGS: Str, Init, Cstr
///
Str str_init_from_cstr(Zstr cstr, size len, Allocator *alloc);
///
- In
Insert.h:12:
#include "Type.h"
#include <Misra/Std/Container/Vec/Insert.h>
#include <Misra/Std/Zstr.h>
#ifdef __cplusplus- In
Insert.h:85:
#define StrInsertMany(...) OVERLOAD(StrInsertMany, __VA_ARGS__)
#define StrInsertMany_3(str, zstr, idx) \
_Generic((zstr), Zstr: VecInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))), char *: VecInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))))
#define StrInsertMany_4(str, cstr, cstr_len, idx) \
_Generic((cstr), Zstr: VecInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)), char *: VecInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)))- In
Insert.h:87:
_Generic((zstr), Zstr: VecInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))), char *: VecInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))))
#define StrInsertMany_4(str, cstr, cstr_len, idx) \
_Generic((cstr), Zstr: VecInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)), char *: VecInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)))
///
- In
Insert.h:100:
#define StrMustInsertMany(...) OVERLOAD(StrMustInsertMany, __VA_ARGS__)
#define StrMustInsertMany_3(str, zstr, idx) \
_Generic((zstr), Zstr: VecMustInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))), char *: VecMustInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))))
#define StrMustInsertMany_4(str, cstr, cstr_len, idx) \
_Generic((cstr), Zstr: VecMustInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)), char *: VecMustInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)))- In
Insert.h:102:
_Generic((zstr), Zstr: VecMustInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))), char *: VecMustInsertRangeR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))))
#define StrMustInsertMany_4(str, cstr, cstr_len, idx) \
_Generic((cstr), Zstr: VecMustInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)), char *: VecMustInsertRangeR((str), (Zstr)(cstr), (idx), (cstr_len)))
///
- In
Insert.h:118:
#define StrInsertManyFast(...) OVERLOAD(StrInsertManyFast, __VA_ARGS__)
#define StrInsertManyFast_3(str, zstr, idx) \
_Generic((zstr), Zstr: VecInsertRangeFastR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))), char *: VecInsertRangeFastR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))))
#define StrInsertManyFast_4(str, cstr, cstr_len, idx) \
_Generic((cstr), Zstr: VecInsertRangeFastR((str), (Zstr)(cstr), (idx), (cstr_len)), char *: VecInsertRangeFastR((str), (Zstr)(cstr), (idx), (cstr_len)))- In
Insert.h:120:
_Generic((zstr), Zstr: VecInsertRangeFastR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))), char *: VecInsertRangeFastR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))))
#define StrInsertManyFast_4(str, cstr, cstr_len, idx) \
_Generic((cstr), Zstr: VecInsertRangeFastR((str), (Zstr)(cstr), (idx), (cstr_len)), char *: VecInsertRangeFastR((str), (Zstr)(cstr), (idx), (cstr_len)))
///
- In
Insert.h:132:
#define StrMustInsertManyFast(...) OVERLOAD(StrMustInsertManyFast, __VA_ARGS__)
#define StrMustInsertManyFast_3(str, zstr, idx) \
_Generic((zstr), Zstr: VecMustInsertRangeFastR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))), char *: VecMustInsertRangeFastR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))))
#define StrMustInsertManyFast_4(str, cstr, cstr_len, idx) \
_Generic((cstr), Zstr: VecMustInsertRangeFastR((str), (Zstr)(cstr), (idx), (cstr_len)), char *: VecMustInsertRangeFastR((str), (Zstr)(cstr), (idx), (cstr_len)))- In
Insert.h:134:
_Generic((zstr), Zstr: VecMustInsertRangeFastR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))), char *: VecMustInsertRangeFastR((str), (Zstr)(zstr), (idx), ZstrLen((Zstr)(zstr))))
#define StrMustInsertManyFast_4(str, cstr, cstr_len, idx) \
_Generic((cstr), Zstr: VecMustInsertRangeFastR((str), (Zstr)(cstr), (idx), (cstr_len)), char *: VecMustInsertRangeFastR((str), (Zstr)(cstr), (idx), (cstr_len)))
// ---------------------------------------------------------------------------
- In
Insert.h:207:
#define StrPushBackMany(...) OVERLOAD(StrPushBackMany, __VA_ARGS__)
#define StrPushBackMany_2(str, zstr) \
_Generic((zstr), Zstr: VecPushBackArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecPushBackArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrPushBackMany_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecPushBackArrR((str), (Zstr)(cstr), (cstr_len)), char *: VecPushBackArrR((str), (Zstr)(cstr), (cstr_len)))- In
Insert.h:209:
_Generic((zstr), Zstr: VecPushBackArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecPushBackArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrPushBackMany_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecPushBackArrR((str), (Zstr)(cstr), (cstr_len)), char *: VecPushBackArrR((str), (Zstr)(cstr), (cstr_len)))
///
- In
Insert.h:221:
#define StrMustPushBackMany(...) OVERLOAD(StrMustPushBackMany, __VA_ARGS__)
#define StrMustPushBackMany_2(str, zstr) \
_Generic((zstr), Zstr: VecMustPushBackArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecMustPushBackArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrMustPushBackMany_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecMustPushBackArrR((str), (Zstr)(cstr), (cstr_len)), char *: VecMustPushBackArrR((str), (Zstr)(cstr), (cstr_len)))- In
Insert.h:223:
_Generic((zstr), Zstr: VecMustPushBackArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecMustPushBackArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrMustPushBackMany_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecMustPushBackArrR((str), (Zstr)(cstr), (cstr_len)), char *: VecMustPushBackArrR((str), (Zstr)(cstr), (cstr_len)))
// ---------------------------------------------------------------------------
- In
Insert.h:287:
#define StrPushFrontMany(...) OVERLOAD(StrPushFrontMany, __VA_ARGS__)
#define StrPushFrontMany_2(str, zstr) \
_Generic((zstr), Zstr: VecPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrPushFrontMany_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecPushFrontArrR((str), (Zstr)(cstr), (cstr_len)), char *: VecPushFrontArrR((str), (Zstr)(cstr), (cstr_len)))- In
Insert.h:289:
_Generic((zstr), Zstr: VecPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrPushFrontMany_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecPushFrontArrR((str), (Zstr)(cstr), (cstr_len)), char *: VecPushFrontArrR((str), (Zstr)(cstr), (cstr_len)))
///
- In
Insert.h:301:
#define StrMustPushFrontMany(...) OVERLOAD(StrMustPushFrontMany, __VA_ARGS__)
#define StrMustPushFrontMany_2(str, zstr) \
_Generic((zstr), Zstr: VecMustPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecMustPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrMustPushFrontMany_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecMustPushFrontArrR((str), (Zstr)(cstr), (cstr_len)), char *: VecMustPushFrontArrR((str), (Zstr)(cstr), (cstr_len)))- In
Insert.h:303:
_Generic((zstr), Zstr: VecMustPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecMustPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrMustPushFrontMany_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecMustPushFrontArrR((str), (Zstr)(cstr), (cstr_len)), char *: VecMustPushFrontArrR((str), (Zstr)(cstr), (cstr_len)))
///
- In
Insert.h:319:
#define StrPushFrontManyFast(...) OVERLOAD(StrPushFrontManyFast, __VA_ARGS__)
#define StrPushFrontManyFast_2(str, zstr) \
_Generic((zstr), Zstr: VecPushFrontArrFastR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecPushFrontArrFastR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrPushFrontManyFast_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecPushFrontArrFastR((str), (Zstr)(cstr), (cstr_len)), char *: VecPushFrontArrFastR((str), (Zstr)(cstr), (cstr_len)))- In
Insert.h:321:
_Generic((zstr), Zstr: VecPushFrontArrFastR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecPushFrontArrFastR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrPushFrontManyFast_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecPushFrontArrFastR((str), (Zstr)(cstr), (cstr_len)), char *: VecPushFrontArrFastR((str), (Zstr)(cstr), (cstr_len)))
///
- In
Insert.h:333:
#define StrMustPushFrontManyFast(...) OVERLOAD(StrMustPushFrontManyFast, __VA_ARGS__)
#define StrMustPushFrontManyFast_2(str, zstr) \
_Generic((zstr), Zstr: VecMustPushFrontArrFastR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecMustPushFrontArrFastR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrMustPushFrontManyFast_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecMustPushFrontArrFastR((str), (Zstr)(cstr), (cstr_len)), char *: VecMustPushFrontArrFastR((str), (Zstr)(cstr), (cstr_len)))- In
Insert.h:335:
_Generic((zstr), Zstr: VecMustPushFrontArrFastR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecMustPushFrontArrFastR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
#define StrMustPushFrontManyFast_3(str, cstr, cstr_len) \
_Generic((cstr), Zstr: VecMustPushFrontArrFastR((str), (Zstr)(cstr), (cstr_len)), char *: VecMustPushFrontArrFastR((str), (Zstr)(cstr), (cstr_len)))
///
- In
Ops.h:14:
#include "Type.h"
#include <Misra/Std/Utility/StrIter.h>
#include <Misra/Std/Zstr.h>
#ifdef __cplusplus- In
Ops.h:82:
(other), \
Str *: str_cmp_str ((s), (const Str *)(other)), \
Zstr: str_cmp_zstr((s), (Zstr)(other)), \
char *: str_cmp_zstr((s), (Zstr)(other)) \
)- In
Ops.h:83:
Str *: str_cmp_str ((s), (const Str *)(other)), \
Zstr: str_cmp_zstr((s), (Zstr)(other)), \
char *: str_cmp_zstr((s), (Zstr)(other)) \
)
#define StrCmp_3(s, other, other_len) str_cmp_cstr((s), (Zstr)(other), (other_len))- In
Ops.h:85:
char *: str_cmp_zstr((s), (Zstr)(other)) \
)
#define StrCmp_3(s, other, other_len) str_cmp_cstr((s), (Zstr)(other), (other_len))
///
- In
Ops.h:113:
(other), \
Str *: str_cmp_str_ignore_case ((s), (const Str *)(other)), \
Zstr: str_cmp_zstr_ignore_case((s), (Zstr)(other)), \
char *: str_cmp_zstr_ignore_case((s), (Zstr)(other)) \
)- In
Ops.h:114:
Str *: str_cmp_str_ignore_case ((s), (const Str *)(other)), \
Zstr: str_cmp_zstr_ignore_case((s), (Zstr)(other)), \
char *: str_cmp_zstr_ignore_case((s), (Zstr)(other)) \
)
#define StrCmpIgnoreCase_3(s, other, other_len) str_cmp_cstr_ignore_case((s), (Zstr)(other), (other_len))- In
Ops.h:116:
char *: str_cmp_zstr_ignore_case((s), (Zstr)(other)) \
)
#define StrCmpIgnoreCase_3(s, other, other_len) str_cmp_cstr_ignore_case((s), (Zstr)(other), (other_len))
//
- In
Ops.h:149:
(key), \
Str *: str_find_str ((s), (const Str *)(key)), \
Zstr: str_find_zstr((s), (Zstr)(key)), \
char *: str_find_zstr((s), (Zstr)(key)) \
)- In
Ops.h:150:
Str *: str_find_str ((s), (const Str *)(key)), \
Zstr: str_find_zstr((s), (Zstr)(key)), \
char *: str_find_zstr((s), (Zstr)(key)) \
)
#define StrFind_3(s, key, key_len) str_find_cstr((s), (Zstr)(key), (key_len))- In
Ops.h:152:
char *: str_find_zstr((s), (Zstr)(key)) \
)
#define StrFind_3(s, key, key_len) str_find_cstr((s), (Zstr)(key), (key_len))
///
- In
Ops.h:179:
(key), \
Str *: str_index_of_str ((s), (const Str *)(key)), \
Zstr: str_index_of_zstr((s), (Zstr)(key)), \
char *: str_index_of_zstr((s), (Zstr)(key)) \
)- In
Ops.h:180:
Str *: str_index_of_str ((s), (const Str *)(key)), \
Zstr: str_index_of_zstr((s), (Zstr)(key)), \
char *: str_index_of_zstr((s), (Zstr)(key)) \
)
#define StrIndexOf_3(s, key, key_len) str_index_of_cstr((s), (Zstr)(key), (key_len))- In
Ops.h:182:
char *: str_index_of_zstr((s), (Zstr)(key)) \
)
#define StrIndexOf_3(s, key, key_len) str_index_of_cstr((s), (Zstr)(key), (key_len))
///
- In
Ops.h:208:
(key), \
Str *: str_contains_str ((s), (const Str *)(key)), \
Zstr: str_contains_zstr((s), (Zstr)(key)), \
char *: str_contains_zstr((s), (Zstr)(key)) \
)- In
Ops.h:209:
Str *: str_contains_str ((s), (const Str *)(key)), \
Zstr: str_contains_zstr((s), (Zstr)(key)), \
char *: str_contains_zstr((s), (Zstr)(key)) \
)
#define StrContains_3(s, key, key_len) str_contains_cstr((s), (Zstr)(key), (key_len))- In
Ops.h:211:
char *: str_contains_zstr((s), (Zstr)(key)) \
)
#define StrContains_3(s, key, key_len) str_contains_cstr((s), (Zstr)(key), (key_len))
//
- In
Ops.h:243:
(prefix), \
Str *: str_starts_with_str ((s), (const Str *)(prefix)), \
Zstr: str_starts_with_zstr((s), (Zstr)(prefix)), \
char *: str_starts_with_zstr((s), (Zstr)(prefix)) \
)- In
Ops.h:244:
Str *: str_starts_with_str ((s), (const Str *)(prefix)), \
Zstr: str_starts_with_zstr((s), (Zstr)(prefix)), \
char *: str_starts_with_zstr((s), (Zstr)(prefix)) \
)
#define StrStartsWith_3(s, prefix, prefix_len) str_starts_with_cstr((s), (Zstr)(prefix), (prefix_len))- In
Ops.h:246:
char *: str_starts_with_zstr((s), (Zstr)(prefix)) \
)
#define StrStartsWith_3(s, prefix, prefix_len) str_starts_with_cstr((s), (Zstr)(prefix), (prefix_len))
///
- In
Ops.h:274:
(suffix), \
Str *: str_ends_with_str ((s), (const Str *)(suffix)), \
Zstr: str_ends_with_zstr((s), (Zstr)(suffix)), \
char *: str_ends_with_zstr((s), (Zstr)(suffix)) \
)- In
Ops.h:275:
Str *: str_ends_with_str ((s), (const Str *)(suffix)), \
Zstr: str_ends_with_zstr((s), (Zstr)(suffix)), \
char *: str_ends_with_zstr((s), (Zstr)(suffix)) \
)
#define StrEndsWith_3(s, suffix, suffix_len) str_ends_with_cstr((s), (Zstr)(suffix), (suffix_len))- In
Ops.h:277:
char *: str_ends_with_zstr((s), (Zstr)(suffix)) \
)
#define StrEndsWith_3(s, suffix, suffix_len) str_ends_with_cstr((s), (Zstr)(suffix), (suffix_len))
//
- In
Ops.h:312:
(match), \
Str *: str_replace_str ((s), (const Str *)(match), (const Str *)(replacement), (count)), \
Zstr: str_replace_zstr((s), (Zstr)(match), (Zstr)(replacement), (count)), \
char *: str_replace_zstr((s), (Zstr)(match), (Zstr)(replacement), (count)) \
)- In
Ops.h:313:
Str *: str_replace_str ((s), (const Str *)(match), (const Str *)(replacement), (count)), \
Zstr: str_replace_zstr((s), (Zstr)(match), (Zstr)(replacement), (count)), \
char *: str_replace_zstr((s), (Zstr)(match), (Zstr)(replacement), (count)) \
)
#define StrReplace_6(s, match, match_len, replacement, replacement_len, count) \- In
Ops.h:316:
)
#define StrReplace_6(s, match, match_len, replacement, replacement_len, count) \
str_replace_cstr((s), (Zstr)(match), (match_len), (Zstr)(replacement), (replacement_len), (count))
//
- In
Ops.h:346:
(key), \
Str *: str_split_to_iters_str ((s), (const Str *)(key)), \
Zstr: str_split_to_iters_zstr((s), (Zstr)(key)), \
char *: str_split_to_iters_zstr((s), (Zstr)(key)) \
)- In
Ops.h:347:
Str *: str_split_to_iters_str ((s), (const Str *)(key)), \
Zstr: str_split_to_iters_zstr((s), (Zstr)(key)), \
char *: str_split_to_iters_zstr((s), (Zstr)(key)) \
)- In
Ops.h:372:
(key), \
Str *: str_split_str ((s), (const Str *)(key)), \
Zstr: str_split_zstr((s), (Zstr)(key)), \
char *: str_split_zstr((s), (Zstr)(key)) \
)- In
Ops.h:373:
Str *: str_split_str ((s), (const Str *)(key)), \
Zstr: str_split_zstr((s), (Zstr)(key)), \
char *: str_split_zstr((s), (Zstr)(key)) \
)- In
Type.h:12:
#include <Misra/Std/Container/Common.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
Type.h:74:
///
typedef struct {
Zstr name;
MapPolicyShouldRehashFn should_rehash;
MapPolicyNextCapacityFn next_capacity;- In
Socket.h:143:
/// TAGS: Socket, Address
///
bool socket_addr_parse_zstr(SocketAddr *out, Zstr spec, SocketKind kind);
///
- In
Socket.h:162:
(spec), \
Str *: socket_addr_parse_str((out), (const Str *)(spec), (kind)), \
Zstr: socket_addr_parse_zstr((out), (Zstr)(spec), (kind)), \
char *: socket_addr_parse_zstr((out), (Zstr)(spec), (kind)) \
)- In
Socket.h:163:
Str *: socket_addr_parse_str((out), (const Str *)(spec), (kind)), \
Zstr: socket_addr_parse_zstr((out), (Zstr)(spec), (kind)), \
char *: socket_addr_parse_zstr((out), (Zstr)(spec), (kind)) \
)- In
Dir.h:17:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Zstr.h>
typedef enum DirEntryType {- In
Dir.h:40:
/// TAGS: System, Conversion, String, Utility
///
Zstr DirEntryTypeToZstr(DirEntryType type);
///
- In
Dir.h:114:
/// TAGS: System, FileSystem, Directory
///
DirContents dir_get_contents(Zstr path, Allocator *alloc);
#define DirGetContents(...) OVERLOAD(DirGetContents, __VA_ARGS__)
#define DirGetContents_1(path) \- In
Dir.h:119:
_Generic( \
(path), \
Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: dir_get_contents((Zstr)(path), MisraScope), \
char *: dir_get_contents((Zstr)(path), MisraScope) \
- In
Dir.h:120:
(path), \
Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: dir_get_contents((Zstr)(path), MisraScope), \
char *: dir_get_contents((Zstr)(path), MisraScope) \
)- In
Dir.h:121:
Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: dir_get_contents((Zstr)(path), MisraScope), \
char *: dir_get_contents((Zstr)(path), MisraScope) \
)
#define DirGetContents_2(path, alloc) \- In
Dir.h:126:
_Generic( \
(path), \
Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)) \
- In
Dir.h:127:
(path), \
Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Dir.h:128:
Str *: dir_get_contents((Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: dir_get_contents((Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Dir.h:141:
/// TAGS: System, File, Metadata
///
i64 file_get_size(Zstr filename);
#define FileGetSize(path) \
_Generic( \- In
Dir.h:145:
_Generic( \
(path), \
Str *: file_get_size((Zstr)StrBegin((Str *)(path))), \
Zstr: file_get_size((Zstr)(path)), \
char *: file_get_size((Zstr)(path)) \
- In
Dir.h:146:
(path), \
Str *: file_get_size((Zstr)StrBegin((Str *)(path))), \
Zstr: file_get_size((Zstr)(path)), \
char *: file_get_size((Zstr)(path)) \
)- In
Dir.h:147:
Str *: file_get_size((Zstr)StrBegin((Str *)(path))), \
Zstr: file_get_size((Zstr)(path)), \
char *: file_get_size((Zstr)(path)) \
)- In
Dir.h:169:
/// TAGS: System, File, FileSystem
///
i8 file_remove(Zstr path);
#define FileRemove(path) \
_Generic( \- In
Dir.h:173:
_Generic( \
(path), \
Str *: file_remove((Zstr)StrBegin((Str *)(path))), \
Zstr: file_remove((Zstr)(path)), \
char *: file_remove((Zstr)(path)) \
- In
Dir.h:174:
(path), \
Str *: file_remove((Zstr)StrBegin((Str *)(path))), \
Zstr: file_remove((Zstr)(path)), \
char *: file_remove((Zstr)(path)) \
)- In
Dir.h:175:
Str *: file_remove((Zstr)StrBegin((Str *)(path))), \
Zstr: file_remove((Zstr)(path)), \
char *: file_remove((Zstr)(path)) \
)- In
Dir.h:192:
/// TAGS: System, Directory, FileSystem
///
i8 dir_remove(Zstr path);
#define DirRemove(path) \
_Generic( \- In
Dir.h:196:
_Generic( \
(path), \
Str *: dir_remove((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_remove((Zstr)(path)), \
char *: dir_remove((Zstr)(path)) \
- In
Dir.h:197:
(path), \
Str *: dir_remove((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_remove((Zstr)(path)), \
char *: dir_remove((Zstr)(path)) \
)- In
Dir.h:198:
Str *: dir_remove((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_remove((Zstr)(path)), \
char *: dir_remove((Zstr)(path)) \
)- In
Dir.h:215:
/// TAGS: System, Directory, FileSystem
///
i8 dir_create(Zstr path);
#define DirCreate(path) \
_Generic( \- In
Dir.h:219:
_Generic( \
(path), \
Str *: dir_create((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_create((Zstr)(path)), \
char *: dir_create((Zstr)(path)) \
- In
Dir.h:220:
(path), \
Str *: dir_create((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_create((Zstr)(path)), \
char *: dir_create((Zstr)(path)) \
)- In
Dir.h:221:
Str *: dir_create((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_create((Zstr)(path)), \
char *: dir_create((Zstr)(path)) \
)- In
Dir.h:237:
/// TAGS: System, Directory, FileSystem
///
i8 dir_create_all(Zstr path);
#define DirCreateAll(path) \
_Generic( \- In
Dir.h:241:
_Generic( \
(path), \
Str *: dir_create_all((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_create_all((Zstr)(path)), \
char *: dir_create_all((Zstr)(path)) \
- In
Dir.h:242:
(path), \
Str *: dir_create_all((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_create_all((Zstr)(path)), \
char *: dir_create_all((Zstr)(path)) \
)- In
Dir.h:243:
Str *: dir_create_all((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_create_all((Zstr)(path)), \
char *: dir_create_all((Zstr)(path)) \
)- In
Dir.h:258:
/// TAGS: System, Directory, FileSystem
///
i8 dir_remove_all(Zstr path);
#define DirRemoveAll(path) \
_Generic( \- In
Dir.h:262:
_Generic( \
(path), \
Str *: dir_remove_all((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_remove_all((Zstr)(path)), \
char *: dir_remove_all((Zstr)(path)) \
- In
Dir.h:263:
(path), \
Str *: dir_remove_all((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_remove_all((Zstr)(path)), \
char *: dir_remove_all((Zstr)(path)) \
)- In
Dir.h:264:
Str *: dir_remove_all((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_remove_all((Zstr)(path)), \
char *: dir_remove_all((Zstr)(path)) \
)- In
PdbCache.h:98:
bool pdb_cache_resolve_zstr(
PdbCache *self,
Zstr module_path,
u64 module_base,
u64 runtime_ip,- In
PdbCache.h:101:
u64 module_base,
u64 runtime_ip,
Zstr *out_name,
u32 *out_offset
);- In
PdbCache.h:109:
u64 module_base,
u64 runtime_ip,
Zstr *out_name,
u32 *out_offset
);- In
PdbCache.h:123:
(out_offset) \
), \
Zstr: pdb_cache_resolve_zstr( \
(self), \
(Zstr)(module_path), \
- In
PdbCache.h:125:
Zstr: pdb_cache_resolve_zstr( \
(self), \
(Zstr)(module_path), \
(module_base), \
(runtime_ip), \
- In
PdbCache.h:133:
char *: pdb_cache_resolve_zstr( \
(self), \
(Zstr)(module_path), \
(module_base), \
(runtime_ip), \
- In
Proc.h:98:
/// TAGS: Sys, Proc, Spawn
///
Proc proc_init(Zstr path, char **argv, char **envp, Allocator *alloc);
#define ProcInit(...) OVERLOAD(ProcInit, __VA_ARGS__)- In
Proc.h:288:
Str UNPL(buf) = StrInit(); \
ProcReadFromStdout((p), &UNPL(buf)); \
Zstr UNPL(in) = StrBegin(&UNPL(buf)); \
StrReadFmt(UNPL(in), __VA_ARGS__); \
StrDeinit(&UNPL(buf)); \
- In
Proc.h:315:
Str UNPL(buf) = StrInit(); \
ProcReadFromStderr((p), &UNPL(buf)); \
Zstr UNPL(in) = StrBegin(&UNPL(buf)); \
StrReadFmt(UNPL(in), __VA_ARGS__); \
StrDeinit(&UNPL(buf)); \
///
typedef struct ResolvedSymbol {
Zstr module_path;
u64 module_base;
Zstr symbol_name; Zstr module_path;
u64 module_base;
Zstr symbol_name;
u64 symbol_value;
u64 symbol_size; u64 symbol_size;
u64 offset;
Zstr source_file;
Zstr source_dir;
u32 source_line; u64 offset;
Zstr source_file;
Zstr source_dir;
u32 source_line;
u32 source_column;
typedef struct ResolverCacheEntry {
Zstr path; // borrowed from ProcMaps.raw
Elf elf;
// Sidecar debug file found via .gnu_debuglink or .note.gnu.build-id.
- In
Dns.h:116:
///
bool dns_resolver_add_path_str(DnsResolver *self, const Str *path);
bool dns_resolver_add_path_zstr(DnsResolver *self, Zstr path, u64 len);
#define DnsResolverAddPath(...) OVERLOAD(DnsResolverAddPath, __VA_ARGS__)
#define DnsResolverAddPath_2(self, p) dns_resolver_add_path_str((self), (p))- In
Dns.h:122:
bool dns_resolver_add_hosts_path_str(DnsResolver *self, const Str *path);
bool dns_resolver_add_hosts_path_zstr(DnsResolver *self, Zstr path, u64 len);
#define DnsResolverAddHostsPath(...) OVERLOAD(DnsResolverAddHostsPath, __VA_ARGS__)
#define DnsResolverAddHostsPath_2(self, p) dns_resolver_add_hosts_path_str((self), (p))- In
Dns.h:128:
bool dns_resolver_add_resolv_path_str(DnsResolver *self, const Str *path);
bool dns_resolver_add_resolv_path_zstr(DnsResolver *self, Zstr path, u64 len);
#define DnsResolverAddResolvPath(...) OVERLOAD(DnsResolverAddResolvPath, __VA_ARGS__)
#define DnsResolverAddResolvPath_2(self, p) dns_resolver_add_resolv_path_str((self), (p))- In
Dns.h:193:
/// TAGS: Dns, Resolve, API
///
bool dns_resolve_5_zstr(DnsResolver *self, Zstr hostname, u16 port, SocketKind kind, DnsAddrs *out);
bool dns_resolve_5_str(DnsResolver *self, const Str *hostname, u16 port, SocketKind kind, DnsAddrs *out);
#define DnsResolve_5(self, hostname, port, kind, out) \- In
Dns.h:199:
(hostname), \
Str *: dns_resolve_5_str((self), (const Str *)(hostname), (port), (kind), (out)), \
Zstr: dns_resolve_5_zstr((self), (Zstr)(hostname), (port), (kind), (out)), \
char *: dns_resolve_5_zstr((self), (Zstr)(hostname), (port), (kind), (out)) \
)- In
Dns.h:200:
Str *: dns_resolve_5_str((self), (const Str *)(hostname), (port), (kind), (out)), \
Zstr: dns_resolve_5_zstr((self), (Zstr)(hostname), (port), (kind), (out)), \
char *: dns_resolve_5_zstr((self), (Zstr)(hostname), (port), (kind), (out)) \
)- In
Dns.h:217:
/// TAGS: Dns, Resolve, API
///
bool dns_resolve_4_vec_zstr(DnsResolver *self, Zstr spec, SocketKind kind, DnsAddrs *out);
bool dns_resolve_4_vec_str(DnsResolver *self, const Str *spec, SocketKind kind, DnsAddrs *out);
#define DnsResolve_4_vec(self, spec, kind, out) \- In
Dns.h:223:
(spec), \
Str *: dns_resolve_4_vec_str((self), (const Str *)(spec), (kind), (out)), \
Zstr: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (out)), \
char *: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (out)) \
)- In
Dns.h:224:
Str *: dns_resolve_4_vec_str((self), (const Str *)(spec), (kind), (out)), \
Zstr: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (out)), \
char *: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (out)) \
)- In
Dns.h:239:
/// TAGS: Dns, Resolve, API
///
bool dns_resolve_4_one_zstr(DnsResolver *self, Zstr spec, SocketKind kind, SocketAddr *out);
bool dns_resolve_4_one_str(DnsResolver *self, const Str *spec, SocketKind kind, SocketAddr *out);- In
Dns.h:257:
(spec), \
Str *: dns_resolve_4_vec_str((self), (const Str *)(spec), (kind), (DnsAddrs *)(out)), \
Zstr: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (DnsAddrs *)(out)), \
char *: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (DnsAddrs *)(out)) \
), \
- In
Dns.h:258:
Str *: dns_resolve_4_vec_str((self), (const Str *)(spec), (kind), (DnsAddrs *)(out)), \
Zstr: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (DnsAddrs *)(out)), \
char *: dns_resolve_4_vec_zstr((self), (Zstr)(spec), (kind), (DnsAddrs *)(out)) \
), \
SocketAddr *: _Generic( \
- In
Dns.h:263:
(spec), \
Str *: dns_resolve_4_one_str((self), (const Str *)(spec), (kind), (SocketAddr *)(out)), \
Zstr: dns_resolve_4_one_zstr((self), (Zstr)(spec), (kind), (SocketAddr *)(out)), \
char *: dns_resolve_4_one_zstr((self), (Zstr)(spec), (kind), (SocketAddr *)(out)) \
) \
- In
Dns.h:264:
Str *: dns_resolve_4_one_str((self), (const Str *)(spec), (kind), (SocketAddr *)(out)), \
Zstr: dns_resolve_4_one_zstr((self), (Zstr)(spec), (kind), (SocketAddr *)(out)), \
char *: dns_resolve_4_one_zstr((self), (Zstr)(spec), (kind), (SocketAddr *)(out)) \
) \
)- In
MachoCache.h:102:
bool macho_cache_resolve_zstr(
MachoCache *self,
Zstr module_path,
u64 slide,
u64 runtime_ip,- In
MachoCache.h:105:
u64 slide,
u64 runtime_ip,
Zstr *out_name,
u32 *out_offset
);- In
MachoCache.h:113:
u64 slide,
u64 runtime_ip,
Zstr *out_name,
u32 *out_offset
);- In
MachoCache.h:120:
(module_path), \
Str *: macho_cache_resolve_str((self), (const Str *)(module_path), (slide), (runtime_ip), (out_name), (out_offset)), \
Zstr: macho_cache_resolve_zstr((self), (Zstr)(module_path), (slide), (runtime_ip), (out_name), (out_offset)), \
char *: macho_cache_resolve_zstr((self), (Zstr)(module_path), (slide), (runtime_ip), (out_name), (out_offset)) \
)- In
MachoCache.h:121:
Str *: macho_cache_resolve_str((self), (const Str *)(module_path), (slide), (runtime_ip), (out_name), (out_offset)), \
Zstr: macho_cache_resolve_zstr((self), (Zstr)(module_path), (slide), (runtime_ip), (out_name), (out_offset)), \
char *: macho_cache_resolve_zstr((self), (Zstr)(module_path), (slide), (runtime_ip), (out_name), (out_offset)) \
)- In
Http.h:96:
/// TAGS: Http, Find, Header
///
HttpHeader *http_headers_find_zstr(HttpHeaders *headers, Zstr key);
HttpHeader *http_headers_find_str(HttpHeaders *headers, const Str *key);
#define HttpHeadersFind(headers, key) \- In
Http.h:99:
HttpHeader *http_headers_find_str(HttpHeaders *headers, const Str *key);
#define HttpHeadersFind(headers, key) \
_Generic((key), Str *: http_headers_find_str, Zstr: http_headers_find_zstr, char *: http_headers_find_zstr)( \
(headers), \
(key) \- In
Http.h:267:
(in), \
Str *: http_request_parse_str((req), (const Str *)(in)), \
Zstr: http_request_parse_zstr((req), (Zstr)(in)), \
char *: http_request_parse_zstr((req), (Zstr)(in)) \
)- In
Http.h:268:
Str *: http_request_parse_str((req), (const Str *)(in)), \
Zstr: http_request_parse_zstr((req), (Zstr)(in)), \
char *: http_request_parse_zstr((req), (Zstr)(in)) \
)- In
Http.h:329:
/// TAGS: Http, ResponseCode, Response, Convert, Zstr
///
Zstr HttpResponseCodeToZstr(HttpResponseCode code);
Zstr HttpContentTypeToZstr(HttpContentType content_type);- In
Http.h:330:
///
Zstr HttpResponseCodeToZstr(HttpResponseCode code);
Zstr HttpContentTypeToZstr(HttpContentType content_type);
///
- In
Http.h:359:
(filepath), \
Str *: http_respond_with_file_str((response), (status), (content_type), (const Str *)(filepath)), \
Zstr: http_respond_with_file_zstr((response), (status), (content_type), (Zstr)(filepath)), \
char *: http_respond_with_file_zstr((response), (status), (content_type), (Zstr)(filepath)) \
)- In
Http.h:360:
Str *: http_respond_with_file_str((response), (status), (content_type), (const Str *)(filepath)), \
Zstr: http_respond_with_file_zstr((response), (status), (content_type), (Zstr)(filepath)), \
char *: http_respond_with_file_zstr((response), (status), (content_type), (Zstr)(filepath)) \
)
#endif- In
KvConfig.h:36:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Utility/StrIter.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
KvConfig.h:220:
///
#define KvConfigGet(cfg, key) \
_Generic((key), Str *: kvconfig_get_str, Zstr: kvconfig_get_zstr, char *: kvconfig_get_zstr)((cfg), (key))
///
- In
KvConfig.h:234:
///
#define KvConfigGetPtr(cfg, key) \
_Generic((key), Str *: kvconfig_get_ptr_str, Zstr: kvconfig_get_ptr_zstr, char *: kvconfig_get_ptr_zstr)( \
(cfg), \
(key) \- In
KvConfig.h:251:
///
#define KvConfigContains(cfg, key) \
_Generic((key), Str *: kvconfig_contains_str, Zstr: kvconfig_contains_zstr, char *: kvconfig_contains_zstr)( \
(cfg), \
(key) \- In
KvConfig.h:271:
///
#define KvConfigGetBool(cfg, key, value) \
_Generic((key), Str *: kvconfig_get_bool_str, Zstr: kvconfig_get_bool_zstr, char *: kvconfig_get_bool_zstr)( \
(cfg), \
(key), \- In
KvConfig.h:290:
///
#define KvConfigGetI64(cfg, key, value) \
_Generic((key), Str *: kvconfig_get_i64_str, Zstr: kvconfig_get_i64_zstr, char *: kvconfig_get_i64_zstr)( \
(cfg), \
(key), \- In
KvConfig.h:309:
///
#define KvConfigGetF64(cfg, key, value) \
_Generic((key), Str *: kvconfig_get_f64_str, Zstr: kvconfig_get_f64_zstr, char *: kvconfig_get_f64_zstr)( \
(cfg), \
(key), \- In
Pdb.h:33:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
Pdb.h:51:
u32 rva;
u32 size;
Zstr name;
} PdbFunction;- In
Pdb.h:134:
_Generic( \
(path), \
Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: pdb_open((out), (Zstr)(path), MisraScope), \
char *: pdb_open((out), (Zstr)(path), MisraScope) \
- In
Pdb.h:135:
(path), \
Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: pdb_open((out), (Zstr)(path), MisraScope), \
char *: pdb_open((out), (Zstr)(path), MisraScope) \
)- In
Pdb.h:136:
Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: pdb_open((out), (Zstr)(path), MisraScope), \
char *: pdb_open((out), (Zstr)(path), MisraScope) \
)
#define PdbOpen_3(out, path, alloc) \- In
Pdb.h:141:
_Generic( \
(path), \
Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
- In
Pdb.h:142:
(path), \
Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Pdb.h:143:
Str *: pdb_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pdb_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Dwarf.h:50:
typedef struct DwarfLineEntry {
u64 address;
Zstr file;
Zstr dir;
u32 line;- In
Dwarf.h:51:
u64 address;
Zstr file;
Zstr dir;
u32 line;
u32 column;- In
Dwarf.h:323:
u64 low_pc; // file-relative virtual address (same space as ElfSymbol.value)
u64 high_pc; // exclusive end
Zstr name; // borrowed from `string_pool`
} DwarfFunction;- In
Elf.h:24:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
Elf.h:125:
///
typedef struct ElfSection {
Zstr name;
u32 type; // ElfSectionType plus arch-specific extensions
u64 flags;- In
Elf.h:141:
///
typedef struct ElfSymbol {
Zstr name;
ElfSymbolBind bind;
ElfSymbolType type;- In
Elf.h:229:
const u8 *build_id;
u32 build_id_size;
Zstr debuglink_name;
u32 debuglink_crc;
} Elf;- In
Elf.h:262:
_Generic( \
(path), \
Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: elf_open((out), (Zstr)(path), MisraScope), \
char *: elf_open((out), (Zstr)(path), MisraScope) \
- In
Elf.h:263:
(path), \
Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: elf_open((out), (Zstr)(path), MisraScope), \
char *: elf_open((out), (Zstr)(path), MisraScope) \
)- In
Elf.h:264:
Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: elf_open((out), (Zstr)(path), MisraScope), \
char *: elf_open((out), (Zstr)(path), MisraScope) \
)
#define ElfOpen_3(out, path, alloc) \- In
Elf.h:269:
_Generic( \
(path), \
Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
- In
Elf.h:270:
(path), \
Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Elf.h:271:
Str *: elf_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: elf_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Elf.h:381:
///
#define ElfFindSection(self, name) \
_Generic((name), Str *: elf_find_section_str, Zstr: elf_find_section_zstr, char *: elf_find_section_zstr)( \
(self), \
(name) \- In
Pe.h:26:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
Pe.h:77:
u8 guid[16];
u32 age;
Zstr pdb_path;
} PeCodeViewInfo;- In
Pe.h:139:
_Generic( \
(path), \
Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: pe_open((out), (Zstr)(path), MisraScope), \
char *: pe_open((out), (Zstr)(path), MisraScope) \
- In
Pe.h:140:
(path), \
Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: pe_open((out), (Zstr)(path), MisraScope), \
char *: pe_open((out), (Zstr)(path), MisraScope) \
)- In
Pe.h:141:
Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: pe_open((out), (Zstr)(path), MisraScope), \
char *: pe_open((out), (Zstr)(path), MisraScope) \
)
#define PeOpen_3(out, path, alloc) \- In
Pe.h:146:
_Generic( \
(path), \
Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
- In
Pe.h:147:
(path), \
Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Pe.h:148:
Str *: pe_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: pe_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
Pe.h:214:
///
#define PeFindSection(self, name) \
_Generic((name), Str *: pe_find_section_str, Zstr: pe_find_section_zstr, char *: pe_find_section_zstr)( \
(self), \
(name) \- In
JSON.h:745:
StrPushBackR(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (Zstr)(k)); \
JW_OBJ(j, writer); \
} while (0)- In
JSON.h:811:
StrPushBackR(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (Zstr)(k)); \
JW_ARR(j, arr, item, writer); \
} while (0)- In
JSON.h:857:
StrPushBackR(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (Zstr)(k)); \
JW_INT(j, i); \
} while (0)- In
JSON.h:903:
StrPushBackR(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (Zstr)(k)); \
JW_FLT(j, f); \
} while (0)- In
JSON.h:925:
const Str *UNPL(jw_s) = &(s); \
u64 UNPL(jw_len) = StrLen(UNPL(jw_s)); \
StrAppendFmt(&(j), "\"{}\"", UNPL(jw_len) ? (Zstr)StrBegin(UNPL(jw_s)) : (Zstr) ""); \
} while (0)- In
JSON.h:950:
StrPushBackR(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (Zstr)(k)); \
JW_STR(j, s); \
} while (0)- In
JSON.h:970:
#define JW_BOOL(j, b) \
do { \
StrAppendFmt(&(j), "{}", (Zstr)((b) ? "true" : "false")); \
} while (0)- In
JSON.h:995:
StrPushBackR(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (Zstr)(k)); \
JW_BOOL(j, b); \
} while (0)- In
MachO.h:30:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
MachO.h:74:
///
typedef struct MachoSymbol {
Zstr name;
u64 value; // virtual address
u8 type; // n_type bitfield
- In
MachO.h:160:
_Generic( \
(path), \
Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: macho_open((out), (Zstr)(path), MisraScope), \
char *: macho_open((out), (Zstr)(path), MisraScope) \
- In
MachO.h:161:
(path), \
Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: macho_open((out), (Zstr)(path), MisraScope), \
char *: macho_open((out), (Zstr)(path), MisraScope) \
)- In
MachO.h:162:
Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), MisraScope), \
Zstr: macho_open((out), (Zstr)(path), MisraScope), \
char *: macho_open((out), (Zstr)(path), MisraScope) \
)
#define MachoOpen_3(out, path, alloc) \- In
MachO.h:167:
_Generic( \
(path), \
Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
- In
MachO.h:168:
(path), \
Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
MachO.h:169:
Str *: macho_open((out), (Zstr)StrBegin((Str *)(path)), ALLOCATOR_OF(alloc)), \
Zstr: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)), \
char *: macho_open((out), (Zstr)(path), ALLOCATOR_OF(alloc)) \
)- In
MachO.h:238:
macho_find_section( \
(self), \
_Generic((segment), Str *: (Zstr)StrBegin((Str *)(segment)), Zstr: (Zstr)(segment), char *: (Zstr)(segment)), \
_Generic((section), Str *: (Zstr)StrBegin((Str *)(section)), Zstr: (Zstr)(section), char *: (Zstr)(section)) \
)- In
MachO.h:239:
(self), \
_Generic((segment), Str *: (Zstr)StrBegin((Str *)(segment)), Zstr: (Zstr)(segment), char *: (Zstr)(segment)), \
_Generic((section), Str *: (Zstr)StrBegin((Str *)(section)), Zstr: (Zstr)(section), char *: (Zstr)(section)) \
)- In
Dns.h:126:
(name), \
Str *: dns_build_query_str((out), (id), (const Str *)(name), (type)), \
Zstr: dns_build_query_zstr((out), (id), (Zstr)(name), (type)), \
char *: dns_build_query_zstr((out), (id), (Zstr)(name), (type)) \
)- In
Dns.h:127:
Str *: dns_build_query_str((out), (id), (const Str *)(name), (type)), \
Zstr: dns_build_query_zstr((out), (id), (Zstr)(name), (type)), \
char *: dns_build_query_zstr((out), (id), (Zstr)(name), (type)) \
)- In
ProcMaps.h:44:
u32 perms; // bitmask of ProcMapPerms
u64 file_offset; // offset within the backing file
Zstr path; // backing file path, or "" if anonymous
} ProcMapEntry;- In
VecCharPtr.c:11:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Zstr.h>
// Copy function for char* - duplicates the string. Signature must match
- In
_WinStubs.c:27:
#include <Misra/Config.h>
#include <Misra/Std/Zstr.h>
#if PLATFORM_WINDOWS- In
_WinStubs.c:183:
// without libc). Same `__imp_<name>` indirect-call convention as
// `__stdio_common_vsprintf` above.
static char *getenv_stub(Zstr name) {
(void)name;
return ((char *)0);- In
Sys.c:32:
// (UCRT) maps most of them to the same values; the ones it diverges
// on don't matter for our call sites today.
static Zstr errno_description(i32 eno) {
switch (eno) {
#ifdef EPERM- In
Sys.c:325:
char **envp_global = NULL;
#elif PLATFORM_WINDOWS
__declspec(dllimport) extern char *__cdecl getenv(Zstr name);
#endif- In
Sys.c:328:
#endif
Zstr EnvGet(Zstr name) {
if (!name) {
return NULL;- In
Sys.c:338:
// Match `name` against the prefix of each entry up to '='.
for (char **e = envp_global; *e; ++e) {
Zstr entry = *e;
Zstr n = name;
while (*n && *entry == *n) {- In
Sys.c:339:
for (char **e = envp_global; *e; ++e) {
Zstr entry = *e;
Zstr n = name;
while (*n && *entry == *n) {
++entry;- In
Sys.c:350:
return NULL;
#elif PLATFORM_WINDOWS
return (Zstr)getenv(name);
#elif PLATFORM_DARWIN
// No libSystem `_getenv` reference -- callers must capture envp
- In
Log.c:39:
#endif
void LogWrite(LogMessageType type, Zstr tag, u64 line, Zstr msg) {
if (!msg) {
return;- In
Log.c:47:
}
static Zstr NAMES[] = {
[LOG_MESSAGE_TYPE_FATAL] = "FATAL",
[LOG_MESSAGE_TYPE_ERROR] = "ERROR",- In
Log.c:55:
HeapAllocator h = HeapAllocatorInit();
Str full = StrInit(&h);
StrAppendFmt(&full, "[{}] [{}:{}] {}\n", (Zstr)NAMES[type], (Zstr)tag, line, (Zstr)msg);
File out = (type == LOG_MESSAGE_TYPE_INFO) ? FileFromFd(1) : FileFromFd(2);- In
File.c:36:
// in higher-level code, not at the syscall boundary. Returns false if
// the mode is malformed.
static bool parse_open_mode(Zstr mode, int *out_flags) {
#if PLATFORM_WINDOWS
(void)mode;- In
File.c:47:
char primary = mode[0];
bool plus = false;
for (Zstr p = mode + 1; *p; ++p) {
if (*p == '+') {
plus = true;- In
File.c:76:
// ---------------------------------------------------------------------------
File file_open(Zstr path, Zstr mode) {
File f = {0};
#if PLATFORM_WINDOWS- In
File.c:86:
DWORD disposition = OPEN_EXISTING;
bool plus = false;
for (Zstr p = mode + 1; *p; ++p) {
if (*p == '+')
plus = true;- In
ArgParse.c:9:
#include <Misra/Std/ArgParse.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Io.h>- In
ArgParse.c:22:
// Human-readable type name used in invalid-value error messages. Lines
// up 1:1 with the ArgKind enum; new entries get a label here.
static Zstr arg_kind_label(ArgKind k) {
switch (k) {
case ARG_KIND_ZSTR :- In
ArgParse.c:55:
}
static bool zstr_eq(Zstr a, Zstr b) {
return a && b && ZstrCompare(a, b) == 0;
}- In
ArgParse.c:62:
// Returns false on empty input, non-digit content, or trailing junk.
// Signed range checked against the caller-supplied lo/hi.
static bool parse_signed(Zstr s, i64 lo, i64 hi, i64 *out) {
if (!s || !*s)
return false;- In
ArgParse.c:65:
if (!s || !*s)
return false;
Zstr end = NULL;
i64 v = ZstrToI64(s, &end);
if (!end || end == s || *end != '\0')- In
ArgParse.c:77:
// Same shape, unsigned. ZstrToI64 doesn't span the unsigned-64 range
// past 0x7fffffffffffffff so we walk decimal digits ourselves.
static bool parse_unsigned(Zstr s, u64 hi, u64 *out) {
if (!s || !*s)
return false;- In
ArgParse.c:101:
}
static bool parse_bool(Zstr s, bool *out) {
if (zstr_eq(s, "true") || zstr_eq(s, "1") || zstr_eq(s, "yes") || zstr_eq(s, "on")) {
*out = true;- In
ArgParse.c:113:
}
static bool parse_f64_full(Zstr s, f64 *out) {
if (!s || !*s)
return false;- In
ArgParse.c:116:
if (!s || !*s)
return false;
Zstr end = NULL;
f64 v = ZstrToF64(s, &end);
if (!end || end == s || *end != '\0')- In
ArgParse.c:128:
// false on type-mismatch / out-of-range so the caller can emit a
// "invalid value 'X' for --flag: expected <type>" message.
static bool store_value(ArgKind kind, void *target, Zstr value) {
switch (kind) {
case ARG_KIND_ZSTR : {- In
ArgParse.c:131:
switch (kind) {
case ARG_KIND_ZSTR : {
*(Zstr *)target = value;
return true;
}- In
ArgParse.c:238:
// ---------------------------------------------------------------------------
static ArgSpec *find_long(ArgParse *self, Zstr long_name) {
VecForeachPtr(&self->specs, sp) {
if (sp->role == ARG_ROLE_POSITIONAL)- In
ArgParse.c:248:
}
static ArgSpec *find_short(ArgParse *self, Zstr short_name) {
VecForeachPtr(&self->specs, sp) {
if (sp->role == ARG_ROLE_POSITIONAL)- In
ArgParse.c:267:
// short-only options without a long form we fall back to "VALUE".
static void append_metavar(Str *out, const ArgSpec *sp) {
Zstr src = sp->long_name;
if (!src) {
StrPushBackMany(out, "VALUE");- In
ArgParse.c:422:
// ---------------------------------------------------------------------------
void arg_register(ArgParse *self, ArgRole role, Zstr short_name, Zstr long_name, Zstr help, ArgTarget target) {
if (!self)
LOG_FATAL("arg_register: NULL parser");- In
ArgParse.c:471:
static ArgRun handle_option_token(
ArgParse *self,
Zstr tok,
int *i_io, // walked forward by 1 when we consume a value
int argc,- In
ArgParse.c:478:
) {
bool is_long = (tok[0] == '-' && tok[1] == '-');
Zstr eq = NULL;
Zstr inline_v = NULL;- In
ArgParse.c:479:
bool is_long = (tok[0] == '-' && tok[1] == '-');
Zstr eq = NULL;
Zstr inline_v = NULL;
if (is_long) {- In
ArgParse.c:493:
ArgRun result = ARG_RUN_ERROR;
StrInitStack(flagbuf, 128) {
Zstr flag = tok;
if (eq) {
u64 n = (u64)(eq - tok);- In
ArgParse.c:545:
case ARG_ROLE_REQUIRED :
case ARG_ROLE_OPTIONAL : {
Zstr val = inline_v;
if (!val) {
if (*i_io + 1 >= argc) {- In
ArgParse.c:581:
// when -v is a Flag or a Count. -lFOO (stuck value) is intentionally
// not supported in v1.
static ArgRun handle_short_bundle(ArgParse *self, Zstr tok, File *err) {
// tok looks like "-XYZ..."; verify every char maps to a Flag/Count.
ArgRun result = ARG_RUN_OK;- In
ArgParse.c:584:
// tok looks like "-XYZ..."; verify every char maps to a Flag/Count.
ArgRun result = ARG_RUN_OK;
for (Zstr p = tok + 1; *p; ++p) {
bool iter_ok = false;
StrInitStack(buf, 3) {- In
ArgParse.c:593:
StrResize(&buf, 2);
ArgSpec *sp = find_short(self, (Zstr)data);
if (!sp) {
FWriteFmtLn(err, "{}: unknown option: {}", self->name, (Zstr)data);- In
ArgParse.c:595:
ArgSpec *sp = find_short(self, (Zstr)data);
if (!sp) {
FWriteFmtLn(err, "{}: unknown option: {}", self->name, (Zstr)data);
break;
}- In
ArgParse.c:605:
sp->seen = true;
} else {
FWriteFmtLn(err, "{}: option {} requires a value, can't bundle", self->name, (Zstr)data);
break;
}- In
ArgParse.c:660:
for (int i = 1; i < argc; ++i) {
Zstr tok = argv[i];
if (!rest_positional) {- In
ArgParse.c:690:
StrResize(&two, 2);
ArgSpec *first = find_short(self, (Zstr)data);
if (first && (first->role == ARG_ROLE_FLAG || first->role == ARG_ROLE_COUNT)) {
decision = BUNDLE_TRY;- In
ArgParse.c:698:
"{}: short value option '{}' cannot be bundled; use form '{} VAL' or '{}=VAL'",
self->name,
(Zstr)data,
(Zstr)data,
(Zstr)data- In
ArgParse.c:699:
self->name,
(Zstr)data,
(Zstr)data,
(Zstr)data
);- In
ArgParse.c:700:
(Zstr)data,
(Zstr)data,
(Zstr)data
);
}- In
Io.c:19:
#include <Misra/Std/Log.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys.h>
#include <Misra/Types.h>- In
Io.c:63:
static bool _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);
static Zstr _read_r8(Zstr i, FmtInfo *fmt_info, u8 *v);
static Zstr _read_r16(Zstr i, FmtInfo *fmt_info, u16 *v);
static Zstr _read_r32(Zstr i, FmtInfo *fmt_info, u32 *v);- In
Io.c:64:
static Zstr _read_r8(Zstr i, FmtInfo *fmt_info, u8 *v);
static Zstr _read_r16(Zstr i, FmtInfo *fmt_info, u16 *v);
static Zstr _read_r32(Zstr i, FmtInfo *fmt_info, u32 *v);
static Zstr _read_r64(Zstr i, FmtInfo *fmt_info, u64 *v);- In
Io.c:65:
static Zstr _read_r8(Zstr i, FmtInfo *fmt_info, u8 *v);
static Zstr _read_r16(Zstr i, FmtInfo *fmt_info, u16 *v);
static Zstr _read_r32(Zstr i, FmtInfo *fmt_info, u32 *v);
static Zstr _read_r64(Zstr i, FmtInfo *fmt_info, u64 *v);- In
Io.c:66:
static Zstr _read_r16(Zstr i, FmtInfo *fmt_info, u16 *v);
static Zstr _read_r32(Zstr i, FmtInfo *fmt_info, u32 *v);
static Zstr _read_r64(Zstr i, FmtInfo *fmt_info, u64 *v);
// Avoids `__builtin_clzll`: we'd need a separate MSVC branch via
- In
Io.c:109:
// any base prefix; type is one of `c`/`a`/`A`/`x`/`X`/`b`/`o`/`r`/`e`/
// `E`/`s`.
static bool parse_format_spec(Zstr spec, u32 len, FmtInfo *fi) {
if (!spec || !fi) {
LOG_FATAL("Invalid arguments");- In
Io.c:293:
}
bool str_append_fmt(Str *o, Zstr fmt, TypeSpecificIO *args, u64 argc) {
if (!o || !fmt) {
LOG_FATAL("Invalid arguments");- In
Io.c:480:
}
bool str_write_fmt(Str *o, Zstr fmt, TypeSpecificIO *args, u64 argc) {
if (!o || !fmt) {
LOG_FATAL("Invalid arguments");- In
Io.c:489:
}
bool str_patch_fmt(Str *o, size offset, Zstr fmt, TypeSpecificIO *args, u64 argc) {
if (!o || !fmt) {
LOG_FATAL("Invalid arguments");- In
Io.c:519:
}
bool f_write_fmt(File *stream, Zstr fmtstr, TypeSpecificIO *argv, u64 argc, bool append_newline) {
Str out;
bool ok = true;- In
Io.c:558:
}
Zstr str_read_fmt(Zstr input, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
if (!input || !fmtstr) {
LOG_FATAL("Invalid arguments");- In
Io.c:563:
}
Zstr p = fmtstr;
Zstr in = input;
u64 rem_p = ZstrLen(fmtstr);- In
Io.c:564:
Zstr p = fmtstr;
Zstr in = input;
u64 rem_p = ZstrLen(fmtstr);
u64 rem_in = ZstrLen(in);- In
Io.c:590:
rem_p--;
Zstr start = p;
size spec_len = 0;
while (rem_p > 0 && *p != '}') {- In
Io.c:646:
// table instead of the type-specific reader the caller
// registered.
Zstr next = NULL;
TypeSpecificReader raw_reader = NULL;
if (fmt_info.flags & FMT_FLAG_RAW) {- In
Io.c:759:
if (space_len) {
Zstr e = NULL;
if ((e = ZstrFindSubstringN(in, p, space_len))) {
fmt_info.max_read_len = e - in;- In
Io.c:812:
// ---------------------------------------------------------------------------
bool buf_read_fmt(BufIter *iter, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
if (!iter || !fmtstr) {
LOG_FATAL("buf_read_fmt: NULL iter or fmtstr");- In
Io.c:848:
}
StrIter spec_start_fsi = fsi;
Zstr spec_start = (Zstr)StrIterPos(&fsi);
char sc = 0;
while (StrIterPeek(&fsi, &sc) && sc != '}') {- In
Io.c:883:
// Read the raw bytes into a u64 with the spec's endianness.
Zstr in = (Zstr)IterPos(iter);
u64 x = 0;
Zstr next = NULL;- In
Io.c:885:
Zstr in = (Zstr)IterPos(iter);
u64 x = 0;
Zstr next = NULL;
switch (fmt_info.width) {
case 1 : {- In
Io.c:1021:
// ultimately writes into. Shared between buf_append_fmt and the body
// rendering done by buf_write_fmt / buf_patch_fmt.
static bool render_binary_fmt(Str *out, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
u64 arg_index = 0;
StrIter fsi = StrIterFromZstr(fmtstr);- In
Io.c:1045:
}
StrIter spec_start_fsi = fsi;
Zstr spec_start = (Zstr)StrIterPos(&fsi);
char sc = 0;
while (StrIterPeek(&fsi, &sc) && sc != '}') {- In
Io.c:1080:
}
bool buf_append_fmt(Buf *out, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
if (!out || !fmtstr) {
LOG_FATAL("buf_append_fmt: NULL out or fmtstr");- In
Io.c:1089:
}
bool buf_write_fmt(Buf *out, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
if (!out || !fmtstr) {
LOG_FATAL("buf_write_fmt: NULL out or fmtstr");- In
Io.c:1097:
}
bool buf_patch_fmt(Buf *out, size offset, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
if (!out || !fmtstr) {
LOG_FATAL("buf_patch_fmt: NULL out or fmtstr");- In
Io.c:1126:
}
void f_read_fmt(File *file, Zstr fmtstr, TypeSpecificIO *argv, u64 argc) {
// DefaultAllocator: the slurp buffer below sizes itself from file length
// (potentially many MiB on seekable inputs), so no stack-bound applies.
- In
Io.c:1178:
if (StrLen(&buffer)) {
Zstr new_pos = str_read_fmt(StrBegin(&buffer), fmtstr, argv, argc);
if (!new_pos) {
LOG_ERROR("Parse failed, rolling back...");- In
Io.c:1237:
}
static inline bool write_char_internal(Str *o, FormatFlags flags, Zstr vs, size len) {
if (!o || !vs || !len) {
LOG_FATAL("Invalid arguments");- In
Io.c:1382:
{
Zstr body = StrBegin(&canonical);
Zstr dot = NULL;
u64 prefix = 0;- In
Io.c:1383:
{
Zstr body = StrBegin(&canonical);
Zstr dot = NULL;
u64 prefix = 0;
u64 frac = 0;- In
Io.c:1543:
}
static size float_fmt_token_length(Zstr input) {
size pos = 0;
bool saw_digit = false;- In
Io.c:1602:
// post-read cursor so the outer reader can splice it back into the
// surrounding format-walk.
static inline Zstr read_chars_internal(Zstr i, u8 *buffer, size buffer_size, FmtInfo *fmt_info) {
if (!i || !buffer || !buffer_size) {
LOG_FATAL("Invalid arguments");- In
Io.c:1608:
size bytes_read = 0;
Zstr current = i;
bool force_case = fmt_info && (fmt_info->flags & FMT_FLAG_FORCE_CASE) != 0;
bool is_caps = fmt_info && (fmt_info->flags & FMT_FLAG_CAPS) != 0;- In
Io.c:1656:
return _write_Str(o, fmt_info, (Str *)b);
}
Zstr _read_Buf(Zstr i, FmtInfo *fmt_info, Buf *b) {
return _read_Str(i, fmt_info, (Str *)b);
}- In
Io.c:1698:
}
Zstr _read_DateTime(Zstr i, FmtInfo *fmt_info, DateTime *dt) {
(void)fmt_info;
if (!i || !dt) {- In
Io.c:1703:
LOG_FATAL("Invalid arguments");
}
Zstr p = i;
i32 year = 0;
u32 mon = 0, day = 0, hh = 0, mm = 0, ss = 0;- In
Io.c:1714:
if (*p == '.') {
p++;
Zstr frac_at = p;
StrReadFmt(p, "{}", nanos);
if (p == frac_at) {- In
Io.c:1726:
} else if (*p == '+' || *p == '-') {
i32 sign = (*p == '-') ? -1 : 1;
Zstr off_at = ++p;
u32 oh = 0, om = 0;
StrReadFmt(p, "{}:{}", oh, om);- In
Io.c:1811:
if (fmt_info->flags & FMT_FLAG_CHAR) {
if (!write_char_internal(o, fmt_info->flags, (Zstr)StrBegin(s), len)) {
return false;
}- In
Io.c:1821:
}
} else {
Zstr digits = "0123456789abcdef";
if (!StrPushBackMany(o, "\\x") || !StrPushBackR(o, digits[(c >> 4) & 0xf]) ||
!StrPushBackR(o, digits[c & 0xf])) {- In
Io.c:1842:
}
bool _write_Zstr(Str *o, FmtInfo *fmt_info, Zstr *s) {
if (!o || !s || !*s || !fmt_info) {
LOG_FATAL("Invalid arguments");- In
Io.c:1853:
// size of just-this-field, not the accumulated buffer.
size start_len = StrLen(o);
Zstr xs = *s;
// Empty Zstr: skip the body and fall straight through to padding.
- In
Io.c:1908:
}
} else {
Zstr digits = "0123456789abcdef";
if (!StrPushBackMany(o, "\\x") || !StrPushBackR(o, digits[(xs[i] >> 4) & 0xf]) ||
!StrPushBackR(o, digits[xs[i] & 0xf])) {- In
Io.c:1930:
bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg) {
Zstr *value = NULL;
if (!arg) {- In
Io.c:1936:
}
value = (Zstr *)arg->value;
return _write_Zstr(o, fmt_info, value);
}- In
Io.c:2296:
#endif // FEATURE_FLOAT
char ZstrProcessEscape(Zstr *str) {
if (!str || !*str)
return 0;- In
Io.c:2300:
return 0;
Zstr s = *str;
if (*s != '\\') {
LOG_ERROR("ZstrProcessEscape called on non-escape sequence");- In
Io.c:2369:
}
Zstr _read_Str(Zstr i, FmtInfo *fmt_info, Str *s) {
if (!i || !s)
LOG_FATAL("Invalid arguments");- In
Io.c:2394:
if (quote) {
if (*i == '\\') {
Zstr curr = i;
char c = ZstrProcessEscape(&curr);
if (c == 0) {- In
Io.c:2433:
if (*i == '\\') {
Zstr curr = i;
char c = ZstrProcessEscape(&curr);
if (c == 0) {- In
Io.c:2639:
// ---------------------------------------------------------------------------
Zstr _read_f64(Zstr i, FmtInfo *fmt_info, f64 *v) {
DefaultAllocator scratch = DefaultAllocatorInit();- In
Io.c:2649:
if (fmt_info && (fmt_info->flags & FMT_FLAG_CHAR)) {
u64 temp = 0;
Zstr next = read_chars_internal(i, (u8 *)&temp, sizeof(temp), fmt_info);
*v = (f64)temp;
DefaultAllocatorDeinit(&scratch);- In
Io.c:2675:
if ((c == 'i' || c == 'I' || c == 'n' || c == 'N') || (c == '-' && (c1 == 'i' || c1 == 'I'))) {
StrIter saved = si;
Zstr start = StrIterDataAt(&si, StrIterIndex(&si));
while (StrIterPeek(&si, &c) && !IS_SPACE(c)) {
StrIterMustNext(&si);- In
Io.c:2736:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:2760:
}
Zstr _read_u8(Zstr i, FmtInfo *fmt_info, u8 *v) {
DefaultAllocator scratch = DefaultAllocatorInit();- In
Io.c:2782:
if (fmt_info && (fmt_info->flags & FMT_FLAG_CHAR)) {
Zstr next = read_chars_internal(StrIterDataAt(&si, StrIterIndex(&si)), (u8 *)v, sizeof(*v), fmt_info);
DefaultAllocatorDeinit(&scratch);
return next;- In
Io.c:2797:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:2872:
// ---------------------------------------------------------------------------
#define _MAKE_READ_TXT_INT(NAME, T, VAL_T, PARSER, BOUND_CHECK) \
Zstr _read_##NAME(Zstr i, FmtInfo *fmt_info, T *v) { \
DefaultAllocator scratch = DefaultAllocatorInit(); \
\- In
Io.c:2882:
if (fmt_info && (fmt_info->flags & FMT_FLAG_CHAR)) { \
*v = 0; \
Zstr next = read_chars_internal(i, (u8 *)v, sizeof(*v), fmt_info); \
DefaultAllocatorDeinit(&scratch); \
return next; \
- In
Io.c:2908:
} \
\
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved)); \
size pos = StrIterIndex(&si) - StrIterIndex(&saved); \
Str temp = StrInitFromCstr(start, pos, &scratch); \
- In
Io.c:2974:
#undef _I_BOUND
Zstr _read_Zstr(Zstr i, FmtInfo *fmt_info, Zstr *out) {
(void)fmt_info;
(void)out;- In
Io.c:2977:
(void)fmt_info;
(void)out;
LOG_FATAL("Zstr reads require explicit allocator provenance; use ZstrIO(zstr, alloc) instead");
return i;
}- In
Io.c:2981:
}
Zstr _read_ZstrAlloc(Zstr i, FmtInfo *fmt_info, ZstrIOArg *arg) {
char **out = NULL;
char *previous = NULL;- In
Io.c:2985:
char *previous = NULL;
char *result = NULL;
Zstr next = NULL;
Allocator *allocator_ptr = NULL;
Str temp;- In
Io.c:3136:
(void)IntToBytesBE(value, buffer, byte_len);
if (!write_char_internal(o, fmt_info->flags, (Zstr)buffer, byte_len)) {
AllocatorFree(StrAllocator(o), buffer);
return false;- In
Io.c:3176:
#if FEATURE_BITVEC
Zstr _read_BitVec(Zstr i, FmtInfo *fmt_info, BitVec *bv) {
(void)fmt_info; // Unused parameter
if (!i || !bv) {- In
Io.c:3197:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&si));
char c0 = 0;- In
Io.c:3309:
#if FEATURE_INT
Zstr _read_Int(Zstr i, FmtInfo *fmt_info, Int *value) {
if (!i || !value) {
LOG_FATAL("Invalid arguments");- In
Io.c:3335:
StrIter saved = si;
StrIter digits_saved = si;
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
u8 radix = int_fmt_radix_from_flags(fmt_info);- In
Io.c:3396:
#if FEATURE_FLOAT
Zstr _read_Float(Zstr i, FmtInfo *fmt_info, Float *value) {
size token_len = 0;
Zstr start = NULL;- In
Io.c:3398:
Zstr _read_Float(Zstr i, FmtInfo *fmt_info, Float *value) {
size token_len = 0;
Zstr start = NULL;
Str temp;
Float parsed;- In
Io.c:3458:
#endif // FEATURE_FLOAT
Zstr _read_f32(Zstr i, FmtInfo *fmt_info, f32 *v) {
DefaultAllocator scratch = DefaultAllocatorInit();- In
Io.c:3468:
if (fmt_info && (fmt_info->flags & FMT_FLAG_CHAR)) {
u32 temp = 0;
Zstr next = read_chars_internal(i, (u8 *)&temp, sizeof(temp), fmt_info);
*v = (f32)temp;
DefaultAllocatorDeinit(&scratch);- In
Io.c:3494:
if ((c == 'i' || c == 'I' || c == 'n' || c == 'N') || (c == '-' && (c1 == 'i' || c1 == 'I'))) {
StrIter saved = si;
Zstr start = StrIterDataAt(&si, StrIterIndex(&si));
while (StrIterPeek(&si, &c) && !IS_SPACE(c)) {
StrIterMustNext(&si);- In
Io.c:3554:
}
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved));
size pos = StrIterIndex(&si) - StrIterIndex(&saved);- In
Io.c:3677:
}
static Zstr _read_r8(Zstr i, FmtInfo *fmt_info, u8 *v) {
if (!i || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:3686:
}
static Zstr _read_r16(Zstr i, FmtInfo *fmt_info, u16 *v) {
if (!i || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:3714:
}
static Zstr _read_r32(Zstr i, FmtInfo *fmt_info, u32 *v) {
if (!i || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:3740:
}
static Zstr _read_r64(Zstr i, FmtInfo *fmt_info, u64 *v) {
if (!i || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:9:
#include <Misra/Std/Log.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Zstr.h>
size ZstrLen(Zstr str) {- In
Zstr.c:11:
#include <Misra/Std/Zstr.h>
size ZstrLen(Zstr str) {
if (!str) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:16:
}
Zstr s = str;
while (*s)
s++;- In
Zstr.c:22:
}
i32 ZstrCompare(Zstr s1, Zstr s2) {
if (!s1 || !s2) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:37:
// is the generic-callback shape (sizeof the Zstr slot, = sizeof(Zstr));
// the real length is walked here until the NUL.
u64 zstr_hash(const Zstr *key, u32 ignored_size) {
Zstr s = NULL;
const u8 *ptr = NULL;- In
Zstr.c:38:
// the real length is walked here until the NUL.
u64 zstr_hash(const Zstr *key, u32 ignored_size) {
Zstr s = NULL;
const u8 *ptr = NULL;
u64 hash = 1469598103934665603ULL;- In
Zstr.c:58:
}
i32 zstr_compare(const Zstr *a, const Zstr *b, u32 ignored_size) {
i32 cmp = 0;- In
Zstr.c:77:
}
i32 ZstrCompareN(Zstr s1, Zstr s2, size n) {
if (!s1 || !s2) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:99:
}
i32 ZstrCompareIgnoreCase(Zstr s1, Zstr s2) {
if (!s1 || !s2) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:115:
}
i32 ZstrCompareNIgnoreCase(Zstr s1, Zstr s2, size n) {
if (!s1 || !s2) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:134:
}
Zstr ZstrFindChar(Zstr str, char ch) {
if (!str) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:148:
}
Zstr zstr_dup_n(Zstr src, size n, Allocator *alloc) {
if (!src || !alloc) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:171:
}
Zstr zstr_dup(Zstr src, Allocator *alloc) {
if (!src) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:179:
bool zstr_init_clone(void *dst_ptr, const void *src_ptr, const Allocator *alloc) {
Zstr *dst = (Zstr *)dst_ptr;
const Zstr *src = (const Zstr *)src_ptr;- In
Zstr.c:180:
bool zstr_init_clone(void *dst_ptr, const void *src_ptr, const Allocator *alloc) {
Zstr *dst = (Zstr *)dst_ptr;
const Zstr *src = (const Zstr *)src_ptr;
if (!dst || !src || !*src || !alloc) {- In
Zstr.c:191:
void zstr_deinit(void *zs_ptr, const Allocator *alloc) {
Zstr *zs = (Zstr *)zs_ptr;
if (!zs || !alloc) {- In
Zstr.c:207:
}
i64 ZstrToI64(Zstr s, Zstr *endptr) {
if (!s) {
if (endptr)- In
Zstr.c:226:
// Overflow saturates so callers see a pinned value rather than a
// silent wrap.
Zstr digit_start = s;
const u64 bound = neg ? ((u64)1 << 63) : (u64)0x7FFFFFFFFFFFFFFFULL;
u64 val = 0;- In
Zstr.c:253:
}
f64 ZstrToF64(Zstr s, Zstr *endptr) {
if (!s) {
if (endptr)- In
Zstr.c:268:
s++;
}
Zstr digit_start = s;
f64 val = 0.0;
while (*s >= '0' && *s <= '9') {- In
Zstr.c:331:
}
Zstr ZstrFindSubstring(Zstr haystack, Zstr needle) {
if (!needle) {
LOG_FATAL("Invalid arguments");- In
Zstr.c:338:
}
Zstr ZstrFindSubstringN(Zstr haystack, Zstr needle, size needle_len) {
if (!haystack || !needle) {
LOG_FATAL("Invalid arguments");- In
Str.c:9:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Str/Private.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Vec/Private.h>
#include <Misra/Std/Log.h>- In
Str.c:91:
}
bool str_try_init_from_cstr(Str *out, Zstr cstr, size len, Allocator *alloc) {
if (!out || !cstr) {
LOG_FATAL("Invalid arguments");- In
Str.c:111:
}
Str str_init_from_cstr(Zstr cstr, size len, Allocator *alloc) {
Str result = StrInit(alloc);- In
Str.c:213:
}
i32 str_cmp_zstr(const Str *s, Zstr other) {
ValidateStr(s);
return ZstrCompare(StrBegin(s), other);- In
Str.c:218:
}
i32 str_cmp_cstr(const Str *s, Zstr other, size other_len) {
ValidateStr(s);
return ZstrCompareN(StrBegin(s), other, other_len);- In
Str.c:229:
}
i32 str_cmp_zstr_ignore_case(const Str *s, Zstr other) {
ValidateStr(s);
return ZstrCompareIgnoreCase(StrBegin(s), other);- In
Str.c:234:
}
i32 str_cmp_cstr_ignore_case(const Str *s, Zstr other, size other_len) {
ValidateStr(s);
return ZstrCompareNIgnoreCase(StrBegin(s), other, other_len);- In
Str.c:239:
}
Zstr str_find_cstr(const Str *s, Zstr key, size key_len) {
ValidateStr(s);
return ZstrFindSubstringN(StrBegin(s), key, key_len);- In
Str.c:244:
}
Zstr str_find_zstr(const Str *s, Zstr key) {
ValidateStr(s);
return ZstrFindSubstring(StrBegin(s), key);- In
Str.c:249:
}
Zstr str_find_str(const Str *s, const Str *key) {
ValidateStr(s);
ValidateStr(key);- In
Str.c:255:
}
static StrIters str_split_to_iters_impl(Str *s, Zstr key, size keylen) {
ValidateStr(s);- In
Str.c:259:
StrIters sv = (StrIters)VecInit(s->allocator);
Zstr prev = s->data;
Zstr end = s->data + s->length;- In
Str.c:260:
StrIters sv = (StrIters)VecInit(s->allocator);
Zstr prev = s->data;
Zstr end = s->data + s->length;
while (prev <= end) {- In
Str.c:263:
while (prev <= end) {
Zstr next = ZstrFindSubstringN(prev, key, keylen);
if (next) {
StrIter si = {.data = (char *)prev, .length = next - prev, .pos = 0, .alignment = 1};- In
Str.c:278:
}
StrIters str_split_to_iters_zstr(Str *s, Zstr key) {
return str_split_to_iters_impl(s, key, ZstrLen(key));
}- In
Str.c:289:
}
static Strs str_split_impl(Str *s, Zstr key, size keylen) {
ValidateStr(s);- In
Str.c:294:
Strs sv = (Strs)VecInit(s->allocator);
sv.copy_deinit = (GenericCopyDeinit)str_deinit;
Zstr prev = s->data;
if (prev) {- In
Str.c:297:
if (prev) {
Zstr end = s->data + s->length;
while (prev <= end) {
Zstr next = ZstrFindSubstringN(prev, key, keylen);- In
Str.c:299:
Zstr end = s->data + s->length;
while (prev <= end) {
Zstr next = ZstrFindSubstringN(prev, key, keylen);
if (next) {
Str tmp = StrInitFromCstr(prev, next - prev, s->allocator);- In
Str.c:317:
}
Strs str_split_zstr(Str *s, Zstr key) {
return str_split_impl(s, key, ZstrLen(key));
}- In
Str.c:328:
}
size str_index_of_cstr(const Str *s, Zstr key, size key_len) {
Zstr found = NULL;- In
Str.c:329:
size str_index_of_cstr(const Str *s, Zstr key, size key_len) {
Zstr found = NULL;
ValidateStr(s);- In
Str.c:349:
}
size str_index_of_zstr(const Str *s, Zstr key) {
if (!key) {
LOG_FATAL("Invalid arguments");- In
Str.c:371:
}
bool str_contains_cstr(const Str *s, Zstr key, size key_len) {
return str_index_of_cstr(s, key, key_len) != SIZE_MAX;
}- In
Str.c:375:
}
bool str_contains_zstr(const Str *s, Zstr key) {
return str_index_of_zstr(s, key) != SIZE_MAX;
}- In
Str.c:393:
}
static inline bool is_strip_char(char c, Zstr strip_chars) {
Zstr p = strip_chars;
while (*p) {- In
Str.c:394:
static inline bool is_strip_char(char c, Zstr strip_chars) {
Zstr p = strip_chars;
while (*p) {
if (c == *p)- In
Str.c:406:
// = -1 means from left
// = 1 means from right
Str strip_str(Str *s, Zstr chars_to_strip, int split_direction) {
ValidateStr(s);- In
Str.c:416:
}
Zstr strip_chars = chars_to_strip ? chars_to_strip : " \t\n\r\v\f";
Zstr start = s->data;
Zstr end = s->data + s->length - 1;- In
Str.c:417:
Zstr strip_chars = chars_to_strip ? chars_to_strip : " \t\n\r\v\f";
Zstr start = s->data;
Zstr end = s->data + s->length - 1;- In
Str.c:418:
Zstr strip_chars = chars_to_strip ? chars_to_strip : " \t\n\r\v\f";
Zstr start = s->data;
Zstr end = s->data + s->length - 1;
if (split_direction <= 0) {- In
Str.c:436:
}
static inline bool starts_with(Zstr data, size data_len, Zstr prefix, size prefix_len) {
return data_len >= prefix_len && MemCompare(data, prefix, prefix_len) == 0;
}- In
Str.c:440:
}
static inline bool ends_with(Zstr data, size data_len, Zstr suffix, size suffix_len) {
return data_len >= suffix_len && MemCompare(data + data_len - suffix_len, suffix, suffix_len) == 0;
}- In
Str.c:444:
}
bool str_starts_with_zstr(const Str *s, Zstr prefix) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix, ZstrLen(prefix));- In
Str.c:449:
}
bool str_ends_with_zstr(const Str *s, Zstr suffix) {
ValidateStr(s);
return ends_with(s->data, s->length, suffix, ZstrLen(suffix));- In
Str.c:454:
}
bool str_starts_with_cstr(const Str *s, Zstr prefix, size prefix_len) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix, prefix_len);- In
Str.c:459:
}
bool str_ends_with_cstr(const Str *s, Zstr suffix, size suffix_len) {
ValidateStr(s);
return ends_with(s->data, s->length, suffix, suffix_len);- In
Str.c:474:
}
void str_replace_cstr(Str *s, Zstr match, size match_len, Zstr replacement, size replacement_len, size count) {
ValidateStr(s);
size i = 0;- In
Str.c:491:
}
void str_replace_zstr(Str *s, Zstr match, Zstr replacement, size count) {
ValidateStr(s);
str_replace_cstr(s, match, ZstrLen(match), replacement, ZstrLen(replacement), count);- In
Str.c:675:
if (isnan_f64(value)) {
Zstr nan_str = config->uppercase ? "NAN" : "nan";
for (size i = 0; i < 3; i++) {
if (!StrPushBackR(str, nan_str[i])) {- In
Str.c:694:
}
}
Zstr inf_str = config->uppercase ? "INF" : "inf";
for (size i = 0; i < 3; i++) {
if (!StrPushBackR(str, inf_str[i])) {- In
Map.c:80:
}
static size map_validate_policy_index(size idx, size capacity, Zstr callback_name) {
if (capacity && idx >= capacity) {
LOG_FATAL("{} returned index {} for capacity {}", callback_name, idx, capacity);- In
Int.c:8:
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Int/Private.h>
#include <Misra/Std/Container/BitVec.h>- In
Int.c:28:
static inline void int_store_le8(u8 *data, u64 byte_len, u64 off, u64 value);
static bool int_validate_radix(u8 radix);
static bool int_try_from_str_radix_impl(Int *out, Zstr digits, u64 length, u64 start, u8 radix, bool allow_underscores);
static bool int_try_from_i64_with_allocator(Int *out, i64 value, Allocator *alloc);
static bool int_try_clone_value(Int *out, const Int *value);- In
Int.c:342:
static bool
int_try_from_str_radix_impl(Int *out, Zstr digits, u64 length, u64 start, u8 radix, bool allow_underscores) {
Int result;
bool saw_digit = false;- In
Int.c:645:
}
bool int_try_from_str_zstr(Int *out, Zstr decimal) {
u64 start = 0;
u64 len = 0;- In
Int.c:675:
}
Int int_from_str_zstr(Zstr decimal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:705:
}
bool int_try_from_str_radix_zstr(Int *out, Zstr digits, u8 radix) {
u64 start = 0;
u64 len = 0;- In
Int.c:733:
}
Int int_from_str_radix_zstr(Zstr digits, u8 radix, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:868:
}
bool int_try_from_binary_zstr(Int *out, Zstr binary) {
u64 start = 0;
u64 len = 0;- In
Int.c:899:
}
Int int_from_binary_zstr(Zstr binary, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:917:
}
bool int_try_from_oct_str_zstr(Int *out, Zstr octal) {
u64 start = 0;
u64 len = 0;- In
Int.c:948:
}
Int int_from_oct_str_zstr(Zstr octal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:966:
}
bool int_try_from_hex_str_zstr(Int *out, Zstr hex) {
u64 len = 0;- In
Int.c:985:
}
Int int_from_hex_str_zstr(Zstr hex, Allocator *alloc) {
Int out = IntInit(alloc);- In
Float.c:8:
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float/Private.h>
#include <Misra/Std/Container/Int.h>- In
Float.c:488:
}
static bool float_try_from_str_impl(Float *out, Zstr text, size length) {
Float result;
Str digits;- In
Float.c:540:
if (ch == 'e' || ch == 'E') {
Zstr endptr = NULL;
Zstr exp_start = NULL;
long long parsed = 0;- In
Float.c:541:
if (ch == 'e' || ch == 'E') {
Zstr endptr = NULL;
Zstr exp_start = NULL;
long long parsed = 0;
size exp_offset = 0;- In
Float.c:608:
}
bool float_try_from_str_zstr(Float *out, Zstr text) {
if (!out || !text) {
LOG_FATAL("Invalid arguments");- In
Float.c:622:
}
Float float_from_str_zstr(Zstr text, Allocator *alloc) {
Float result = FloatInit(alloc);- In
BitVec.c:8:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Memory.h>- In
BitVec.c:924:
}
static bool bitvec_try_from_str_impl(BitVec *out, Zstr str, u64 str_len, Allocator *alloc) {
if (!str) {
LOG_FATAL("str is NULL");- In
BitVec.c:960:
}
bool bitvec_try_from_str_zstr(BitVec *out, Zstr str, Allocator *alloc) {
if (!str) {
LOG_FATAL("str is NULL");- In
BitVec.c:974:
}
BitVec bitvec_from_str_zstr(Zstr str, Allocator *alloc) {
BitVec result;- In
BitVec.c:1904:
}
bool bitvec_regex_match_zstr(BitVec *bv, Zstr pattern) {
ValidateBitVec(bv);
if (!pattern) {- In
Debug.c:278:
}
static void debug_emit_trace(const StackFrame *frames, size count, Zstr label, Allocator *meta) {
if (!count) {
LOG_ERROR(" {} trace: (none captured)", label);- In
Dir.c:20:
#include "../_Syscall.h"
Zstr DirEntryTypeToZstr(DirEntryType type) {
switch (type) {
case DIR_ENTRY_TYPE_UNKNOWN :- In
Dir.c:65:
#if PLATFORM_WINDOWS
// Windows-specific implementation using FindFirstFile/FindNextFile
DirContents dir_get_contents(Zstr path, Allocator *alloc) {
if (!path || !alloc) {
LOG_FATAL("Invalid argument");- In
Dir.c:193:
}
DirContents dir_get_contents(Zstr path, Allocator *alloc) {
if (!path || !alloc) {
LOG_FATAL("Invalid arguments");- In
Dir.c:251:
for (long off = 0; off < n;) {
struct kernel_dirent *de = (struct kernel_dirent *)(void *)(buf + off);
Zstr nm = de->d_name;
# if PLATFORM_DARWIN
// Darwin gives d_namlen explicitly (not null-terminated
- In
Dir.c:281:
// Cross-platform function to get file size
i64 file_get_size(Zstr filename) {
#if PLATFORM_WINDOWS
// Windows-specific code using GetFileSizeEx
- In
Dir.c:340:
// ---------------------------------------------------------------------------
i8 file_remove(Zstr path) {
if (!path) {
LOG_FATAL("FileRemove: NULL path");- In
Dir.c:369:
}
i8 dir_remove(Zstr path) {
if (!path) {
LOG_FATAL("DirRemove: NULL path");- In
Dir.c:410:
#define DIR_CREATE_MODE 0755
i8 dir_create(Zstr path) {
if (!path) {
LOG_FATAL("DirCreate: NULL path");- In
Dir.c:441:
// DirCreateAll to make EEXIST tolerant (idempotent). Avoids re-walking
// the existing tree on the second invocation.
static bool dir_already_exists(Zstr path) {
#if PLATFORM_WINDOWS
DWORD attrs = GetFileAttributesA(path);- In
Dir.c:463:
}
i8 dir_create_all(Zstr path) {
if (!path) {
LOG_FATAL("DirCreateAll: NULL path");- In
Dir.c:494:
data[i] = 0;
if (!dir_already_exists(data)) {
if (!DirCreate((Zstr)data)) {
// DirCreate logged the syscall error; re-check
// in case a concurrent process beat us to it.
- In
Dir.c:523:
#define DIR_REMOVE_ALL_PATH_CAP 512
i8 dir_remove_all(Zstr path) {
if (!path) {
LOG_FATAL("DirRemoveAll: NULL path");- In
Dir.c:547:
for (size i = 0; i < VecLen(&dc); ++i) {
DirEntry *e = VecPtrAt(&dc, i);
Zstr entry_nm = StrBegin(&e->name);
if (ZstrCompare(entry_nm, ".") == 0 || ZstrCompare(entry_nm, "..") == 0) {
continue; //
// Returns true on success; `out` is populated with an opened Elf.
static bool try_open_sidecar(Zstr main_path, const Elf *main, Elf *out, Allocator *alloc) {
Str path = StrInit(alloc); // (2-4) debuglink in standard locations
if (main->debuglink_name && main->debuglink_name[0]) {
Zstr cand_prefix = "/usr/lib/debug";
// (2) {dir}/{name}
// ---------------------------------------------------------------------------
static ResolverCacheEntry *resolver_cache_find_or_open(SymbolResolver *self, Zstr path) {
for (u64 i = 0; i < VecLen(&self->cache); ++i) {
ResolverCacheEntry *e = VecPtrAt(&self->cache, i);- In
PdbCache.c:30:
//
// On success populates `out_path` (an owned Str the caller frees).
static bool find_pdb(const Pe *pe, Zstr pe_path, Str *out_path) {
const PeCodeViewInfo *cv = PeCodeView(pe);
if (!cv->present || !cv->pdb_path)- In
PdbCache.c:42:
// (2) basename alongside PE
Zstr pdb_base = sys_basename_of(cv->pdb_path);
if (pdb_base[0] == '\0')
return false;- In
PdbCache.c:93:
// Find an existing entry for `module_path` or create a fresh one.
static PdbCacheEntry *cache_find_or_open(PdbCache *self, Zstr module_path) {
for (size i = 0; i < VecLen(&self->entries); ++i) {
PdbCacheEntry *e = VecPtrAt(&self->entries, i);- In
PdbCache.c:135:
bool pdb_cache_resolve_zstr(
PdbCache *self,
Zstr module_path,
u64 module_base,
u64 runtime_ip,- In
PdbCache.c:138:
u64 module_base,
u64 runtime_ip,
Zstr *out_name,
u32 *out_offset
) {- In
PdbCache.c:172:
u64 module_base,
u64 runtime_ip,
Zstr *out_name,
u32 *out_offset
) {- In
Dns.c:11:
#include <Misra/Sys/Dns.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Parsers/Dns.h>- In
Dns.c:100:
// on the Str. Returns false on read error; missing file returns true
// with an empty Str.
static bool slurp_file(Zstr path, Str *out) {
File f = FileOpen(path, "rb");
if (!FileIsOpen(&f)) {- In
Dns.c:154:
}
static void parse_hosts_path(HostsTable *table, Zstr path, Allocator *alloc) {
Str buf = StrInit(alloc);
if (!slurp_file(path, &buf)) {- In
Dns.c:188:
// the longest reasonable IPv6-with-zone-id literal.
StrInitStack(ip_buf, 64) {
StrPushBackMany(&ip_buf, (Zstr)StrIterDataAt(&si, ip_start), ip_len);
got_v4 = parse_ipv4(StrBegin(&ip_buf), v4);
if (!got_v4) {- In
Dns.c:217:
HostsEntry e = {0};
e.name = StrInitFromCstr((Zstr)StrIterDataAt(&si, nm_start), nm_len, alloc);
ascii_lower((u8 *)StrBegin(&e.name), StrLen(&e.name));
if (got_v4) {- In
Dns.c:249:
// ---------------------------------------------------------------------------
static void parse_resolv_path(DnsAddrs *out, Zstr path, Allocator *alloc) {
Str buf = StrInit(alloc);
if (!slurp_file(path, &buf)) {- In
Dns.c:286:
if (ip_len > 0 && ip_len < 64) {
StrInitStack(ip_buf, 64) {
StrPushBackMany(&ip_buf, (Zstr)StrIterDataAt(&si, ip_start), ip_len);
u8 v4[4] = {0};
u8 v6[16] = {0};- In
Dns.c:330:
// ---------------------------------------------------------------------------
static bool dns_add_path(DnsResolver *self, Zstr path, bool do_hosts, bool do_resolv) {
if (!self || !path)
return false;- In
Dns.c:340:
}
static bool dns_add_path_len(DnsResolver *self, Zstr path, u64 len, bool do_hosts, bool do_resolv) {
if (!self || !path)
return false;- In
Dns.c:356:
}
bool dns_resolver_add_path_zstr(DnsResolver *self, Zstr path, u64 len) {
return dns_add_path_len(self, path, len, true, true);
}- In
Dns.c:366:
}
bool dns_resolver_add_hosts_path_zstr(DnsResolver *self, Zstr path, u64 len) {
return dns_add_path_len(self, path, len, true, false);
}- In
Dns.c:376:
}
bool dns_resolver_add_resolv_path_zstr(DnsResolver *self, Zstr path, u64 len) {
return dns_add_path_len(self, path, len, false, true);
}- In
Dns.c:434:
// Strip trailing dot, lowercase, write into `out` (caller-managed Str).
static void normalize_hostname(Zstr name, Str *out) {
if (!name) {
return;- In
Dns.c:513:
// response's id is checked to match before the records are extracted.
static bool
try_one_query(DnsResolver *self, const SocketAddr *ns, Zstr hostname, DnsType qtype, u16 port, DnsAddrs *out) {
// Per-call scratch: one DNS query buffer (<= 1232 B) plus the parsed
// response with its records vector. Everything is dropped at function
- In
Dns.c:560:
}
bool dns_resolve_5_zstr(DnsResolver *self, Zstr hostname, u16 port, SocketKind kind, DnsAddrs *out) {
(void)kind; // protocol byte doesn't affect resolution
if (!self || !hostname || !out) {- In
Dns.c:580:
// is a valid Zstr for the matchers / DNS query below.
normalize_hostname(hostname, &norm);
Zstr nq = StrBegin(&norm);
// 1. /etc/hosts fast path.
- In
Dns.c:622:
}
bool dns_resolve_4_vec_zstr(DnsResolver *self, Zstr spec, SocketKind kind, DnsAddrs *out) {
if (!self || !spec || !out) {
return false;- In
Dns.c:704:
}
bool dns_resolve_4_one_zstr(DnsResolver *self, Zstr spec, SocketKind kind, SocketAddr *out) {
if (!self || !spec || !out) {
return false;- In
Backtrace.c:219:
DWORD64 ip = (DWORD64)(u64)frames[i].ip;
bool named = false;
Zstr sym_name = NULL;
u32 sym_off = 0;- In
Backtrace.c:239:
DWORD64 d_off = 0;
if (SymFromAddr(proc, ip, &d_off, sym)) {
sym_name = (Zstr)sym->Name;
sym_off = (u32)d_off;
named = true;- In
Backtrace.c:253:
DWORD line_disp = 0;
if (g_dbghelp_initialized && SymGetLineFromAddr64(proc, ip, &line_disp, &line) && line.FileName) {
Zstr fname = sys_basename_of(line.FileName);
StrAppendFmt(out, " ({}:{})", fname, (u32)line.LineNumber);
}- In
Backtrace.c:298:
extern u32 _dyld_image_count(void);
extern const void *_dyld_get_image_header(u32 image_index);
extern Zstr _dyld_get_image_name(u32 image_index);
extern i64 _dyld_get_image_vmaddr_slide(u32 image_index);- In
Backtrace.c:358:
# if FEATURE_PARSER_MACHO
static bool dyld_image_for_ip(void *ip, Zstr *out_path, u64 *out_slide) {
u64 ipx = (u64)ip;
u32 n = _dyld_image_count();- In
Backtrace.c:396:
for (size i = 0; i < count; ++i) {
u64 ip = (u64)frames[i].ip;
Zstr sym_name = NULL;
u32 sym_off = 0;
Zstr mod_path = NULL;- In
Backtrace.c:398:
Zstr sym_name = NULL;
u32 sym_off = 0;
Zstr mod_path = NULL;
bool named = false;- In
Backtrace.c:411:
if (named) {
Zstr mod = sys_basename_of(mod_path);
StrAppendFmt(out, " #{} {}!{}+{x} [{x}]\n", (u32)i, mod, sym_name, (u64)sym_off, ip);
} else if (mod_path) {- In
Backtrace.c:414:
StrAppendFmt(out, " #{} {}!{}+{x} [{x}]\n", (u32)i, mod, sym_name, (u64)sym_off, ip);
} else if (mod_path) {
Zstr mod = sys_basename_of(mod_path);
StrAppendFmt(out, " #{} {}+? [{x}]\n", (u32)i, mod, ip);
} else {- In
Backtrace.c:463:
static void emit_resolved_line(Str *out, u32 idx, const ResolvedSymbol *r, void *ip) {
if (r->symbol_name) {
Zstr mod = sys_basename_of(r->module_path);
StrAppendFmt(out, " #{} {}!{}+{x} [{x}]", idx, mod, r->symbol_name, r->offset, (u64)ip);
} else if (r->module_path) {- In
Backtrace.c:466:
StrAppendFmt(out, " #{} {}!{}+{x} [{x}]", idx, mod, r->symbol_name, r->offset, (u64)ip);
} else if (r->module_path) {
Zstr mod = sys_basename_of(r->module_path);
StrAppendFmt(out, " #{} {}+{x} [{x}]", idx, mod, r->offset, (u64)ip);
} else {- In
Backtrace.c:472:
}
if (r->source_file) {
Zstr file = sys_basename_of(r->source_file);
if (r->source_line > 0) {
StrAppendFmt(out, " ({}:{})", file, r->source_line);- In
Socket.c:131:
// Parse a decimal port number (0..65535) from a NUL-terminated string.
// Empty / non-numeric input -> false. Out-of-range -> false.
static bool parse_port(Zstr s, u16 *out) {
if (!s || !*s)
return false;- In
Socket.c:135:
return false;
u32 v = 0;
for (Zstr p = s; *p; ++p) {
if (*p < '0' || *p > '9')
return false;- In
Socket.c:315:
}
static bool split_host_port(Zstr spec, char *host_out, size host_cap, Zstr *port_out) {
if (!spec || !host_out || !port_out) {
return false;- In
Socket.c:321:
if (spec[0] == '[') {
Zstr close = NULL;
for (Zstr p = spec + 1; *p; ++p) {
if (*p == ']') {- In
Socket.c:322:
if (spec[0] == '[') {
Zstr close = NULL;
for (Zstr p = spec + 1; *p; ++p) {
if (*p == ']') {
close = p;- In
Socket.c:341:
}
Zstr colon = NULL;
for (Zstr p = spec; *p; ++p) {
if (*p == ':') {- In
Socket.c:342:
Zstr colon = NULL;
for (Zstr p = spec; *p; ++p) {
if (*p == ':') {
colon = p;- In
Socket.c:381:
// ---------------------------------------------------------------------------
bool socket_addr_parse_zstr(SocketAddr *out, Zstr spec, SocketKind kind) {
if (!out) {
LOG_FATAL("SocketAddrParse: out is NULL");- In
Socket.c:396:
StrInitStack(host, 256) {
char *host_data = StrBegin(&host);
Zstr port_str = NULL;
if (!split_host_port(spec, host_data, 256, &port_str)) {
break;- In
Socket.c:475:
StrResize(&host, ZstrLen(host_data));
port = FROM_BIG_ENDIAN2(sa->sin_port);
StrAppendFmt(&out, "{}:{}", (Zstr)host_data, (u32)port);
} else if (addr->family == SOCKET_FAMILY_INET6) {
const struct sockaddr_in6 *sa = (const struct sockaddr_in6 *)addr->raw;- In
Socket.c:486:
StrResize(&host, ZstrLen(host_data));
port = FROM_BIG_ENDIAN2(sa->sin6_port);
StrAppendFmt(&out, "[{}]:{}", (Zstr)host_data, (u32)port);
} else {
LOG_ERROR("SocketAddrFormat: unknown family {}", (u32)addr->family);- In
Socket.c:564:
int len = (int)((n > (size)0x7FFFFFFF) ? (size)0x7FFFFFFF : n);
// No MSG_NOSIGNAL needed -- Winsock doesn't raise SIGPIPE.
int r = send((SOCKET)s, (Zstr)buf, len, 0);
if (r == SOCKET_ERROR) {
LOG_SOCK_ERROR(0, "send() failed");- In
Socket.c:573:
static bool plat_setsockopt(SockFd s, int level, int optname, const void *optval, u32 optlen) {
if (setsockopt((SOCKET)s, level, optname, (Zstr)optval, (int)optlen) == SOCKET_ERROR) {
LOG_SOCK_ERROR(0, "setsockopt() failed");
return false;- In
MachoCache.c:22:
// Compose the conventional dSYM location for `binary_path`:
// <binary_path>.dSYM/Contents/Resources/DWARF/<basename>
static bool compose_dsym_path(Zstr binary_path, Str *out) {
if (!binary_path)
return false;- In
MachoCache.c:25:
if (!binary_path)
return false;
Zstr base = sys_basename_of(binary_path);
if (base[0] == '\0')
return false;- In
MachoCache.c:39:
// ---------------------------------------------------------------------------
static MachoCacheEntry *cache_find_or_create(MachoCache *self, Zstr module_path) {
for (size i = 0; i < VecLen(&self->entries); ++i) {
MachoCacheEntry *e = VecPtrAt(&self->entries, i);- In
MachoCache.c:149:
bool macho_cache_resolve_zstr(
MachoCache *self,
Zstr module_path,
u64 slide,
u64 runtime_ip,- In
MachoCache.c:152:
u64 slide,
u64 runtime_ip,
Zstr *out_name,
u32 *out_offset
) {- In
MachoCache.c:209:
u64 slide,
u64 runtime_ip,
Zstr *out_name,
u32 *out_offset
) {- In
_IpParse.h:12:
#define MISRA_SYS_IP_PARSE_H
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
_IpParse.h:30:
/// Parse "a.b.c.d" into four octets. Empty / NULL / out-of-range / any
/// trailing bytes -> false.
static inline bool parse_ipv4(Zstr s, u8 octets[4]) {
if (!s)
return false;- In
_IpParse.h:56:
/// RFC 5952 "::" compression. Does not handle zone IDs or embedded
/// IPv4-in-IPv6.
static inline bool parse_ipv6(Zstr s, u8 bytes[16]) {
if (!s)
return false;- In
Proc.c:10:
#include <Misra/Std/Log.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys.h>
#include "../_Syscall.h"- In
Proc.c:85:
# endif
}
static inline long proc_readlink(Zstr path, char *buf, unsigned long sz) {
# if PLATFORM_DARWIN || ARCHITECTURE_X86_64
return direct_sys3(MISRA_SYS_readlink, (long)(u64)path, (long)(u64)buf, (long)sz);- In
Proc.c:109:
#define WRITE_END 1
Proc proc_init(Zstr filepath, char **argv, char **envp, Allocator *alloc) {
Proc proc = {0};
#if PLATFORM_UNIX- In
Proc.c:688:
// Sys/Backtrace already makes per-frame.
# if PLATFORM_DARWIN
extern Zstr _dyld_get_image_name(u32 image_index);
Zstr exe = _dyld_get_image_name(0);
if (exe) {- In
Proc.c:689:
# if PLATFORM_DARWIN
extern Zstr _dyld_get_image_name(u32 image_index);
Zstr exe = _dyld_get_image_name(0);
if (exe) {
*exe_path = StrInitFromCstr(exe, ZstrLen(exe), alloc);- In
_Helpers.h:15:
#include <Misra/Std/File.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
_Helpers.h:22:
/// concurrent unlink, which is acceptable for the existence-probe
/// callers (cache lookups, sidecar discovery).
static inline bool sys_path_exists(Zstr path) {
File f = FileOpen(path, "rb");
if (!FileIsOpen(&f)) {- In
_Helpers.h:34:
/// '/' or '\\'). Returns "" on NULL; the returned pointer aliases
/// `path` itself, so it stays valid for `path`'s lifetime.
static inline Zstr sys_basename_of(Zstr path) {
if (!path)
return "";- In
_Helpers.h:37:
if (!path)
return "";
Zstr base = path;
for (Zstr p = path; *p; ++p) {
if (*p == '/' || *p == '\\')- In
_Helpers.h:38:
return "";
Zstr base = path;
for (Zstr p = path; *p; ++p) {
if (*p == '/' || *p == '\\')
base = p + 1;- In
_Helpers.h:48:
/// including the last separator) into `out`. No-op on NULL or on paths
/// with no separator.
static inline void sys_append_dirname(Str *out, Zstr path) {
if (!path)
return;- In
_Helpers.h:51:
if (!path)
return;
Zstr last_sep = NULL;
for (Zstr p = path; *p; ++p) {
if (*p == '/' || *p == '\\')- In
_Helpers.h:52:
return;
Zstr last_sep = NULL;
for (Zstr p = path; *p; ++p) {
if (*p == '/' || *p == '\\')
last_sep = p;- In
Pe.c:493:
if (!terminated)
continue;
cv->pdb_path = (Zstr)path_start;
cv->present = true;
return; // first CodeView entry wins
- In
Pe.c:556:
}
bool pe_open(Pe *out, Zstr path, Allocator *alloc) {
if (!out || !path || !alloc) {
LOG_FATAL("PeOpen: NULL argument (contract violation)");- In
Pe.c:577:
}
const PeSection *pe_find_section_zstr(const Pe *self, Zstr name) {
if (!self || !name)
return NULL;- In
DwarfInfo.c:185:
u64 u;
i64 i;
Zstr s;
u64 off;
};- In
DwarfInfo.c:274:
}
case DW_FORM_string : {
Zstr s = BufReadZstr(cur);
if (!s)
return false;- In
DwarfInfo.c:374:
u64 low_pc = 0, high_pc = 0;
bool high_pc_is_offset = false;
Zstr name = NULL;
u64 name_str_off = 0;
bool name_from_strp = false;- In
DwarfInfo.c:454:
// Resolve name into the pool now (or later if it came
// from .debug_str — same pool either way).
Zstr src;
if (name_from_strp) {
src = (Zstr)(debug_str + name_str_off);- In
DwarfInfo.c:456:
Zstr src;
if (name_from_strp) {
src = (Zstr)(debug_str + name_str_off);
} else {
src = name;- In
Dns.c:22:
// e.g. "example.com" -> 0x07 "example" 0x03 "com" 0x00.
// Returns false on label > 63 bytes or total > 255 bytes.
static bool encode_qname(DnsWireBuf *out, Zstr name) {
if (!name) {
return false;- In
Dns.c:65:
}
bool dns_build_query_zstr(DnsWireBuf *out, u16 id, Zstr name, DnsType type) {
if (!out || !name) {
return false;- In
KvConfig.c:10:
#include <Misra/Std/Log.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Zstr.h>
- In
KvConfig.c:44:
static bool kvconfig_parse_i64_value(const Str *value, i64 *out) {
Zstr endptr = NULL;
i64 parsed;- In
KvConfig.c:62:
static bool kvconfig_parse_f64_value(const Str *value, f64 *out) {
Zstr endptr = NULL;
f64 parsed;- In
KvConfig.c:341:
}
Str *kvconfig_get_ptr_zstr(KvConfig *cfg, Zstr key) {
Str lookup = {0};
Str *value = NULL;- In
KvConfig.c:365:
}
Str kvconfig_get_zstr(KvConfig *cfg, Zstr key) {
Str *value = kvconfig_get_ptr_zstr(cfg, key);- In
KvConfig.c:379:
}
bool kvconfig_contains_zstr(KvConfig *cfg, Zstr key) {
return kvconfig_get_ptr_zstr(cfg, key) != NULL;
}- In
KvConfig.c:393:
}
bool kvconfig_get_bool_zstr(KvConfig *cfg, Zstr key, bool *value) {
Str *str = kvconfig_get_ptr_zstr(cfg, key);- In
KvConfig.c:413:
}
bool kvconfig_get_i64_zstr(KvConfig *cfg, Zstr key, i64 *value) {
Str *str = kvconfig_get_ptr_zstr(cfg, key);- In
KvConfig.c:433:
}
bool kvconfig_get_f64_zstr(KvConfig *cfg, Zstr key, f64 *value) {
Str *str = kvconfig_get_ptr_zstr(cfg, key);- In
Pdb.c:504:
// invalidates earlier pointers -- we resolve to pointers in a second
// pass after the walk completes.
static bool pool_append_cstr(Str *pool, Zstr s, u64 *out_offset) {
*out_offset = StrLen(pool);
if (!StrPushBackMany(pool, s))- In
Pdb.c:583:
continue;
}
Zstr name = (Zstr)IterDataAt(&body, IterIndex(&body));
(void)flags; // permissive: we don't filter by FUNCTION bit;
- In
Pdb.c:744:
}
bool pdb_open(Pdb *out, Zstr path, Allocator *alloc) {
if (!out || !path || !alloc) {
LOG_FATAL("PdbOpen: NULL argument (contract violation)");- In
ProcMaps.c:152:
out->perms = perms;
out->file_offset = offset;
out->path = (Zstr)StrIterDataAt(si, path_start_pos); // may be empty if anonymous
if (line_terminator_pos < StrIterLength(si) && *StrIterDataAt(si, line_terminator_pos) == '\n') {- In
Http.c:9:
#include <Misra/Parsers/Http.h>
#include <Misra/Std/Zstr.h>
#if FEATURE_FILE- In
Http.c:58:
}
HttpHeader *http_headers_find_zstr(HttpHeaders *headers, Zstr key) {
if (!headers || !key) {
LOG_FATAL("invalid arguments");- In
Http.c:108:
}
Zstr http_request_parse_zstr(HttpRequest *req, Zstr in) {
if (!req || !req->allocator || !in) {
LOG_FATAL("invalid arguments");- In
Http.c:114:
Allocator *alloc = req->allocator;
Zstr cursor = in;
Str method = StrInit(alloc);
Str version = StrInit(alloc);- In
Http.c:147:
while (true) {
Zstr line_start = cursor;
if (0 == ZstrCompareN(cursor, "\r\n", 2)) {- In
Http.c:177:
}
Zstr http_request_parse_str(HttpRequest *req, const Str *in) {
if (!req || !in) {
LOG_FATAL("invalid arguments");- In
Http.c:200:
// ---------------------------------------------------------------------------
Zstr HttpResponseCodeToZstr(HttpResponseCode code) {
switch (code) {
case HTTP_RESPONSE_CODE_CONTINUE :- In
Http.c:331:
}
Zstr HttpContentTypeToZstr(HttpContentType type) {
switch (type) {
case HTTP_CONTENT_TYPE_TEXT_PLAIN :- In
Http.c:424:
HttpResponseCode status,
HttpContentType content_type,
Zstr filepath
) {
if (!response || !response->allocator || !filepath) {- In
Http.c:449:
LOG_FATAL("invalid arguments");
}
return http_respond_with_file_zstr(response, status, content_type, (Zstr)StrBegin(filepath));
}
#endif- In
Http.c:460:
}
Zstr response_code = HttpResponseCodeToZstr(response->status_code);
if (!response_code) {
LOG_ERROR("HttpResponseSerialize: invalid/unknown response code {}", (u32)response->status_code);- In
Http.c:465:
return out;
}
Zstr content_type = HttpContentTypeToZstr(response->content_type);
if (!content_type) {
LOG_ERROR("HttpResponseSerialize: invalid/unknown content type {}", (u32)response->content_type);- In
JSON.c:10:
#include <Misra/Parsers/JSON.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
static StrIter JSkipObject(StrIter si) {- In
JSON.c:407:
// convert to number
Zstr end = NULL;
if (is_flt) {
num->f = ZstrToF64(StrBegin(&ns), &end);- In
JSON.c:511:
if (StrIterRemainingLength(&si) >= 4) {
if (StrIterPeek(&si, &c) && c == 't') {
Zstr pos = StrIterPos(&si);
if (pos && ZstrCompareN(pos, "true", 4) == 0) {
StrIterMustMove(&si, 4);- In
JSON.c:523:
if (StrIterRemainingLength(&si) >= 5) {
if (StrIterPeek(&si, &c) && c == 'f') {
Zstr pos = StrIterPos(&si);
if (pos && ZstrCompareN(pos, "false", 5) == 0) {
StrIterMustMove(&si, 5);- In
JSON.c:561:
if (StrIterRemainingLength(&si) >= 4) {
if (StrIterPeek(&si, &c) && c == 'n') {
Zstr pos = StrIterPos(&si);
if (pos && ZstrCompareN(pos, "null", 4) == 0) {
StrIterMustMove(&si, 4); out->version = version;
Zstr augmentation = BufReadZstr(body);
if (!augmentation)
return false;- In
MachO.c:402:
continue;
MachoSymbol sym;
sym.name = (Zstr)(str_base + n_strx);
sym.value = n_value;
sym.type = n_type;- In
MachO.c:461:
}
bool macho_open(Macho *out, Zstr path, Allocator *alloc) {
if (!out || !path || !alloc) {
LOG_FATAL("MachoOpen: NULL argument (contract violation)");- In
MachO.c:484:
}
const MachoSection *macho_find_section(const Macho *self, Zstr segment, Zstr section) {
if (!self || !segment || !section)
return NULL;- In
Elf.c:104:
// ---------------------------------------------------------------------------
static Zstr elf_str_at(const Elf *self, u64 strtab_offset, u64 strtab_size, u32 idx) {
if ((u64)idx >= strtab_size) {
return "";- In
Elf.c:112:
// read past the strtab. Scan forward; if no NUL is found inside
// [idx, strtab_size), return an empty string.
Zstr base = (Zstr)(BufData(&self->data) + strtab_offset);
for (u64 p = idx; p < strtab_size; ++p) {
if (base[p] == '\0') {- In
Elf.c:435:
return;
}
Zstr base = (Zstr)(BufData(&self->data) + dl->offset);
// filename runs up to (and including) the NUL; CRC follows in the
// last 4 bytes of the section, after alignment padding.
- In
Elf.c:525:
}
bool elf_open(Elf *out, Zstr path, Allocator *alloc) {
if (!out || !path || !alloc) {
LOG_FATAL("ElfOpen: NULL argument (contract violation)");- In
Elf.c:585:
}
const ElfSection *elf_find_section_zstr(const Elf *self, Zstr name) {
if (!self || !name)
return NULL;- In
Dwarf.c:53:
// Append `s` (NUL-terminated) including its terminator into `pool` and
// return the offset at which it was inserted.
static bool pool_append(Str *pool, Zstr s, u64 *out_offset) {
u64 start = StrLen(pool);
if (!StrPushBackMany(pool, s))- In
Dwarf.c:230:
// include_directories
while (IterIndex(&cur) < IterLength(&cur) && *IterDataAt(&cur, IterIndex(&cur)) != 0) {
Zstr dir = BufReadZstr(&cur);
if (!dir)
return false;- In
Dwarf.c:246:
// file_names
while (IterIndex(&cur) < IterLength(&cur) && *IterDataAt(&cur, IterIndex(&cur)) != 0) {
Zstr name = BufReadZstr(&cur);
if (!name)
return false;- In
Dwarf.c:643:
u64 fo = VecAt(&pending_file_offsets, i);
u64 dofs = VecAt(&pending_dir_offsets, i);
VecPtrAt(&out->entries, i)->file = fo ? (Zstr)(StrBegin(&out->string_pool) + fo) : NULL;
VecPtrAt(&out->entries, i)->dir = dofs ? (Zstr)(StrBegin(&out->string_pool) + dofs) : NULL;
}- In
Dwarf.c:644:
u64 dofs = VecAt(&pending_dir_offsets, i);
VecPtrAt(&out->entries, i)->file = fo ? (Zstr)(StrBegin(&out->string_pool) + fo) : NULL;
VecPtrAt(&out->entries, i)->dir = dofs ? (Zstr)(StrBegin(&out->string_pool) + dofs) : NULL;
}
}- In
Resolve.c:21:
int main(int argc, char **argv) {
Scope(alloc, DefaultAllocator) {
Zstr hostname = NULL;
ArgParse ap = ArgParseInit("resolve", "look up a hostname via /etc/hosts and DNS");- In
Resolve.c:49:
// bracket form on v6 to round-trip through SocketAddrParse.
size n = StrLen(&s);
Zstr p = StrBegin(&s);
if (n >= 2 && p[n - 1] == '0' && p[n - 2] == ':') {
StrMustResize(&s, n - 2);- In
Beam.c:247:
}
static void log_request_summary(Zstr client_addr, Zstr prefix_bytes, size prefix_len) {
Scope(scope, DefaultAllocator) {
Str raw = StrInit(scope);- In
Beam.c:253:
HttpRequest req = HttpRequestInit(scope);
Zstr end = HttpRequestParse(&req, (Zstr)StrBegin(&raw));
if (end == StrBegin(&raw)) {
LOG_INFO("[{}] (unparseable request, {} bytes)", client_addr, (u64)prefix_len);- In
Beam.c:257:
LOG_INFO("[{}] (unparseable request, {} bytes)", client_addr, (u64)prefix_len);
} else {
Zstr method = "?";
switch (req.method) {
case HTTP_REQUEST_METHOD_GET :- In
Beam.c:300:
// directions close. `first_chunk` (if non-NULL) is sent toward `b`
// before the poll loop runs, so the initial client read isn't lost.
static void proxy_pump(Socket *a, Socket *b, Zstr first_chunk, size first_len) {
if (first_chunk && first_len > 0) {
if (SocketSend(b, first_chunk, first_len) < 0) {- In
Beam.c:386:
Scope(alloc, DefaultAllocator) {
Zstr listen_spec = NULL;
Zstr upstream_spec = NULL;- In
Beam.c:387:
Scope(alloc, DefaultAllocator) {
Zstr listen_spec = NULL;
Zstr upstream_spec = NULL;
ArgParse ap = ArgParseInit("beam", "small reverse-proxy");- In
File.c:6:
#include <Misra/Std/Log.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys/Dir.h>- In
File.c:14:
// is the caller's Str; on success it holds the resolved name so the
// caller can read it back and remove it.
static bool write_test_file(Zstr text, Str *out_path, Allocator *alloc) {
File f = FileOpenTemp(out_path, alloc);
if (!FileIsOpen(&f)) {- In
File.c:88:
FileClose(&f);
Zstr expected = "this is longer than the initial buffer";
bool result = (got == (i64)ZstrLen(expected)) && (StrLen(&body) == (size)ZstrLen(expected)) &&
ZstrCompare(StrBegin(&body), expected) == 0 && StrCapacity(&body) >= StrLen(&body) + 1;- In
File.c:181:
}
Zstr msg = "abcdefgh"; // 8 bytes
i64 wrote = FileWrite(&f, msg, 8);
bool ok = (wrote == 8);- In
File.c:332:
FileClose(&seed);
Zstr payload = "round-trip payload";
u64 n = ZstrLen(payload);- In
File.c:776:
Str path;
Zstr payload = "the quick brown fox jumps over the lazy dog"; // 43 bytes
bool ok = write_test_file(payload, &path, alloc_base);
if (!ok) {- In
File.c:867:
FileClose(&seed);
Zstr payload = "payload-through-the-convenience-API";
u64 n = ZstrLen(payload);- In
Buf.c:138:
BufIter it = BufIterFromBuf(&b);
Zstr s1 = BufReadZstr(&it);
Zstr s2 = BufReadZstr(&it);
bool ok = s1 && s2 && s1[0] == 'h' && s2[0] == 'w';- In
Buf.c:139:
BufIter it = BufIterFromBuf(&b);
Zstr s1 = BufReadZstr(&it);
Zstr s2 = BufReadZstr(&it);
bool ok = s1 && s2 && s1[0] == 'h' && s2[0] == 'w';
ok = ok && IterRemainingLength(&it) == 0;- In
AllocDebug.c:22:
#include <Misra.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Zstr.h>
#include "../Util/TestRunner.h"- In
ArgParse.c:4:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/ArgParse.h>
#include <Misra/Std/Container/Str.h>- In
ArgParse.c:21:
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr listen = NULL;
ArgRequired(&p, "-l", "--listen", &listen, "host:port");- In
ArgParse.c:37:
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr listen = NULL;
ArgRequired(&p, "-l", "--listen", &listen, "host:port");- In
ArgParse.c:53:
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr listen = NULL;
ArgRequired(&p, "-l", "--listen", &listen, "host:port");- In
ArgParse.c:165:
ArgParse p = ArgParseInit("cp", NULL, &a);
Zstr src = NULL;
Zstr dst = NULL;
ArgPositional(&p, "source", &src, "from");- In
ArgParse.c:166:
Zstr src = NULL;
Zstr dst = NULL;
ArgPositional(&p, "source", &src, "from");
ArgPositional(&p, "dest", &dst, "to");- In
ArgParse.c:183:
ArgParse p = ArgParseInit("cp", NULL, &a);
Zstr src = NULL;
Zstr dst = NULL;
bool verbose = false;- In
ArgParse.c:184:
Zstr src = NULL;
Zstr dst = NULL;
bool verbose = false;
ArgPositional(&p, "source", &src, "from");- In
ArgParse.c:276:
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr listen = NULL;
ArgRequired(&p, "-l", "--listen", &listen, "");- In
ArgParse.c:292:
ArgParse p = ArgParseInit("cp", NULL, &a);
Zstr src = NULL;
Zstr dst = NULL;
ArgPositional(&p, "source", &src, "");- In
ArgParse.c:293:
Zstr src = NULL;
Zstr dst = NULL;
ArgPositional(&p, "source", &src, "");
ArgPositional(&p, "dest", &dst, "");- In
ArgParse.c:358:
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr x = NULL;
ArgPositional(&p, "x", &x, "");- In
ArgParse.c:375:
// ----------------------------------------------------------------------------
static bool run_bool_value(Zstr text, bool *out) {
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);- In
ArgParse.c:387:
static bool test_bool_value_truthy_spellings(void) {
Zstr truthy[] = {"true", "1", "yes", "on"};
for (u32 i = 0; i < 4; i++) {
bool v = false;- In
ArgParse.c:397:
static bool test_bool_value_falsey_spellings(void) {
Zstr falsey[] = {"false", "0", "no", "off"};
for (u32 i = 0; i < 4; i++) {
bool v = true;- In
ArgParse.c:474:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr listen = NULL;
ArgRequired(&p, "-l", "--listen", &listen, "host:port");
char *argv[] = {(char *)"prog", (char *)"--listen"};- In
ArgParse.c:516:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr listen = NULL;
ArgRequired(&p, "-l", "--listen", &listen, "host:port");
char *argv[] = {(char *)"prog", (char *)"-lhost"};- In
ArgParse.c:564:
ArgParse p = ArgParseInit("cat", NULL, &a);
Zstr file = NULL;
ArgPositional(&p, "file", &file, "input file");- In
ArgParse.c:588:
ArgParse p = ArgParseInit("prog", "test prog", &a);
Zstr required = NULL;
ArgRequired(&p, "-l", "--listen", &required, "host:port");- In
ArgParse.c:635:
}
static bool help_equals(ArgParse *p, Zstr expected) {
DefaultAllocator a = DefaultAllocatorInit();
Str out = StrInit(&a);- In
ArgParse.c:665:
ArgParse p = ArgParseInit("prog", "test prog", &a);
Zstr src = NULL;
Zstr listen = NULL;
u32 timeout = 0;- In
ArgParse.c:666:
Zstr src = NULL;
Zstr listen = NULL;
u32 timeout = 0;
bool verbose = false;- In
ArgParse.c:674:
ArgFlag(&p, "-v", "--verbose", &verbose, "be loud");
Zstr expected =
"prog -- test prog\n"
"\n"- In
ArgParse.c:705:
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr listen = NULL;
ArgRequired(&p, "-l", "--listen", &listen, "host:port");- In
ArgParse.c:711:
// [OPTIONS] DOES appear. Use that fact: it is a flag, so any_option
// becomes true via the synthetic spec.
Zstr expected =
"prog\n"
"\n"- In
ArgParse.c:738:
ArgParse p = ArgParseInit("cp", NULL, &a);
Zstr from = NULL;
Zstr to = NULL;
ArgPositional(&p, "from", &from, "source path");- In
ArgParse.c:739:
Zstr from = NULL;
Zstr to = NULL;
ArgPositional(&p, "from", &from, "source path");
ArgPositional(&p, "to", &to, "dest path");- In
ArgParse.c:743:
ArgPositional(&p, "to", &to, "dest path");
Zstr expected =
"cp\n"
"\n"- In
ArgParse.c:778:
ArgFlag(&p, "-q", NULL, &quiet, "quiet");
Zstr expected =
"prog\n"
"\n"- In
ArgParse.c:804:
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr mode = NULL;
ArgOptional(&p, NULL, "--mode", &mode, "");- In
ArgParse.c:808:
// " --mode <MODE>" width = 19, widest, pad to 21.
Zstr expected =
"prog\n"
"\n"- In
ArgParse.c:906:
// True iff `needle` occurs as a substring of `hay` (a Str body).
static bool str_contains(Str *hay, Zstr needle) {
u64 hn = StrLen(hay);
Zstr beg = StrBegin(hay);- In
ArgParse.c:908:
static bool str_contains(Str *hay, Zstr needle) {
u64 hn = StrLen(hay);
Zstr beg = StrBegin(hay);
u64 nn = ZstrLen(needle);
if (nn == 0)- In
ArgParse.c:928:
// ----------------------------------------------------------------------------
static bool run_u32(Zstr text, u32 *out, ArgRun *rc) {
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);- In
ArgParse.c:939:
}
static bool run_u64(Zstr text, u64 *out, ArgRun *rc) {
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);- In
ArgParse.c:1165:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr s = NULL;
ArgOptional(&p, NULL, "--name", &s, "n");
char *argv[] = {(char *)"prog", (char *)"--name", (char *)"carol"};- In
ArgParse.c:1269:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr v = NULL;
ArgRequired(&p, "-l", "--listen", &v, "addr");
Str help = StrInit(&a);- In
ArgParse.c:1285:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr v = NULL;
ArgRequired(&p, NULL, "--read-only", &v, "mode");
Str help = StrInit(&a);- In
ArgParse.c:1301:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr v = NULL;
ArgRequired(&p, NULL, "--port", &v, "p");
Str help = StrInit(&a);- In
ArgParse.c:1317:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr v = NULL;
ArgRequired(&p, "-x", NULL, &v, "x");
Str help = StrInit(&a);- In
ArgParse.c:1333:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr v = NULL;
ArgRequired(&p, NULL, "--ip6", &v, "x");
Str help = StrInit(&a);- In
ArgParse.c:1350:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr v = NULL;
ArgRequired(&p, NULL, "--gzip", &v, "x");
Str help = StrInit(&a);- In
ArgParse.c:1367:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr v = NULL;
ArgRequired(&p, NULL, "--abc", &v, "x");
Str help = StrInit(&a);- In
ArgParse.c:1386:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("cp", NULL, &a);
Zstr s = NULL;
ArgPositional(&p, "source", &s, "from");
Str help = StrInit(&a);- In
ArgParse.c:1401:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr v = NULL;
ArgRequired(&p, "-l", "--listen", &v, "addr");
Str help = StrInit(&a);- In
ArgParse.c:1417:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr v = NULL;
ArgRequired(&p, "-l", "--listen", &v, "addr");
Str help = StrInit(&a);- In
ArgParse.c:1472:
ArgParse p = ArgParseInit("prog", NULL, &a);
bool aa = false;
Zstr bb = NULL;
ArgFlag(&p, "-a", "--a", &aa, "AAA");
ArgRequired(&p, NULL, "--a-very-long-option-name", &bb, "BBB");- In
ArgParse.c:1530:
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr listen = NULL;
ArgRequired(&p, "-l", "--listen", &listen, "host:port");- In
ArgParse.c:1667:
u32 verbose = 0;
Zstr listen = NULL;
ArgCount(&p, "-v", "--verbose", &verbose, "v");
ArgRequired(&p, "-l", "--listen", &listen, "host:port");- In
ArgParse.c:1739:
ArgParse p = ArgParseInit("cp", NULL, &a);
Zstr from = NULL;
Zstr to = NULL;
ArgPositional(&p, "from", &from, "source path");- In
ArgParse.c:1740:
Zstr from = NULL;
Zstr to = NULL;
ArgPositional(&p, "from", &from, "source path");
ArgPositional(&p, "to", &to, "dest path");- In
ArgParse.c:1744:
ArgPositional(&p, "to", &to, "dest path");
Zstr expected =
"cp\n"
"\n"- In
ArgParse.c:1790:
}
static bool str_has(Str *hay, Zstr needle) {
u64 hn = StrLen(hay);
Zstr beg = StrBegin(hay);- In
ArgParse.c:1792:
static bool str_has(Str *hay, Zstr needle) {
u64 hn = StrLen(hay);
Zstr beg = StrBegin(hay);
u64 nn = ZstrLen(needle);
if (nn == 0)- In
ArgParse.c:1820:
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr x = NULL;
ArgPositional(&p, "x", &x, "");- In
ArgParse.c:1845:
ArgParse p = ArgParseInit("prog", NULL, &a);
Zstr listen = NULL;
ArgRequired(&p, "-l", "--listen", &listen, "host:port");- In
ArgParse.c:1880:
name[128] = '\0';
Zstr v = NULL;
ArgRequired(&p, NULL, name, &v, "x");- In
ArgParse.c:1928:
ArgParse p = ArgParseInit("prog", "an about line", adbg);
Zstr listen = NULL;
u32 timeout = 0;
bool verbose = false;- In
ArgParse.c:1931:
u32 timeout = 0;
bool verbose = false;
Zstr hostname = NULL;
ArgRequired(&p, "-l", "--listen", &listen, "host:port to listen on");
ArgOptional(&p, NULL, "--timeout", &timeout, "connection timeout");- In
DateTime.c:185:
DateTime b = {0};
Zstr p = StrBegin(&s);
StrReadFmt(p, "{}", b);- In
DateTime.c:197:
// Parse an externally-supplied ISO string directly.
static bool test_iso_read_direct(void) {
Zstr in = "2026-06-26T17:34:11-07:00";
DateTime d = {0};
StrReadFmt(in, "{}", d);- In
Init.c:3:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Heap.h>
#include <Misra/Std/Container/Graph.h>- In
Foreach.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Graph.h>
#include <Misra/Std/Container/Map.h>- In
Access.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Graph.h>
#include <Misra/Std/Log.h>- In
Access.c:63:
DefaultAllocator alloc = DefaultAllocatorInit();
typedef Graph(Zstr) ZstrGraph;
ZstrGraph graph = GraphInit(&alloc);- In
Type.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>- In
Math.c:3:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>- In
Convert.c:3:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Float.h>
#include <Misra/Std/Container/Int.h>- In
Convert.c:252:
DefaultAllocator alloc = DefaultAllocatorInit();
FloatFromStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false;- In
Convert.c:263:
Float value = FloatInit(ALLOCATOR_OF(&alloc));
FloatTryFromStr(&value, (Zstr)NULL);
FloatDeinit(&value);
DefaultAllocatorDeinit(&alloc);- In
Complex.c:3:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Allocator/Heap.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Memory.h>- In
Complex.c:36:
// owns the storage and needs a writable handle to feed into a raw `char *`
// struct field, so the cast is correct here.
static inline char *ZstrDupAlloc(Zstr s) {
return (char *)zstr_dup(s, fixture_alloc());
}- In
Complex.c:108:
// only proves the container's deep-copy hooks call user destructors against
// independently-allocated payloads.
ComplexItem InitComplexItem(Zstr name, int *values, size num_values) {
ComplexItem item = {0};- In
Memory.c:6:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h> BitVec source = BitVecInit(ALLOCATOR_OF(&alloc));
BitVecPush(&source, true);
BitVecRegexMatch(&source, (Zstr)NULL);
BitVecDeinit(&source);
DefaultAllocatorDeinit(&alloc);- In
Convert.c:2:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Str.h>- In
Convert.c:78:
// Convert from string
Zstr str = "1011";
BitVec bv;
bool ok = BitVecTryFromStr(&bv, str, ALLOCATOR_OF(&alloc));- In
Convert.c:449:
// Test string round-trip
Zstr patterns[] = {"101", "1111000011110000", "1", "0", "10101010", "01010101"};
for (size i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) {- In
Convert.c:562:
// Test specific bit patterns with exact expectations
struct {
Zstr pattern;
u64 expected_value;
u8 expected_bytes[8];- In
Convert.c:772:
// Test NULL string - should abort
BitVecFromStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);- In
Math.c:3:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Int.h>
#include <Misra/Std/Log.h>- In
Convert.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Container/Int.h>- In
Convert.c:175:
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr digits = "123456789012345678901234567890";
Int value = IntFromStr(digits, ALLOCATOR_OF(&alloc));
Str text = IntToStr(&value);- In
Convert.c:322:
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr hex = "deadbeefcafebabe1234";
Int value = IntFromHexStr(hex, ALLOCATOR_OF(&alloc));
Str text = IntToHexStr(&value);- In
Convert.c:466:
DefaultAllocator alloc = DefaultAllocatorInit();
IntFromBinary((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false;- In
Convert.c:477:
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromBinary(&value, (Zstr)NULL);
IntDeinit(&value);
DefaultAllocatorDeinit(&alloc);- In
Convert.c:488:
DefaultAllocator alloc = DefaultAllocatorInit();
IntFromStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false;- In
Convert.c:499:
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromStr(&value, (Zstr)NULL);
IntDeinit(&value);
DefaultAllocatorDeinit(&alloc);- In
Convert.c:510:
DefaultAllocator alloc = DefaultAllocatorInit();
IntFromStrRadix((Zstr)NULL, 10, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false;- In
Convert.c:521:
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromStrRadix(&value, (Zstr)NULL, 10);
IntDeinit(&value);
DefaultAllocatorDeinit(&alloc);- In
Convert.c:532:
DefaultAllocator alloc = DefaultAllocatorInit();
IntFromOctStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false;- In
Convert.c:543:
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromOctStr(&value, (Zstr)NULL);
IntDeinit(&value);
DefaultAllocatorDeinit(&alloc);- In
Convert.c:554:
DefaultAllocator alloc = DefaultAllocatorInit();
IntFromHexStr((Zstr)NULL, ALLOCATOR_OF(&alloc));
DefaultAllocatorDeinit(&alloc);
return false;- In
Convert.c:565:
Int value = IntInit(ALLOCATOR_OF(&alloc));
IntTryFromHexStr(&value, (Zstr)NULL);
IntDeinit(&value);
DefaultAllocatorDeinit(&alloc);- In
UserTypes.c:12:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
UserTypes.c:54:
// the extending-io guide.
bool _write_Point2D(Str *o, FmtInfo *info, Point2D *p);
Zstr _read_Point2D(Zstr i, FmtInfo *info, Point2D *p);
bool _write_Bounds(Str *o, FmtInfo *info, Bounds *b);
Zstr _read_Bounds(Zstr i, FmtInfo *info, Bounds *b);- In
UserTypes.c:56:
Zstr _read_Point2D(Zstr i, FmtInfo *info, Point2D *p);
bool _write_Bounds(Str *o, FmtInfo *info, Bounds *b);
Zstr _read_Bounds(Zstr i, FmtInfo *info, Bounds *b);
bool _write_Region(Str *o, FmtInfo *info, Region *r);
Zstr _read_Region(Zstr i, FmtInfo *info, Region *r);- In
UserTypes.c:58:
Zstr _read_Bounds(Zstr i, FmtInfo *info, Bounds *b);
bool _write_Region(Str *o, FmtInfo *info, Region *r);
Zstr _read_Region(Zstr i, FmtInfo *info, Region *r);
bool _write_Point2D(Str *o, FmtInfo *info, Point2D *p) {- In
UserTypes.c:68:
}
Zstr _read_Point2D(Zstr i, FmtInfo *info, Point2D *p) {
(void)info;
if (!i || !p) {- In
UserTypes.c:88:
}
Zstr _read_Bounds(Zstr i, FmtInfo *info, Bounds *b) {
(void)info;
if (!i || !b) {- In
UserTypes.c:108:
}
Zstr _read_Region(Zstr i, FmtInfo *info, Region *r) {
(void)info;
if (!i || !r) {- In
UserTypes.c:161:
WriteFmt("Testing user-type read through IOFMT_USER_CASE_\n");
Zstr in = "(42, -9)";
Point2D p = {0};
StrReadFmt(in, "{}", p);- In
UserTypes.c:179:
bool ok = StrAppendFmt(&out, "{}", src);
Zstr in = StrBegin(&out);
StrReadFmt(in, "{}", dst);
ok = ok && (dst.x == src.x) && (dst.y == src.y);- In
UserTypes.c:219:
bool ok = StrAppendFmt(&out, "{}", src);
Zstr in = StrBegin(&out);
StrReadFmt(in, "{}", dst);- In
UserTypes.c:263:
bool ok = StrAppendFmt(&out, "{}", src);
Zstr in = StrBegin(&out);
StrReadFmt(in, "{}", dst);- In
Write.c:3:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/BitVec.h>- In
Write.c:73:
bool success = true;
Zstr str = "Hello";
StrAppendFmt(&output, "{}", str);
success = success && (ZstrCompare(StrBegin(&output), "Hello") == 0);- In
Write.c:78:
StrClear(&output);
Zstr empty = "";
StrAppendFmt(&output, "{}", empty);
success = success && (StrLen(&output) == 0);- In
Write.c:328:
StrClear(&output);
Zstr str = "abc";
StrAppendFmt(&output, "{5}", str);
success = success && (ZstrCompare(StrBegin(&output), " abc") == 0);- In
Write.c:353:
bool success = true;
Zstr hello = "Hello";
i32 num = 42;
f64 pi = 3.14;- In
Write.c:377:
bool success = true;
Zstr mixed_case = "MiXeD CaSe";
StrAppendFmt(&output, "{c}", mixed_case);
success = success && (ZstrCompare(StrBegin(&output), "MiXeD CaSe") == 0);- In
Write.c:963:
// Helper: decode one "\\xHL" escape and return the produced char (0 on fail).
static char decode_hex_escape(Zstr lit) {
Zstr p = lit;
return ZstrProcessEscape(&p);- In
Write.c:964:
// Helper: decode one "\\xHL" escape and return the produced char (0 on fail).
static char decode_hex_escape(Zstr lit) {
Zstr p = lit;
return ZstrProcessEscape(&p);
}- In
Write.c:990:
// changes the token boundary into an unparseable token (or a zero-length
// token) leaves the sentinel in place instead of the expected value.
static bool read_float_equals(Zstr input, Zstr expected) {
DefaultAllocator alloc = DefaultAllocatorInit();- In
Write.c:1008:
}
static bool roundtrip_eq(Zstr path, Zstr expect) {
DefaultAllocator alloc = DefaultAllocatorInit();
File f = FileOpen(path, "r");- In
Write.c:1043:
// argc = 1: only one argument is allowed even though two placeholders
// appear in the format.
Zstr out = str_read_fmt("3-4", "{}-{}", argv, 1);
// Real: rejects the second placeholder -> NULL, and b stays untouched.
- In
Write.c:1056:
static bool test_m1_invalid_spec_leaves_dest(void) {
i32 val = 77;
Zstr out = READ1("5", "{q}", TO_TYPE_SPECIFIC_IO(i32, &val));
// Real: parse fails -> NULL, val unchanged.
return out == NULL && val == 77;- In
Write.c:1069:
static bool test_m1_char_spec_then_literal(void) {
u8 ch = 0;
Zstr in = "AZ";
Zstr out = READ1(in, "{c}Z", TO_TYPE_SPECIFIC_IO(u8, &ch));
// Real: reads 'A' as the {c} field, matches literal 'Z', consumes all.
- In
Write.c:1070:
u8 ch = 0;
Zstr in = "AZ";
Zstr out = READ1(in, "{c}Z", TO_TYPE_SPECIFIC_IO(u8, &ch));
// Real: reads 'A' as the {c} field, matches literal 'Z', consumes all.
return out == in + 2 && ch == 'A';- In
Write.c:1083:
// 50 'A's inside quotes.
Zstr in = "\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"";
Str s = StrInit(&alloc);- In
Write.c:1086:
Str s = StrInit(&alloc);
Zstr out = READ1(in, "{s}", TO_TYPE_SPECIFIC_IO(Str, &s));
bool ok = (out != NULL) && (StrLen(&s) == 50);- In
Write.c:1097:
static bool test_m1_raw_u8(void) {
u8 v = 0;
Zstr in = "\x07";
Zstr out = READ1(in, "{<1r}", TO_TYPE_SPECIFIC_IO(u8, &v));
return out == in + 1 && v == 0x07;- In
Write.c:1098:
u8 v = 0;
Zstr in = "\x07";
Zstr out = READ1(in, "{<1r}", TO_TYPE_SPECIFIC_IO(u8, &v));
return out == in + 1 && v == 0x07;
}- In
Write.c:1104:
static bool test_m1_raw_i8(void) {
i8 v = 0;
Zstr in = "\x07";
Zstr out = READ1(in, "{<1r}", TO_TYPE_SPECIFIC_IO(i8, &v));
return out == in + 1 && v == 0x07;- In
Write.c:1105:
i8 v = 0;
Zstr in = "\x07";
Zstr out = READ1(in, "{<1r}", TO_TYPE_SPECIFIC_IO(i8, &v));
return out == in + 1 && v == 0x07;
}- In
Write.c:1111:
static bool test_m1_raw_u16_le(void) {
u16 v = 0;
Zstr in = "\x34\x12"; // LE -> 0x1234
Zstr out = READ1(in, "{<2r}", TO_TYPE_SPECIFIC_IO(u16, &v));
return out == in + 2 && v == 0x1234;- In
Write.c:1112:
u16 v = 0;
Zstr in = "\x34\x12"; // LE -> 0x1234
Zstr out = READ1(in, "{<2r}", TO_TYPE_SPECIFIC_IO(u16, &v));
return out == in + 2 && v == 0x1234;
}- In
Write.c:1118:
static bool test_m1_raw_i16_be(void) {
i16 v = 0;
Zstr in = "\x12\x34"; // BE -> 0x1234
Zstr out = READ1(in, "{>2r}", TO_TYPE_SPECIFIC_IO(i16, &v));
return out == in + 2 && v == 0x1234;- In
Write.c:1119:
i16 v = 0;
Zstr in = "\x12\x34"; // BE -> 0x1234
Zstr out = READ1(in, "{>2r}", TO_TYPE_SPECIFIC_IO(i16, &v));
return out == in + 2 && v == 0x1234;
}- In
Write.c:1125:
static bool test_m1_raw_u32_le(void) {
u32 v = 0;
Zstr in = "\xEF\xBE\xAD\xDE"; // LE -> 0xDEADBEEF
Zstr out = READ1(in, "{<4r}", TO_TYPE_SPECIFIC_IO(u32, &v));
return out == in + 4 && v == 0xDEADBEEFu;- In
Write.c:1126:
u32 v = 0;
Zstr in = "\xEF\xBE\xAD\xDE"; // LE -> 0xDEADBEEF
Zstr out = READ1(in, "{<4r}", TO_TYPE_SPECIFIC_IO(u32, &v));
return out == in + 4 && v == 0xDEADBEEFu;
}- In
Write.c:1132:
static bool test_m1_raw_i32_be(void) {
i32 v = 0;
Zstr in = "\x12\x34\x56\x78"; // BE -> 0x12345678
Zstr out = READ1(in, "{>4r}", TO_TYPE_SPECIFIC_IO(i32, &v));
return out == in + 4 && v == 0x12345678;- In
Write.c:1133:
i32 v = 0;
Zstr in = "\x12\x34\x56\x78"; // BE -> 0x12345678
Zstr out = READ1(in, "{>4r}", TO_TYPE_SPECIFIC_IO(i32, &v));
return out == in + 4 && v == 0x12345678;
}- In
Write.c:1139:
static bool test_m1_raw_u64_le(void) {
u64 v = 0;
Zstr in = "\x08\x07\x06\x05\x04\x03\x02\x01"; // LE -> 0x0102030405060708
Zstr out = READ1(in, "{<8r}", TO_TYPE_SPECIFIC_IO(u64, &v));
return out == in + 8 && v == 0x0102030405060708ull;- In
Write.c:1140:
u64 v = 0;
Zstr in = "\x08\x07\x06\x05\x04\x03\x02\x01"; // LE -> 0x0102030405060708
Zstr out = READ1(in, "{<8r}", TO_TYPE_SPECIFIC_IO(u64, &v));
return out == in + 8 && v == 0x0102030405060708ull;
}- In
Write.c:1146:
static bool test_m1_raw_i64_be(void) {
i64 v = 0;
Zstr in = "\x01\x02\x03\x04\x05\x06\x07\x08"; // BE -> 0x0102030405060708
Zstr out = READ1(in, "{>8r}", TO_TYPE_SPECIFIC_IO(i64, &v));
return out == in + 8 && v == 0x0102030405060708ll;- In
Write.c:1147:
i64 v = 0;
Zstr in = "\x01\x02\x03\x04\x05\x06\x07\x08"; // BE -> 0x0102030405060708
Zstr out = READ1(in, "{>8r}", TO_TYPE_SPECIFIC_IO(i64, &v));
return out == in + 8 && v == 0x0102030405060708ll;
}- In
Write.c:1159:
} got = {0};
Zstr in = "\xEF\xBE\xAD\xDE"; // LE bytes -> bit pattern 0xDEADBEEF
Zstr out = READ1(in, "{<4r}", TO_TYPE_SPECIFIC_IO(f32, &got.f));- In
Write.c:1160:
Zstr in = "\xEF\xBE\xAD\xDE"; // LE bytes -> bit pattern 0xDEADBEEF
Zstr out = READ1(in, "{<4r}", TO_TYPE_SPECIFIC_IO(f32, &got.f));
return out == in + 4 && got.u == 0xDEADBEEFu;- In
Write.c:1172:
} got = {0};
Zstr in = "\x08\x07\x06\x05\x04\x03\x02\x01"; // LE -> 0x0102030405060708
Zstr out = READ1(in, "{<8r}", TO_TYPE_SPECIFIC_IO(f64, &got.f));- In
Write.c:1173:
Zstr in = "\x08\x07\x06\x05\x04\x03\x02\x01"; // LE -> 0x0102030405060708
Zstr out = READ1(in, "{<8r}", TO_TYPE_SPECIFIC_IO(f64, &got.f));
return out == in + 8 && got.u == 0x0102030405060708ull;- In
Write.c:1347:
// real guard is false; either swap to != makes the guard true and errors. ---
static bool test_m11_hex_two_digits_not_truncated(void) {
Zstr p = "\\x41"; // 'A'
char c = ZstrProcessEscape(&p);
return c == 'A';- In
Write.c:1356:
// 0x41 = 65 != 42, so the decoded byte mismatches. ---
static bool test_m11_hex_value_is_decoded_not_42(void) {
Zstr p = "\\x41"; // must yield 65 ('A'), not 42 ('*')
char c = ZstrProcessEscape(&p);
return c == (char)65;- In
Write.c:1364:
// is actually consumed (255 != 42).
static bool test_m11_hex_ff(void) {
Zstr p = "\\xff";
char c = ZstrProcessEscape(&p);
return (unsigned char)c == 0xFFu;- In
Write.c:1373:
// error branch and returns 0; real returns the byte. ---
static bool test_m11_hex_valid_not_rejected(void) {
Zstr p = "\\x41";
return ZstrProcessEscape(&p) == 'A';
}- In
Write.c:1393:
// 0x41 -> 65, distinct from 42. ---
static bool test_m11_hex_result_assigned_from_value(void) {
Zstr p = "\\x41";
return ZstrProcessEscape(&p) == (char)65;
}- In
Write.c:1400:
// the hex_byte<0 path so the lt mutants have a contrasting branch covered.
static bool test_m11_hex_invalid_returns_zero(void) {
Zstr p = "\\xZZ";
return ZstrProcessEscape(&p) == 0;
}- In
Write.c:1414:
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0x1";
StrReadFmt(z, "{}", bv);- In
Write.c:1432:
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0xDEAD";
StrReadFmt(z, "{}", bv);- In
Write.c:1448:
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0xDEAD";
StrReadFmt(z, "{}", bv);- In
Write.c:1467:
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0o1";
StrReadFmt(z, "{}", bv);- In
Write.c:1486:
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0o10";
StrReadFmt(z, "{}", bv);- In
Write.c:1503:
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0o755";
StrReadFmt(z, "{}", bv);- In
Write.c:1521:
Str output = StrInit(&alloc);
Zstr s = "AB"; // 0x41 0x42
StrAppendFmt(&output, "{x}", s);
bool ok = (ZstrCompare(StrBegin(&output), "0x41 0x42") == 0);- In
Write.c:1537:
Str output = StrInit(&alloc);
Zstr s = "Z"; // 0x5a
StrAppendFmt(&output, "{x}", s);
bool ok = (ZstrCompare(StrBegin(&output), "0x5a") == 0);- In
Write.c:1554:
Str output = StrInit(&alloc);
Zstr s = "\xab"; // single byte 0xab
StrAppendFmt(&output, "{x}", s);
bool ok = (ZstrCompare(StrBegin(&output), "0xab") == 0);- In
Write.c:1571:
Str output = StrInit(&alloc);
Zstr s = "\xab";
StrAppendFmt(&output, "{X}", s);
bool ok = (ZstrCompare(StrBegin(&output), "0xAB") == 0);- In
Write.c:1587:
Str output = StrInit(&alloc);
Zstr s = "\x05"; // single byte 0x05
StrAppendFmt(&output, "{x}", s);
bool ok = (ZstrCompare(StrBegin(&output), "0x05") == 0);- In
Write.c:1602:
Str output = StrInit(&alloc);
Zstr s = "\xfe";
StrAppendFmt(&output, "{x}", s);
bool ok = (ZstrCompare(StrBegin(&output), "0xfe") == 0);- In
Write.c:1618:
Str output = StrInit(&alloc);
Zstr s = "Hello";
StrAppendFmt(&output, "{.3}", s);
bool ok = (ZstrCompare(StrBegin(&output), "Hel") == 0);- In
Write.c:1634:
Str output = StrInit(&alloc);
Zstr s = "Hi";
StrAppendFmt(&output, "{.10}", s);
bool ok = (ZstrCompare(StrBegin(&output), "Hi") == 0);- In
Write.c:1651:
Str output = StrInit(&alloc);
Zstr s = "Hello";
StrAppendFmt(&output, "{.0}", s);
bool ok = (StrLen(&output) == 0);- In
Write.c:1667:
Str output = StrInit(&alloc);
Zstr s = "Hello";
StrAppendFmt(&output, "{.1}", s);
bool ok = (ZstrCompare(StrBegin(&output), "H") == 0);- In
Write.c:1686:
Str output = StrInit(&alloc);
Zstr s = "Hi";
StrAppendFmt(&output, "abc{>10}", s);
bool ok = (ZstrCompare(StrBegin(&output), " abcHi") == 0);- In
Write.c:1701:
Str output = StrInit(&alloc);
Zstr s = "Hi";
StrAppendFmt(&output, "xy{<10}", s);
bool ok = (ZstrCompare(StrBegin(&output), "xyHi ") == 0);- In
Write.c:1716:
Str output = StrInit(&alloc);
Zstr s = "";
StrAppendFmt(&output, "{>5}", s);
bool ok = (ZstrCompare(StrBegin(&output), " ") == 0);- In
Write.c:1733:
// ---------------------------------------------------------------------------
static bool test_m14_hex_prefix_uses_first_char_flag(void) {
Zstr z = "0x1f";
u8 v = 0;
StrReadFmt(z, "{}", v);- In
Write.c:1747:
// ---------------------------------------------------------------------------
static bool test_m14_slice_length_is_difference(void) {
Zstr z = " 5";
u8 v = 0;
StrReadFmt(z, "{}", v);- In
Write.c:1760:
// ---------------------------------------------------------------------------
static bool test_m14_prefix_guard_len_gate(void) {
Zstr z = "0xff";
u8 v = 0;
StrReadFmt(z, "{}", v);- In
Write.c:1775:
// ---------------------------------------------------------------------------
static bool test_m14_prefix_guard_letters(void) {
Zstr z = "05";
u8 v = 0;
StrReadFmt(z, "{}", v);- In
Write.c:2083:
// The 42-mutant stores '*' instead.
static bool test_m18_bad_nibble_salvage(void) {
Zstr z = "\\xZZ"; // '\', 'x', 'Z', 'Z'
u8 v = 0;
StrReadFmt(z, "{c}", v);- In
Write.c:2097:
// the 42-mutant on 1607 stores '*'.
static bool test_m18_force_lowercase(void) {
Zstr z = "A";
u8 v = 0;
StrReadFmt(z, "{a}", v);- In
Write.c:2108:
// the 42-mutant on 1607 stores '*'.
static bool test_m18_force_uppercase(void) {
Zstr z = "a";
u8 v = 0;
StrReadFmt(z, "{A}", v);- In
Write.c:2123:
static bool test_m18_buffer_size_stop(void) {
u8 buf[4] = {0, 0, 0, 0};
Zstr z = "AB";
StrReadFmt(z, "{c}", buf[0]);
bool ok = (buf[0] == 'A');- In
Write.c:2143:
static bool test_m19_neg_inf_lower(void) {
f64 v = 123.0;
Zstr z = "-inf";
Zstr orig = z;
StrReadFmt(z, "{}", v);- In
Write.c:2144:
f64 v = 123.0;
Zstr z = "-inf";
Zstr orig = z;
StrReadFmt(z, "{}", v);
// Real: consumed (z advanced) and v is -inf. Mutant: not consumed.
- In
Write.c:2162:
static bool test_m19_neg_inf_upper(void) {
f64 v = 7.0;
Zstr z = "-Inf";
Zstr orig = z;
StrReadFmt(z, "{}", v);- In
Write.c:2163:
f64 v = 7.0;
Zstr z = "-Inf";
Zstr orig = z;
StrReadFmt(z, "{}", v);
return (z != orig) && F64IsInf(v) && (v < 0.0);- In
Write.c:2184:
static bool test_m19_dash_clause_not_minus(void) {
f64 v = 0.0;
Zstr z = "5inf";
StrReadFmt(z, "{}", v);
// Real: advanced by 1 -> *z == 'i'. Mutant: advanced by 4 -> *z == '\0'.
- In
Write.c:2203:
static bool test_m19_inf_branch_strtof64_truthy(void) {
f64 v = 55.0;
Zstr z = "info";
Zstr orig = z;
StrReadFmt(z, "{}", v);- In
Write.c:2204:
f64 v = 55.0;
Zstr z = "info";
Zstr orig = z;
StrReadFmt(z, "{}", v);
// Real: not consumed (z unchanged). Mutant: consumed (z advanced).
- In
Write.c:2224:
static bool test_m19_token_length_leading_space(void) {
f64 v = -1.0;
Zstr z = " 3.14";
StrReadFmt(z, "{}", v);
// Real: v == 3.14. Mutant: parse fails, v left at -1.0.
- In
Write.c:2243:
static bool test_m19_numeric_string_guard(void) {
f64 v = 88.0;
Zstr z = "1f";
Zstr orig = z;
StrReadFmt(z, "{}", v);- In
Write.c:2244:
f64 v = 88.0;
Zstr z = "1f";
Zstr orig = z;
StrReadFmt(z, "{}", v);
// Real: rejected, not consumed (z unchanged). Mutant: consumed.
- In
Write.c:2271:
f64 v = SENTINEL;
Zstr z = "0x";
StrReadFmt(z, "{}", v);- In
Write.c:2285:
f64 v = SENTINEL;
Zstr z = "0b";
StrReadFmt(z, "{}", v);- In
Write.c:2295:
f64 v = SENTINEL;
Zstr z = "0o";
StrReadFmt(z, "{}", v);- In
Write.c:2314:
f64 v = SENTINEL;
Zstr z = "0X1F";
StrReadFmt(z, "{}", v);- In
Write.c:2328:
f64 v = SENTINEL;
Zstr z = "0B11";
StrReadFmt(z, "{}", v);- In
Write.c:2341:
f64 v = SENTINEL;
Zstr z = "0O7";
StrReadFmt(z, "{}", v);- In
Write.c:2355:
f64 v = SENTINEL;
Zstr z = "12.5";
StrReadFmt(z, "{}", v);- In
Write.c:2365:
f64 v = SENTINEL;
Zstr z = "0x1f";
StrReadFmt(z, "{}", v);- In
Write.c:2387:
Float val = FloatInit(alloc_base);
Zstr z = "3.5;";
StrReadFmt(z, "{};", val);- In
Write.c:2417:
Float val = FloatInit(alloc_base);
Zstr z = "12.25";
StrReadFmt(z, "{}", val);- In
Write.c:2443:
Float val = FloatInit(alloc_base);
Zstr z = "1.5e2!";
StrReadFmt(z, "{e}!", val);- In
Write.c:2469:
Float val = FloatInit(alloc_base);
Zstr z = "-0.25";
StrReadFmt(z, "{}", val);- In
Write.c:2491:
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0x3ff";
StrReadFmt(z, "{}", bv);- In
Write.c:2510:
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0xff";
StrReadFmt(z, "{}", bv);- In
Write.c:2529:
BitVec bv = BitVecInit(alloc_base);
Zstr z = "0x10000";
StrReadFmt(z, "{}", bv);- In
Write.c:3031:
static bool test_m28_fwrite_roundtrip_string(void) {
Zstr path = "io_mutants28_str.txt"; // CWD-relative: portable (no /tmp on Windows)
File f = FileOpen(path, "w");
if (!FileIsOpen(&f)) {- In
Write.c:3037:
}
Zstr s = "World";
bool ret = FWriteFmt(&f, "Hello {}!", s);
FileClose(&f);- In
Write.c:3048:
static bool test_m28_fwrite_roundtrip_int(void) {
Zstr path = "io_mutants28_int.txt"; // CWD-relative: portable (no /tmp on Windows)
File f = FileOpen(path, "w");
if (!FileIsOpen(&f)) {- In
Write.c:3065:
// compare still holds (543:83) with the '\n' counted.
static bool test_m28_fwriteln_roundtrip(void) {
Zstr path = "io_mutants28_ln.txt"; // CWD-relative: portable (no /tmp on Windows)
File f = FileOpen(path, "w");
if (!FileIsOpen(&f)) {- In
Write.c:3180:
static bool test_m29_hexbyte_printable_roundtrip(void) {
u8 v = 0;
Zstr z = "\\x41";
StrReadFmt(z, "{c}", v);
return v == 0x41;- In
Write.c:3190:
static bool test_m29_hexbyte_high_nibble_zero(void) {
u8 v = 0;
Zstr z = "\\x01";
StrReadFmt(z, "{c}", v);
return v == 0x01;- In
Write.c:3199:
static bool test_m29_hexbyte_low_nibble_zero(void) {
u8 v = 0;
Zstr z = "\\x10";
StrReadFmt(z, "{c}", v);
return v == 0x10;- In
Write.c:3209:
static bool test_m29_hexbyte_letter_nibble(void) {
u8 v = 0;
Zstr z = "\\x4f";
StrReadFmt(z, "{c}", v);
return v == 0x4f;- In
Write.c:3822:
Int oct = IntInit(alloc_base);
Zstr z = "78";
StrReadFmt(z, "{o}", oct);- In
Write.c:3842:
Str output = StrInit(&alloc);
Zstr name = "hello";
StrAppendFmt(&output, "{s}", ZstrIO(name, alloc_base));- In
Write.c:4056:
// "abc" is 3 chars; field width 3 -> no padding at all.
Zstr s = "abc";
StrAppendFmt(&out, "{3}", s);
ok = ok && (ZstrCompare(StrBegin(&out), "abc") == 0);- In
Write.c:4260:
static bool test_m5_char_flag_empty_keeps_zero_init(void) {
f32 v = -1.0f;
Zstr z = " ";
StrReadFmt(z, "{c}", v);
return f32_close(v, 0.0f);- In
Write.c:4271:
static bool test_m5_special_lower_inf(void) { // c == 'i'
f32 v = 0.0f;
Zstr z = "inf";
StrReadFmt(z, "{}", v);
return v > 1e30f;- In
Write.c:4278:
static bool test_m5_special_upper_inf(void) { // c == 'I'
f32 v = 0.0f;
Zstr z = "INF";
StrReadFmt(z, "{}", v);
return v > 1e30f;- In
Write.c:4285:
static bool test_m5_special_lower_nan(void) { // c == 'n'
f32 v = 0.0f;
Zstr z = "nan";
StrReadFmt(z, "{}", v);
return v != v; // NaN is the only value not equal to itself
- In
Write.c:4292:
static bool test_m5_special_upper_nan(void) { // c == 'N'
f32 v = 0.0f;
Zstr z = "NAN";
StrReadFmt(z, "{}", v);
return v != v;- In
Write.c:4299:
static bool test_m5_special_neg_inf_dash(void) { // c == '-'
f32 v = 0.0f;
Zstr z = "-inf";
StrReadFmt(z, "{}", v);
return v < -1e30f;- In
Write.c:4306:
static bool test_m5_special_neg_inf_c1_lower(void) { // c1 == 'i'
f32 v = 0.0f;
Zstr z = "-inf";
StrReadFmt(z, "{}", v);
return v < -1e30f;- In
Write.c:4313:
static bool test_m5_special_neg_inf_c1_upper(void) { // c1 == 'I'
f32 v = 0.0f;
Zstr z = "-INF";
StrReadFmt(z, "{}", v);
return v < -1e30f;- In
Write.c:4322:
static bool test_m5_special_value_is_not_42(void) {
f32 v = 0.0f;
Zstr z = "inf";
StrReadFmt(z, "{}", v);
return v > 1e30f; // 42.0 would fail this
- In
Write.c:4333:
static bool test_m5_exponent_lower_with_sign(void) {
f32 v = 0.0f;
Zstr z = "1e+3";
StrReadFmt(z, "{}", v);
return f32_close(v, 1000.0f);- In
Write.c:4341:
static bool test_m5_exponent_upper_with_sign(void) {
f32 v = 0.0f;
Zstr z = "1E+3";
StrReadFmt(z, "{}", v);
return f32_close(v, 1000.0f);- In
Write.c:4351:
static bool test_m5_exponent_guard_not_le(void) {
f32 v = 0.0f;
Zstr z = "2e-2";
StrReadFmt(z, "{}", v);
return f32_close(v, 0.02f);- In
Write.c:4360:
static bool test_m5_exponent_plus_sign(void) {
f32 v = 0.0f;
Zstr z = "1e+3";
StrReadFmt(z, "{}", v);
return f32_close(v, 1000.0f);- In
Write.c:4368:
static bool test_m5_exponent_minus_sign(void) {
f32 v = 0.0f;
Zstr z = "1e-3";
StrReadFmt(z, "{}", v);
return f32_close(v, 0.001f);- In
Write.c:4380:
static bool test_m5_leading_sign_is_first_char(void) {
f32 v = 0.0f;
Zstr z = "+1.5";
StrReadFmt(z, "{}", v);
return f32_close(v, 1.5f);- In
Write.c:4392:
static bool test_m5_token_length_uses_subtraction(void) {
f32 v = 0.0f;
Zstr z = " 3.5";
StrReadFmt(z, "{}", v);
return f32_close(v, 3.5f);- In
Write.c:4406:
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "9z";
StrReadFmt(z, "{}", v);
bool ok = (IntCompare(&v, 9) == 0);- In
Write.c:4423:
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "5";
StrReadFmt(z, "{}", v);
bool ok = (IntCompare(&v, 5) == 0);- In
Write.c:4439:
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "+8";
StrReadFmt(z, "{}", v);
bool ok = (IntCompare(&v, 8) == 0);- In
Write.c:4455:
Int v = IntFromStr("123", &alloc);
Zstr z = "9_";
StrReadFmt(z, "{}", v);
bool ok = (IntCompare(&v, 123) == 0);- In
Write.c:4472:
Int v = IntFromStr("200", &alloc);
Zstr z = "0xFF";
StrReadFmt(z, "{x}", v);
bool ok = (IntCompare(&v, 200) == 0);- In
Write.c:4488:
Int v = IntFromStr("200", &alloc);
Zstr z = "0XFF";
StrReadFmt(z, "{x}", v);
bool ok = (IntCompare(&v, 200) == 0);- In
Write.c:4503:
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "ff";
StrReadFmt(z, "{x}", v);
bool ok = (IntCompare(&v, 255) == 0);- In
Write.c:4518:
Int v = IntFromStr("5", &alloc);
Zstr z = "0b1";
StrReadFmt(z, "{b}", v);
bool ok = (IntCompare(&v, 5) == 0);- In
Write.c:4532:
Int v = IntFromStr("5", &alloc);
Zstr z = "0B1";
StrReadFmt(z, "{b}", v);
bool ok = (IntCompare(&v, 5) == 0);- In
Write.c:4546:
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "101";
StrReadFmt(z, "{b}", v);
bool ok = (IntCompare(&v, 5) == 0);- In
Write.c:4561:
Int v = IntFromStr("9", &alloc);
Zstr z = "0o7";
StrReadFmt(z, "{o}", v);
bool ok = (IntCompare(&v, 9) == 0);- In
Write.c:4575:
Int v = IntFromStr("9", &alloc);
Zstr z = "0O7";
StrReadFmt(z, "{o}", v);
bool ok = (IntCompare(&v, 9) == 0);- In
Write.c:4589:
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = "17";
StrReadFmt(z, "{o}", v);
bool ok = (IntCompare(&v, 15) == 0);- In
Write.c:4604:
Int v = IntInit(ALLOCATOR_OF(&alloc));
Zstr z = " 42";
StrReadFmt(z, "{}", v);
bool ok = (IntCompare(&v, 42) == 0);- In
Write.c:4742:
bool ok = true;
Zstr s = "Hello";
bool rc = StrAppendFmt(&out, "{.9s}", s);
ok = ok && rc;- In
Write.c:4821:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Zstr s = "ab";
StrAppendFmt(&out, "{4}", s);
bool ok = (ZstrCompare(StrBegin(&out), " ab") == 0);- In
Write.c:4908:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Zstr s = "abc";
StrAppendFmt(&out, "{3}", s);
bool ok = (ZstrCompare(StrBegin(&out), "abc") == 0);- In
Write.c:5090:
static bool test_zstr_hex_no_leak(void) {
DBG_BEGIN(dbg, out);
Zstr s = "\x01\x4f";
StrAppendFmt(&out, "{x}", s);
bool ok = (ZstrCompare(StrBegin(&out), "0x01 0x4f") == 0);- In
Write.c:5098:
static bool test_zstr_hex_nibble_no_leak(void) {
DBG_BEGIN(dbg, out);
Zstr s = "\x05";
StrAppendFmt(&out, "{x}", s);
bool ok = (ZstrCompare(StrBegin(&out), "0x05") == 0);- In
Write.c:5124:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Zstr s = "hi";
StrAppendFmt(&out, "{}", s);
bool ok = (ZstrCompare(StrBegin(&out), "hi") == 0);- In
Write.c:5624:
Allocator *adbg = ALLOCATOR_OF(&dbg);
Zstr s = "AB"; // multi-byte Zstr -> hex loop runs per byte
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{x}", s);- In
Read.c:3:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/BitVec.h>- In
Read.c:72:
WriteFmt("Testing integer decimal reading\n");
Zstr z = NULL;
bool success = true;- In
Read.c:167:
WriteFmt("Testing integer hexadecimal reading\n");
Zstr z = NULL;
bool success = true;- In
Read.c:202:
WriteFmt("Testing integer binary reading\n");
Zstr z = NULL;
bool success = true;- In
Read.c:227:
WriteFmt("Testing integer octal reading\n");
Zstr z = NULL;
bool success = true;- In
Read.c:257:
WriteFmt("Testing basic float reading\n");
Zstr z = NULL;
bool success = true;- In
Read.c:299:
WriteFmt("Testing scientific notation reading\n");
Zstr z = NULL;
bool success = true;- In
Read.c:347:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr z = NULL;
bool success = true;- In
Read.c:368:
{
Zstr zs = NULL;
z = "Allocator-backed";- In
Read.c:391:
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr z = NULL;
bool success = true;- In
Read.c:428:
WriteFmt("Testing error handling for reading\n");
Zstr z = NULL;
bool success = true;- In
Read.c:455:
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr z = NULL;
bool success = true;- In
Read.c:516:
z = "AB";
StrReadFmt(z, "{c}", u16_val);
bool u16_multi_pass = (ZstrCompareN((Zstr)&u16_val, "AB", 2) == 0);
WriteFmt("u16_val multi-char test: comparing memory with 'AB', pass = {}\n", u16_multi_pass ? "true" : "false");
WriteFmt(- In
Read.c:530:
z = "CD";
StrReadFmt(z, "{c}", i16_val);
bool i16_multi_pass = (ZstrCompareN((Zstr)&i16_val, "CD", 2) == 0);
WriteFmt("i16_val multi-char test: comparing memory with 'CD', pass = {}\n", i16_multi_pass ? "true" : "false");
success = success && i16_multi_pass;- In
Read.c:537:
z = "EFGH";
StrReadFmt(z, "{c}", u32_val);
bool u32_multi_pass = (ZstrCompareN((Zstr)&u32_val, "EFGH", 4) == 0);
WriteFmt("u32_val multi-char test: comparing memory with 'EFGH', pass = {}\n", u32_multi_pass ? "true" : "false");
success = success && u32_multi_pass;- In
Read.c:544:
z = "IJKL";
StrReadFmt(z, "{c}", i32_val);
bool i32_multi_pass = (ZstrCompareN((Zstr)&i32_val, "IJKL", 4) == 0);
WriteFmt("i32_val multi-char test: comparing memory with 'IJKL', pass = {}\n", i32_multi_pass ? "true" : "false");
success = success && i32_multi_pass;- In
Read.c:551:
z = "MNOPQRST";
StrReadFmt(z, "{c}", u64_val);
bool u64_multi_pass = (ZstrCompareN((Zstr)&u64_val, "MNOPQRST", 8) == 0);
WriteFmt(
"u64_val multi-char test: comparing memory with 'MNOPQRST', pass = {}\n",- In
Read.c:561:
z = "UVWXYZab";
StrReadFmt(z, "{c}", i64_val);
bool i64_multi_pass = (ZstrCompareN((Zstr)&i64_val, "UVWXYZab", 8) == 0);
WriteFmt(
"i64_val multi-char test: comparing memory with 'UVWXYZab', pass = {}\n",- In
Read.c:592:
z = "XY";
StrReadFmt(z, "{c}", u32_val);
bool xy_pass = (ZstrCompareN((Zstr)&u32_val, "XY", 2) == 0);
WriteFmt("u32_val partial test: comparing memory with 'XY', pass = {}\n", xy_pass ? "true" : "false");
success = success && xy_pass;- In
Read.c:599:
z = "abc";
StrReadFmt(z, "{c}", u64_val);
bool abc_pass = (ZstrCompareN((Zstr)&u64_val, "abc", 3) == 0);
WriteFmt("u64_val partial test: comparing memory with 'abc', pass = {}\n", abc_pass ? "true" : "false");
success = success && abc_pass;- In
Read.c:633:
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr z = NULL;
bool success = true;- In
Read.c:640:
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";
z = in;- In
Read.c:665:
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";
z = in;- In
Read.c:690:
{
Str result = StrInit(&alloc);
Zstr in = "hello world";
z = in;- In
Read.c:716:
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world";
z = in;- In
Read.c:737:
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world mighty misra";
z = in;- In
Read.c:759:
{
Str result = StrInit(&alloc);
Zstr in = "\"MiXeD CaSe\"";
z = in;- In
Read.c:784:
{
Str result = StrInit(&alloc);
Zstr in = "\"abc123XYZ\"";
z = in;- In
Read.c:809:
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";
z = in;- In
Read.c:842:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr z = NULL;
bool success = true;- In
Read.c:912:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr z = NULL;
bool success = true;- In
Read.c:964:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr z = NULL;
bool success = true;- In
Read.c:1011:
// "{{" branch), 571 ne_to_eq (*in != '{'), 577 sub_assign (rem_p -= 2).
static bool test_m1_escaped_open_brace(void) {
Zstr in = "{rest";
Zstr out = str_read_fmt(
in,- In
Read.c:1012:
static bool test_m1_escaped_open_brace(void) {
Zstr in = "{rest";
Zstr out = str_read_fmt(
in,
"{{",- In
Read.c:1029:
// Reinforces 570/571/577.
static bool test_m1_escaped_open_brace_exact(void) {
Zstr in = "{";
Zstr out = str_read_fmt(
in,- In
Read.c:1030:
static bool test_m1_escaped_open_brace_exact(void) {
Zstr in = "{";
Zstr out = str_read_fmt(
in,
"{{",- In
Read.c:1045:
// 585 sub_assign (rem_p -= 2).
static bool test_m1_escaped_close_brace(void) {
Zstr in = "}rest";
Zstr out = str_read_fmt(
in,- In
Read.c:1046:
static bool test_m1_escaped_close_brace(void) {
Zstr in = "}rest";
Zstr out = str_read_fmt(
in,
"}}",- In
Read.c:1058:
static bool test_m1_escaped_close_brace_exact(void) {
Zstr in = "}";
Zstr out = str_read_fmt(
in,- In
Read.c:1059:
static bool test_m1_escaped_close_brace_exact(void) {
Zstr in = "}";
Zstr out = str_read_fmt(
in,
"}}",- In
Read.c:1076:
// decodes; the mutant `*s == '\\'` enters the error branch and returns 0.
static bool test_m11_simple_escape_decodes(void) {
Zstr p = "\\n";
char c = ZstrProcessEscape(&p);
return c == '\n';- In
Read.c:1086:
// on any one case mismatches.
static bool test_m11_escape_n(void) {
Zstr p = "\\n";
return ZstrProcessEscape(&p) == '\n';
}- In
Read.c:1090:
}
static bool test_m11_escape_r(void) {
Zstr p = "\\r";
return ZstrProcessEscape(&p) == '\r';
}- In
Read.c:1094:
}
static bool test_m11_escape_t(void) {
Zstr p = "\\t";
return ZstrProcessEscape(&p) == '\t';
}- In
Read.c:1098:
}
static bool test_m11_escape_b(void) {
Zstr p = "\\b";
return ZstrProcessEscape(&p) == '\b';
}- In
Read.c:1102:
}
static bool test_m11_escape_f(void) {
Zstr p = "\\f";
return ZstrProcessEscape(&p) == '\f';
}- In
Read.c:1106:
}
static bool test_m11_escape_v(void) {
Zstr p = "\\v";
return ZstrProcessEscape(&p) == '\v';
}- In
Read.c:1110:
}
static bool test_m11_escape_a(void) {
Zstr p = "\\a";
return ZstrProcessEscape(&p) == '\a';
}- In
Read.c:1114:
}
static bool test_m11_escape_backslash(void) {
Zstr p = "\\\\";
return ZstrProcessEscape(&p) == '\\';
}- In
Read.c:1118:
}
static bool test_m11_escape_dquote(void) {
Zstr p = "\\\"";
return ZstrProcessEscape(&p) == '"';
}- In
Read.c:1122:
}
static bool test_m11_escape_squote(void) {
Zstr p = "\\'";
return ZstrProcessEscape(&p) == '\'';
}- In
Read.c:1127:
// case '0' -> result = '\0'; cxx_assign_const(42) at 2216 makes it '*'.
static bool test_m11_escape_nul(void) {
Zstr p = "\\0";
return ZstrProcessEscape(&p) == '\0';
}- In
Read.c:1142:
// ---------------------------------------------------------------------------
static bool test_m14_scan_stops_at_invalid_char(void) {
Zstr z = "42!";
u8 v = 0;
StrReadFmt(z, "{}", v);- In
Read.c:1159:
// substitutes 42 ('*') for the decoded byte -- all differ from 0x41.
static bool test_m18_hex_escape_decode(void) {
Zstr z = "\\x41"; // four bytes: '\', 'x', '4', '1'
Zstr beg = z;
u8 v = 0;- In
Read.c:1160:
static bool test_m18_hex_escape_decode(void) {
Zstr z = "\\x41"; // four bytes: '\', 'x', '4', '1'
Zstr beg = z;
u8 v = 0;
StrReadFmt(z, "{c}", v);- In
Read.c:1173:
// decode and salvages the literal '\' (0x5C) instead.
static bool test_m18_hex_escape_zero_byte(void) {
Zstr z = "\\x00"; // '\', 'x', '0', '0'
u8 v = 0xAA; // poison so a no-write is detectable too
StrReadFmt(z, "{c}", v);- In
Read.c:1188:
// the 42-mutant stores '*'.
static bool test_m18_truncated_hex_escape(void) {
Zstr z = "\\x"; // '\', 'x', then NUL
u8 v = 0;
StrReadFmt(z, "{c}", v);- In
Read.c:1483:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr input = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmn"; // 50 chars, no spaces/backslashes
char *out = NULL;- In
Read.c:1489:
FmtInfo fmt = {0}; // max_read_len == 0 -> hits the !max_read_len branch
Zstr next = _read_ZstrAlloc(input, &fmt, &arg);
bool ok = (next != NULL) && out && (ZstrCompare(out, input) == 0);- In
Read.c:1507:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr input = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmn"; // 50 chars
char *out = NULL;- In
Read.c:1512:
ZstrIOArg arg = {.value = (void *)&out, .allocator = alloc_base};
Zstr next = _read_ZstrAlloc(input, NULL, &arg);
bool ok = (next != NULL) && out && (ZstrCompare(out, input) == 0);- In
Read.c:1532:
// (little -> 0x3412 on this platform).
static bool test_m32_read_r16_big_endian(void) {
Zstr input = "\x12\x34"; // big-endian 0x1234
Zstr start = input;
u16 v = 0;- In
Read.c:1533:
static bool test_m32_read_r16_big_endian(void) {
Zstr input = "\x12\x34"; // big-endian 0x1234
Zstr start = input;
u16 v = 0;
StrReadFmt(input, "{>2r}", v); // advances `input` on success
- In
Read.c:1546:
// code succeeds and yields the host-order interpretation of 0x12,0x34.
static bool test_m32_read_r16_native_resolves(void) {
Zstr input = "\x12\x34";
Zstr start = input;
u16 v = 0;- In
Read.c:1547:
static bool test_m32_read_r16_native_resolves(void) {
Zstr input = "\x12\x34";
Zstr start = input;
u16 v = 0;
u16 expected = IS_LITTLE_ENDIAN() ? (u16)0x3412 : (u16)0x1234;- In
Read.c:1581:
static bool test_m33_read_leading_plus(void) {
i32 v = 0;
Zstr z = "+5";
StrReadFmt(z, "{}", v);
return v == 5;- In
Read.c:1619:
f32 v = 7.5f;
Zstr z = "1f";
StrReadFmt(z, "{}", v);
// Real rejects "1f" -> v stays 7.5. Mutant bypasses the gate.
- In
Read.c:1693:
static bool test_m5_char_flag_reads_ordinal(void) {
f32 v = 0.0f;
Zstr z = "A";
StrReadFmt(z, "{c}", v); // 'A' == 0x41 == 65
return f32_close(v, 65.0f);- In
Read.c:1705:
static bool test_m5_invalid_char_breaks_scan(void) {
f32 v = 0.0f;
Zstr z = "12g3";
StrReadFmt(z, "{}", v);
return f32_close(v, 12.0f);- In
Read.c:1723:
Str s = StrInit(&alloc);
Zstr z = "\\x41BC"; // backslash, x, 4, 1, B, C -> 'A', 'B', 'C'
StrReadFmt(z, "{}", s);- In
Read.c:1744:
Str s = StrInit(&alloc);
Zstr z = "\\x41"; // -> 'A'
StrReadFmt(z, "{}", s);- In
Read.c:1765:
Str s = StrInit(&alloc);
Zstr z = "\\x61"; // -> 'a'
StrReadFmt(z, "{A}", s);- In
Read.c:1789:
Str s = StrInit(&alloc);
// "\x41BC" inside double quotes -> decoded "ABC"
Zstr z = "\"\\x41BC\"";
StrReadFmt(z, "{s}", s);- In
Read.c:1809:
Str s = StrInit(&alloc);
Zstr z = "\"\\x41\""; // quoted -> 'A'
StrReadFmt(z, "{s}", s);- In
Read.c:1829:
Str s = StrInit(&alloc);
Zstr z = "\"\\x61\""; // quoted -> 'a'
StrReadFmt(z, "{As}", s);- In
Read.c:1856:
bool ok = true;
Zstr b = "\x12";
StrAppendFmt(&out, "{c}", b);
ok = ok && (ZstrCompare(StrBegin(&out), "\\x12") == 0);- In
Read.c:1874:
bool ok = true;
Zstr b = "\x90";
StrAppendFmt(&out, "{c}", b);
ok = ok && (ZstrCompare(StrBegin(&out), "\\x90") == 0);- In
Read.c:1895:
bool ok = true;
Zstr b = "\xab";
StrAppendFmt(&out, "{c}", b);
ok = ok && (ZstrCompare(StrBegin(&out), "\\xab") == 0);- In
Read.c:1915:
bool ok = true;
Zstr b = "\xcd";
StrAppendFmt(&out, "{c}", b);
ok = ok && (ZstrCompare(StrBegin(&out), "\\xcd") == 0);- In
Read.c:1935:
bool ok = true;
Zstr b = "\xab";
StrAppendFmt(&out, "{A}", b);
ok = ok && (ZstrCompare(StrBegin(&out), "\\xAB") == 0);- In
Read.c:1953:
bool ok = true;
Zstr b = "\xcd";
StrAppendFmt(&out, "{A}", b);
ok = ok && (ZstrCompare(StrBegin(&out), "\\xCD") == 0);- In
Read.c:1972:
bool ok = true;
Zstr lo_letter = "\x1b";
StrAppendFmt(&out, "{c}", lo_letter);
ok = ok && (ZstrCompare(StrBegin(&out), "\\x1b") == 0);- In
Read.c:1977:
StrClear(&out);
Zstr hi_letter = "\xb1";
StrAppendFmt(&out, "{c}", hi_letter);
ok = ok && (ZstrCompare(StrBegin(&out), "\\xb1") == 0);- In
Read.c:1993:
bool ok = true;
{
Zstr in = "2021-01-01T00:00:00Z";
DateTime d = {0};
StrReadFmt(in, "{}", d);- In
Read.c:2000:
}
{
Zstr in = "2021-01-01T05:30:00+05:30";
DateTime d = {0};
StrReadFmt(in, "{}", d);- In
Read.c:2006:
}
{
Zstr in = "2020-12-31T14:30:00-09:30";
DateTime d = {0};
StrReadFmt(in, "{}", d);- In
Read.c:2013:
}
{
Zstr in = "2021-01-01T00:00:00.123456789Z";
DateTime d = {0};
StrReadFmt(in, "{}", d);- In
Read.c:2025:
static bool test_read_spec_too_long_rejected(void) {
u64 v = 0;
Zstr p = "ff";
Zstr start = p;
StrReadFmt(p, "{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}", v); // exactly 32 'x'
- In
Read.c:2026:
u64 v = 0;
Zstr p = "ff";
Zstr start = p;
StrReadFmt(p, "{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}", v); // exactly 32 'x'
return (p == start) && (v == 0);- In
Read.c:2033:
static bool test_read_spec_len_32_boundary_rejected(void) {
u64 v = 999;
Zstr p = "5";
Zstr start = p;
StrReadFmt(p, "{11111111111111111111111111111111}", v); // valid 32-char width spec
- In
Read.c:2034:
u64 v = 999;
Zstr p = "5";
Zstr start = p;
StrReadFmt(p, "{11111111111111111111111111111111}", v); // valid 32-char width spec
return (p == start) && (v == 999);- In
Read.c:2045:
DefaultAllocator a = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&a));
Zstr p = "\\n\\n#rest";
StrReadFmt(p, "{}#", out);
bool ok = (StrLen(&out) == 2) && (StrBegin(&out)[0] == '\n') && (StrBegin(&out)[1] == '\n');- In
Read.c:2059:
u8 v = 0;
{
Zstr p = "0xff";
StrReadFmt(p, "{}", v);
if (v != 255)- In
Read.c:2066:
// Every bare prefix (no digits) must be rejected -- covers whichever
// prefix-letter comparison the mutant flips.
Zstr bare[] = {"0x", "0X", "0b", "0B", "0o", "0O"};
for (u32 k = 0; k < sizeof(bare) / sizeof(bare[0]); ++k) {
Zstr p = bare[k];- In
Read.c:2068:
Zstr bare[] = {"0x", "0X", "0b", "0B", "0o", "0O"};
for (u32 k = 0; k < sizeof(bare) / sizeof(bare[0]); ++k) {
Zstr p = bare[k];
Zstr start = p;
u8 w = 7;- In
Read.c:2069:
for (u32 k = 0; k < sizeof(bare) / sizeof(bare[0]); ++k) {
Zstr p = bare[k];
Zstr start = p;
u8 w = 7;
StrReadFmt(p, "{}", w);- In
Read.c:2086:
// Quoted string of 50 chars: max_read_len (= rem_in) must allow the full
// read; the `max_read_len = rem_in` survivor would cap it at 42.
Zstr p = "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\""; // 50 'a' quoted
StrReadFmt(p, "{s}", out);
bool ok = (StrLen(&out) == 50);- In
Read.c:2111:
// Read a Float and compare its canonical form. A wrong token boundary leaves
// the pre-read sentinel.
static bool read_float_is(Zstr in, Zstr expect) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);- In
Read.c:2129:
static bool test_read_spec_scan(void) {
i32 v = 0;
Zstr in = "42";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(i32, &v));
return out == in + 2 && v == 42;- In
Read.c:2130:
i32 v = 0;
Zstr in = "42";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(i32, &v));
return out == in + 2 && v == 42;
}- In
Read.c:2138:
i32 v = 7;
// 32 chars inside braces -> spec_len == 32 -> rejected.
Zstr out = READ1("x", "{qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq}", TO_TYPE_SPECIFIC_IO(i32, &v));
return out == NULL && v == 7;
}- In
Read.c:2147:
static bool test_read_invalid_spec_leaves_dest(void) {
i32 v = 77;
Zstr out = READ1("5", "{q}", TO_TYPE_SPECIFIC_IO(i32, &v));
return out == NULL && v == 77;
}- In
Read.c:2158:
static bool test_read_max_read_len_set(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr in = "\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\""; // 50 A's quoted
Str s = StrInit(&alloc);
Zstr out = READ1(in, "{s}", TO_TYPE_SPECIFIC_IO(Str, &s));- In
Read.c:2160:
Zstr in = "\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\""; // 50 A's quoted
Str s = StrInit(&alloc);
Zstr out = READ1(in, "{s}", TO_TYPE_SPECIFIC_IO(Str, &s));
bool ok = (out != NULL) && (StrLen(&s) == 50);
StrDeinit(&s);- In
Read.c:2172:
static bool test_read_raw_u32_le(void) {
u32 v = 0;
Zstr in = "\xEF\xBE\xAD\xDE";
Zstr out = READ1(in, "{<4r}", TO_TYPE_SPECIFIC_IO(u32, &v));
return out == in + 4 && v == 0xDEADBEEFu;- In
Read.c:2173:
u32 v = 0;
Zstr in = "\xEF\xBE\xAD\xDE";
Zstr out = READ1(in, "{<4r}", TO_TYPE_SPECIFIC_IO(u32, &v));
return out == in + 4 && v == 0xDEADBEEFu;
}- In
Read.c:2182:
static bool test_read_raw_then_literal(void) {
u8 v = 0;
Zstr in = "\x05Z";
Zstr out = READ1(in, "{<1r}Z", TO_TYPE_SPECIFIC_IO(u8, &v));
return out == in + 2 && v == 0x05;- In
Read.c:2183:
u8 v = 0;
Zstr in = "\x05Z";
Zstr out = READ1(in, "{<1r}Z", TO_TYPE_SPECIFIC_IO(u8, &v));
return out == in + 2 && v == 0x05;
}- In
Read.c:2194:
static bool test_read_field_bounded_by_literal(void) {
i32 v = 0;
Zstr in = "12-end";
Zstr out = READ1(in, "{}-end", TO_TYPE_SPECIFIC_IO(i32, &v));
return out == in + 6 && v == 12;- In
Read.c:2195:
i32 v = 0;
Zstr in = "12-end";
Zstr out = READ1(in, "{}-end", TO_TYPE_SPECIFIC_IO(i32, &v));
return out == in + 6 && v == 12;
}- In
Read.c:2206:
static bool test_read_field_literal_with_escape(void) {
i32 v = 0;
Zstr in = "5!{y";
Zstr out = READ1(in, "{}!{{y", TO_TYPE_SPECIFIC_IO(i32, &v));
return out == in + 4 && v == 5;- In
Read.c:2207:
i32 v = 0;
Zstr in = "5!{y";
Zstr out = READ1(in, "{}!{{y", TO_TYPE_SPECIFIC_IO(i32, &v));
return out == in + 4 && v == 5;
}- In
Read.c:2277:
static bool test_vns_inf_len3(void) {
f64 v = SENTINEL;
Zstr z = "inf";
StrReadFmt(z, "{}", v);
return F64IsInf(v) && v > 0;- In
Read.c:2286:
static bool test_vns_inf_nan_cases(void) {
f64 a = SENTINEL, b = SENTINEL, c = SENTINEL;
Zstr za = "INF", zb = "nan", zc = "NaN";
StrReadFmt(za, "{}", a);
StrReadFmt(zb, "{}", b);- In
Read.c:2296:
static bool test_vns_neg_inf_len4(void) {
f64 a = SENTINEL, b = SENTINEL;
Zstr za = "-inf", zb = "-INF";
StrReadFmt(za, "{}", a);
StrReadFmt(zb, "{}", b);- In
Read.c:2306:
static bool test_vns_len4_not_neginf(void) {
f64 v = SENTINEL;
Zstr z = "1234";
StrReadFmt(z, "{}", v);
return f64_is(v, 1234.0);- In
Read.c:2319:
static bool test_vns_hex_slice_accepted(void) {
f64 v = SENTINEL;
Zstr z = "0x1f";
StrReadFmt(z, "{}", v);
// accepted -> StrToF64("0x1f") parses leading 0 -> 0.0.
- In
Read.c:2327:
static bool test_vns_bin_slice_accepted(void) {
f64 v = SENTINEL;
Zstr z = "0b11";
StrReadFmt(z, "{}", v);
return f64_is(v, 0.0);- In
Read.c:2334:
static bool test_vns_oct_slice_accepted(void) {
f64 v = SENTINEL;
Zstr z = "0o7";
StrReadFmt(z, "{}", v);
return f64_is(v, 0.0);- In
Read.c:2344:
static bool test_vns_bin_digits(void) {
f64 v = SENTINEL;
Zstr z = "0b101";
StrReadFmt(z, "{}", v);
return f64_is(v, 0.0);- In
Read.c:2351:
static bool test_vns_oct_digits(void) {
f64 v = SENTINEL;
Zstr z = "0o17";
StrReadFmt(z, "{}", v);
return f64_is(v, 0.0);- In
Read.c:2360:
static bool test_vns_oct_boundary_digits(void) {
f64 v = SENTINEL;
Zstr z = "0o70";
StrReadFmt(z, "{}", v);
return f64_is(v, 0.0);- In
Read.c:2371:
static bool test_vns_exp_sign(void) {
f64 v = SENTINEL;
Zstr z = "1e+5";
StrReadFmt(z, "{}", v);
return f64_is(v, 100000.0);- In
Read.c:2381:
static bool test_vns_double_decimal_rejected(void) {
f64 v = SENTINEL;
Zstr z = "1.2.3";
StrReadFmt(z, "{}", v);
// The f64 scanner stops the token at the 2nd '.', so the slice is "1.2" and
- In
Read.c:2395:
static bool test_vns_trailing_exp(void) {
f64 v = SENTINEL;
Zstr z = "12e";
StrReadFmt(z, "{}", v);
return f64_is(v, 12.0);- In
Read.c:2404:
static bool test_read_f64_char(void) {
f64 v = 0;
Zstr in = "ABCDEFGH";
Zstr out = READ1(in, "{c}", TO_TYPE_SPECIFIC_IO(f64, &v));
union {- In
Read.c:2405:
f64 v = 0;
Zstr in = "ABCDEFGH";
Zstr out = READ1(in, "{c}", TO_TYPE_SPECIFIC_IO(f64, &v));
union {
f64 f;- In
Read.c:2425:
static bool test_read_f64_exponent(void) {
f64 v = 0;
Zstr in = "1e5";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(f64, &v));
return out == in + 3 && f64_is(v, 100000.0);- In
Read.c:2426:
f64 v = 0;
Zstr in = "1e5";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(f64, &v));
return out == in + 3 && f64_is(v, 100000.0);
}- In
Read.c:2433:
static bool test_read_f64_neg_inf(void) {
f64 v = 0;
Zstr in = "-inf";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(f64, &v));
return out == in + 4 && F64IsInf(v) && v < 0;- In
Read.c:2434:
f64 v = 0;
Zstr in = "-inf";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(f64, &v));
return out == in + 4 && F64IsInf(v) && v < 0;
}- In
Read.c:2443:
static bool test_read_f64_double_dot(void) {
f64 v = 0;
Zstr in = "1.5.6";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(f64, &v));
return out == in + 3 && f64_is(v, 1.5) && (*out == '.');- In
Read.c:2444:
f64 v = 0;
Zstr in = "1.5.6";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(f64, &v));
return out == in + 3 && f64_is(v, 1.5) && (*out == '.');
}- In
Read.c:2451:
static bool test_read_u8(void) {
u8 v = 0;
Zstr in = "200";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(u8, &v));
return out == in + 3 && v == 200;- In
Read.c:2452:
u8 v = 0;
Zstr in = "200";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(u8, &v));
return out == in + 3 && v == 200;
}- In
Read.c:2461:
static bool test_blind_read_u8_hex(void) {
u8 v = 0;
Zstr in = "0xff";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(u8, &v));
return out == in + 4 && v == 255;- In
Read.c:2462:
u8 v = 0;
Zstr in = "0xff";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(u8, &v));
return out == in + 4 && v == 255;
}- In
Read.c:2472:
static bool test_read_u8_invalid_rejected(void) {
u8 v = 7;
Zstr in = "1f";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(u8, &v));
// _read_u8 returns `start` (no advance) -> str_read_fmt sees next==in ->
- In
Read.c:2473:
u8 v = 7;
Zstr in = "1f";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(u8, &v));
// _read_u8 returns `start` (no advance) -> str_read_fmt sees next==in ->
// returns NULL; v untouched.
- In
Read.c:2483:
static bool test_read_u8_bare_prefix(void) {
u8 v = 7;
Zstr in = "0x";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(u8, &v));
return out == NULL && v == 7;- In
Read.c:2484:
u8 v = 7;
Zstr in = "0x";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(u8, &v));
return out == NULL && v == 7;
}- In
Read.c:2496:
DebugAllocator dbg = DebugAllocatorInit();
char *s = NULL;
Zstr in = "hello world";
Zstr out = str_read_fmt(in, "{}", (TypeSpecificIO[]) {ZstrIO(s, &dbg.base)}, 1);
// Unquoted, non-{s} read takes the whole input (whitespace only ends an
- In
Read.c:2497:
char *s = NULL;
Zstr in = "hello world";
Zstr out = str_read_fmt(in, "{}", (TypeSpecificIO[]) {ZstrIO(s, &dbg.base)}, 1);
// Unquoted, non-{s} read takes the whole input (whitespace only ends an
// is_string field), so s is the full "hello world".
- In
Read.c:2514:
DebugAllocator dbg = DebugAllocatorInit();
BitVec bv = BitVecInit(&dbg.base);
Zstr z = "0x1";
StrReadFmt(z, "{}", bv);
bool ok = (BitVecToInteger(&bv) == 1) && (BitVecLen(&bv) == 4); // min-width clamp
- In
Read.c:2527:
DefaultAllocator alloc = DefaultAllocatorInit();
BitVec bv = BitVecInit(&alloc.base);
Zstr z = "0xDEAD";
StrReadFmt(z, "{}", bv);
bool ok = (BitVecToInteger(&bv) == 0xDEAD) && (BitVecLen(&bv) == 16);- In
Read.c:2539:
DebugAllocator dbg = DebugAllocatorInit();
BitVec bv = BitVecInit(&dbg.base);
Zstr z = "0o1";
StrReadFmt(z, "{}", bv);
bool ok = (BitVecToInteger(&bv) == 1) && (BitVecLen(&bv) == 3);- In
Read.c:2552:
DebugAllocator dbg = DebugAllocatorInit();
BitVec bv = BitVecInit(&dbg.base);
Zstr z = "10110";
StrReadFmt(z, "{}", bv);
bool ok = (BitVecLen(&bv) == 5) && (BitVecToInteger(&bv) == 13);- In
Read.c:2566:
DebugAllocator dbg = DebugAllocatorInit();
Int v = IntInit(&dbg.base);
Zstr z = "12345";
StrReadFmt(z, "{}", v);
Str t = IntToStr(&v);- In
Read.c:2581:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(&alloc.base);
Zstr z = "+99";
StrReadFmt(z, "{}", v);
Str t = IntToStr(&v);- In
Read.c:2597:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntInit(&alloc.base);
Zstr z = "ff";
StrReadFmt(z, "{x}", v);
Str t = IntToStr(&v);- In
Read.c:2613:
DefaultAllocator alloc = DefaultAllocatorInit();
Int v = IntFrom(777, &alloc.base);
Zstr z = "12_3";
Zstr out = str_read_fmt(z, "{}", (TypeSpecificIO[]) {TO_TYPE_SPECIFIC_IO(Int, &v)}, 1);
// Real: '_' rejected -> returns start (==z) -> str_read_fmt sees next==in ->
- In
Read.c:2614:
Int v = IntFrom(777, &alloc.base);
Zstr z = "12_3";
Zstr out = str_read_fmt(z, "{}", (TypeSpecificIO[]) {TO_TYPE_SPECIFIC_IO(Int, &v)}, 1);
// Real: '_' rejected -> returns start (==z) -> str_read_fmt sees next==in ->
// NULL; v unchanged (still 777).
- In
Read.c:2633:
DebugAllocator dbg = DebugAllocatorInit();
Float f = FloatInit(&dbg.base);
Zstr z = "3.14159";
StrReadFmt(z, "{}", f);
Str t = FloatToStr(&f);- In
Read.c:2650:
Float f = FloatInit(&dbg.base);
(void)FloatTryFromStr(&f, "42");
Zstr z = "xyz"; // no float token
Zstr out = str_read_fmt(z, "{}", (TypeSpecificIO[]) {TO_TYPE_SPECIFIC_IO(Float, &f)}, 1);
Str t = FloatToStr(&f);- In
Read.c:2651:
(void)FloatTryFromStr(&f, "42");
Zstr z = "xyz"; // no float token
Zstr out = str_read_fmt(z, "{}", (TypeSpecificIO[]) {TO_TYPE_SPECIFIC_IO(Float, &f)}, 1);
Str t = FloatToStr(&f);
bool ok = (out == NULL) && (ZstrCompare(StrBegin(&t), "42") == 0);- In
Read.c:2664:
static bool test_read_f32_decimal(void) {
f32 v = 0;
Zstr in = "2.5";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(f32, &v));
return out == in + 3 && F64Abs((f64)v - 2.5) < 1e-4;- In
Read.c:2665:
f32 v = 0;
Zstr in = "2.5";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(f32, &v));
return out == in + 3 && F64Abs((f64)v - 2.5) < 1e-4;
}- In
Read.c:2672:
static bool test_read_f32_neg_inf(void) {
f32 v = 0;
Zstr in = "-inf";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(f32, &v));
return out == in + 4 && F64IsInf((f64)v) && v < 0;- In
Read.c:2673:
f32 v = 0;
Zstr in = "-inf";
Zstr out = READ1(in, "{}", TO_TYPE_SPECIFIC_IO(f32, &v));
return out == in + 4 && F64IsInf((f64)v) && v < 0;
}- In
Read.c:2729:
// 2408 / 2421 / 2466: quoted-string read whose budget saturates before the
// closing quote -> unterminated-quote branch frees the destination Str.
static bool leak_quoted_unterminated(Zstr input, Zstr fmt) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str s = StrInit(ALLOCATOR_OF(&dbg));- In
Read.c:2732:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str s = StrInit(ALLOCATOR_OF(&dbg));
Zstr p = input;
StrReadFmt(p, fmt, s); // reader frees s on the unterminated/error branch
bool ok = (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);- In
Read.c:2741:
// 3232 / 3273: BitVec hex/oct read overflow error path frees the internal
// scratch (allocated through the destination BitVec's allocator).
static bool leak_bitvec_overflow(Zstr input) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
BitVec bv = BitVecInit(ALLOCATOR_OF(&dbg));- In
Read.c:2744:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
BitVec bv = BitVecInit(ALLOCATOR_OF(&dbg));
Zstr p = input;
StrReadFmt(p, "{}", bv);
BitVecDeinit(&bv);- In
Read.c:2772:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str s = StrInit(ALLOCATOR_OF(&dbg));
Zstr p = "aaaaaaaaaaaaaaaaaaaaaaaa\\q"; // 24 'a' + invalid \q
StrReadFmt(p, "{}", s);
bool ok = (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);- In
Read.c:2792:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Float fv = FloatInit(ALLOCATOR_OF(&dbg));
Zstr p = "1e99999999999999999999999999999999999999999999999999";
StrReadFmt(p, "{}", fv);
FloatDeinit(&fv);- In
Read.c:2823:
Int value = IntFromStr("123456789012345678901234567890", adbg);
Zstr input = "42";
Zstr start = input;
StrReadFmt(input, "{}", value);- In
Read.c:2824:
Zstr input = "42";
Zstr start = input;
StrReadFmt(input, "{}", value);
bool ok = (input != start); // pointer advanced => read succeeded
- In
Read.c:2850:
Float value = FloatFromStr("987654321098765432109876543210.5", adbg);
Zstr input = "2.5";
Zstr start = input;
StrReadFmt(input, "{}", value);- In
Read.c:2851:
Zstr input = "2.5";
Zstr start = input;
StrReadFmt(input, "{}", value);
bool ok = (input != start); // pointer advanced => read succeeded
- In
Ops.c:2:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Ops.c:71:
// Test StrFind (Str * key) with match at end
Zstr found1 = StrFind(&haystack, &needle1);
bool result = (found1 != NULL && ZstrCompare(found1, "World") == 0);- In
Ops.c:75:
// Test StrFind (Str * key) with match at beginning
Zstr found2 = StrFind(&haystack, &needle2);
result = result && (found2 != NULL && ZstrCompare(found2, "Hello World") == 0);- In
Ops.c:79:
// Test StrFind (Str * key) with no match
Zstr found3 = StrFind(&haystack, &needle3);
result = result && (found3 == NULL);- In
Ops.c:83:
// Test StrFind (Zstr key)
Zstr found4 = StrFind(&haystack, "World");
result = result && (found4 != NULL && ZstrCompare(found4, "World") == 0);- In
Ops.c:87:
// Test StrFind (Cstr key, key_len)
Zstr found5 = StrFind(&haystack, "Wor", 3);
result = result && (found5 != NULL && ZstrCompareN(found5, "World", 3) == 0);- In
Ops.c:466:
// key reports contained. An absent key via the Cstr/Zstr path must be false.
static bool test_contains_cstr_absent_key_false(void) {
WriteFmt("Testing StrContains(Zstr) absent key is false\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Ops.c:553:
// it 42.
static bool test_cmp_zstr_equal(void) {
WriteFmt("Testing StrCmp (Zstr form) reports equality\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Ops.c:560:
bool result = (StrCmp(&hello, "Hello") == 0);
if (!result) {
WriteFmt(" FAIL: Expected StrCmp(==0) for equal Zstr\n");
}- In
Ops.c:827:
WriteFmt("Testing StrEndsWith(zstr) validates a NULL s (should abort)\n");
(void)StrEndsWith((const Str *)NULL, "x"); // Zstr suffix -> str_ends_with_zstr
return false; // unreachable on real code
- In
Ops.c:959:
// (Str.Mutants7).
static bool test_cmp_zstr_validates(void) {
WriteFmt("Testing StrCmp (Zstr form) validates its Str (deadend)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Memory.c:2:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Init.c:2:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Allocator/Debug.h>- In
Init.c:49:
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr test_str = "Hello, World!";
size len = 5; // Just "Hello"
Str s = StrInitFromCstr(test_str, len, &alloc);- In
Init.c:70:
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr test_str = "Hello, World!";
Str s = StrInitFromZstr(test_str, &alloc);- In
Init.c:90:
DefaultAllocator alloc = DefaultAllocatorInit();
Zstr test_str = "Alias Test";
Str s = StrZ(test_str, &alloc);- In
Insert.c:2:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Insert.c:79:
// Test StrInsertMany 3-arg Zstr form
bool test_str_insert_zstr(void) {
WriteFmt("Testing StrInsertMany (Zstr form)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Insert.c:86:
// Insert a string in the middle
Zstr w = " World";
StrInsertMany(&s, w, 2);- In
Insert.c:345:
// Append formatted suffix.
StrAppendFmt(&s, " {} {}", (Zstr) "World", (u32)2023);
// Check that the string was appended correctly
- In
Type.c:2:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Remove.c:2:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Convert.c:2:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Allocator/Budget.h>- In
Convert.c:555:
// Test prefix handling
struct {
Zstr input;
u64 expected;
u8 base;- In
Convert.c:598:
// String should have expected decimal places
Zstr dot_pos = ZstrFindChar(StrBegin(&s), '.');
if (dot_pos) {
size decimal_places = ZstrLen(dot_pos + 1);- In
Foreach.c:2:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Ops.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>- In
Ops.c:32:
static bool test_map_deep_copy_zstrs(void) {
typedef Map(Zstr, Zstr) ZstrMap;
DefaultAllocator alloc = DefaultAllocatorInit();
ZstrMap map = MapInitWithDeepCopy(- In
Ops.c:49:
const char *value = value_buf;
const char *second_value = second_value_buf;
Zstr *stored_value;
int value_count = 0;- In
Ops.c:78:
static bool test_map_policy_switch_preserves_entries(void) {
typedef Map(Zstr, Zstr) ZstrMap;
DefaultAllocator alloc = DefaultAllocatorInit();
ZstrMap map = MapInitWithDeepCopy(- In
Init.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>- In
Init.c:220:
static bool test_map_init_deep_copy_typed(void) {
typedef Map(Zstr, Zstr) ZstrMap;
DefaultAllocator alloc = DefaultAllocatorInit();
ZstrMap map = MapInitWithDeepCopyT(- In
Type.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>- In
Type.c:160:
static bool test_map_type_deep_copy_wiring(void) {
typedef Map(Zstr, Zstr) ZstrMap;
DefaultAllocator alloc = DefaultAllocatorInit();
ZstrMap map = MapInitWithDeepCopy(- In
Remove.c:5:
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Zstr.h>
#include "../../Util/TestRunner.h"- In
Remove.c:325:
// callbacks, the clones would leak and the live count would be non-zero.
static bool test_map_deep_copy_deinit_on_remove(void) {
typedef Map(Zstr, Zstr) ZstrMap;
DebugAllocator dbg = DebugAllocatorInit();
// Deep-copy callbacks for both key and value, plus a value comparator
- In
TestRunner.c:367:
TestFunction *deadend_tests,
int deadend_count,
Zstr test_name
) {
WriteFmt("[INFO] Starting {} tests\n\n", test_name ? test_name : "Test Suite");- In
TestRunner.h:11:
#define TEST_RUNNER_H
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
TestRunner.h:85:
TestFunction *deadend_tests,
int deadend_count,
Zstr test_name
);- In
PdbCache.c:14:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Memory.h>
#include <Misra/Sys.h>- In
PdbCache.c:26:
// borrowed (env-var lifetime) or a static literal -- caller must not
// free.
static Zstr tmp_dir_path(void) {
#if PLATFORM_WINDOWS
Zstr p = EnvGet("TEMP");- In
PdbCache.c:28:
static Zstr tmp_dir_path(void) {
#if PLATFORM_WINDOWS
Zstr p = EnvGet("TEMP");
if (p && *p)
return p;- In
PdbCache.c:36:
return "C:/Windows/Temp";
#else
Zstr p = EnvGet("TMPDIR");
if (p && *p)
return p;- In
PdbCache.c:45:
// Compose `<tmp_dir>/<name>` into `out`. Forward slash works on both
// POSIX and Win32 (CRT + kernel APIs accept either separator).
static void tmp_path_join(char *out, size out_size, Zstr name) {
Zstr base = tmp_dir_path();
size baselen = 0;- In
PdbCache.c:46:
// POSIX and Win32 (CRT + kernel APIs accept either separator).
static void tmp_path_join(char *out, size out_size, Zstr name) {
Zstr base = tmp_dir_path();
size baselen = 0;
while (base[baselen])- In
PdbCache.c:86:
static const u32 kAge = 7;
static bool write_file(Zstr path, const u8 *data, u64 size) {
// Use Misra's File API so this test runs under -nostdlib too
// (no libc fopen/fwrite/fclose).
- In
PdbCache.c:117:
static u8 pe_blob[PE_BLOB_SIZE];
static void build_pe_blob(Zstr pdb_path) {
MemSet(pe_blob, 0, sizeof(pe_blob));- In
PdbCache.c:200:
// corrupted so the (GUID, age) pairing check in the cache rejects the PDB
// even though PdbOpen itself still succeeds.
static void build_pdb_blob_va(Zstr func_name, u32 sec_va, u32 func_rva, bool match_guid) {
MemSet(pdb_blob, 0, sizeof(pdb_blob));- In
PdbCache.c:274:
// Standard PDB: one function in a `.text` section based at RVA 0x1000,
// GUID/age matching the PE built by `build_pe_blob`.
static void build_pdb_blob(Zstr func_name, u32 func_rva) {
build_pdb_blob_va(func_name, 0x1000, func_rva, true);
}- In
PdbCache.c:281:
// `cv_path`: pass the on-disk `pdb_path` for the exact-path case, or a bogus
// path whose basename equals the sidecar to exercise the basename fallback.
static bool write_pe_pdb(Zstr pe_path, Zstr pdb_path, Zstr cv_path) {
build_pe_blob(cv_path);
build_pdb_blob("winproc", 0x1100);- In
PdbCache.c:318:
const u64 module_base = 0x140000000ull;
const u64 ip = module_base + 0x1100;
Zstr name = NULL;
u32 offset = 0;
bool ok = PdbCacheResolve(&cache, (Zstr)pe_path, module_base, ip, &name, &offset);- In
PdbCache.c:320:
Zstr name = NULL;
u32 offset = 0;
bool ok = PdbCacheResolve(&cache, (Zstr)pe_path, module_base, ip, &name, &offset);
ok = ok && name && ZstrCompare(name, "winproc") == 0 && offset == 0;- In
PdbCache.c:328:
name = NULL;
offset = 0;
ok = ok && PdbCacheResolve(&cache, (Zstr)pe_path, module_base, ip2, &name, &offset);
ok = ok && name && ZstrCompare(name, "winproc") == 0 && offset == 0x10;- In
PdbCache.c:334:
DefaultAllocatorDeinit(&alloc);
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
return ok;- In
PdbCache.c:335:
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
return ok;
}- In
PdbCache.c:347:
PdbCache cache = PdbCacheInit(base);
Zstr name = NULL;
bool ok = !PdbCacheResolve(&cache, (Zstr)missing, 0, 0x1000, &name, NULL);
PdbCacheDeinit(&cache);- In
PdbCache.c:348:
PdbCache cache = PdbCacheInit(base);
Zstr name = NULL;
bool ok = !PdbCacheResolve(&cache, (Zstr)missing, 0, 0x1000, &name, NULL);
PdbCacheDeinit(&cache);
DefaultAllocatorDeinit(&alloc);- In
PdbCache.c:367:
// Bare names (no separator), resolved relative to cwd.
Zstr pe_name = "misra_pdbcache_fb.exe";
Zstr pdb_name = "misra_pdbcache_fb.pdb";- In
PdbCache.c:368:
// Bare names (no separator), resolved relative to cwd.
Zstr pe_name = "misra_pdbcache_fb.exe";
Zstr pdb_name = "misra_pdbcache_fb.pdb";
// CodeView points at a path that does NOT exist; its basename matches the
- In
PdbCache.c:378:
PdbCache cache = PdbCacheInit(base);
const u64 mbase = 0x140000000ull;
Zstr name = NULL;
u32 off = 0;
ok = PdbCacheResolve(&cache, pe_name, mbase, mbase + 0x1100, &name, &off);- In
PdbCache.c:412:
if (wrote) {
PdbCache cache = PdbCacheInit(base);
Zstr name = NULL;
// PE opens, PDB lookup fails -> resolve returns false.
ok = !PdbCacheResolve(&cache, (Zstr)pe_path, 0x140000000ull, 0x140001100ull, &name, NULL);- In
PdbCache.c:414:
Zstr name = NULL;
// PE opens, PDB lookup fails -> resolve returns false.
ok = !PdbCacheResolve(&cache, (Zstr)pe_path, 0x140000000ull, 0x140001100ull, &name, NULL);
PdbCacheDeinit(&cache);
// Teardown returns every allocation (the failed-lookup candidate too).
- In
PdbCache.c:420:
}
FileRemove((Zstr)pe_path);
DebugAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:450:
if (wrote) {
PdbCache cache = PdbCacheInit(base);
Zstr name = NULL;
// PDB opens but GUID/age disagree -> resolve rejects it.
ok = !PdbCacheResolve(&cache, (Zstr)pe_path, 0x140000000ull, 0x140001100ull, &name, NULL);- In
PdbCache.c:452:
Zstr name = NULL;
// PDB opens but GUID/age disagree -> resolve rejects it.
ok = !PdbCacheResolve(&cache, (Zstr)pe_path, 0x140000000ull, 0x140001100ull, &name, NULL);
PdbCacheDeinit(&cache);
// The briefly-opened, then-rejected PDB must be freed.
- In
PdbCache.c:458:
}
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DebugAllocatorDeinit(&alloc);- In
PdbCache.c:459:
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DebugAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:488:
PdbCache cache = PdbCacheInit(base);
const u64 mbase = 0x140000000ull;
Zstr name = NULL;
u32 off = 0;- In
PdbCache.c:491:
u32 off = 0;
bool ra = PdbCacheResolve(&cache, (Zstr)a_pe, mbase, mbase + 0x1100, &name, &off);
bool rb = PdbCacheResolve(&cache, (Zstr)b_pe, mbase, mbase + 0x1100, &name, &off);- In
PdbCache.c:492:
bool ra = PdbCacheResolve(&cache, (Zstr)a_pe, mbase, mbase + 0x1100, &name, &off);
bool rb = PdbCacheResolve(&cache, (Zstr)b_pe, mbase, mbase + 0x1100, &name, &off);
// Both modules now open and cached; snapshot the live allocations.
- In
PdbCache.c:498:
// Re-resolve B at a different IP: must hit B's existing slot.
Zstr name2 = NULL;
bool rb2 = PdbCacheResolve(&cache, (Zstr)b_pe, mbase, mbase + 0x1108, &name2, &off);
size after = DebugAllocatorLiveCount(&alloc);- In
PdbCache.c:499:
// Re-resolve B at a different IP: must hit B's existing slot.
Zstr name2 = NULL;
bool rb2 = PdbCacheResolve(&cache, (Zstr)b_pe, mbase, mbase + 0x1108, &name2, &off);
size after = DebugAllocatorLiveCount(&alloc);- In
PdbCache.c:507:
}
FileRemove((Zstr)a_pe);
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);- In
PdbCache.c:508:
FileRemove((Zstr)a_pe);
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);
FileRemove((Zstr)b_pdb);- In
PdbCache.c:509:
FileRemove((Zstr)a_pe);
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);
FileRemove((Zstr)b_pdb);
DebugAllocatorDeinit(&alloc);- In
PdbCache.c:510:
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);
FileRemove((Zstr)b_pdb);
DebugAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:537:
PdbCache cache = PdbCacheInit(base);
const u64 mbase = 0x140000000ull;
Zstr name = NULL;
u32 off = 0;
bool r = PdbCacheResolve(&cache, (Zstr)pe_path, mbase, mbase + 0x1100, &name, &off);- In
PdbCache.c:539:
Zstr name = NULL;
u32 off = 0;
bool r = PdbCacheResolve(&cache, (Zstr)pe_path, mbase, mbase + 0x1100, &name, &off);
// A populated cache with an opened PE+PDB sits strictly above baseline.
- In
PdbCache.c:549:
}
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DebugAllocatorDeinit(&alloc);- In
PdbCache.c:550:
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DebugAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:583:
PdbCache cache = PdbCacheInit(base);
const u64 mbase = 0x140000000ull;
Zstr name = NULL;
u32 off = 0;
// ip exactly at module_base -> RVA 0 -> resolves under real `<`.
- In
PdbCache.c:586:
u32 off = 0;
// ip exactly at module_base -> RVA 0 -> resolves under real `<`.
ok = PdbCacheResolve(&cache, (Zstr)pe_path, mbase, mbase, &name, &off);
ok = ok && name && ZstrCompare(name, "winzero") == 0 && off == 0;
PdbCacheDeinit(&cache);- In
PdbCache.c:591:
}
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DefaultAllocatorDeinit(&alloc);- In
PdbCache.c:592:
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DefaultAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:617:
PdbCache cache = PdbCacheInit(base);
const u64 mbase = 0x140000000ull;
Zstr name = NULL;
u32 off = 0;
ok = PdbCacheResolve(&cache, (Zstr)pe_path, mbase, mbase + 0xFFFFFFFFull, &name, &off);- In
PdbCache.c:619:
Zstr name = NULL;
u32 off = 0;
ok = PdbCacheResolve(&cache, (Zstr)pe_path, mbase, mbase + 0xFFFFFFFFull, &name, &off);
ok = ok && name && ZstrCompare(name, "winmax") == 0 && off == 0;
PdbCacheDeinit(&cache);- In
PdbCache.c:624:
}
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DefaultAllocatorDeinit(&alloc);- In
PdbCache.c:625:
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DefaultAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:651:
const u64 mbase = 0x140000000ull;
StrInitStack(mod, 1100) {
StrPushBackMany(&mod, (Zstr)pe_path);
Zstr name = NULL;
u32 off = 0;- In
PdbCache.c:652:
StrInitStack(mod, 1100) {
StrPushBackMany(&mod, (Zstr)pe_path);
Zstr name = NULL;
u32 off = 0;
// ip strictly below module_base -> delegated resolve returns false.
- In
PdbCache.c:660:
}
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DefaultAllocatorDeinit(&alloc);- In
PdbCache.c:661:
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DefaultAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:689:
PdbCache cache = PdbCacheInit(base);
const u64 mbase = 0x140000000ull;
Zstr name = NULL;
u32 off = 0;
ok = PdbCacheResolve(&cache, (Zstr)pe_path, mbase, mbase + 0x1100, &name, &off);- In
PdbCache.c:691:
Zstr name = NULL;
u32 off = 0;
ok = PdbCacheResolve(&cache, (Zstr)pe_path, mbase, mbase + 0x1100, &name, &off);
ok = ok && name && ZstrCompare(name, "winproc") == 0 && off == 0;
PdbCacheDeinit(&cache);- In
PdbCache.c:696:
}
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DefaultAllocatorDeinit(&alloc);- In
PdbCache.c:697:
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DefaultAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:726:
if (wrote) {
PdbCache cache = PdbCacheInit(a);
Zstr name = NULL;
ok = !PdbCacheResolve(&cache, (Zstr)pe_path, 0x140000000ull, 0x140001100ull, &name, NULL);
PdbCacheDeinit(&cache);- In
PdbCache.c:727:
PdbCache cache = PdbCacheInit(a);
Zstr name = NULL;
ok = !PdbCacheResolve(&cache, (Zstr)pe_path, 0x140000000ull, 0x140001100ull, &name, NULL);
PdbCacheDeinit(&cache);
ok = ok && DebugAllocatorLiveCount(&alloc) == baseline;- In
PdbCache.c:732:
}
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DebugAllocatorDeinit(&alloc);- In
PdbCache.c:733:
FileRemove((Zstr)pe_path);
FileRemove((Zstr)pdb_path);
DebugAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:763:
PdbCache cache = PdbCacheInit(base);
const u64 mbase = 0x140000000ull;
Zstr na = NULL;
Zstr nb = NULL;
u32 off = 0;- In
PdbCache.c:764:
const u64 mbase = 0x140000000ull;
Zstr na = NULL;
Zstr nb = NULL;
u32 off = 0;
bool ra = PdbCacheResolve(&cache, (Zstr)a_pe, mbase, mbase + 0x1100, &na, &off);- In
PdbCache.c:766:
Zstr nb = NULL;
u32 off = 0;
bool ra = PdbCacheResolve(&cache, (Zstr)a_pe, mbase, mbase + 0x1100, &na, &off);
bool rb = PdbCacheResolve(&cache, (Zstr)b_pe, mbase, mbase + 0x1100, &nb, &off);
ok = ra && rb && na && nb && ZstrCompare(na, "aproc") == 0 && ZstrCompare(nb, "bproc") == 0;- In
PdbCache.c:767:
u32 off = 0;
bool ra = PdbCacheResolve(&cache, (Zstr)a_pe, mbase, mbase + 0x1100, &na, &off);
bool rb = PdbCacheResolve(&cache, (Zstr)b_pe, mbase, mbase + 0x1100, &nb, &off);
ok = ra && rb && na && nb && ZstrCompare(na, "aproc") == 0 && ZstrCompare(nb, "bproc") == 0;
PdbCacheDeinit(&cache);- In
PdbCache.c:772:
}
FileRemove((Zstr)a_pe);
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);- In
PdbCache.c:773:
FileRemove((Zstr)a_pe);
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);
FileRemove((Zstr)b_pdb);- In
PdbCache.c:774:
FileRemove((Zstr)a_pe);
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);
FileRemove((Zstr)b_pdb);
DefaultAllocatorDeinit(&alloc);- In
PdbCache.c:775:
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);
FileRemove((Zstr)b_pdb);
DefaultAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:805:
PdbCache cache = PdbCacheInit(base);
const u64 mbase = 0x140000000ull;
Zstr name = NULL;
u32 off = 0;- In
PdbCache.c:809:
// Two distinct modules -> two cache entries, each opening a PE+PDB.
bool ra = PdbCacheResolve(&cache, (Zstr)a_pe, mbase, mbase + 0x1100, &name, &off);
bool rb = PdbCacheResolve(&cache, (Zstr)b_pe, mbase, mbase + 0x1100, &name, &off);- In
PdbCache.c:810:
// Two distinct modules -> two cache entries, each opening a PE+PDB.
bool ra = PdbCacheResolve(&cache, (Zstr)a_pe, mbase, mbase + 0x1100, &name, &off);
bool rb = PdbCacheResolve(&cache, (Zstr)b_pe, mbase, mbase + 0x1100, &name, &off);
// A populated two-entry cache sits strictly above baseline.
- In
PdbCache.c:820:
}
FileRemove((Zstr)a_pe);
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);- In
PdbCache.c:821:
FileRemove((Zstr)a_pe);
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);
FileRemove((Zstr)b_pdb);- In
PdbCache.c:822:
FileRemove((Zstr)a_pe);
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);
FileRemove((Zstr)b_pdb);
DebugAllocatorDeinit(&alloc);- In
PdbCache.c:823:
FileRemove((Zstr)a_pdb);
FileRemove((Zstr)b_pe);
FileRemove((Zstr)b_pdb);
DebugAllocatorDeinit(&alloc);
return ok;- In
PdbCache.c:840:
PdbCache cache = PdbCacheInit(&bp);
Zstr name = NULL;
if (PdbCacheResolve(&cache, (char *)"/x", 0, 0x1000, &name, NULL))
return false; // the entry must have failed to allocate
- In
Backtrace.c:3:
#include <Misra.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys/Backtrace.h>
#if FEATURE_SYS_SYMRESOLVE- In
SysDns.c:20:
#include <Misra/Std/File.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys/Dir.h>
#include <Misra/Sys/Dns.h>- In
SysDns.c:42:
}
static void hosts_push_v4(DnsResolver *r, Zstr name, u8 b0, u8 b1, u8 b2, u8 b3) {
HostsEntry e = {0};
e.name = StrInitFromCstr(name, ZstrLen(name), r->allocator);- In
SysDns.c:53:
}
static void hosts_push_v6(DnsResolver *r, Zstr name, const u8 ip16[16]) {
HostsEntry e = {0};
e.name = StrInitFromCstr(name, ZstrLen(name), r->allocator);- In
SysDns.c:76:
}
static bool v4_is(const SocketAddr *ad, Allocator *a, Zstr expect) {
if (ad->family != SOCKET_FAMILY_INET) {
return false;- In
SysDns.c:86:
}
static bool v6_is(const SocketAddr *ad, Allocator *a, Zstr expect) {
if (ad->family != SOCKET_FAMILY_INET6) {
return false;- In
SysDns.c:98:
// Write `body` to a fresh temp file in the cwd; returns its path (caller
// FileRemove + StrDeinit). The on-disk file holds exactly `body`.
static Str write_temp(Allocator *a, Zstr body) {
Str path = StrInit(a);
File f = file_open_temp(&path, a);- In
SysDns.c:116:
}
static const HostsEntry *find_host(HostsTable *t, Zstr name) {
VecForeachPtr(t, e) {
if (StrLen(&e->name) > 0 && ZstrCompare(StrBegin(&e->name), name) == 0) {- In
SysDns.c:130:
// Compare nameserver `i` formatted as "ip:port" against `expect`.
static bool ns_fmt_is(DnsResolver *r, u64 i, Allocator *a, Zstr expect) {
if (VecLen(&r->nameservers) <= i) {
return false;- In
SysDns.c:670:
buf[k] = 'x';
}
Zstr tail = " spuriousname\n10.0.0.4 goodname\n";
for (u64 i = 0; tail[i] != '\0'; ++i) {
buf[k++] = tail[i];- In
SysDns.c:676:
buf[k] = '\0';
Str path = write_temp(a, (Zstr)buf);
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:735:
Str body = StrInit(a);
Zstr pad = "# padding line to push the fixture past the four kilobyte chunk\n";
u64 padlen = ZstrLen(pad);
for (int i = 0; i < 300; ++i) {- In
Socket.c:8:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Io.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Log.h>
#include <Misra/Sys/Socket.h>- In
Socket.c:48:
Str local_str = SocketAddrFormat(&local, a);
SocketAddr connect_addr;
bool parsed = SocketAddrParse(&connect_addr, (Zstr)StrBegin(&local_str), SOCKET_KIND_TCP);
StrDeinit(&local_str);
if (!parsed) {- In
Socket.c:69:
}
Zstr payload = "hello from socket test";
size n = (size)ZstrLen(payload);
if (SocketSend(&client, payload, n) != (i64)n) {- In
Socket.c:166:
Str local_str = SocketAddrFormat(&local, a);
SocketAddr connect_addr;
bool parsed = SocketAddrParse(&connect_addr, (Zstr)StrBegin(&local_str), SOCKET_KIND_TCP);
StrDeinit(&local_str);
if (!parsed) {- In
Socket.c:214:
}
Zstr payload = "X";
bool sent = SocketSend(&p.client, payload, 1) == 1;- In
Socket.c:639:
// Parse `spec`, format the result, compare against `expect` exactly.
// Returns true iff the parse succeeded and the rendered string matches.
static bool fmt_eq(Zstr spec, Zstr expect) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);- In
Socket.c:971:
ok = ok && StrLen(&s) > 0;
if (ok) {
Zstr rendered = StrBegin(&s);
ok = ok && ZstrCompareN(rendered, "127.0.0.1:", 10u) == 0;
// a real ephemeral port is non-zero: last char is not ":0\0"
- In
Socket.c:1010:
Str local_str = SocketAddrFormat(&local, a);
SocketAddr connect_addr;
bool parsed = SocketAddrParse(&connect_addr, (Zstr)StrBegin(&local_str), SOCKET_KIND_TCP);
StrDeinit(&local_str);
if (!parsed) {- In
Socket.c:1118:
Str local_str = SocketAddrFormat(&local, a);
SocketAddr connect_addr;
bool parsed = SocketAddrParse(&connect_addr, (Zstr)StrBegin(&local_str), SOCKET_KIND_TCP);
StrDeinit(&local_str);
if (!parsed) {- In
Socket.c:1171:
{
Str peer = SocketAddrFormat(&server.peer, a);
Zstr p = StrBegin(&peer);
ok = ok && StrLen(&peer) > 0 && p[0] == '1' && p[1] == '2' && p[2] == '7' && p[3] == '.';
StrDeinit(&peer);- In
Socket.c:1181:
// client -> server
Zstr c2s = "client=>server:ABCDEFG";
size n1 = (size)ZstrLen(c2s);
ok = ok && SocketSend(&client, c2s, n1) == (i64)n1;- In
Socket.c:1190:
// server -> client (different payload + length so a swapped fd or a
// length mutation surfaces here too)
Zstr s2c = "server=>client:0123456789";
size n2 = (size)ZstrLen(s2c);
ok = ok && SocketSend(&server, s2c, n2) == (i64)n2;- In
Socket.c:1269:
ok = ok && ZstrCompare(StrBegin(&rendered), "127.0.0.1:0") != 0;
// host portion must be exactly the loopback address.
Zstr r = StrBegin(&rendered);
ok = ok && r[0] == '1' && r[1] == '2' && r[2] == '7' && r[3] == '.';
StrDeinit(&rendered);- In
Socket.c:1310:
// Now send data; poll(with a short timeout) must report READ ready.
Zstr payload = "poke";
size n = (size)ZstrLen(payload);
ok = ok && SocketSend(&client, payload, n) == (i64)n;- In
Socket.c:1364:
// Data is available, so the recv returns immediately with the bytes
// -- never touching the timeout/error path.
Zstr payload = "recv-timeout-set";
size n = (size)ZstrLen(payload);
ok = ok && SocketSend(&client, payload, n) == (i64)n;- In
Socket.c:1402:
ok = ok && SocketSetSendTimeoutMs(client.fd, 500);
Zstr payload = "after-send-timeout";
size n = (size)ZstrLen(payload);
ok = ok && SocketSend(&client, payload, n) == (i64)n;- In
Socket.c:1445:
// Connection still usable after toggling options.
Zstr payload = "opts-ok";
size n = (size)ZstrLen(payload);
ok = ok && SocketSend(&client, payload, n) == (i64)n;- In
Socket.c:1541:
Str spec = StrInit(a);
StrAppendFmt(&spec, "{}", (Zstr) "1.2.3.4:4660");
SocketAddr addr;- In
Socket.c:1608:
// Parse `spec`, format the result, compare against `expect` exactly.
static bool bl_fmt_eq(Zstr spec, Zstr expect) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *a = ALLOCATOR_OF(&alloc);- In
MachoCache.c:16:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/File.h>- In
MachoCache.c:43:
}
static bool write_file(Zstr path, const u8 *data, u64 size) {
File f = FileOpen(path, "wb");
if (!FileIsOpen(&f))- In
MachoCache.c:76:
typedef struct SymSpec {
u64 vmaddr;
Zstr name;
} SymSpec;- In
MachoCache.c:92:
u32 str_size = 1;
for (u32 i = 0; i < nsyms; ++i) {
Zstr s = syms[i].name;
u32 n = 0;
while (s[n])- In
MachoCache.c:154:
wr_u64(&n[8], syms[i].vmaddr);
Zstr s = syms[i].name;
u32 nlen = 0;
while (s[nlen])- In
MachoCache.c:181:
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_macho_main.bin";
SymSpec sym = {.vmaddr = 0x100000100ull, .name = "real_main_proc"};
u64 bin_size = build_macho_image(bin_buf, kUuid, &sym, 1);- In
MachoCache.c:195:
const u64 slide = 0x100;
const u64 runtime_ip = 0x100000100ull + 0x10 + slide;
Zstr name = NULL;
u32 offset = 0;
bool ok = MachoCacheResolve(&cache, bin_path, slide, runtime_ip, &name, &offset);- In
MachoCache.c:210:
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_macho_stripped";
Zstr dsym_dir = "/tmp/misra_macho_stripped.dSYM/Contents/Resources/DWARF";
Zstr dsym_path = "/tmp/misra_macho_stripped.dSYM/Contents/Resources/DWARF/misra_macho_stripped";- In
MachoCache.c:211:
Zstr bin_path = "/tmp/misra_macho_stripped";
Zstr dsym_dir = "/tmp/misra_macho_stripped.dSYM/Contents/Resources/DWARF";
Zstr dsym_path = "/tmp/misra_macho_stripped.dSYM/Contents/Resources/DWARF/misra_macho_stripped";- In
MachoCache.c:212:
Zstr bin_path = "/tmp/misra_macho_stripped";
Zstr dsym_dir = "/tmp/misra_macho_stripped.dSYM/Contents/Resources/DWARF";
Zstr dsym_path = "/tmp/misra_macho_stripped.dSYM/Contents/Resources/DWARF/misra_macho_stripped";
// Make the dSYM bundle directory.
- In
MachoCache.c:232:
const u64 slide = 0;
const u64 runtime_ip = 0x100000208ull; // 8 bytes into dsym_only_fn
Zstr name = NULL;
u32 offset = 0;
bool ok = MachoCacheResolve(&cache, bin_path, slide, runtime_ip, &name, &offset);- In
MachoCache.c:251:
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_macho_uuidmiss";
Zstr dsym_path = "/tmp/misra_macho_uuidmiss.dSYM/Contents/Resources/DWARF/misra_macho_uuidmiss";- In
MachoCache.c:252:
Zstr bin_path = "/tmp/misra_macho_uuidmiss";
Zstr dsym_path = "/tmp/misra_macho_uuidmiss.dSYM/Contents/Resources/DWARF/misra_macho_uuidmiss";
DirCreateAll("/tmp/misra_macho_uuidmiss.dSYM/Contents/Resources/DWARF");- In
MachoCache.c:268:
MachoCache cache = MachoCacheInit(base);
Zstr name = NULL;
bool ok = !MachoCacheResolve(&cache, bin_path, 0, 0x100000208ull, &name, NULL);- In
MachoCache.c:305:
}
static bool mc_write_file(Zstr path, const u8 *data, u64 size) {
File f = FileOpen(path, "wb");
if (!FileIsOpen(&f))- In
MachoCache.c:331:
typedef struct McSymSpec {
u64 vmaddr;
Zstr name;
} McSymSpec;- In
MachoCache.c:345:
u32 str_size = 1;
for (u32 i = 0; i < nsyms; ++i) {
Zstr s = syms[i].name;
u32 n = 0;
while (s[n])- In
MachoCache.c:401:
mc_wr_u16(&n[6], 0);
mc_wr_u64(&n[8], syms[i].vmaddr);
Zstr s = syms[i].name;
u32 nlen = 0;
while (s[nlen])- In
MachoCache.c:475:
// payloads live after the load commands; the section records point at
// their file offsets.
static u64 mc_build_dwarf_dsym(u8 *out, const u8 uuid[16], u64 low, u64 high_off, Zstr fn_name) {
MemSet(out, 0, MC_BLOB_CAP);- In
MachoCache.c:614:
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_path = "/tmp/misra_mc_main.bin";
McSymSpec sym = {.vmaddr = 0x100000100ull, .name = "real_main_proc"};
u64 bin_size = mc_build_macho_image(mc_bin_buf, mc_kUuid, &sym, 1);- In
MachoCache.c:622:
MachoCache cache = MachoCacheInit(base);
Zstr name = NULL;
u32 offset = 0;
const u64 slide = 0x100;- In
MachoCache.c:648:
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_a = "/tmp/misra_mc_hit_a.bin";
Zstr bin_b = "/tmp/misra_mc_hit_b.bin";
McSymSpec sym = {.vmaddr = 0x100000100ull, .name = "fn_alpha"};- In
MachoCache.c:649:
Zstr bin_a = "/tmp/misra_mc_hit_a.bin";
Zstr bin_b = "/tmp/misra_mc_hit_b.bin";
McSymSpec sym = {.vmaddr = 0x100000100ull, .name = "fn_alpha"};
u64 sz_a = mc_build_macho_image(mc_bin_buf, mc_kUuid, &sym, 1);- In
MachoCache.c:660:
MachoCache cache = MachoCacheInit(base);
Zstr name = NULL;
u32 off = 0;- In
MachoCache.c:705:
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_path = "/tmp/misra_mc_dsym";
Zstr dsym_path = "/tmp/misra_mc_dsym.dSYM/Contents/Resources/DWARF/misra_mc_dsym";
DirCreateAll("/tmp/misra_mc_dsym.dSYM/Contents/Resources/DWARF");- In
MachoCache.c:706:
Zstr bin_path = "/tmp/misra_mc_dsym";
Zstr dsym_path = "/tmp/misra_mc_dsym.dSYM/Contents/Resources/DWARF/misra_mc_dsym";
DirCreateAll("/tmp/misra_mc_dsym.dSYM/Contents/Resources/DWARF");- In
MachoCache.c:718:
MachoCache cache = MachoCacheInit(base);
Zstr name = NULL;
u32 offset = 0;
bool resolved = MachoCacheResolve(&cache, bin_path, 0, 0x100000208ull, &name, &offset);- In
MachoCache.c:742:
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_path = "/tmp/misra_mc_uuidmiss";
Zstr dsym_path = "/tmp/misra_mc_uuidmiss.dSYM/Contents/Resources/DWARF/misra_mc_uuidmiss";
DirCreateAll("/tmp/misra_mc_uuidmiss.dSYM/Contents/Resources/DWARF");- In
MachoCache.c:743:
Zstr bin_path = "/tmp/misra_mc_uuidmiss";
Zstr dsym_path = "/tmp/misra_mc_uuidmiss.dSYM/Contents/Resources/DWARF/misra_mc_uuidmiss";
DirCreateAll("/tmp/misra_mc_uuidmiss.dSYM/Contents/Resources/DWARF");- In
MachoCache.c:759:
MachoCache cache = MachoCacheInit(base);
Zstr name = NULL;
// Resolve must fail: stripped main + UUID-mismatched dSYM.
ok = ok && !MachoCacheResolve(&cache, bin_path, 0, 0x100000208ull, &name, NULL);- In
MachoCache.c:783:
Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_path = "/tmp/misra_mc_dwarf";
Zstr dsym_path = "/tmp/misra_mc_dwarf.dSYM/Contents/Resources/DWARF/misra_mc_dwarf";
DirCreateAll("/tmp/misra_mc_dwarf.dSYM/Contents/Resources/DWARF");- In
MachoCache.c:784:
Zstr bin_path = "/tmp/misra_mc_dwarf";
Zstr dsym_path = "/tmp/misra_mc_dwarf.dSYM/Contents/Resources/DWARF/misra_mc_dwarf";
DirCreateAll("/tmp/misra_mc_dwarf.dSYM/Contents/Resources/DWARF");- In
MachoCache.c:790:
// bytes -- otherwise the info_n->42 value-substitution would be a
// no-op against this exact fixture.
Zstr fn_name = "dwarf_widget_function_with_long_name";
const u64 low = 0x100004000ull;
const u64 high_off = 0x80;- In
MachoCache.c:801:
MachoCache cache = MachoCacheInit(base);
Zstr name = NULL;
u32 offset = 0;
// file-relative VA low+0x20 -> 0x20 into the function.
- In
MachoCache.c:827:
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_mc_slide.bin";
// Symbol at vmaddr 0: resolves a file-relative VA of 0.
McSymSpec sym = {.vmaddr = 0x0ull, .name = "fn_at_zero"};- In
MachoCache.c:834:
MachoCache cache = MachoCacheInit(base);
Zstr name = NULL;
u32 off = 0;- In
MachoCache.c:860:
Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_mc_str.bin";
McSymSpec sym = {.vmaddr = 0x100000100ull, .name = "str_fn"};
u64 bin_size = mc_build_macho_image(mc_bin_buf, mc_kUuid, &sym, 1);- In
MachoCache.c:870:
StrPushBackMany(&mod, bin_path);
Zstr name = NULL;
u32 off = 0;
// Str overload -> macho_cache_resolve_str -> macho_cache_resolve_zstr.
- In
MachoCache.c:922:
}
static bool bl_write_file(Zstr path, const u8 *data, u64 size) {
File f = FileOpen(path, "wb");
if (!FileIsOpen(&f)) // 42 (mutant 118) makes the parser read 30 bytes of __debug_str as
// abbrev entries, corrupting the abbrev table.
static u64 bl_build_dwarf_dsym(u8 *out, const u8 uuid[16], u64 low, u64 high_off, Zstr fn_name) {
MemSet(out, 0, BL_BLOB_CAP); Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_bl_dwarf";
Zstr dsym_path = "/tmp/misra_bl_dwarf.dSYM/Contents/Resources/DWARF/misra_bl_dwarf";
DirCreateAll("/tmp/misra_bl_dwarf.dSYM/Contents/Resources/DWARF");
Zstr bin_path = "/tmp/misra_bl_dwarf";
Zstr dsym_path = "/tmp/misra_bl_dwarf.dSYM/Contents/Resources/DWARF/misra_bl_dwarf";
DirCreateAll("/tmp/misra_bl_dwarf.dSYM/Contents/Resources/DWARF"); DirCreateAll("/tmp/misra_bl_dwarf.dSYM/Contents/Resources/DWARF");
Zstr fn_name = "dwarf_widget_function_with_long_name";
const u64 low = 0x100004000ull;
const u64 high_off = 0x80;
MachoCache cache = MachoCacheInit(base);
Zstr name = NULL;
u32 offset = 0;
bool resolved = MachoCacheResolve(&cache, bin_path, 0, low + 0x20, &name, &offset); Allocator *base = ALLOCATOR_OF(&alloc);
Zstr bin_path = "/tmp/misra_bl_dwarf2";
Zstr dsym_path = "/tmp/misra_bl_dwarf2.dSYM/Contents/Resources/DWARF/misra_bl_dwarf2";
DirCreateAll("/tmp/misra_bl_dwarf2.dSYM/Contents/Resources/DWARF");
Zstr bin_path = "/tmp/misra_bl_dwarf2";
Zstr dsym_path = "/tmp/misra_bl_dwarf2.dSYM/Contents/Resources/DWARF/misra_bl_dwarf2";
DirCreateAll("/tmp/misra_bl_dwarf2.dSYM/Contents/Resources/DWARF"); DirCreateAll("/tmp/misra_bl_dwarf2.dSYM/Contents/Resources/DWARF");
Zstr fn_name = "second_pass_dwarf_routine";
const u64 low = 0x100008000ull;
const u64 high_off = 0x40; MachoCache cache = MachoCacheInit(base);
Zstr name1 = NULL;
u32 off1 = 0;
ok = ok && MachoCacheResolve(&cache, bin_path, 0, low + 0x10, &name1, &off1); // Second resolve hits the cached entry: dsym already open, dwarf already
// built. Same answer expected.
Zstr name2 = NULL;
u32 off2 = 0;
ok = ok && MachoCacheResolve(&cache, bin_path, 0, low + 0x30, &name2, &off2); Allocator *base = ALLOCATOR_OF(&dbg);
Zstr bin_path = "/tmp/misra_bl_dwarf3";
Zstr dsym_path = "/tmp/misra_bl_dwarf3.dSYM/Contents/Resources/DWARF/misra_bl_dwarf3";
DirCreateAll("/tmp/misra_bl_dwarf3.dSYM/Contents/Resources/DWARF");
Zstr bin_path = "/tmp/misra_bl_dwarf3";
Zstr dsym_path = "/tmp/misra_bl_dwarf3.dSYM/Contents/Resources/DWARF/misra_bl_dwarf3";
DirCreateAll("/tmp/misra_bl_dwarf3.dSYM/Contents/Resources/DWARF"); DirCreateAll("/tmp/misra_bl_dwarf3.dSYM/Contents/Resources/DWARF");
Zstr fn_name = "dwarf_leakcheck_routine_name";
const u64 low = 0x10000c000ull;
const u64 high_off = 0x60;
MachoCache cache = MachoCacheInit(base);
Zstr name = NULL;
u32 offset = 0;
bool resolved = MachoCacheResolve(&cache, bin_path, 0, low + 0x14, &name, &offset); #include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Parsers/ProcMaps.h>
#include <Misra/Sys/SymbolResolver.h> // Start address of an executable, file-backed mapping in a module OTHER than
// `self_path`, via the public ProcMaps API only.
static bool find_other_module_addr(Zstr self_path, u64 *out_addr) {
DefaultAllocator a = DefaultAllocatorInit();
ProcMaps maps;- In
SymBind.c:15:
#include <Misra.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys/SymbolResolver.h> #include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys/SymbolResolver.h>- In
SidecarSub.c:16:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys/SymbolResolver.h>- In
Sidecar.c:16:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys/SymbolResolver.h> #include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys/SymbolResolver.h>- In
Bias.c:18:
#include <Misra.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Parsers/ProcMaps.h>
#include <Misra/Sys/SymbolResolver.h>- In
Bias.c:30:
// back its runtime start and backing-file offset so a test can compute the
// historical `start - file_offset` fallback base independently.
static bool find_rw_mapping(Zstr path, u64 addr, u64 *map_start, u64 *map_file_offset) {
DefaultAllocator a = DefaultAllocatorInit();
ProcMaps maps;- In
Pe.c:12:
#include <Misra.h>
#include <Misra/Parsers/Pe.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>- In
Pe.c:76:
static const u8 kGuid[16] =
{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99};
static Zstr const kPdbPath = "C:\\build\\test.pdb";
static void build_pe_blob(void) {- In
Pe.c:1658:
}
FileClose(&f);
if (FileWriteAndClose((Zstr)StrBegin(&path), blob, sizeof(blob)) < 0) {
FileRemove(&path);
StrDeinit(&path);- In
Pe.c:1666:
Pe pe;
bool ok = PeOpen(&pe, (Zstr)StrBegin(&path), base);
if (ok) {
ok = pe.machine == PE_MACHINE_X86_64 && VecLen(&pe.sections) == 1 &&- In
Pe.c:1700:
}
FileClose(&f);
if (FileWriteAndClose((Zstr)StrBegin(&path), junk, sizeof(junk)) < 0) {
FileRemove(&path);
StrDeinit(&path);- In
Pe.c:1708:
Pe pe;
bool opened = PeOpen(&pe, (Zstr)StrBegin(&path), base);
if (opened)
PeDeinit(&pe);- In
Dns.c:2:
#include <Misra/Parsers/Dns.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Allocator/Debug.h>- In
Pdb.c:13:
#include <Misra.h>
#include <Misra/Parsers/Pdb.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Allocator/Debug.h>- In
Pdb.c:322:
// Write one S_PUB32 record at `*sym` and advance it. Returns nothing;
// `*sym` points past the record on return.
static void write_pub32(u8 **sym, u32 offset, u16 segment, Zstr name) {
u32 namelen = (u32)ZstrLen(name) + 1; // include NUL
u16 rec_len = (u16)(2 + 4 + 4 + 2 + namelen);- In
Pdb.c:1521:
// Write one S_PUB32 record at `*sym` and advance `*sym` past it.
// `rec_kind` overridable so a non-PUB32 record can be injected.
static void write_pub32_kind(u8 **sym, u16 rec_kind, u32 flags, u32 offset, u16 segment, Zstr name) {
u32 namelen = (u32)ZstrLen(name) + 1; // include NUL
u16 rec_len = (u16)(2 + 4 + 4 + 2 + namelen);- In
Pdb.c:1562:
// Write one IMAGE_SECTION_HEADER at `sec` (40 bytes).
static void write_section(u8 *sec, Zstr name8, u32 vsize, u32 vaddr) {
u8 nm[8] = {0, 0, 0, 0, 0, 0, 0, 0};
u32 i;- In
Pdb.c:2565:
u32 offset;
u16 segment;
Zstr name;
} PubSpec;- In
Pdb.c:2988:
}
static u32 put_pub32(u8 *dst, u32 offset, u16 segment, Zstr name) {
u32 namelen = (u32)ZstrLen(name) + 1;
u16 rec_len = (u16)(2 + 4 + 4 + 2 + namelen);- In
ProcMaps.c:6:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Parsers/ProcMaps.h>
#include <Misra/Sys/Dir.h>- In
ProcMaps.c:22:
// the loader's own success flag (true even when a line is malformed: a bad
// line is skipped, not a hard failure).
static bool pm_load_text(ProcMaps *m, Zstr text, DefaultAllocator *alloc) {
return ProcMapsLoadFrom(m, text, ZstrLen(text), alloc);
}- In
ProcMaps.c:579:
// 200 * 26 bytes = 5200 bytes of filler, comfortably past one 4096 chunk,
// before the distinctive trailing entry lands.
Zstr filler = "1000-1001 ---p 0 0:0 0 /f\n";
bool wrote_ok = true;
for (int i = 0; i < 200 && wrote_ok; ++i) {- In
ProcMaps.c:585:
wrote_ok = (w == (i64)ZstrLen(filler));
}
Zstr late = "deadbeef000-deadbeef100 r-xp 0 0:0 0 /late\n";
if (wrote_ok) {
i64 w = FileWrite(&f, late, (u64)ZstrLen(late));- In
Http.c:4:
#include <Misra/Parsers/Http.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>- In
Http.c:17:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr raw =
"GET /index.html HTTP/1.1\r\n"
"Host: example.com\r\n"- In
Http.c:25:
HttpRequest req = HttpRequestInit(alloc_base);
Zstr next = HttpRequestParse(&req, raw);
bool ok = (next != raw) && (req.method == HTTP_REQUEST_METHOD_GET) && (StrLen(&req.url) == 11) &&- In
Http.c:74:
struct {
Zstr raw;
HttpRequestMethod method;
} cases[] = {- In
Http.c:91:
for (u64 i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
HttpRequest req = HttpRequestInit(alloc_base);
Zstr next = HttpRequestParse(&req, cases[i].raw);
ok = ok && (next != cases[i].raw) && (req.method == cases[i].method);
HttpRequestDeinit(&req);- In
Http.c:106:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr cases[] = {
"GETX / HTTP/1.1\r\n\r\n",
"PUTT / HTTP/1.1\r\n\r\n",- In
Http.c:115:
for (u64 i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
HttpRequest req = HttpRequestInit(alloc_base);
Zstr next = HttpRequestParse(&req, cases[i]);
ok = ok && (next == cases[i]) && (req.method == HTTP_REQUEST_METHOD_UNKNOWN);
HttpRequestDeinit(&req);- In
Http.c:130:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Zstr cases[] = {
"GE / HTTP/1.1\r\n\r\n",
"POSTX / HTTP/1.1\r\n\r\n",- In
Http.c:138:
for (u64 i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
HttpRequest req = HttpRequestInit(alloc_base);
Zstr next = HttpRequestParse(&req, cases[i]);
ok = ok && (next == cases[i]) && (req.method == HTTP_REQUEST_METHOD_UNKNOWN);
HttpRequestDeinit(&req);- In
Http.c:166:
HttpRequest req = HttpRequestInit(alloc_base);
Zstr in = StrBegin(&raw);
Zstr next = HttpRequestParse(&req, in);- In
Http.c:167:
HttpRequest req = HttpRequestInit(alloc_base);
Zstr in = StrBegin(&raw);
Zstr next = HttpRequestParse(&req, in);
// Real code rejects: cursor returned unchanged (== in).
- In
Http.c:193:
HttpRequest req = HttpRequestInit(alloc_base);
Zstr in = StrBegin(&raw);
Zstr next = HttpRequestParse(&req, in);- In
Http.c:194:
HttpRequest req = HttpRequestInit(alloc_base);
Zstr in = StrBegin(&raw);
Zstr next = HttpRequestParse(&req, in);
bool ok = (next != in) && (VecLen(&req.headers) == 100);- In
Http.c:217:
bool ok = FileIsOpen(&f);
Zstr payload = "hello-body";
ok = ok && (FileWrite(&f, payload, ZstrLen(payload)) == (i64)ZstrLen(payload));
FileClose(&f);- In
Http.c:326:
// A long URL forces the url Str onto the heap.
Zstr raw =
"GET /a-deliberately-long-url-path-to-force-heap-allocation HTTP/1.1\r\n"
"\r\n";- In
Http.c:331:
HttpRequest req = HttpRequestInit(adbg);
Zstr next = HttpRequestParse(&req, raw);
bool ok = (next != raw) && (StrLen(&req.url) > 0);
ok = ok && (DebugAllocatorLiveCount(&dbg) > 0);- In
Http.c:390:
File f = FileOpenTemp(&path, adbg);
bool ok = FileIsOpen(&f);
Zstr payload = "file-payload-long-enough-to-heap-allocate-body";
ok = ok && (FileWrite(&f, payload, ZstrLen(payload)) == (i64)ZstrLen(payload));
FileClose(&f);- In
MachO.c:14:
#include <Misra/Std/File.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Sys/Dir.h>- In
MachO.c:571:
// `_NSGetExecutablePath` wants `char *`; everything past this
// point reads it through the project's `Zstr` (const char *).
Zstr path = path_buf;
DefaultAllocator alloc = DefaultAllocatorInit();- In
MachO.c:605:
if (_NSGetExecutablePath(path_buf, &pathsize) != 0)
return false;
Zstr path = path_buf;
DefaultAllocator alloc = DefaultAllocatorInit();- In
Stripped.c:16:
#include <Misra.h>
#include <Misra/Parsers/Dwarf.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Parsers/Elf.h>
#include <Misra/Std/Allocator/Default.h>- In
Stripped.c:35:
}
static Zstr stripped_path_arg = NULL;
// Open the stripped sibling and try to resolve `func_addr` (a runtime
- In
Stripped.c:41:
// address is the same in both copies because objcopy -R only removes
// non-allocated sections.
static bool resolve_through_stripped(void (*func)(void), Zstr expect_name) {
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *base = ALLOCATOR_OF(&alloc);- In
Dwarf.c:3:
#include <Misra.h>
#include <Misra/Parsers/Dwarf.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Parsers/Elf.h>
#include <Misra/Std/Allocator/Debug.h>- In
Dwarf.c:250:
// the total length. `version` and `length_override` allow malformed /
// unsupported variants.
static u64 build_debug_info(u8 *buf, u16 version, u32 length_override, u64 low, u64 high_off, Zstr name) {
// CU body after unit_length: version(2) abbrev_off(4) addr_size(1)
// + DIE: abbrev_code(1) name(NUL-terminated) low_pc(8) high_pc(8)
// Helper function to compare JSON output (removes spaces for comparison)
bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
// Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected, alloc); );
Zstr expected = "{}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"numbers\":[],\"strings\":[]}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"name\":\"\",\"description\":\"\"}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"temp\":-25,\"balance\":-1000.500000,\"delta\":-0.001000}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"int_zero\":0,\"float_zero\":0.000000,\"bool_false\":false}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"outer\":{},\"list\":[],\"deep\":{\"inner\":{}}}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"empty_obj\":{},\"filled_obj\":{\"x\":1},\"empty_arr\":[],\"filled_arr\":[1,2]}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"max_int\":2147483647,\"min_int\":-2147483648,\"one\":1,\"minus_one\":-1}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; JW_OBJ(json4, { JW_FLT_KV(json4, "pi", single_float); });
Zstr expected1 = "{\"value\":42}";
Zstr expected2 = "{\"text\":\"hello\"}";
Zstr expected3 = "{\"flag\":true}";
Zstr expected1 = "{\"value\":42}";
Zstr expected2 = "{\"text\":\"hello\"}";
Zstr expected3 = "{\"flag\":true}";
Zstr expected4 = "{\"pi\":3.140000}"; Zstr expected1 = "{\"value\":42}";
Zstr expected2 = "{\"text\":\"hello\"}";
Zstr expected3 = "{\"flag\":true}";
Zstr expected4 = "{\"pi\":3.140000}"; Zstr expected2 = "{\"text\":\"hello\"}";
Zstr expected3 = "{\"flag\":true}";
Zstr expected4 = "{\"pi\":3.140000}";
if (!compare_json_output(&json1, expected1, &alloc))
// Helper function to compare JSON output (removes whitespace for comparison)
bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc); });
Zstr expected = "{\"user\":{\"id\":123,\"profile\":{\"name\":\"Alice\",\"age\":30}},\"status\":\"active\"}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected =
"{\"company\":{\"departments\":{\"engineering\":{\"head\":\"John\",\"count\":25,\"budget\":150000.000000}},"
"\"name\":\"TechCorp\"}}"; });
Zstr expected =
"{\"status\":true,\"message\":\"Success\",\"data\":{\"12345\":{\"67890\":{\"distance\":0.850000,\"nearest_"
"neighbor_analysis_id\":999,\"nearest_neighbor_binary_id\":888,\"nearest_neighbor_analysis_name\":\"test_" });
Zstr expected =
"{\"functions\":[{\"id\":12345,\"name\":\"test_func\",\"size\":1024,\"vaddr\":4096},{\"id\":54321,\"name\":"
"\"helper_func\",\"size\":512,\"vaddr\":8192}]}"; });
Zstr expected =
"{\"binary_id\":888,\"binary_name\":\"test_binary\",\"analysis_id\":999,\"sha256\":\"abc123\",\"tags\":["
"\"malware\",\"x86\"],\"created_at\":\"2024-04-01\",\"model_id\":12345,\"model_name\":\"test_model\",\"owned_" });
Zstr expected =
"{\"functions\":{\"111\":{\"222\":{\"distance\":0.900000,\"name\":\"func1\"}},\"333\":{\"444\":{\"distance\":0."
"800000,\"name\":\"func2\"}}}}"; });
Zstr expected =
"{\"level1\":{\"level2\":{\"level3\":{\"message\":\"deep\",\"value\":42},\"flag\":true},\"name\":\"test\"}}";
if (!compare_json_output(&json, expected, &alloc)) { });
Zstr expected = "{\"numbers\":[1,2,3],\"strings\":[\"a\",\"b\",\"c\"],\"booleans\":[true,false,true]}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false;
// Helper function to compare expected JSON strings (removes spaces for comparison)
bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
// Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected, alloc); });
Zstr expected = "{\"name\":\"Alice\",\"city\":\"New York\"}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"count\":42,\"score\":95.500000,\"year\":2024}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"enabled\":true,\"visible\":false}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"id\":1001,\"name\":\"Bob\",\"age\":25,\"is_active\":true,\"salary\":50000.000000}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"debug_mode\":false,\"timeout\":30,\"log_level\":\"INFO\"}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; JW_OBJ(json, { JW_ARR_KV(json, "languages", languages, lang, { JW_STR(json, lang); }); });
Zstr expected = "{\"languages\":[\"C\",\"Python\",\"Rust\"]}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected = "{\"user\":{\"name\":\"Charlie\",\"email\":\"charlie@example.com\"},\"active\":true}";
if (!compare_json_output(&json, expected, &alloc)) {
success = false; });
Zstr expected =
"{\"id\":12345,\"name\":\"Laptop\",\"price\":999.990000,\"tags\":[\"electronics\",\"computers\",\"portable\"]}";
if (!compare_json_output(&json, expected, &alloc)) { // message: "Hello, \"World\"!" -> Hello, "World"!
// data: "line1\nline2\ttab" -> line1<LF>line2<HT>tab
Zstr path_want = "C:\\Program Files\\App";
Zstr msg_want = "Hello, \"World\"!";
Zstr data_want = "line1\nline2\ttab"; // data: "line1\nline2\ttab" -> line1<LF>line2<HT>tab
Zstr path_want = "C:\\Program Files\\App";
Zstr msg_want = "Hello, \"World\"!";
Zstr data_want = "line1\nline2\ttab";
if (StrLen(&obj.path) != ZstrLen(path_want) || MemCompare(StrBegin(&obj.path), path_want, StrLen(&obj.path)) != 0) { Zstr path_want = "C:\\Program Files\\App";
Zstr msg_want = "Hello, \"World\"!";
Zstr data_want = "line1\nline2\ttab";
if (StrLen(&obj.path) != ZstrLen(path_want) || MemCompare(StrBegin(&obj.path), path_want, StrLen(&obj.path)) != 0) {
WriteFmtLn("[DEBUG] Special characters FAILED: path content wrong"); const Str *got;
char want;
Zstr name;
} expect[] = {
{ &obj.quote, '"', "quote"},
// "\u" with no following hex digits, then closing quote/EOF.
Zstr cases[] = {"\"\\u\"", "\"\\u12\"", "\"ab\\u\""};
for (u64 i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
Str j = StrInitFromZstr(cases[i], &alloc);
// missing ':' separator, missing closing brace, missing comma.
Zstr cases[] = {
"{\"a\" 1}", // no colon
"{\"a\":1", // truncated, no closing brace
- In
Parse.c:13:
// Helper: parse `src` into a fresh cfg, look up `key`, and compare the
// stored value byte-for-byte against `expect`. Returns true on match.
static bool kv_value_equals(Zstr src, Zstr key, Zstr expect) {
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);- In
Parse.c:487:
(void)KvConfigParse(input, &cfg);
Zstr trues[] = {"t1", "t2", "t3", "t4"};
Zstr falses[] = {"f1", "f2", "f3", "f4"};
for (u64 i = 0; i < 4; i++) {- In
Parse.c:488:
Zstr trues[] = {"t1", "t2", "t3", "t4"};
Zstr falses[] = {"f1", "f2", "f3", "f4"};
for (u64 i = 0; i < 4; i++) {
v = false;- In
Parse.c:637:
// KvConfigParse branch where that Str actually holds a heap buffer leaks
// it, leaving DebugAllocatorLiveCount > 0.
static bool kv_parse_is_leak_free(Zstr src) {
DebugAllocator dbg = kv_lean_debug_allocator();
Allocator *base = ALLOCATOR_OF(&dbg);