Str
Description
The Str type is a specialization of Vec for characters
Usage example (Cross-references)
Usage examples (Cross-references)
- In
ArgParse.h:42:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/File.h>- In
ArgParse.h:60:
ARG_KIND_INVALID = 0, // unknown target type -- registration fails
ARG_KIND_ZSTR, // `Zstr *` / `char **`
ARG_KIND_STR, // `Str *`
ARG_KIND_BOOL, // `bool *`
ARG_KIND_U8,- In
ArgParse.h:236:
Zstr *: ((ArgTarget) {ARG_KIND_ZSTR, (void *)(t)}), \
char **: ((ArgTarget) {ARG_KIND_ZSTR, (void *)(t)}), \
Str *: ((ArgTarget) {ARG_KIND_STR, (void *)(t)}), \
bool *: ((ArgTarget) {ARG_KIND_BOOL, (void *)(t)}), \
u8 *: ((ArgTarget) {ARG_KIND_U8, (void *)(t)}), \
- In
File.h:15:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- 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:175:
///
i64 file_read(File *f, void *buf, u64 n);
i64 file_read_to_str(File *f, Str *out);
i64 file_read_to_buf(File *f, Buf *out);
#define FileRead(...) OVERLOAD(FileRead, __VA_ARGS__)- In
File.h:179:
#define FileRead(...) OVERLOAD(FileRead, __VA_ARGS__)
#define FileRead_2(f, out) \
_Generic((out), Buf *: file_read_to_buf((f), (Buf *)(out)), Str *: file_read_to_str((f), (Str *)(out)))
#define FileRead_3(f, buf, n) file_read((f), (buf), (n))- 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:211:
char *: file_read_and_close_to_buf((Zstr)(path), (Buf *)(out)) \
), \
Str *: _Generic( \
(path), \
Str *: file_read_and_close_to_str((Zstr)StrBegin((Str *)(path)), (Str *)(out)), \
- 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: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: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:262:
char *: file_write_and_close_from_buf((Zstr)(path), (const Buf *)(container)) \
), \
Str *: _Generic( \
(path), \
Str *: file_write_and_close_from_str((Zstr)StrBegin((Str *)(path)), (const Str *)(container)), \
- 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:356:
/// TAGS: File, Temp
///
File file_open_temp(Str *out_path, Allocator *alloc);
#define FileOpenTemp(...) OVERLOAD(FileOpenTemp, __VA_ARGS__)
#define FileOpenTemp_1(out_path) file_open_temp((out_path), MisraScope)- In
Container.h:15:
// Foundation: always available.
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>- In
Log.h:43:
do { \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m))); \
- In
Log.h:67:
do { \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m))); \
- In
Log.h:90:
do { \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m))); \
- In
Log.h:125:
i32 UNPL(sys_eno) = (i32)(eno); \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
StrInitStack(UNPL(syserr), 256) { \
- In
Log.h:154:
i32 UNPL(sys_eno) = (i32)(eno); \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
StrInitStack(UNPL(syserr), 256) { \
- In
Log.h:182:
i32 UNPL(sys_eno) = (i32)(eno); \
HeapAllocator UNPL(log_alloc) = HeapAllocatorInit(); \
Str UNPL(m) = StrInit(&UNPL(log_alloc)); \
StrAppendFmt(&UNPL(m), __VA_ARGS__); \
StrInitStack(UNPL(syserr), 256) { \
- In
Io.h:108:
/// TAGS: I/O, Callback, Generic
///
typedef bool (*TypeSpecificWriter)(Str *o, FmtInfo *fmt_info, void *data);
///
- In
Io.h:300:
(x), \
TypeSpecificIO: (x), \
Str: TO_TYPE_SPECIFIC_IO(Str, &(x)), \
Buf: TO_TYPE_SPECIFIC_IO(Buf, &(x)), \
DateTime: TO_TYPE_SPECIFIC_IO(DateTime, &(x)), \
- In
Io.h:326:
(x), \
TypeSpecificIO: (x), \
Str: TO_TYPE_SPECIFIC_IO(Str, (void *)&(x)), \
Buf: TO_TYPE_SPECIFIC_IO(Buf, (void *)&(x)), \
DateTime: TO_TYPE_SPECIFIC_IO(DateTime, (void *)&(x)), \
- In
Io.h:373:
/// TAGS: Str, Format, Pad
///
bool StrPad(Str *o, size width, Alignment align, size content_len);
#if FEATURE_FLOAT- In
Io.h:395:
/// TAGS: Float, Format, Decimal
///
bool float_try_to_decimal_str(Str *out, Float *value, u32 precision, bool has_precision, Allocator *alloc);
# define FloatTryToDecimalStr(...) OVERLOAD(FloatTryToDecimalStr, __VA_ARGS__)
# define FloatTryToDecimalStr_4(out, value, precision, has_precision) \- In
Io.h:421:
///
bool float_try_to_scientific_str(
Str *out,
Float *value,
u32 precision,- In
Io.h:736:
// not for direct use
bool _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
bool _write_Buf(Str *o, FmtInfo *fmt_info, Buf *b);
bool _write_DateTime(Str *o, FmtInfo *fmt_info, DateTime *dt);- In
Io.h:737:
// not for direct use
bool _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
bool _write_Buf(Str *o, FmtInfo *fmt_info, Buf *b);
bool _write_DateTime(Str *o, FmtInfo *fmt_info, DateTime *dt);
bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);- In
Io.h:738:
bool _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
bool _write_Buf(Str *o, FmtInfo *fmt_info, Buf *b);
bool _write_DateTime(Str *o, FmtInfo *fmt_info, DateTime *dt);
bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);- In
Io.h:739:
bool _write_Buf(Str *o, FmtInfo *fmt_info, Buf *b);
bool _write_DateTime(Str *o, FmtInfo *fmt_info, DateTime *dt);
bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);- In
Io.h:740:
bool _write_DateTime(Str *o, FmtInfo *fmt_info, DateTime *dt);
bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);- In
Io.h:741:
bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);- In
Io.h:742:
bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);- In
Io.h:743:
bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);- In
Io.h:744:
bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);- In
Io.h:745:
bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
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);- In
Io.h:746:
bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
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);- 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:748:
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);
bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);- In
Io.h:749:
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);
bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
#if FEATURE_FLOAT- In
Io.h:750:
bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg);
bool _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
#if FEATURE_FLOAT
bool _write_Float(Str *o, FmtInfo *fmt_info, Float *value);- In
Io.h:752:
bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
#if FEATURE_FLOAT
bool _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
#endif
#if FEATURE_BITVEC- In
Io.h:755:
#endif
#if FEATURE_BITVEC
bool _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
#endif
#if FEATURE_INT- In
Io.h:758:
#endif
#if FEATURE_INT
bool _write_Int(Str *o, FmtInfo *fmt_info, Int *value);
#endif- 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
Str.h:11:
// clang-format off
#include "Str/Type.h"
#include "Str/Init.h"
#include "Str/Insert.h"- In
Str.h:12:
// clang-format off
#include "Str/Type.h"
#include "Str/Init.h"
#include "Str/Insert.h"
#include "Str/Remove.h"- In
Str.h:13:
#include "Str/Type.h"
#include "Str/Init.h"
#include "Str/Insert.h"
#include "Str/Remove.h"
#include "Str/Access.h"- In
Str.h:14:
#include "Str/Init.h"
#include "Str/Insert.h"
#include "Str/Remove.h"
#include "Str/Access.h"
#include "Str/Memory.h"- In
Str.h:15:
#include "Str/Insert.h"
#include "Str/Remove.h"
#include "Str/Access.h"
#include "Str/Memory.h"
#include "Str/Convert.h"- In
Str.h:16:
#include "Str/Remove.h"
#include "Str/Access.h"
#include "Str/Memory.h"
#include "Str/Convert.h"
#include "Str/Foreach.h"- In
Str.h:17:
#include "Str/Access.h"
#include "Str/Memory.h"
#include "Str/Convert.h"
#include "Str/Foreach.h"
#include "Str/Ops.h"- In
Str.h:18:
#include "Str/Memory.h"
#include "Str/Convert.h"
#include "Str/Foreach.h"
#include "Str/Ops.h"
#include "Str/Private.h"- In
Str.h:19:
#include "Str/Convert.h"
#include "Str/Foreach.h"
#include "Str/Ops.h"
#include "Str/Private.h"
// clang-format on
- In
Str.h:20:
#include "Str/Foreach.h"
#include "Str/Ops.h"
#include "Str/Private.h"
// clang-format on
- In
Convert.h:12:
#include "Access.h"
#include "Private.h"
#include <Misra/Std/Container/Str.h>
#ifdef __cplusplus- In
Convert.h:86:
///
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) \
_Generic((text), Str *: float_try_from_str_str, Zstr: float_try_from_str_zstr, char *: float_try_from_str_zstr)( \- 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:105:
///
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__)
#define FloatFromStr_1(text) \- 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
Convert.h:118:
)
bool float_try_to_str(Str *out, const Float *value, Allocator *alloc);
Str float_to_str(const Float *value, Allocator *alloc);- In
Convert.h:119:
bool float_try_to_str(Str *out, const Float *value, Allocator *alloc);
Str float_to_str(const Float *value, Allocator *alloc);
#ifdef __cplusplus- In
Pattern.h:11:
#include "Type.h"
#include <Misra/Std/Container/Str/Type.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
Pattern.h:257:
///
bool bitvec_regex_match_zstr(BitVec *bv, Zstr pattern);
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)( \- 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:13:
#include "Type.h"
#include <Misra/Types.h>
#include <Misra/Std/Container/Str.h>
#ifdef __cplusplus- In
Convert.h:31:
/// TAGS: BitVec, Convert, String, Allocator
///
bool bitvec_try_to_str(Str *out, BitVec *bv, Allocator *alloc);
///
- In
Convert.h:44:
/// TAGS: BitVec, Convert, String, Allocator
///
Str bitvec_to_str(BitVec *bv, Allocator *alloc);
///
- In
Convert.h:59:
///
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__)
#define BitVecTryFromStr_2(out, str) \- 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:86:
///
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__)
#define BitVecFromStr_1(str) \- 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:12:
#include "Access.h"
#include "Private.h"
#include <Misra/Std/Container/Str.h>
#ifdef __cplusplus- In
Convert.h:183:
///
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) \
_Generic((digits), Str *: int_try_from_str_radix_str, Zstr: int_try_from_str_radix_zstr, char *: int_try_from_str_radix_zstr)( \- 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:203:
///
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__)
#define IntFromStrRadix_2(digits, radix) \- 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:236:
/// TAGS: Int, Convert, String, Radix, Allocator
///
bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc);
Str int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc);- In
Convert.h:237:
///
bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc);
Str int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc);
///
- In
Convert.h:259:
///
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) \
_Generic((decimal), Str *: int_try_from_str_str, Zstr: int_try_from_str_zstr, char *: int_try_from_str_zstr)( \- 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:278:
///
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__)
#define IntFromStr_1(decimal) \- 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:307:
/// TAGS: Int, Convert, String, Decimal, Allocator
///
bool int_try_to_str(Str *out, const Int *value, Allocator *alloc);
Str int_to_str(const Int *value, Allocator *alloc);- In
Convert.h:308:
///
bool int_try_to_str(Str *out, const Int *value, Allocator *alloc);
Str int_to_str(const Int *value, Allocator *alloc);
///
- In
Convert.h:330:
///
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) \
_Generic((binary), Str *: int_try_from_binary_str, Zstr: int_try_from_binary_zstr, char *: int_try_from_binary_zstr)( \- 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:349:
///
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__)
#define IntFromBinary_1(binary) \- 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:379:
/// TAGS: Int, Convert, Binary
///
Str IntToBinary(const Int *value);
///
- In
Convert.h:401:
///
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) \
_Generic((octal), Str *: int_try_from_oct_str_str, Zstr: int_try_from_oct_str_zstr, char *: int_try_from_oct_str_zstr)( \- 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:420:
///
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__)
#define IntFromOctStr_1(octal) \- 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:450:
/// TAGS: Int, Convert, Oct
///
Str IntToOctStr(const Int *value);
///
- In
Convert.h:474:
///
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) \
_Generic((hex), Str *: int_try_from_hex_str_str, Zstr: int_try_from_hex_str_zstr, char *: int_try_from_hex_str_zstr)( \- 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:493:
///
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__)
#define IntFromHexStr_1(hex) \- 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
Convert.h:523:
/// TAGS: Int, Convert, Hex
///
Str IntToHexStr(const Int *value);
#ifdef __cplusplus- In
Type.h:26:
/// TAGS: Str, Type, Vector
///
typedef Vec(Str) Strs;
///
- In
Type.h:40:
/// TAGS: Str, Validate, API
///
void ValidateStr(const Str *s);
///
- In
Convert.h:61:
/// TAGS: Str, Convert, U64
///
Str *StrFromU64(Str *str, u64 value, const StrIntFormat *config);
///
- In
Convert.h:78:
/// TAGS: Str, Convert, I64
///
Str *StrFromI64(Str *str, i64 value, const StrIntFormat *config);
///
- In
Convert.h:95:
/// TAGS: Str, Convert, F64
///
Str *StrFromF64(Str *str, f64 value, const StrFloatFormat *config);
///
- In
Convert.h:109:
/// TAGS: Str, Convert, U64
///
bool StrToU64(const Str *str, u64 *value, const StrParseConfig *config);
///
- In
Convert.h:123:
/// TAGS: Str, Convert, I64
///
bool StrToI64(const Str *str, i64 *value, const StrParseConfig *config);
///
- In
Convert.h:137:
/// TAGS: Str, Convert, F64
///
bool StrToF64(const Str *str, f64 *value, const StrParseConfig *config);
- 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
Init.h:174:
#define StrInit(...) OVERLOAD(StrInit, __VA_ARGS__)
#ifdef __cplusplus
# define StrInit_0() (Str VecInit_1(MisraScope))
# define StrInit_1(alloc_ptr) (Str VecInit_1(alloc_ptr))
#else- In
Init.h:175:
#ifdef __cplusplus
# define StrInit_0() (Str VecInit_1(MisraScope))
# define StrInit_1(alloc_ptr) (Str VecInit_1(alloc_ptr))
#else
# define StrInit_0() ((Str)VecInit_1(MisraScope))- In
Init.h:177:
# define StrInit_1(alloc_ptr) (Str VecInit_1(alloc_ptr))
#else
# define StrInit_0() ((Str)VecInit_1(MisraScope))
# define StrInit_1(alloc_ptr) ((Str)VecInit_1(alloc_ptr))
#endif- In
Init.h:178:
#else
# define StrInit_0() ((Str)VecInit_1(MisraScope))
# define StrInit_1(alloc_ptr) ((Str)VecInit_1(alloc_ptr))
#endif- In
Init.h:235:
for (char UNPL(_d)[(ne) + 1] = {0}, *UNPL(_loop) = UNPL(_d); UNPL(_loop); \
MemSet(UNPL(_d), 0, sizeof(UNPL(_d))), UNPL(_loop) = NULL) \
for (Str name = {.length = 0, \
.capacity = (ne), \
.data = UNPL(_d), \
- In
Init.h:255:
/// TAGS: Str, Deinit, Init
///
void StrDeinit(Str *str);
///
- In
Init.h:280:
/// TAGS: Str, Init, Copy
///
bool StrInitCopy(Str *dst, const Str *src);
///
- In
Ops.h:81:
_Generic( \
(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:112:
_Generic( \
(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:148:
_Generic( \
(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:178:
_Generic( \
(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:207:
_Generic( \
(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:242:
_Generic( \
(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:273:
_Generic( \
(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:311:
_Generic( \
(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:345:
_Generic( \
(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:371:
_Generic( \
(key), \
Str *: str_split_str ((s), (const Str *)(key)), \
Zstr: str_split_zstr((s), (Zstr)(key)), \
char *: str_split_zstr((s), (Zstr)(key)) \
- In
Debug.h:59:
#include <Misra/Std/Allocator/Page.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Sys/Backtrace.h>- In
Debug.h:412:
/// TAGS: Allocator, Debug, Reporting
///
void DebugAllocatorReportLeaks(DebugAllocator *self, Str *out);
#ifdef __cplusplus- In
Backtrace.h:45:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Types.h>- In
Backtrace.h:141:
/// TAGS: Backtrace, Format, Trace, Stack
///
void format_stack_trace_raw(Str *out, const StackFrame *frames, size count, Allocator *alloc);
///
- In
Backtrace.h:153:
/// TAGS: Backtrace, Format, Trace, Stack
///
void format_stack_trace_vec(Str *out, const StackFrames *frames, Allocator *alloc);
#if FEATURE_SYS_SYMRESOLVE- In
Backtrace.h:168:
/// TAGS: Backtrace, Format, Trace, Symbol, Stack
///
void format_stack_trace_with_raw(Str *out, const StackFrame *frames, size count, SymbolResolver *resolver);
void format_stack_trace_with_vec(Str *out, const StackFrames *frames, SymbolResolver *resolver);
#endif- In
Backtrace.h:169:
///
void format_stack_trace_with_raw(Str *out, const StackFrame *frames, size count, SymbolResolver *resolver);
void format_stack_trace_with_vec(Str *out, const StackFrames *frames, SymbolResolver *resolver);
#endif- In
Socket.h:27:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Types.h>- In
Socket.h:157:
/// TAGS: Socket, Parse, Address
///
bool socket_addr_parse_str(SocketAddr *out, const Str *spec, SocketKind kind);
#define SocketAddrParse(out, spec, kind) \
_Generic( \- In
Socket.h:161:
_Generic( \
(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:181:
/// TAGS: Socket, Address, Format
///
Str socket_addr_format(const SocketAddr *addr, Allocator *alloc);
#define SocketAddrFormat(...) OVERLOAD(SocketAddrFormat, __VA_ARGS__)
#define SocketAddrFormat_1(addr) socket_addr_format((addr), MisraScope)- In
Dir.h:15:
#define MISRA_SYS_DIR_H
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Zstr.h>- In
Dir.h:49:
typedef struct DirEntry {
DirEntryType type;
Str name;
} DirEntry;- 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: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: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:173:
_Generic( \
(path), \
Str *: file_remove((Zstr)StrBegin((Str *)(path))), \
Zstr: file_remove((Zstr)(path)), \
char *: file_remove((Zstr)(path)) \
- 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:219:
_Generic( \
(path), \
Str *: dir_create((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_create((Zstr)(path)), \
char *: dir_create((Zstr)(path)) \
- 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:262:
_Generic( \
(path), \
Str *: dir_remove_all((Zstr)StrBegin((Str *)(path))), \
Zstr: dir_remove_all((Zstr)(path)), \
char *: dir_remove_all((Zstr)(path)) \
- In
PdbCache.h:29:
#include <Misra/Parsers/Pe.h>
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Str/Type.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Types.h>- In
PdbCache.h:34:
typedef struct PdbCacheEntry {
Str module_path; // owned; cleaned via StrDeinit
Pe pe;
Pdb pdb;- In
PdbCache.h:106:
bool pdb_cache_resolve_str(
PdbCache *self,
const Str *module_path,
u64 module_base,
u64 runtime_ip,- In
PdbCache.h:115:
_Generic( \
(module_path), \
Str *: pdb_cache_resolve_str( \
(self), \
(const Str *)(module_path), \
- In
PdbCache.h:117:
Str *: pdb_cache_resolve_str( \
(self), \
(const Str *)(module_path), \
(module_base), \
(runtime_ip), \
- In
Proc.h:14:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Types.h>- In
Proc.h:188:
/// TAGS: Proc, Write, Stdio
///
i32 ProcWriteToStdin(Proc *proc, const Str *buf);
///
- In
Proc.h:213:
/// TAGS: Proc, Read, Stdio
///
i32 ProcReadFromStdout(Proc *proc, Str *buf);
///
- In
Proc.h:226:
/// TAGS: Proc, Read, Stdio
///
i32 ProcReadFromStderr(Proc *proc, Str *buf);
///
- In
Proc.h:262:
/// TAGS: Proc, Get, Executable, Path
///
Str *GetCurrentExecutablePath(Str *exe_path);
///
- In
Proc.h:286:
#define ProcReadFromStdoutFmt(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
ProcReadFromStdout((p), &UNPL(buf)); \
Zstr UNPL(in) = StrBegin(&UNPL(buf)); \- In
Proc.h:313:
#define ProcReadFromStderrFmt(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
ProcReadFromStderr((p), &UNPL(buf)); \
Zstr UNPL(in) = StrBegin(&UNPL(buf)); \- In
Proc.h:340:
#define ProcWriteToStdinFmt(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
StrAppendFmt(&UNPL(buf), __VA_ARGS__); \
ProcWriteToStdin((p), &UNPL(buf)); \- In
Proc.h:365:
#define ProcWriteToStdinFmtLn(p, ...) \
do { \
Str UNPL(buf) = StrInit(); \
StrAppendFmt(&UNPL(buf), __VA_ARGS__); \
StrPushBackR(&UNPL(buf), '\n'); \- In
Dns.h:30:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Sys/Socket.h>- In
Dns.h:47:
///
typedef struct HostsEntry {
Str name;
u8 ip[16];
bool is_ipv6;- In
Dns.h:115:
/// TAGS: Dns, Resolve, Init, Hosts
///
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__)- In
Dns.h:121:
#define DnsResolverAddPath_3(self, p, n) dns_resolver_add_path_zstr((self), (p), (n))
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__)- In
Dns.h:127:
#define DnsResolverAddHostsPath_3(self, p, n) dns_resolver_add_hosts_path_zstr((self), (p), (n))
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__)- In
Dns.h:194:
///
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) \
_Generic( \- In
Dns.h:198:
_Generic( \
(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:218:
///
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) \
_Generic( \- In
Dns.h:222:
_Generic( \
(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:240:
///
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:256:
DnsAddrs *: _Generic( \
(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:262:
SocketAddr *: _Generic( \
(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
MachoCache.h:27:
#include <Misra/Parsers/MachO.h>
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Str/Type.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Types.h>- In
MachoCache.h:32:
typedef struct MachoCacheEntry {
Str module_path;
u64 slide;
Macho main;- In
MachoCache.h:110:
bool macho_cache_resolve_str(
MachoCache *self,
const Str *module_path,
u64 slide,
u64 runtime_ip,- In
MachoCache.h:119:
_Generic( \
(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
Http.h:40:
///
typedef struct HttpHeader {
Str key;
Str value;
} HttpHeader;- In
Http.h:41:
typedef struct HttpHeader {
Str key;
Str value;
} HttpHeader;- In
Http.h:97:
///
HttpHeader *http_headers_find_zstr(HttpHeaders *headers, Zstr key);
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)( \- 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:228:
Allocator *allocator;
HttpRequestMethod method;
Str url;
HttpHeaders headers;
} HttpRequest;- In
Http.h:266:
_Generic( \
(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:293:
HttpResponseCode status_code;
HttpHeaders headers;
Str body;
} HttpResponse;- In
Http.h:342:
/// TAGS: Http, Respond, Html
///
HttpResponse *HttpRespondWithHtml(HttpResponse *response, HttpResponseCode status, const Str *html);
#if FEATURE_FILE- In
Http.h:358:
_Generic( \
(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
KvConfig.h:34:
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Utility/StrIter.h>
#include <Misra/Std/Zstr.h>- In
KvConfig.h:43:
// translation-unit-visible spot so the public header and the
// implementation agree on the layout.
typedef Map(Str, Str) KvConfig;
// Private backends. Included AFTER the KvConfig typedef so the
- In
KvConfig.h:152:
/// TAGS: KvConfig, Parse, Key, Read
///
StrIter KvConfigReadKey(StrIter si, Str *key);
///
- In
KvConfig.h:168:
/// TAGS: KvConfig, Parse, Value, Read
///
StrIter KvConfigReadValue(StrIter si, Str *value);
///
- In
KvConfig.h:184:
/// TAGS: KvConfig, Parse, Pair, Read
///
StrIter KvConfigReadPair(StrIter si, Str *key, Str *value);
///
- 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:31:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Zstr.h>- In
Pdb.h:108:
// is a borrowed pointer into here; pool and entries are freed
// together in `PdbDeinit`.
Str name_pool;
} Pdb;- 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: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
Dwarf.h:27:
#include <Misra/Parsers/Elf.h>
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Types.h>- In
Dwarf.h:80:
Allocator *allocator;
DwarfLineEntries entries;
Str string_pool;
} DwarfLines;- In
Dwarf.h:344:
Allocator *allocator;
DwarfFunctionEntries entries;
Str string_pool;
} DwarfFunctions;- In
Elf.h:22:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Zstr.h>- 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: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: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:24:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Zstr.h>- 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: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: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:32:
#define MISRA_PARSERS_JSON_H
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Utility/StrIter.h>- In
JSON.h:153:
/// TAGS: JSON, String, Parsing, EscapeSequences
///
StrIter JReadString(StrIter si, Str *str);
///
- In
JSON.h:249:
#define JR_STR(si, str) \
do { \
Str UNPL(my_str) = StrInit(); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \- In
JSON.h:272:
do { \
if (!StrCmp(&key, (k))) { \
Str UNPL(my_str) = StrInit(); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \
- In
JSON.h:570:
\
\
Str key = StrInit(); \
\
/* key start */ \
- In
JSON.h:923:
#define JW_STR(j, s) \
do { \
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) ""); \- In
MachO.h:28:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Zstr.h>- 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: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: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:24:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Vec.h>- In
Dns.h:71:
///
typedef struct DnsRecord {
Str name;
DnsType type;
u16 rclass;- In
Dns.h:77:
u8 ipv4[4];
u8 ipv6[16];
Str target;
DnsWireBuf rdata;
} DnsRecord;- In
Dns.h:125:
_Generic( \
(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
ProcMaps.h:22:
#include <Misra/Std/Allocator.h>
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/File.h>- In
ProcMaps.h:50:
typedef struct ProcMaps {
Str raw; // owns the raw /proc/self/maps bytes
ProcMapEntries entries; // pointers into `raw`
u64 min_addr; // lowest `start` across all entries (0 if none)
- In
ProcMaps.h:103:
(src), \
File *: proc_maps_load_from_file((out), (File *)(src), MisraScope), \
Str *: proc_maps_load_from_bytes((out), (const u8 *)StrBegin((Str *)(src)), StrLen((Str *)(src)), MisraScope), \
Buf *: proc_maps_load_from_bytes((out), BufData((Buf *)(src)), BufLength((Buf *)(src)), MisraScope) \
)- In
ProcMaps.h:110:
(src), \
File *: proc_maps_load_from_file((out), (File *)(src), ALLOCATOR_OF(alloc)), \
Str *: proc_maps_load_from_bytes( \
(out), \
(const u8 *)StrBegin((Str *)(src)), \
- In
ProcMaps.h:112:
Str *: proc_maps_load_from_bytes( \
(out), \
(const u8 *)StrBegin((Str *)(src)), \
StrLen((Str *)(src)), \
ALLOCATOR_OF(alloc) \
- In
ProcMaps.h:113:
(out), \
(const u8 *)StrBegin((Str *)(src)), \
StrLen((Str *)(src)), \
ALLOCATOR_OF(alloc) \
), \
- In
VecStr.h:11:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Types.h>- In
VecStr.h:16:
// Vec(Str) typedef
typedef Vec(Str) StrVec;
// Vec(Str) function enumeration
- In
VecStr.c:10:
#include "VecStr.h"
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>- In
VecStr.c:23:
// `GenericCopyInit` signature `(void *dst, const void *src, const Allocator *)`.
static bool str_clone_init(void *dst_ptr, const void *src_ptr, const Allocator *alloc) {
const Str *src = (const Str *)src_ptr;
// StrBegin on an empty Str returns NULL, which str_try_init_from_cstr
// treats as a fatal arg violation. An empty source clones to an
- In
VecStr.c:27:
// treats as a fatal arg violation. An empty source clones to an
// empty fresh Str.
Str copy = (StrLen(src) == 0) ? StrInit((Allocator *)alloc) :
StrInitFromCstr(StrBegin(src), StrLen(src), (Allocator *)alloc);
*(Str *)dst_ptr = copy;- In
VecStr.c:29:
Str copy = (StrLen(src) == 0) ? StrInit((Allocator *)alloc) :
StrInitFromCstr(StrBegin(src), StrLen(src), (Allocator *)alloc);
*(Str *)dst_ptr = copy;
return true;
}- In
VecStr.c:34:
// Generate a Str from fuzz input data
static Str generate_str_from_input(
const uint8_t *data,
size_t *offset,- In
VecStr.c:46:
// Create Str with capacity
Str str = StrInit(alloc);
// Fill with data or generate simple pattern if not enough input
- In
VecStr.c:88:
switch (func) {
case VEC_STR_PUSH_BACK : {
Str str = generate_str_from_input(data, offset, data_size, 32, alloc);
VecPushBack(vec, str);
break;- In
VecStr.c:94:
case VEC_STR_PUSH_FRONT : {
Str str = generate_str_from_input(data, offset, data_size, 32, alloc);
VecPushFront(vec, str);
break;- In
VecStr.c:101:
case VEC_STR_POP_BACK : {
if (VecLen(vec) > 0) {
Str str;
VecPopBack(vec, &str);
// StrDeinit is called automatically by the vector
- In
VecStr.c:110:
case VEC_STR_POP_FRONT : {
if (VecLen(vec) > 0) {
Str str;
VecPopFront(vec, &str);
// StrDeinit is called automatically by the vector
- In
VecStr.c:120:
if (*offset + 4 <= data_size) {
size_t index = extract_u32(data, offset, data_size) % (VecLen(vec) + 1);
Str str = generate_str_from_input(data, offset, data_size, 32, alloc);
VecInsert(vec, str, index);
}- In
VecStr.c:129:
if (VecLen(vec) > 0 && *offset + 4 <= data_size) {
size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
Str str;
VecRemove(vec, &str, index);
// StrDeinit is called automatically by the vector
- In
VecStr.c:148:
if (VecLen(vec) > 0 && *offset + 4 <= data_size) {
size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
Str str = VecAt(vec, index);
(void)str; // Use the result to avoid warnings
}- In
VecStr.c:162:
case VEC_STR_FIRST : {
if (VecLen(vec) > 0) {
Str first = VecFirst(vec);
(void)first; // Use the result to avoid warnings
}- In
VecStr.c:170:
case VEC_STR_LAST : {
if (VecLen(vec) > 0) {
Str last = VecLast(vec);
(void)last; // Use the result to avoid warnings
}- In
VecStr.c:194:
if (new_size > old_size) {
for (size_t i = old_size; i < new_size; i++) {
Str str = generate_str_from_input(data, offset, data_size, 16, alloc);
VecAt(vec, i) = str;
}- In
VecStr.c:243:
// moves each Str into the vector and zeros the source slot,
// so no per-element StrDeinit is needed here.
Str temp_strings[10];
for (size_t i = 0; i < count; i++) {
temp_strings[i] = generate_str_from_input(data, offset, data_size, 16, alloc);- In
VecStr.c:257:
size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
size_t count = extract_u32(data, offset, data_size) % (VecLen(vec) - index + 1);
VecRemoveRange(vec, (Str *)NULL, index, count);
}
break;- In
VecStr.c:274:
if (*offset + 4 <= data_size) {
size_t index = extract_u32(data, offset, data_size) % (VecLen(vec) + 1);
Str str = generate_str_from_input(data, offset, data_size, 32, alloc);
VecInsertFast(vec, str, index);
}- In
VecStr.c:283:
if (VecLen(vec) > 0 && *offset + 4 <= data_size) {
size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
Str str;
VecRemoveFast(vec, &str, index);
// StrDeinit is called automatically by the vector
- In
VecStr.c:294:
size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
size_t count = extract_u32(data, offset, data_size) % (VecLen(vec) - index + 1);
VecRemoveRangeFast(vec, (Str *)NULL, index, count);
}
break;- In
VecStr.c:314:
// L-form VecPushBackArr moves each Str into the vector and
// zeros the source slot, so no per-element cleanup needed.
Str temp_strings[10];
for (size_t i = 0; i < count; i++) {
temp_strings[i] = generate_str_from_input(data, offset, data_size, 16, alloc);- In
VecStr.c:330:
// L-form VecPushFrontArr moves each Str into the vector and
// zeros the source slot, so no per-element cleanup needed.
Str temp_strings[10];
for (size_t i = 0; i < count; i++) {
temp_strings[i] = generate_str_from_input(data, offset, data_size, 16, alloc);- In
VecStr.c:346:
// L-form VecPushFrontArrFast moves each Str into the vector
// and zeros the source slot, so no per-element cleanup needed.
Str temp_strings[10];
for (size_t i = 0; i < count; i++) {
temp_strings[i] = generate_str_from_input(data, offset, data_size, 16, alloc);- In
VecStr.c:364:
case VEC_STR_BEGIN : {
if (VecLen(vec) > 0) {
Str *begin = VecBegin(vec);
(void)begin; // Use the result to avoid warnings
}- In
VecStr.c:372:
case VEC_STR_END : {
if (VecLen(vec) > 0) {
Str *end = VecEnd(vec);
(void)end; // Use the result to avoid warnings
}- In
VecStr.c:381:
if (VecLen(vec) > 0 && *offset + 4 <= data_size) {
size_t index = extract_u32(data, offset, data_size) % VecLen(vec);
Str *ptr = VecPtrAt(vec, index);
(void)ptr; // Use the result to avoid warnings
}- In
VecStr.c:395:
size_t count = extract_u32(data, offset, data_size) % 5;
for (size_t i = 0; i < count; i++) {
Str str = generate_str_from_input(data, offset, data_size, 16, alloc);
VecPushBack(&temp, str);
}- In
VecStr.c:412:
// L-form VecInsertRangeFast moves each Str into the vector and
// zeros the source slot, so no per-element cleanup needed.
Str temp_strings[10];
for (size_t i = 0; i < count; i++) {
temp_strings[i] = generate_str_from_input(data, offset, data_size, 16, alloc);- In
VecStr.c:458:
size_t count = extract_u32(data, offset, data_size) % 5;
for (size_t i = 0; i < count; i++) {
Str str = generate_str_from_input(data, offset, data_size, 16, alloc);
VecPushBack(&temp, str);
StrDeinit(&str);- In
Sys.c:239:
// on the first byte via `reserve_vec`, regardless of platform; it only
// stayed hidden because the errno paths that reach here are rare.
Str *StrError(i32 eno, Str *err_str) {
ValidateStr(err_str);
StrClear(err_str);- In
Log.c:29:
#include <Misra/Std/Allocator/Heap.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Io.h>- In
Log.c:54:
HeapAllocator h = HeapAllocatorInit();
Str full = StrInit(&h);
StrAppendFmt(&full, "[{}] [{}:{}] {}\n", (Zstr)NAMES[type], (Zstr)tag, line, (Zstr)msg);- In
Log.c:67:
StackFrame frames[32];
size n = CaptureStackTrace(frames, 32, 1);
Str trace = StrInit(&h);
// FormatStackTrace takes `Allocator *` -- legitimate erasure
// boundary; pass at the call site, no intermediate variable.
- In
File.c:10:
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Log.h>- In
ArgParse.c:135:
}
case ARG_KIND_STR : {
Str *s = (Str *)target;
StrClear(s);
StrPushBackMany(s, value);- In
ArgParse.c:266:
// long-flag name upper-cased and hyphens swapped for underscores. For
// 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) {- In
ArgParse.c:287:
// Build the " -l, --listen <LISTEN>" left column for one spec. Returns
// the visible width so the caller can pad to a shared right margin.
static u64 spec_format_left(const ArgSpec *sp, Str *out) {
u64 start = StrLen(out);
StrPushBackMany(out, " ");- In
ArgParse.c:326:
// Usage line: "usage: name [OPTIONS] --req <REQ>... <POS>..."
Str usage = StrInit(self->alloc);
StrPushBackMany(&usage, "usage: ");
StrPushBackMany(&usage, self->name);- In
ArgParse.c:367:
// padding. We allocate one Str per spec to remember its left side
// so we don't have to format it twice.
Str left_col[64];
u64 left_w[64];
u64 max_w = 0;- In
Io.c:14:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Buf.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Io.h>- In
Io.c:58:
}
static bool _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);- In
Io.c:59:
static bool _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
static bool _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);- In
Io.c:60:
static bool _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
static bool _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);- In
Io.c:61:
static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
static bool _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);
static Zstr _read_r8(Zstr i, FmtInfo *fmt_info, u8 *v);- In
Io.c:237:
// first digit, producing e.g. "-0000042" rather than "0000-0042".
// width and content_len are measured in chars (sign counts as content).
static bool pad_numeric_zeros(Str *o, size content_start, size width, size content_len) {
if (content_len >= width) {
return true;- In
Io.c:256:
}
bool StrPad(Str *o, size width, Alignment align, size content_len) {
if (content_len >= width)
return true;- 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:499:
// sense. Library-internal scratch keeps the debug-build instrumentation.
DefaultAllocator scratch = DefaultAllocatorInit();
Str tmp = StrInit(&scratch);
bool ok = str_append_fmt(&tmp, fmt, args, argc);
if (ok) {- In
Io.c:520:
bool f_write_fmt(File *stream, Zstr fmtstr, TypeSpecificIO *argv, u64 argc, bool append_newline) {
Str out;
bool ok = true;
// DefaultAllocator: rendered line size is caller-controlled (depends on the
- In
Io.c:971:
// raw output. Returns the index of the next byte after the directive,
// or 0 on a failed write (fmt error / OOM).
static bool render_one_raw_field(Str *out, FmtInfo *fmt_info, TypeSpecificIO *io, u64 arg_index) {
if (!io->writer) {
LOG_FATAL("buf_*_fmt: argument {} has no writer", arg_index);- 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:1086:
// The raw-write helpers (_write_rN) emit into a Str. Buf is Vec(u8)
// and Str is Vec(char); both have identical layout, so we alias.
return render_binary_fmt((Str *)out, fmtstr, argv, argc);
}- In
Io.c:1094:
}
VecClear(out);
return render_binary_fmt((Str *)out, fmtstr, argv, argc);
}- In
Io.c:1106:
// DefaultAllocator: rendered size is caller-controlled (open-ended).
DefaultAllocator scratch = DefaultAllocatorInit();
Str tmp = StrInit(&scratch);
bool ok = render_binary_fmt(&tmp, fmtstr, argv, argc);
if (ok) {- In
Io.c:1136:
}
Str buffer = StrInit(&scratch);
i32 fd = FileFd(file);- In
Io.c:1197:
// characters look identical on LE and BE hosts -- the format spec
// implies a wire-style representation independent of host endianness.
static inline bool write_int_as_chars(Str *o, FormatFlags flags, u64 value, size num_bytes) {
if (!o || !num_bytes || num_bytes > 8) {
LOG_FATAL("Invalid arguments");- 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:1317:
}
static bool float_fmt_append_exponent(Str *out, i64 exponent, bool uppercase) {
char sign = exponent < 0 ? '-' : '+';
u64 magnitude = exponent < 0 ? (u64)(-(exponent + 1)) + 1 : (u64)exponent;- In
Io.c:1362:
}
bool float_try_to_decimal_str(Str *out, Float *value, u32 precision, bool has_precision, Allocator *alloc) {
Str canonical;
Str result;- In
Io.c:1363:
bool float_try_to_decimal_str(Str *out, Float *value, u32 precision, bool has_precision, Allocator *alloc) {
Str canonical;
Str result;- In
Io.c:1364:
bool float_try_to_decimal_str(Str *out, Float *value, u32 precision, bool has_precision, Allocator *alloc) {
Str canonical;
Str result;
if (!out) {- In
Io.c:1450:
bool float_try_to_scientific_str(
Str *out,
Float *value,
u32 precision,- In
Io.c:1457:
Allocator *alloc
) {
Str digits;
Str result;
u64 frac_digits = 0;- In
Io.c:1458:
) {
Str digits;
Str result;
u64 frac_digits = 0;
i64 exponent = 0;- In
Io.c:1653:
// Buf is Vec(u8), Str is Vec(char) -- identical layout, so Buf text I/O
// aliases the Str path (same (Str *) cast buf_append_fmt relies on).
bool _write_Buf(Str *o, FmtInfo *fmt_info, Buf *b) {
return _write_Str(o, fmt_info, (Str *)b);
}- In
Io.c:1654:
// aliases the Str path (same (Str *) cast buf_append_fmt relies on).
bool _write_Buf(Str *o, FmtInfo *fmt_info, Buf *b) {
return _write_Str(o, fmt_info, (Str *)b);
}
Zstr _read_Buf(Zstr i, FmtInfo *fmt_info, Buf *b) {- In
Io.c:1657:
}
Zstr _read_Buf(Zstr i, FmtInfo *fmt_info, Buf *b) {
return _read_Str(i, fmt_info, (Str *)b);
}- In
Io.c:1665:
// fraction is exactly the nanosecond count, so it parses back as a plain
// integer. Writer and reader share the layout, so a value round-trips.
bool _write_DateTime(Str *o, FmtInfo *fmt_info, DateTime *dt) {
(void)fmt_info;
if (!o || !dt) {- In
Io.c:1754:
}
bool _write_Str(Str *o, FmtInfo *fmt_info, Str *s) {
if (!o || !s || !fmt_info) {
LOG_FATAL("Invalid arguments");- 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:1929:
}
bool _write_ZstrAlloc(Str *o, FmtInfo *fmt_info, ZstrIOArg *arg) {
Zstr *value = NULL;- In
Io.c:1940:
}
bool _write_u64(Str *o, FmtInfo *fmt_info, u64 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1998:
}
bool _write_u32(Str *o, FmtInfo *fmt_info, u32 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:2012:
}
bool _write_u16(Str *o, FmtInfo *fmt_info, u16 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:2026:
}
bool _write_u8(Str *o, FmtInfo *fmt_info, u8 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:2040:
}
bool _write_i64(Str *o, FmtInfo *fmt_info, i64 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:2095:
}
bool _write_i32(Str *o, FmtInfo *fmt_info, i32 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:2109:
}
bool _write_i16(Str *o, FmtInfo *fmt_info, i16 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:2123:
}
bool _write_i8(Str *o, FmtInfo *fmt_info, i8 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:2137:
}
bool _write_f64(Str *o, FmtInfo *fmt_info, f64 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:2220:
}
bool _write_f32(Str *o, FmtInfo *fmt_info, f32 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:2239:
#if FEATURE_FLOAT
bool _write_Float(Str *o, FmtInfo *fmt_info, Float *value) {
size start_len = 0;
Str temp;- In
Io.c:2241:
bool _write_Float(Str *o, FmtInfo *fmt_info, Float *value) {
size start_len = 0;
Str temp;
if (!o || !fmt_info || !value) {- In
Io.c:2369:
}
Zstr _read_Str(Zstr i, FmtInfo *fmt_info, Str *s) {
if (!i || !s)
LOG_FATAL("Invalid arguments");- In
Io.c:2507:
// (when `allow_float` is false) any decimal/exponent residue, before
// the slice is handed to the typed `StrToU64` / `StrToI64` parser.
static bool is_valid_numeric_string(const Str *str, bool allow_float) {
if (!str || !StrBegin(str))
return false;- In
Io.c:2680:
}
Str temp = StrInitFromCstr(start, (size)(StrIterIndex(&si) - StrIterIndex(&saved)), &scratch);
// Special-value tokens (`inf`, `nan`, ...) carry through the
- In
Io.c:2739:
size pos = StrIterIndex(&si) - StrIterIndex(&saved);
Str temp = StrInitFromCstr(start, pos, &scratch);
if (!is_valid_numeric_string(&temp, true)) {- In
Io.c:2800:
size pos = StrIterIndex(&si) - StrIterIndex(&saved);
Str temp = StrInitFromCstr(start, pos, &scratch);
// A bare base prefix ("0x", "0b", "0o") with no following digits is
- In
Io.c:2910:
Zstr start = StrIterDataAt(&si, StrIterIndex(&saved)); \
size pos = StrIterIndex(&si) - StrIterIndex(&saved); \
Str temp = StrInitFromCstr(start, pos, &scratch); \
\
if (StrLen(&temp) == 2 && StrBegin(&temp)[0] == '0' && \
- In
Io.c:2987:
Zstr next = NULL;
Allocator *allocator_ptr = NULL;
Str temp;
FmtInfo default_fmt;- In
Io.c:3038:
#if FEATURE_BITVEC
bool _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv) {
if (!o || !fmt_info || !bv) {
LOG_FATAL("Invalid arguments");- In
Io.c:3087:
// requested width below.
} else {
Str bit_str;
if (!bitvec_try_to_str(&bit_str, bv, StrAllocator(o))) {- In
Io.c:3112:
#if FEATURE_INT
bool _write_Int(Str *o, FmtInfo *fmt_info, Int *value) {
if (!o || !fmt_info || !value) {
LOG_FATAL("Invalid arguments");- In
Io.c:3145:
size start_len = StrLen(o);
Str temp;
u8 radix = int_fmt_radix_from_flags(fmt_info);- In
Io.c:3220:
}
Str hex_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&hex_saved)),
StrIterIndex(&si) - StrIterIndex(&hex_saved),- In
Io.c:3261:
}
Str oct_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&oct_saved)),
StrIterIndex(&si) - StrIterIndex(&oct_saved),- In
Io.c:3295:
}
Str bin_str = StrInitFromCstr(
StrIterDataAt(&si, StrIterIndex(&bin_saved)),
StrIterIndex(&si) - StrIterIndex(&bin_saved),- In
Io.c:3378:
}
Str temp = StrInitFromCstr(start, StrIterIndex(&si) - StrIterIndex(&saved), IntAllocator(value));
Int parsed = IntInit(IntAllocator(value));
bool ok = IntTryFromStrRadix(&parsed, StrBegin(&temp), radix);- In
Io.c:3399:
size token_len = 0;
Zstr start = NULL;
Str temp;
Float parsed;- In
Io.c:3499:
}
Str temp = StrInitFromCstr(start, (size)(StrIterIndex(&si) - StrIterIndex(&saved)), &scratch);
// Special-value tokens (`inf`, `nan`, ...) carry through the
- In
Io.c:3557:
size pos = StrIterIndex(&si) - StrIterIndex(&saved);
Str temp = StrInitFromCstr(start, pos, &scratch);
if (!is_valid_numeric_string(&temp, true)) {- In
Io.c:3582:
}
static bool _write_r8(Str *o, FmtInfo *fmt_info, u8 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:3591:
}
static bool _write_r16(Str *o, FmtInfo *fmt_info, u16 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:3617:
}
static bool _write_r32(Str *o, FmtInfo *fmt_info, u32 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:3645:
}
static bool _write_r64(Str *o, FmtInfo *fmt_info, u64 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Str.c:7:
/// Str implementation
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Str/Private.h>
#include <Misra/Std/Zstr.h>- In
Str.c:8:
#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>- 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:112:
Str str_init_from_cstr(Zstr cstr, size len, Allocator *alloc) {
Str result = StrInit(alloc);
// Try-form leaves `result` empty-but-valid on OOM, so the caller
- In
Str.c:122:
}
bool StrInitCopy(Str *dst, const Str *src) {
if (!dst || !src) {
LOG_FATAL("Invalid arguments");- In
Str.c:131:
bool str_init_copy(void *dst_ptr, const void *src_ptr, const Allocator *alloc) {
Str *dst = (Str *)dst_ptr;
const Str *src = (const Str *)src_ptr;
Allocator *clone_allocator = NULL;- In
Str.c:132:
bool str_init_copy(void *dst_ptr, const void *src_ptr, const Allocator *alloc) {
Str *dst = (Str *)dst_ptr;
const Str *src = (const Str *)src_ptr;
Allocator *clone_allocator = NULL;- In
Str.c:142:
clone_allocator = alloc ? (Allocator *)alloc : src->allocator;
MemSet(dst, 0, sizeof(Str));
*dst = StrInit(clone_allocator);
dst->copy_init = src->copy_init;- In
Str.c:154:
}
void StrDeinit(Str *copy) {
ValidateStr(copy);
deinit_vec(GENERIC_VEC(copy), sizeof(char));- In
Str.c:161:
void str_deinit(void *copy, const Allocator *alloc) {
(void)alloc;
StrDeinit((Str *)copy);
}- In
Str.c:168:
// real length lives inside the Str header itself.
u64 str_hash(const void *data, u32 ignored_size) {
const Str *str = (const Str *)data;
u64 hash = 1469598103934665603ULL;
size idx = 0;- In
Str.c:184:
i32 str_compare(const void *lhs, const void *rhs) {
const Str *a = (const Str *)lhs;
const Str *b = (const Str *)rhs;
size min = 0;- In
Str.c:185:
i32 str_compare(const void *lhs, const void *rhs) {
const Str *a = (const Str *)lhs;
const Str *b = (const Str *)rhs;
size min = 0;
i32 cmp = 0;- In
Str.c:207:
}
i32 str_cmp_str(const Str *s, const Str *other) {
ValidateStr(s);
ValidateStr(other);- 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:223:
}
i32 str_cmp_str_ignore_case(const Str *s, const Str *other) {
ValidateStr(s);
ValidateStr(other);- 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:278:
}
StrIters str_split_to_iters_zstr(Str *s, Zstr key) {
return str_split_to_iters_impl(s, key, ZstrLen(key));
}- In
Str.c:282:
}
StrIters str_split_to_iters_str(Str *s, const Str *key) {
if (!key) {
LOG_FATAL("Invalid arguments");- In
Str.c:289:
}
static Strs str_split_impl(Str *s, Zstr key, size keylen) {
ValidateStr(s);- In
Str.c:301:
Zstr next = ZstrFindSubstringN(prev, key, keylen);
if (next) {
Str tmp = StrInitFromCstr(prev, next - prev, s->allocator);
VecPushBack(&sv, tmp);
prev = next + keylen;- In
Str.c:306:
} else {
if (ZstrCompareN(prev, key, end - prev)) {
Str tmp = StrInitFromCstr(prev, end - prev, s->allocator);
VecPushBack(&sv, tmp);
}- In
Str.c:317:
}
Strs str_split_zstr(Str *s, Zstr key) {
return str_split_impl(s, key, ZstrLen(key));
}- In
Str.c:321:
}
Strs str_split_str(Str *s, const Str *key) {
if (!key) {
LOG_FATAL("Invalid arguments");- In
Str.c:328:
}
size str_index_of_cstr(const Str *s, Zstr key, size key_len) {
Zstr found = NULL;- In
Str.c:349:
}
size str_index_of_zstr(const Str *s, Zstr key) {
if (!key) {
LOG_FATAL("Invalid arguments");- In
Str.c:357:
}
size str_index_of_str(const Str *s, const Str *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:379:
}
bool str_contains_str(const Str *s, const Str *key) {
if (!key) {
LOG_FATAL("Invalid arguments");- 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: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:464:
}
bool str_starts_with_str(const Str *s, const Str *prefix) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix->data, prefix->length);- In
Str.c:469:
}
bool str_ends_with_str(const Str *s, const Str *suffix) {
ValidateStr(s);
return ends_with(s->data, s->length, suffix->data, suffix->length);- 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:496:
}
void str_replace_str(Str *s, const Str *match, const Str *replacement, size count) {
ValidateStr(s);
str_replace_cstr(s, match->data, match->length, replacement->data, replacement->length, count);- In
Str.c:524:
}
static inline size skip_prefix(const Str *str, size pos, u8 base) {
if (pos + 2 > str->length || str->data[pos] != '0') {
return pos;- In
Str.c:557:
}
Str *StrFromU64(Str *str, u64 value, const StrIntFormat *config) {
ValidateStr(str);- In
Str.c:622:
}
Str *StrFromI64(Str *str, i64 value, const StrIntFormat *config) {
ValidateStr(str);- In
Str.c:660:
}
Str *StrFromF64(Str *str, f64 value, const StrFloatFormat *config) {
ValidateStr(str);- In
Str.c:862:
}
bool StrToU64(const Str *str, u64 *value, const StrParseConfig *config) {
ValidateStr(str);- In
Str.c:949:
}
bool StrToI64(const Str *str, i64 *value, const StrParseConfig *config) {
ValidateStr(str);- In
Str.c:979:
// Borrowed substring view: data points into the caller's bytes and
// capacity stays 0 so StrToU64 never tries to grow it.
Str temp_str = StrInit(str->allocator);
temp_str.data = str->data + pos;
temp_str.length = str->length - pos;- In
Str.c:1009:
}
bool StrToF64(const Str *str, f64 *value, const StrParseConfig *config) {
ValidateStr(str);- In
Str.c:1148:
}
void ValidateStr(const Str *s) {
return ValidateVec(s);
}- In
Vec.c:7:
/// Generic vector implementation
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>- In
Int.c:661:
}
bool int_try_from_str_str(Int *out, const Str *decimal) {
u64 start = 0;- In
Int.c:682:
}
Int int_from_str_str(const Str *decimal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:689:
}
bool int_try_to_str(Str *out, const Int *value, Allocator *alloc) {
return int_try_to_str_radix(out, value, 10, false, alloc);
}- In
Int.c:693:
}
Str int_to_str(const Int *value, Allocator *alloc) {
Str result;- In
Int.c:694:
Str int_to_str(const Int *value, Allocator *alloc) {
Str result;
ValidateInt(value);- In
Int.c:720:
}
bool int_try_from_str_radix_str(Int *out, const Str *digits, u8 radix) {
u64 start = 0;- In
Int.c:740:
}
Int int_from_str_radix_str(const Str *digits, u8 radix, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:747:
}
bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
Int current;
Str result;- In
Int.c:749:
bool int_try_to_str_radix(Str *out, const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
Int current;
Str result;
ValidateInt(value);- In
Int.c:856:
}
Str int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
Str result;- In
Int.c:857:
Str int_to_str_radix(const Int *value, u8 radix, bool uppercase, Allocator *alloc) {
Str result;
ValidateInt(value);- In
Int.c:884:
}
bool int_try_from_binary_str(Int *out, const Str *binary) {
u64 start = 0;- In
Int.c:906:
}
Int int_from_binary_str(const Str *binary, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:913:
}
Str IntToBinary(const Int *value) {
return IntToStrRadix(value, 2, false);
}- In
Int.c:933:
}
bool int_try_from_oct_str_str(Int *out, const Str *octal) {
u64 start = 0;- In
Int.c:955:
}
Int int_from_oct_str_str(const Str *octal, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:962:
}
Str IntToOctStr(const Int *value) {
return IntToStrRadix(value, 8, false);
}- In
Int.c:977:
}
bool int_try_from_hex_str_str(Int *out, const Str *hex) {
if (!out || !hex) {
LOG_FATAL("Invalid arguments");- In
Int.c:992:
}
Int int_from_hex_str_str(const Str *hex, Allocator *alloc) {
Int out = IntInit(alloc);- In
Int.c:999:
}
Str IntToHexStr(const Int *value) {
return IntToStrRadix(value, 16, false);
}- In
Float.c:490:
static bool float_try_from_str_impl(Float *out, Zstr text, size length) {
Float result;
Str digits;
size pos = 0;
bool negative = false;- In
Float.c:615:
}
bool float_try_from_str_str(Float *out, const Str *text) {
if (!out || !text) {
LOG_FATAL("Invalid arguments");- In
Float.c:629:
}
Float float_from_str_str(const Str *text, Allocator *alloc) {
Float result = FloatInit(alloc);- In
Float.c:636:
}
bool float_try_to_str(Str *out, const Float *value, Allocator *alloc) {
Str digits;
Str result;- In
Float.c:637:
bool float_try_to_str(Str *out, const Float *value, Allocator *alloc) {
Str digits;
Str result;- In
Float.c:638:
bool float_try_to_str(Str *out, const Float *value, Allocator *alloc) {
Str digits;
Str result;
ValidateFloat(value);- In
Float.c:719:
}
Str float_to_str(const Float *value, Allocator *alloc) {
Str result;- In
Float.c:720:
Str float_to_str(const Float *value, Allocator *alloc) {
Str result;
ValidateFloat(value);- In
BitVec.c:9:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Log.h>- In
BitVec.c:887:
}
bool bitvec_try_to_str(Str *out, BitVec *bv, Allocator *alloc) {
ValidateBitVec(bv);
if (!out) {- In
BitVec.c:914:
}
Str bitvec_to_str(BitVec *bv, Allocator *alloc) {
Str result;- In
BitVec.c:915:
Str bitvec_to_str(BitVec *bv, Allocator *alloc) {
Str result;
if (!bitvec_try_to_str(&result, bv, alloc)) {- In
BitVec.c:967:
}
bool bitvec_try_from_str_str(BitVec *out, const Str *str, Allocator *alloc) {
if (!str) {
LOG_FATAL("str is NULL");- In
BitVec.c:984:
}
BitVec bitvec_from_str_str(const Str *str, Allocator *alloc) {
BitVec result;- In
BitVec.c:1914:
// wanting true regex semantics should feed BitVecToStr to a regex
// engine themselves.
Str bv_str = BitVecToStr(bv);
bool result = false;- In
BitVec.c:1925:
}
bool bitvec_regex_match_str(BitVec *bv, const Str *pattern) {
ValidateBitVec(bv);
if (!pattern) {- In
BitVec.c:1931:
}
Str bv_str = BitVecToStr(bv);
bool result = false;- In
Debug.c:283:
return;
}
Str rendered = StrInit(meta);
#if !defined(LOG_NO_BACKTRACE) || !LOG_NO_BACKTRACE
FormatStackTrace(&rendered, frames, count, meta);- In
Debug.c:529:
}
void DebugAllocatorReportLeaks(DebugAllocator *self, Str *out) {
if (!self || !out)
return; // Format the build-id bytes as `aa/bbbb...` (first byte separator,
// rest concatenated, lowercase hex). Caller provides the Str.
static void append_build_id_path(Str *out, const u8 *id, u32 n) {
static const char hex[] = "0123456789abcdef";
if (n == 0) // 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);
// (1) Build-ID
- In
PdbCache.c:13:
#include <Misra/Std.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Log.h>- 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:69:
return true;
Str pdb_path = StrInit(alloc);
if (!find_pdb(&entry->pe, StrBegin(&entry->module_path), &pdb_path)) {
StrDeinit(&pdb_path);- In
PdbCache.c:169:
bool pdb_cache_resolve_str(
PdbCache *self,
const Str *module_path,
u64 module_base,
u64 runtime_ip,- 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:155:
static void parse_hosts_path(HostsTable *table, Zstr path, Allocator *alloc) {
Str buf = StrInit(alloc);
if (!slurp_file(path, &buf)) {
StrDeinit(&buf);- In
Dns.c:250:
static void parse_resolv_path(DnsAddrs *out, Zstr path, Allocator *alloc) {
Str buf = StrInit(alloc);
if (!slurp_file(path, &buf)) {
StrDeinit(&buf);- In
Dns.c:343:
if (!self || !path)
return false;
Str buf = StrInit(self->allocator);
StrPushBackMany(&buf, path, len);
bool ok = dns_add_path(self, StrBegin(&buf), do_hosts, do_resolv);- In
Dns.c:350:
}
bool dns_resolver_add_path_str(DnsResolver *self, const Str *path) {
if (!self || !path)
return false;- In
Dns.c:360:
}
bool dns_resolver_add_hosts_path_str(DnsResolver *self, const Str *path) {
if (!self || !path)
return false;- In
Dns.c:370:
}
bool dns_resolver_add_resolv_path_str(DnsResolver *self, const Str *path) {
if (!self || !path)
return false;- 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:690:
}
bool dns_resolve_5_str(DnsResolver *self, const Str *hostname, u16 port, SocketKind kind, DnsAddrs *out) {
if (!self || !hostname || !out) {
return false;- In
Dns.c:697:
}
bool dns_resolve_4_vec_str(DnsResolver *self, const Str *spec, SocketKind kind, DnsAddrs *out) {
if (!self || !spec || !out) {
return false;- In
Dns.c:718:
}
bool dns_resolve_4_one_str(DnsResolver *self, const Str *spec, SocketKind kind, SocketAddr *out) {
if (!self || !spec || !out) {
return false;- In
Backtrace.c:192:
// Shared formatter body (raw view: pointer + length).
static void format_walk_win(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
ensure_dbghelp();
HANDLE proc = GetCurrentProcess();- In
Backtrace.c:265:
}
void format_stack_trace_raw(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
if (!out || !frames)
return;- In
Backtrace.c:271:
}
void format_stack_trace_vec(Str *out, const StackFrames *frames, Allocator *alloc) {
if (!out || !frames)
return;- In
Backtrace.c:386:
# endif
static void format_walk_mac(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
# if FEATURE_PARSER_MACHO
bool cache_ok = (alloc != NULL);- In
Backtrace.c:427:
}
void format_stack_trace_raw(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
if (!out || !frames || !alloc)
return;- In
Backtrace.c:433:
}
void format_stack_trace_vec(Str *out, const StackFrames *frames, Allocator *alloc) {
if (!out || !frames || !alloc)
return;- In
Backtrace.c:461:
}
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);- In
Backtrace.c:482:
}
static void format_walk_with(Str *out, const StackFrame *frames, size count, SymbolResolver *resolver) {
for (size i = 0; i < count; ++i) {
ResolvedSymbol r;- In
Backtrace.c:493:
}
static void format_walk_alloc(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
SymbolResolver res;
if (!SymbolResolverInit(&res, alloc)) {- In
Backtrace.c:505:
}
void format_stack_trace_with_raw(Str *out, const StackFrame *frames, size count, SymbolResolver *resolver) {
if (!out || !frames || !resolver)
return;- In
Backtrace.c:511:
}
void format_stack_trace_with_vec(Str *out, const StackFrames *frames, SymbolResolver *resolver) {
if (!out || !frames || !resolver)
return;- In
Backtrace.c:517:
}
void format_stack_trace_raw(Str *out, const StackFrame *frames, size count, Allocator *alloc) {
if (!out || !frames || !alloc)
return;- In
Backtrace.c:523:
}
void format_stack_trace_vec(Str *out, const StackFrames *frames, Allocator *alloc) {
if (!out || !frames || !alloc)
return;- In
Socket.c:440:
}
bool socket_addr_parse_str(SocketAddr *out, const Str *spec, SocketKind kind) {
if (!out) {
LOG_FATAL("SocketAddrParse: out is NULL");- In
Socket.c:458:
}
Str socket_addr_format(const SocketAddr *addr, Allocator *alloc) {
Str out = StrInit(alloc);
if (!addr || addr->length == 0) {- In
Socket.c:459:
Str socket_addr_format(const SocketAddr *addr, Allocator *alloc) {
Str out = StrInit(alloc);
if (!addr || addr->length == 0) {
return out;- In
MachoCache.c:13:
#include <Misra/Std.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/File.h>- 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:83:
}
Str path = StrInit(alloc);
if (!compose_dsym_path(StrBegin(&e->module_path), &path)) {
StrDeinit(&path);- In
MachoCache.c:206:
bool macho_cache_resolve_str(
MachoCache *self,
const Str *module_path,
u64 slide,
u64 runtime_ip,- In
Proc.c:224:
PROCESS_INFORMATION pi = {0};
Str cmdline = StrInit(alloc);
StrPushBackMany(&cmdline, filepath);
for (char **arg = argv + 1; *arg; ++arg) {- In
Proc.c:465:
}
i32 ProcWriteToStdin(Proc *proc, const Str *buf) {
if (!proc || !buf) {
LOG_FATAL("Invalid arguments");- In
Proc.c:480:
}
static i32 proc_read_internal(Proc *proc, Str *buf, bool is_stdout) {
if (!proc || !buf) {
LOG_FATAL("Invalid argument");- In
Proc.c:559:
}
i32 ProcReadFromStdout(Proc *proc, Str *buf) {
return proc_read_internal(proc, buf, /* is stdout*/ true);
}- In
Proc.c:563:
}
i32 ProcReadFromStderr(Proc *proc, Str *buf) {
return proc_read_internal(proc, buf, /* is stdout*/ false);
}- In
Proc.c:638:
}
Str *GetCurrentExecutablePath(Str *exe_path) {
ValidateStr(exe_path);
Allocator *alloc = StrAllocator(exe_path);- In
_Helpers.h:14:
#include <Misra/Std/File.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- 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
Pe.c:589:
}
const PeSection *pe_find_section_str(const Pe *self, const Str *name) {
if (!self || !name)
return NULL;- In
DwarfInfo.c:341:
const u8 *debug_str,
u64 debug_str_size,
Str *pool,
PendingFns *pending
) {- In
Dns.c:82:
}
bool dns_build_query_str(DnsWireBuf *out, u16 id, const Str *name, DnsType type) {
if (!out || !name) {
return false;- In
Dns.c:102:
//
// Returns false on cycles, oversized names, or out-of-bounds.
static bool decode_name(BufIter *it, Str *out_name) {
const u32 MAX_HOPS = 64;
u32 hops = 0;- In
Dns.c:297:
// Skip echoed question section: each question is qname + qtype(2) + qclass(2).
for (u16 i = 0; i < qd; ++i) {
Str dummy = StrInit(alloc);
if (!decode_name(&it, &dummy)) {
StrDeinit(&dummy);- In
KvConfig.c:21:
}
static bool kvconfig_parse_bool_value(const Str *value, bool *out) {
if (!out) {
LOG_FATAL("Expected valid bool output pointer");- In
KvConfig.c:43:
}
static bool kvconfig_parse_i64_value(const Str *value, i64 *out) {
Zstr endptr = NULL;
i64 parsed;- In
KvConfig.c:61:
}
static bool kvconfig_parse_f64_value(const Str *value, f64 *out) {
Zstr endptr = NULL;
f64 parsed;- In
KvConfig.c:106:
}
StrIter KvConfigReadKey(StrIter si, Str *key) {
StrIter saved_si = si;- In
KvConfig.c:134:
}
StrIter KvConfigReadValue(StrIter si, Str *value) {
StrIter saved_si = si;- In
KvConfig.c:214:
if (StrLen(value) > 0) {
Str stripped = StrStrip(value, NULL);
StrDeinit(value);
*value = stripped;- In
KvConfig.c:222:
}
StrIter KvConfigReadPair(StrIter si, Str *key, Str *value) {
StrIter saved_si = si;- In
KvConfig.c:283:
char c;
while (StrIterPeek(&si, &c)) {
Str key = StrInit(MapAllocator(cfg));
Str value = StrInit(MapAllocator(cfg));
StrIter read_si;- In
KvConfig.c:284:
while (StrIterPeek(&si, &c)) {
Str key = StrInit(MapAllocator(cfg));
Str value = StrInit(MapAllocator(cfg));
StrIter read_si;- In
KvConfig.c:334:
}
Str *kvconfig_get_ptr_str(KvConfig *cfg, const Str *key) {
if (!cfg || !key) {
return NULL;- In
KvConfig.c:341:
}
Str *kvconfig_get_ptr_zstr(KvConfig *cfg, Zstr key) {
Str lookup = {0};
Str *value = NULL;- In
KvConfig.c:342:
Str *kvconfig_get_ptr_zstr(KvConfig *cfg, Zstr key) {
Str lookup = {0};
Str *value = NULL;- In
KvConfig.c:343:
Str *kvconfig_get_ptr_zstr(KvConfig *cfg, Zstr key) {
Str lookup = {0};
Str *value = NULL;
if (!cfg || !key) {- In
KvConfig.c:355:
}
Str kvconfig_get_str(KvConfig *cfg, const Str *key) {
Str *value = kvconfig_get_ptr_str(cfg, key);- In
KvConfig.c:356:
Str kvconfig_get_str(KvConfig *cfg, const Str *key) {
Str *value = kvconfig_get_ptr_str(cfg, key);
if (!value) {- In
KvConfig.c:365:
}
Str kvconfig_get_zstr(KvConfig *cfg, Zstr key) {
Str *value = kvconfig_get_ptr_zstr(cfg, key);- In
KvConfig.c:366:
Str kvconfig_get_zstr(KvConfig *cfg, Zstr key) {
Str *value = kvconfig_get_ptr_zstr(cfg, key);
if (!value) {- In
KvConfig.c:375:
}
bool kvconfig_contains_str(KvConfig *cfg, const Str *key) {
return kvconfig_get_ptr_str(cfg, key) != NULL;
}- In
KvConfig.c:383:
}
bool kvconfig_get_bool_str(KvConfig *cfg, const Str *key, bool *value) {
Str *str = kvconfig_get_ptr_str(cfg, key);- In
KvConfig.c:384:
bool kvconfig_get_bool_str(KvConfig *cfg, const Str *key, bool *value) {
Str *str = kvconfig_get_ptr_str(cfg, key);
if (!str) {- In
KvConfig.c:394:
bool kvconfig_get_bool_zstr(KvConfig *cfg, Zstr key, bool *value) {
Str *str = kvconfig_get_ptr_zstr(cfg, key);
if (!str) {- In
KvConfig.c:403:
}
bool kvconfig_get_i64_str(KvConfig *cfg, const Str *key, i64 *value) {
Str *str = kvconfig_get_ptr_str(cfg, key);- In
KvConfig.c:404:
bool kvconfig_get_i64_str(KvConfig *cfg, const Str *key, i64 *value) {
Str *str = kvconfig_get_ptr_str(cfg, key);
if (!str) {- In
KvConfig.c:414:
bool kvconfig_get_i64_zstr(KvConfig *cfg, Zstr key, i64 *value) {
Str *str = kvconfig_get_ptr_zstr(cfg, key);
if (!str) {- In
KvConfig.c:423:
}
bool kvconfig_get_f64_str(KvConfig *cfg, const Str *key, f64 *value) {
Str *str = kvconfig_get_ptr_str(cfg, key);- In
KvConfig.c:424:
bool kvconfig_get_f64_str(KvConfig *cfg, const Str *key, f64 *value) {
Str *str = kvconfig_get_ptr_str(cfg, key);
if (!str) {- In
KvConfig.c:434:
bool kvconfig_get_f64_zstr(KvConfig *cfg, Zstr key, f64 *value) {
Str *str = kvconfig_get_ptr_zstr(cfg, key);
if (!str) {- 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:536:
const SectionRva *sections,
u32 num_sections,
Str *pool,
PendingPubs *pending
) {- In
ProcMaps.c:207:
// NOT EOF: treating it as one drops every later entry, including [stack]).
// Does not close `f`.
static bool proc_maps_read_all(File *f, Str *raw) {
enum {
CHUNK = 4096- In
Http.c:29:
void http_header_deinit(void *header_ptr, const Allocator *alloc) {
(void)alloc; // each Str carries its own allocator handle
HttpHeader *header = (HttpHeader *)header_ptr;
StrDeinit(&header->key);- In
Http.c:70:
}
HttpHeader *http_headers_find_str(HttpHeaders *headers, const Str *key) {
if (!headers || !key) {
LOG_FATAL("invalid arguments");- In
Http.c:83:
// ---------------------------------------------------------------------------
static HttpRequestMethod http_request_method_from_str(const Str *mstr) {
if (!mstr || !StrBegin(mstr)) {
return HTTP_REQUEST_METHOD_UNKNOWN;- In
Http.c:115:
Allocator *alloc = req->allocator;
Zstr cursor = in;
Str method = StrInit(alloc);
Str version = StrInit(alloc);- In
Http.c:116:
Zstr cursor = in;
Str method = StrInit(alloc);
Str version = StrInit(alloc);
StrReadFmt(cursor, "{} {} {}\r\n", method, req->url, version);- In
Http.c:177:
}
Zstr http_request_parse_str(HttpRequest *req, const Str *in) {
if (!req || !in) {
LOG_FATAL("invalid arguments");- In
Http.c:408:
// ---------------------------------------------------------------------------
HttpResponse *HttpRespondWithHtml(HttpResponse *response, HttpResponseCode status, const Str *html) {
if (!response || !response->allocator || !html) {
LOG_FATAL("invalid arguments");- In
Http.c:444:
HttpResponseCode status,
HttpContentType content_type,
const Str *filepath
) {
if (!filepath) {- In
Http.c:453:
#endif
Str http_response_serialize(const HttpResponse *response, Allocator *alloc) {
Str out = StrInit(alloc);- In
Http.c:454:
Str http_response_serialize(const HttpResponse *response, Allocator *alloc) {
Str out = StrInit(alloc);
if (!response) {- In
JSON.c:54:
}
Str key = StrInit(&scratch);
// key start
- In
JSON.c:181:
}
StrIter JReadString(StrIter si, Str *str) {
if (!StrIterRemainingLength(&si)) {
return si;- In
JSON.c:311:
// stack-backed buffer is unsafe -- DefaultAllocator is the right fit.
DefaultAllocator scratch = DefaultAllocatorInit();
Str ns = StrInit(&scratch);
bool is_neg = false;- In
JSON.c:637:
// valid input. DefaultAllocator is the right fit here.
DefaultAllocator scratch = DefaultAllocatorInit();
Str s = StrInit(&scratch);
si = JReadString(si, &s);
StrDeinit(&s);- In
Elf.c:597:
}
const ElfSection *elf_find_section_str(const Elf *self, const Str *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:227:
// to the first byte after the standard_opcode_lengths array; we
// continue from there.
static bool collect_cu_strings(BufIter cur, Str *pool, CuStrings *cs) {
// include_directories
while (IterIndex(&cur) < IterLength(&cur) && *IterDataAt(&cur, IterIndex(&cur)) != 0) {- In
Dwarf.c:296:
static bool lnp_emit(
DwarfLines *out,
Str *pool,
const CuStrings *cs,
const LnpState *st,- In
Resolve.c:45:
VecForeachPtr(&addrs, a) {
Str s = SocketAddrFormat(a, alloc);
// Strip the trailing ":0" since we resolve with port=0; keep
// bracket form on v6 to round-trip through SocketAddrParse.
- In
Beam.c:249:
static void log_request_summary(Zstr client_addr, Zstr prefix_bytes, size prefix_len) {
Scope(scope, DefaultAllocator) {
Str raw = StrInit(scope);
StrPushBackMany(&raw, prefix_bytes);- In
Beam.c:346:
static void handle_connection(Allocator *alloc, Socket *client, const SocketAddr *upstream_addr) {
Str peer_str = SocketAddrFormat(&client->peer, alloc);
Socket upstream;- In
File.c:2:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Log.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:31:
bool test_file_read_into_str(void) {
WriteFmt("Testing FileRead into Str (whole-file load)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
File.c:36:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
if (!write_test_file("hello from file", &path, alloc_base)) {
DefaultAllocatorDeinit(&alloc);- In
File.c:50:
}
Str body = StrInit(alloc_base);
i64 got = FileRead(&f, &body);
FileClose(&f);- In
File.c:65:
bool test_file_read_grows_str(void) {
WriteFmt("Testing FileRead grows the Str backing buffer\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
File.c:70:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
if (!write_test_file("this is longer than the initial buffer", &path, alloc_base)) {
DefaultAllocatorDeinit(&alloc);- In
File.c:84:
}
Str body = StrInit(alloc_base);
i64 got = FileRead(&f, &body);
FileClose(&f);- In
File.c:108:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("payload", &path, alloc_base);
if (!ok) {- In
File.c:141:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("data", &path, alloc_base);
if (!ok) {- In
File.c:174:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File f = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&f)) {- In
File.c:217:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("hi", &path, alloc_base);
if (!ok) {- In
File.c:252:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("a long original payload", &path, alloc_base);
if (!ok) {- In
File.c:266:
File r = FileOpen(&path, "rb");
ok = ok && FileIsOpen(&r);
Str body = StrInit(alloc_base);
i64 got = FileRead(&r, &body);
FileClose(&r);- In
File.c:287:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("head", &path, alloc_base);
if (!ok) {- In
File.c:300:
File r = FileOpen(&path, "rb");
Str body = StrInit(alloc_base);
i64 got = FileRead(&r, &body);
FileClose(&r);- In
File.c:324:
// Need a path on disk; create+remove a temp to mint a unique name,
// then write to it through the convenience API.
Str path;
File seed = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&seed)) {- In
File.c:338:
bool ok = (wrote == (i64)n);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == (i64)n) && (StrLen(&body) == (size)n) && ZstrCompare(StrBegin(&body), payload) == 0;- In
File.c:358:
// Mint a unique name then remove it so the path is guaranteed absent.
Str path;
File seed = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&seed)) {- In
File.c:367:
FileRemove(&path);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
bool ok = (got == -1);- In
File.c:389:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("seed", &path, alloc_base);
if (!ok) {- In
File.c:416:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("0123456789", &path, alloc_base);
if (!ok) {- In
File.c:430:
// Confirm the write landed.
Str body = StrInit(alloc_base);
File r = FileOpen(&path, "rb");
i64 got = FileRead(&r, &body);- In
File.c:452:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("read-me", &path, alloc_base);
if (!ok) {- In
File.c:510:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File owner = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&owner)) {- In
File.c:528:
FileClose(&owner);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == 10) && ZstrCompare(StrBegin(&body), "helloworld") == 0;- In
File.c:552:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File f = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&f)) {- In
File.c:578:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File f = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&f)) {- In
File.c:608:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File f = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&f)) {- In
File.c:637:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("ab", &path, alloc_base);
if (!ok) {- In
File.c:670:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("abcdef", &path, alloc_base);
if (!ok) {- In
File.c:706:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File f = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&f)) {- In
File.c:742:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("0123456789ABCDEF", &path, alloc_base); // 16 bytes
if (!ok) {- In
File.c:754:
ok = ok && (FileSeek(&f, 10, FILE_SEEK_SET) == 10);
Str body = StrInit(alloc_base);
i64 got = FileRead(&f, &body);
FileClose(&f);- In
File.c:775:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
Zstr payload = "the quick brown fox jumps over the lazy dog"; // 43 bytes
bool ok = write_test_file(payload, &path, alloc_base);- In
File.c:785:
File f = FileOpen(&path, "rb");
ok = ok && FileIsOpen(&f);
Str body = StrInit(alloc_base);
i64 got = FileRead(&f, &body);
FileClose(&f);- In
File.c:813:
// Build a 10000-byte payload (> FILE_READ_CHUNK=4096) on disk.
Str path;
File f = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&f)) {- In
File.c:859:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File seed = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&seed)) {- In
File.c:873:
bool ok = (wrote == (i64)n);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == (i64)n) && (StrLen(&body) == (size)n) && ZstrCompare(StrBegin(&body), payload) == 0;- In
File.c:892:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
bool ok = write_test_file("preexisting content", &path, alloc_base);
if (!ok) {- In
File.c:903:
ok = ok && (wrote == 0);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == 0) && (StrLen(&body) == 0);- In
File.c:922:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File seed = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&seed)) {- In
File.c:937:
ok = ok && (wrote == 5);
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == 5) && ZstrCompare(StrBegin(&body), "12345") == 0;- In
File.c:952:
// length and content.
bool test_fm_521_write_close_from_str(void) {
WriteFmt("Testing FileWriteAndClose(Str) writes the string length exactly\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
File.c:957:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File seed = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&seed)) {- In
File.c:965:
FileClose(&seed);
Str in = StrInit(alloc_base);
StrAppendFmt(&in, "string-content");- In
File.c:971:
bool ok = (wrote == (i64)StrLen(&in));
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == (i64)StrLen(&in)) && ZstrCompare(StrBegin(&body), "string-content") == 0;- In
File.c:995:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File f = FileOpenTemp(&path, alloc_base);
bool ok = FileIsOpen(&f);- In
File.c:1024:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str p1;
File f1 = FileOpenTemp(&p1, alloc_base);
Str p2;- In
File.c:1026:
Str p1;
File f1 = FileOpenTemp(&p1, alloc_base);
Str p2;
File f2 = FileOpenTemp(&p2, alloc_base);- In
File.c:1040:
FileClose(&f2);
Str b1 = StrInit(alloc_base);
Str b2 = StrInit(alloc_base);
ok = ok && (FileReadAndClose(&p1, &b1) == 3) && ZstrCompare(StrBegin(&b1), "one") == 0;- In
File.c:1041:
Str b1 = StrInit(alloc_base);
Str b2 = StrInit(alloc_base);
ok = ok && (FileReadAndClose(&p1, &b1) == 3) && ZstrCompare(StrBegin(&b1), "one") == 0;
ok = ok && (FileReadAndClose(&p2, &b2) == 6) && ZstrCompare(StrBegin(&b2), "twotwo") == 0;- In
File.c:1068:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File f = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&f)) {- In
File.c:1100:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File seed = FileOpenTemp(&path, alloc_base);
if (FileIsOpen(&seed)) {- In
File.c:1155:
// Seed a temp path that exists on disk (so the open succeeds).
Str path;
bool ok = write_test_file("preexisting", &path, alloc_base);
if (!ok) {- In
File.c:1168:
// The file was truncated to empty.
Str body = StrInit(alloc_base);
i64 got = FileReadAndClose(&path, &body);
ok = ok && (got == 0) && (StrLen(&body) == 0);- In
File.c:1195:
// Open file A and keep a second file B open so A's fd slot sits in the
// middle of the table. Record A's fd.
Str pa;
File a = FileOpenTemp(&pa, alloc_base);
Str pb;- In
File.c:1197:
Str pa;
File a = FileOpenTemp(&pa, alloc_base);
Str pb;
File b = FileOpenTemp(&pb, alloc_base);
if (!FileIsOpen(&a) || !FileIsOpen(&b)) {- In
File.c:1223:
// that is exactly fd_a (just released); with the mutant fd_a is still
// occupied so we get a strictly higher number.
Str pc;
File c = FileOpenTemp(&pc, alloc_base);
ok = ok && FileIsOpen(&c);- In
AllocDebug.c:124:
// counted as a leak by the very report we're about to generate.
HeapAllocator scratch = HeapAllocatorInit();
Str out = StrInit(&scratch);
DebugAllocatorReportLeaks(&dbg, &out);
HeapAllocator scratch = HeapAllocatorInit();
Str out = StrInit(&scratch);
DebugAllocatorReportLeaks(&dbg, &out);
HeapAllocator scratch = HeapAllocatorInit();
Str out = StrInit(&scratch);
DebugAllocatorReportLeaks(&dbg, &out);
HeapAllocator scratch = HeapAllocatorInit();
Str out = StrInit(&scratch);
DebugAllocatorReportLeaks(&dbg, &out);
// Build the out-of-range marker "#N " that only the `<=` mutant emits.
Str ns = StrInit(&scratch);
StrAppendFmt(&ns, "#{} ", n);- In
ArgParse.c:6:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/ArgParse.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Io.h>- In
ArgParse.c:255:
ArgParse p = ArgParseInit("prog", NULL, &a);
Str name = StrInit(&a);
ArgOptional(&p, NULL, "--name", &name, "n");- In
ArgParse.c:615:
// spec before printing, so every captured help text ends with that row.
// ---------------------------------------------------------------------------
static void capture_help(ArgParse *p, Str *out) {
Str tmp_path = StrInit(p->alloc);
File tmp = FileOpenTemp(&tmp_path, p->alloc);- In
ArgParse.c:616:
// ---------------------------------------------------------------------------
static void capture_help(ArgParse *p, Str *out) {
Str tmp_path = StrInit(p->alloc);
File tmp = FileOpenTemp(&tmp_path, p->alloc);
StrDeinit(&tmp_path);- In
ArgParse.c:637:
static bool help_equals(ArgParse *p, Zstr expected) {
DefaultAllocator a = DefaultAllocatorInit();
Str out = StrInit(&a);
capture_help(p, &out);
bool ok = (StrLen(&out) == ZstrLen(expected)) && (ZstrCompare(StrBegin(&out), expected) == 0);- In
ArgParse.c:851:
DefaultAllocator a2 = DefaultAllocatorInit();
Str out = StrInit(&a2);
capture_help(&p, &out);- In
ArgParse.c:886:
// Run --help with the parser's output sink pointed at a temp file, then
// read it back into `out`. Returns true on a clean ARG_RUN_HELP capture.
static bool capture_help_file(ArgParse *p, Str *out) {
Str tmp_path = StrInit(p->alloc);
File tmp = FileOpenTemp(&tmp_path, p->alloc);- In
ArgParse.c:887:
// read it back into `out`. Returns true on a clean ARG_RUN_HELP capture.
static bool capture_help_file(ArgParse *p, Str *out) {
Str tmp_path = StrInit(p->alloc);
File tmp = FileOpenTemp(&tmp_path, p->alloc);
StrDeinit(&tmp_path);- 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:1149:
DefaultAllocator a = DefaultAllocatorInit();
ArgParse p = ArgParseInit("prog", NULL, &a);
Str name = StrInit(&a);
StrPushBackMany(&name, "stale");
ArgOptional(&p, NULL, "--name", &name, "n");- In
ArgParse.c:1271:
Zstr v = NULL;
ArgRequired(&p, "-l", "--listen", &v, "addr");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<LISTEN>");- In
ArgParse.c:1287:
Zstr v = NULL;
ArgRequired(&p, NULL, "--read-only", &v, "mode");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<READ_ONLY>");- In
ArgParse.c:1303:
Zstr v = NULL;
ArgRequired(&p, NULL, "--port", &v, "p");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// The metavar is "<PORT>", never "<__PORT>".
- In
ArgParse.c:1319:
Zstr v = NULL;
ArgRequired(&p, "-x", NULL, &v, "x");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<VALUE>");- In
ArgParse.c:1335:
Zstr v = NULL;
ArgRequired(&p, NULL, "--ip6", &v, "x");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<IP6>");- In
ArgParse.c:1352:
Zstr v = NULL;
ArgRequired(&p, NULL, "--gzip", &v, "x");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// "gzip" -> "GZIP": the trailing 'z' in the middle must be upper.
- In
ArgParse.c:1369:
Zstr v = NULL;
ArgRequired(&p, NULL, "--abc", &v, "x");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<ABC>");- In
ArgParse.c:1388:
Zstr s = NULL;
ArgPositional(&p, "source", &s, "from");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "<source>");- In
ArgParse.c:1403:
Zstr v = NULL;
ArgRequired(&p, "-l", "--listen", &v, "addr");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
bool ok = got && str_contains(&help, "-l, --listen");- In
ArgParse.c:1419:
Zstr v = NULL;
ArgRequired(&p, "-l", "--listen", &v, "addr");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// Full left column for this spec: two-space indent, short, ", ",
- In
ArgParse.c:1437:
u32 t = 0;
ArgOptional(&p, NULL, "--timeout", &t, "secs");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// No short form: rendered as four spaces then the long name.
- In
ArgParse.c:1453:
bool f = false;
ArgFlag(&p, "-v", "--verbose", &f, "v");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// The verbose flag must appear but with no "<VERBOSE>" metavar.
- In
ArgParse.c:1475:
ArgFlag(&p, "-a", "--a", &aa, "AAA");
ArgRequired(&p, NULL, "--a-very-long-option-name", &bb, "BBB");
Str help = StrInit(&a);
bool got = capture_help_file(&p, &help);
// The short flag "--a" help ("AAA") must be padded so it starts at
- In
ArgParse.c:1773:
// file, run, then read it back. Fully portable -- no fd/handle redirection.
// ---------------------------------------------------------------------------
static ArgRun capture_run(ArgParse *p, int argc, char **argv, Str *out) {
Str tmp_path = StrInit(p->alloc);
File tmp = FileOpenTemp(&tmp_path, p->alloc);- In
ArgParse.c:1774:
// ---------------------------------------------------------------------------
static ArgRun capture_run(ArgParse *p, int argc, char **argv, Str *out) {
Str tmp_path = StrInit(p->alloc);
File tmp = FileOpenTemp(&tmp_path, p->alloc);
StrDeinit(&tmp_path);- In
ArgParse.c:1790:
}
static bool str_has(Str *hay, Zstr needle) {
u64 hn = StrLen(hay);
Zstr beg = StrBegin(hay);- In
ArgParse.c:1824:
char *argv[] = {(char *)"prog", (char *)"first", (char *)"extra"};
Str out = StrInit(&a);
ArgRun rc = capture_run(&p, 3, argv, &out);- In
ArgParse.c:1849:
char *argv[] = {(char *)"prog"};
Str out = StrInit(&a);
ArgRun rc = capture_run(&p, 1, argv, &out);- In
ArgParse.c:1892:
char *argv[] = {(char *)"prog", tok};
Str out = StrInit(&a);
ArgRun rc = capture_run(&p, 2, argv, &out);- In
DateTime.c:146:
static bool test_iso_write_utc(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
DateTime d = DateTimeFromUnixNs(T_2021 * NS_PER_SEC, 0);
StrAppendFmt(&s, "{}", d);- In
DateTime.c:157:
static bool test_iso_write_offset(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
DateTime d = DateTimeFromUnixNs(T_2021 * NS_PER_SEC, IST);
StrAppendFmt(&s, "{}", d);- In
DateTime.c:168:
static bool test_iso_write_nanos(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
DateTime d = DateTimeFromUnixNs(T_2021 * NS_PER_SEC + 123456789ull, 0);
StrAppendFmt(&s, "{}", d);- In
DateTime.c:180:
static bool test_iso_io_roundtrip(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
DateTime a = DateTimeFromUnixNs(T_2021 * NS_PER_SEC + 123456789ull, MST);
StrAppendFmt(&s, "{}", a);- In
Init.c:6:
#include <Misra/Std/Allocator/Heap.h>
#include <Misra/Std/Container/Graph.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>- In
Init.c:83:
DefaultAllocator alloc = DefaultAllocatorInit();
typedef Graph(Str) StrGraph;
StrGraph graph = GraphInitWithDeepCopy(str_init_copy, str_deinit, &alloc);
Str name = StrInitFromZstr("alpha", &alloc);- In
Init.c:85:
typedef Graph(Str) StrGraph;
StrGraph graph = GraphInitWithDeepCopy(str_init_copy, str_deinit, &alloc);
Str name = StrInitFromZstr("alpha", &alloc);
GraphNodeId node_id;
GraphNode node;- In
Init.c:88:
GraphNodeId node_id;
GraphNode node;
Str *stored_name;
node_id = GraphAddNodeL(&graph, name);- In
Init.c:104:
static bool test_graph_node_owned_str_rvalue(void) {
WriteFmt("Testing Graph node owned Str r-value insertion\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Init.c:108:
DefaultAllocator alloc = DefaultAllocatorInit();
typedef Graph(Str) StrGraph;
StrGraph graph = GraphInitWithDeepCopy(NULL, str_deinit, &alloc);
GraphNodeId node_id;- In
Init.c:112:
GraphNodeId node_id;
GraphNode node;
Str *stored_name;
node_id = GraphAddNodeR(&graph, StrZ("alpha", &alloc));- In
Init.c:129:
WriteFmt("Testing Graph init optional allocator\n");
typedef Graph(Str) StrGraph;
// intentional bypass: no public setter on `Allocator` for effort /
- In
Foreach.c:5:
#include <Misra/Std/Container/Graph.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Memory.h>- In
Foreach.c:30:
}
typedef Graph(Str) CityGraph;
typedef Map(Str, GraphNodeId) CityIndex;- In
Foreach.c:31:
typedef Graph(Str) CityGraph;
typedef Map(Str, GraphNodeId) CityIndex;
static GraphNodeId city_add_intersection(CityGraph *graph, CityIndex *index, const Str *name, DefaultAllocator *alloc) {- In
Foreach.c:33:
typedef Map(Str, GraphNodeId) CityIndex;
static GraphNodeId city_add_intersection(CityGraph *graph, CityIndex *index, const Str *name, DefaultAllocator *alloc) {
GraphNodeId id = GraphAddNodeR(graph, StrInitFromCstr(StrBegin(name), StrLen(name), alloc));- In
Foreach.c:36:
GraphNodeId id = GraphAddNodeR(graph, StrInitFromCstr(StrBegin(name), StrLen(name), alloc));
Str key_copy = StrInitFromCstr(StrBegin(name), StrLen(name), alloc);
MapInsertR(index, key_copy, id);
return id;- In
Foreach.c:66:
}
static bool city_reachable(CityGraph *graph, CityIndex *index, const Str *from, const Str *to) {
GraphNodeId *from_id = MapGetFirstPtr(index, *from);
GraphNodeId *to_id = MapGetFirstPtr(index, *to);- In
Foreach.c:89:
// hand its address through; the helpers + Map / Graph deep-copy
// callbacks own the resulting clones.
Str s_alpha = StrInitFromZstr("Alpha", &alloc);
Str s_beta = StrInitFromZstr("Beta", &alloc);
Str s_gamma = StrInitFromZstr("Gamma", &alloc);- In
Foreach.c:90:
// callbacks own the resulting clones.
Str s_alpha = StrInitFromZstr("Alpha", &alloc);
Str s_beta = StrInitFromZstr("Beta", &alloc);
Str s_gamma = StrInitFromZstr("Gamma", &alloc);
Str s_delta = StrInitFromZstr("Delta", &alloc);- In
Foreach.c:91:
Str s_alpha = StrInitFromZstr("Alpha", &alloc);
Str s_beta = StrInitFromZstr("Beta", &alloc);
Str s_gamma = StrInitFromZstr("Gamma", &alloc);
Str s_delta = StrInitFromZstr("Delta", &alloc);
Str s_echo = StrInitFromZstr("Echo", &alloc);- In
Foreach.c:92:
Str s_beta = StrInitFromZstr("Beta", &alloc);
Str s_gamma = StrInitFromZstr("Gamma", &alloc);
Str s_delta = StrInitFromZstr("Delta", &alloc);
Str s_echo = StrInitFromZstr("Echo", &alloc);
Str s_unknown = StrInitFromZstr("Unknown", &alloc);- In
Foreach.c:93:
Str s_gamma = StrInitFromZstr("Gamma", &alloc);
Str s_delta = StrInitFromZstr("Delta", &alloc);
Str s_echo = StrInitFromZstr("Echo", &alloc);
Str s_unknown = StrInitFromZstr("Unknown", &alloc);- In
Foreach.c:94:
Str s_delta = StrInitFromZstr("Delta", &alloc);
Str s_echo = StrInitFromZstr("Echo", &alloc);
Str s_unknown = StrInitFromZstr("Unknown", &alloc);
GraphNodeId alpha = city_add_intersection(&graph, &index, &s_alpha, &alloc);- In
Type.c:56:
Float clone = FloatClone(&original);
Float expected = FloatFromStr("-12.5", &alloc.base);
Str text = FloatToStr(&clone);
FloatAbs(&original);- In
Type.c:211:
bool ok = FloatToInt(&result, &value);
Str text = IntToStr(&result);
bool right = ok && (ZstrCompare(StrBegin(&text), "5") == 0);- In
Type.c:232:
bool ok = FloatToInt(&result, &value);
Str text = IntToStr(&result);
bool right = ok && (ZstrCompare(StrBegin(&text), "120") == 0);- In
Type.c:288:
Float f = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&f, "1E2");
Str text = StrInit(&alloc.base);
text = FloatToStr(&f);- In
Type.c:335:
double two_pow_60 = 1152921504606846976.0; // 2^60, exact in f64
Float value = FloatFrom(two_pow_60, &alloc.base);
Str text = FloatToStr(&value);
bool result = (FloatExponent(&value) == 0);- In
Type.c:353:
Float b = FloatFromStr("0.1", &alloc.base); // exp -1
Float r = FloatInit(&alloc.base);
Str t = StrInit(&alloc.base);
FloatAdd(&r, &a, &b);- In
Type.c:375:
Float z = FloatFromStr("0", &alloc.base); // exp 0, zero
Float r = FloatInit(&alloc.base);
Str t = StrInit(&alloc.base);
FloatAdd(&r, &a, &z);- In
Math.c:77:
Float value = FloatFromStr("12.5", &alloc.base);
Str text = StrInit(&alloc.base);
FloatNegate(&value);- In
Math.c:103:
Float b = FloatFromStr("0.03", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:126:
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:150:
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:198:
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);- In
Math.c:221:
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);- In
Math.c:245:
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);- In
Math.c:288:
Float b = FloatFromStr("-0.2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);- In
Math.c:311:
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);- In
Math.c:335:
Int whole = IntFrom(2, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);- In
Math.c:378:
Float b = FloatFromStr("8", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatDiv(&result_value, &a, &b, 3);- In
Math.c:401:
Float b = FloatFromStr("2", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatDiv(&result_value, &a, &b, 0);- In
Math.c:425:
Int whole = IntFrom(3, &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatDiv(&result_value, &a, &b, 1);- In
Math.c:499:
Float b = FloatFromStr("5", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:527:
Float b = FloatFromStr("-5", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:553:
Float b = FloatFromStr("1.00", &alloc.base);
Float result_value = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);- In
Math.c:860:
Float f = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&f, "+5");
Str text = StrInit(&alloc.base);
text = FloatToStr(&f);- In
Math.c:882:
Float f = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&f, "19");
Str text = StrInit(&alloc.base);
text = FloatToStr(&f);- In
Math.c:902:
Float b = FloatFromStr("3", &alloc.base);
Float quotient = FloatInit(&alloc.base);
Str text = StrInit(&alloc.base);
bool ok = FloatDiv("ient, &a, &b, 8);- In
Math.c:971:
Float a = FloatFromStr("7.5", &alloc.base);
Float r = FloatInit(&alloc.base);
Str text;
bool ok = FloatDiv(&r, &a, 3u, 1);- In
Convert.c:54:
Float value = float_from_u64(42, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "42") == 0;- In
Convert.c:71:
Float value = float_from_i64(-42, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "-42") == 0;- In
Convert.c:89:
Int integer = IntFromStr("12345678901234567890", ALLOCATOR_OF(&alloc));
Float value = float_from_int(&integer, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "12345678901234567890") == 0;- In
Convert.c:107:
Float value = FloatFromStr("1234500e-2", ALLOCATOR_OF(&alloc));
Int result_value = IntInit(ALLOCATOR_OF(&alloc));
Str text = StrInit(ALLOCATOR_OF(&alloc));
bool result = FloatToInt(&result_value, &value);- In
Convert.c:160:
Float value = FloatFromStr("-123.45", ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "-123.45") == 0;- In
Convert.c:174:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text;
bool ok;- In
Convert.c:203:
Float value = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES, ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), FLOAT_TEST_VERY_LARGE_ONES) == 0;- In
Convert.c:219:
Float value = FloatFromStr("1.2300e3", ALLOCATOR_OF(&alloc));
Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "1230") == 0;- In
Convert.c:332:
Int whole = IntFrom(100, &alloc.base);
Float value = FloatFrom(&whole, &alloc.base);
Str text = FloatToStr(&value);
bool result = ZstrCompare(StrBegin(&text), "100") == 0;- In
Convert.c:358:
FloatNegate(&value);
Str text = FloatToStr(&value);
result = result && FloatIsNegative(&value);- In
Convert.c:390:
Float value = FloatFrom((u64)100, &alloc.base);
Str text = FloatToStr(&value);
bool ok = ZstrCompare(StrBegin(&text), "100") == 0;- In
Convert.c:419:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text = StrInitFromZstr("not-a-number", &alloc.base);
Float value = FloatInit(&alloc.base);
bool ok = (FloatTryFromStr(&value, &text) == false);- In
Convert.c:434:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text = StrInitFromZstr("3.14", &alloc.base);
Float value = FloatInit(&alloc.base);
bool ok = FloatTryFromStr(&value, &text);- In
Convert.c:438:
bool ok = FloatTryFromStr(&value, &text);
Str printed = FloatToStr(&value);
ok = ok && (ZstrCompare(StrBegin(&printed), "3.14") == 0);- In
Convert.c:460:
Float value = FloatFromStr("3.14", &alloc.base);
Str text = FloatToStr(&value);
bool result = (ZstrCompare(StrBegin(&text), "3.14") == 0) && (StrLen(&text) == 4);- In
Convert.c:482:
Float value = FloatFromStr("0.001", &alloc.base);
Str text = FloatToStr(&value);
bool result = (ZstrCompare(StrBegin(&text), "0.001") == 0) && (StrLen(&text) == 5);- In
Convert.c:501:
// 1e2 keeps significand 1 with exponent 2, exercising the >= 0 zero loop.
Float value = FloatFromStr("1e2", &alloc.base);
Str text = FloatToStr(&value);
bool result = (ZstrCompare(StrBegin(&text), "100") == 0) && (StrLen(&text) == 3);- In
Convert.c:606:
bool ok = FloatTryFromStr(&value, "1.");
Str text = FloatToStr(&value);
ok = ok && (ZstrCompare(StrBegin(&text), "1") == 0);- In
Convert.c:647:
Float value = FloatFrom(4503599627370496.0, &alloc.base);
Str text = FloatToStr(&value);
bool result = (ZstrCompare(StrBegin(&text), "4503599627370496") == 0) && (StrLen(&text) == 16);- In
Convert.c:827:
Float v = FloatFromStr("12.5", &dbg.base);
Str out = StrInit(&dbg.base);
bool ok = FloatTryToStr(&out, &v);- In
Convert.c:842:
Float v = FloatFromStr("1200", &dbg.base); // exponent >= 0 arm
Str out = StrInit(&dbg.base);
bool ok = FloatTryToStr(&out, &v);- In
Memory.c:3:
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Allocator/Heap.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>- In
Memory.c:447:
// Str the buffer -- including the NUL sentinel -- must be zeroed.
bool test_clear_str_scrubs_sentinel(void) {
WriteFmt("Testing VecClear scrubs Str sentinel byte\n");
DefaultAllocator local = DefaultAllocatorInit();- In
Memory.c:451:
DefaultAllocator local = DefaultAllocatorInit();
Str s = StrInitFromZstr("hello", &local);
StrClear(&s);- In
Memory.c:465:
// mutation. A one-character Str has capacity == 1 exactly.
bool test_clear_str_cap1_scrubs_sentinel(void) {
WriteFmt("Testing VecClear scrubs single-char Str (capacity 1)\n");
DefaultAllocator local = DefaultAllocatorInit();- In
Memory.c:469:
DefaultAllocator local = DefaultAllocatorInit();
Str s = StrInitFromZstr("x", &local);
StrClear(&s); #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h> bool test_blind_regex_match_str_validates(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str p = StrInitFromZstr("1", &alloc);
bitvec_regex_match_str(NULL, &p);
return false; #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
// "111" never appears in "101010" -> must be false.
Str pat_no = StrInitFromZstr("111", &alloc);
result = result && !BitVecRegexMatch(&source, &pat_no); // Sanity: a genuine substring still matches (guards against a trivially
// always-false implementation).
Str pat_yes = StrInitFromZstr("010", &alloc);
result = result && BitVecRegexMatch(&source, &pat_yes); bool test_regex_match_zstr_frees_rendered_str(void);
bool test_regex_match_zstr_frees_rendered_str(void) {
WriteFmt("Testing bitvec_regex_match_zstr frees its rendered Str (1866:5)\n");
DebugAllocator dbg = DebugAllocatorInitWith(lean_dbg_cfg()); bool test_regex_match_str_frees_rendered_str(void);
bool test_regex_match_str_frees_rendered_str(void) {
WriteFmt("Testing bitvec_regex_match_str frees its rendered Str (1883:5)\n");
DebugAllocator dbg = DebugAllocatorInitWith(lean_dbg_cfg());
// Pattern "101" as a Str on a separate (untracked) allocator.
Str pattern = StrInit(pbase);
StrPushBackR(&pattern, '1');
StrPushBackR(&pattern, '0');- In
Convert.c:4:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <Misra/Types.h>- In
Convert.c:52:
// Convert to string
Str str;
bool ok = BitVecTryToStr(&str, &bv);- In
Convert.c:278:
BitVec bv;
Str str;
bool ok = BitVecTryFromStr(&bv, "101001", ALLOCATOR_OF(&alloc));
bool result = ok && (BitVecAllocator(&bv)->effort == alloc.base.effort) &&- In
Convert.c:322:
// Test converting empty bitvec
Str str_obj = BitVecToStr(&bv);
result = result && (StrLen(&str_obj) == 0);
StrDeinit(&str_obj);- In
Convert.c:453:
for (size i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) {
BitVec bv = BitVecFromStr(patterns[i], ALLOCATOR_OF(&alloc));
Str str = BitVecToStr(&bv);
// Should get exact same string back
- In
Convert.c:533:
BitVec empty = BitVecInit(ALLOCATOR_OF(&alloc));
Str empty_str = BitVecToStr(&empty);
result = result && (StrLen(&empty_str) == 0);
StrDeinit(&empty_str);- In
Convert.c:579:
// Test string conversion consistency
Str str = BitVecToStr(&bv);
result = result && (ZstrCompare(StrBegin(&str), test_cases[i].pattern) == 0);
StrDeinit(&str);- In
Convert.c:611:
BitVec bv3 = BitVecFromBytes((u8[]) {0xD6}, 8, ALLOCATOR_OF(&alloc));
Str str1 = BitVecToStr(&bv1);
Str str2 = BitVecToStr(&bv2);
Str str3 = BitVecToStr(&bv3);- In
Convert.c:612:
Str str1 = BitVecToStr(&bv1);
Str str2 = BitVecToStr(&bv2);
Str str3 = BitVecToStr(&bv3);- In
Convert.c:613:
Str str1 = BitVecToStr(&bv1);
Str str2 = BitVecToStr(&bv2);
Str str3 = BitVecToStr(&bv3);
// str2 and str3 are the same integer/byte packing; str1 is the string
- In
Convert.c:651:
// Test string conversion
Str large_str = BitVecToStr(&large_bv);
result = result && (StrLen(&large_str) == 1000);- In
Convert.c:899:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("111000111", &alloc);
BitVec bv = bitvec_from_str_str(&s, ALLOCATOR_OF(&alloc));
bool result = (BitVecLen(&bv) == 9) && (BitVecCountOnes(&bv) == 6);- In
Math.c:114:
Int b = IntFrom(1, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntAdd(&result_value, &a, &b);- In
Math.c:139:
Int result_value = IntInit(&alloc.base);
Int huge = IntFromStr("123456789012345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);
IntAdd(&result_value, &base, &rhs);- In
Math.c:192:
Int preserved = IntFrom(99, &alloc.base);
Int huge = IntFromStr("12345678901234567890", &alloc.base);
Str text = StrInit(&alloc.base);
bool result = IntSub(&result_value, &base, &rhs);- In
Math.c:266:
Int value = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntMul(&result_value, &value, 25u);- In
Math.c:327:
Int exponent = IntFrom(20, &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntPow(&result_value, &base, 20u);- In
Math.c:354:
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);
IntDivMod("ient, &remainder, ÷nd, 97u);- In
Math.c:395:
Int dividend = IntFromStr("12345678901234567890", &alloc.base);
Int result_value = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
bool result = IntDivExact(&result_value, ÷nd, 90u);- In
Math.c:435:
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
IntDivMod("ient, &remainder, ÷nd, 97);- In
Math.c:905:
Int value = IntFromStr("1000000000", &alloc.base);
Int next = IntInit(&alloc.base);
Str text = StrInit(&alloc.base);
bool ok = IntNextPrime(&next, &value);- In
Math.c:1930:
IntAdd(&sum, &ones, &one);
Str bits = IntToBinary(&sum);
bool result = (IntToU64(&sum) == 128u);- In
Math.c:2447:
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);
bool ok = int_div_mod_u64("ient, &remainder, ÷nd, 97u);- In
Math.c:2477:
Int quotient = IntInit(&alloc.base);
Int remainder = IntInit(&alloc.base);
Str qtext = StrInit(&alloc.base);
bool ok = int_div_mod_i64("ient, &remainder, ÷nd, (i64)13);- In
Math.c:3159:
bool ok = int_div_mod("ient, &remainder, ÷nd, &divisor);
Str qtext = IntToStr("ient);
Str rtext = IntToStr(&remainder);- In
Math.c:3160:
Str qtext = IntToStr("ient);
Str rtext = IntToStr(&remainder);
bool result = ok;- In
Convert.c:99:
Int value = IntFrom(13, ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&value);
bool result = IntBitLength(&value) == 4;- In
Convert.c:120:
Int value = IntFromBytesLE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
u64 written = IntToBytesLE(&value, out, sizeof(out));
Str text = IntToHexStr(&value);
bool result = written == 4;- In
Convert.c:141:
Int value = IntFromBytesBE(bytes, sizeof(bytes), ALLOCATOR_OF(&alloc));
u64 written = IntToBytesBE(&value, out, sizeof(out));
Str text = IntToHexStr(&value);
bool result = written == 4;- In
Convert.c:159:
Int value = IntFromBinary("001011", ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&value);
bool result = IntToU64(&value) == 11;- In
Convert.c:177:
Zstr digits = "123456789012345678901234567890";
Int value = IntFromStr(digits, ALLOCATOR_OF(&alloc));
Str text = IntToStr(&value);
bool result = ZstrCompare(StrBegin(&text), digits) == 0;- In
Convert.c:193:
Int value = IntFromStrRadix("zz", 36, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 36, false);
bool result = IntToU64(&value) == 1295;- In
Convert.c:210:
Int value = IntFrom(0xBEEF, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 16, true);
bool result = ZstrCompare(StrBegin(&text), "BEEF") == 0;- In
Convert.c:224:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text;
bool ok;- In
Convert.c:270:
Int zero = IntFromBinary("0", ALLOCATOR_OF(&alloc));
Str text = IntToBinary(&zero);
bool error = true;- In
Convert.c:306:
Int value = IntFromOctStr("0o7_55", ALLOCATOR_OF(&alloc));
Str text = IntToOctStr(&value);
bool result = IntToU64(&value) == 493;- In
Convert.c:324:
Zstr hex = "deadbeefcafebabe1234";
Int value = IntFromHexStr(hex, ALLOCATOR_OF(&alloc));
Str text = IntToHexStr(&value);
bool result = ZstrCompare(StrBegin(&text), hex) == 0;- In
Convert.c:451:
Int value = IntFrom(255, ALLOCATOR_OF(&alloc));
Str text = IntToStrRadix(&value, 37, false);
bool result = StrLen(&text) == 0;- In
Convert.c:731:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text = StrInitFromZstr("0b101", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_binary_str(&out, &text);- In
Convert.c:758:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text = StrInitFromZstr("0B101", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_binary_str(&out, &text);- In
Convert.c:785:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text = StrInitFromZstr("1101", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_binary_str(&out, &text);- In
Convert.c:819:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text = StrInitFromZstr("0o17", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_oct_str_str(&out, &text);- In
Convert.c:845:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text = StrInitFromZstr("0O17", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_oct_str_str(&out, &text);- In
Convert.c:870:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text = StrInitFromZstr("17", &alloc);
Int out = IntInit(&alloc.base);
bool ok = int_try_from_oct_str_str(&out, &text);- In
Convert.c:894:
Int big = IntFromStr("123456789012345678901234567890", &alloc.base);
Str dec_small = IntToStrRadix(&small, 10, false, &alloc.base);
Str hex_mid = IntToStrRadix(&mid, 16, false, &alloc.base);
Str hex_mid_u = IntToStrRadix(&mid, 16, true, &alloc.base);- In
Convert.c:895:
Str dec_small = IntToStrRadix(&small, 10, false, &alloc.base);
Str hex_mid = IntToStrRadix(&mid, 16, false, &alloc.base);
Str hex_mid_u = IntToStrRadix(&mid, 16, true, &alloc.base);
Str dec_big = IntToStrRadix(&big, 10, false, &alloc.base);- In
Convert.c:896:
Str dec_small = IntToStrRadix(&small, 10, false, &alloc.base);
Str hex_mid = IntToStrRadix(&mid, 16, false, &alloc.base);
Str hex_mid_u = IntToStrRadix(&mid, 16, true, &alloc.base);
Str dec_big = IntToStrRadix(&big, 10, false, &alloc.base);- In
Convert.c:897:
Str hex_mid = IntToStrRadix(&mid, 16, false, &alloc.base);
Str hex_mid_u = IntToStrRadix(&mid, 16, true, &alloc.base);
Str dec_big = IntToStrRadix(&big, 10, false, &alloc.base);
bool result = (ZstrCompare(StrBegin(&dec_small), "7") == 0);- In
Convert.c:927:
Int parsed_hex = IntFromStrRadix("deadbeef", 16, &alloc.base);
Str back_dec = IntToStrRadix(&parsed_dec, 10, false, &alloc.base);
Str back_hex = IntToStrRadix(&parsed_hex, 16, false, &alloc.base);- In
Convert.c:928:
Str back_dec = IntToStrRadix(&parsed_dec, 10, false, &alloc.base);
Str back_hex = IntToStrRadix(&parsed_hex, 16, false, &alloc.base);
bool result = (ZstrCompare(StrBegin(&back_dec), "987654321987654321") == 0);- In
Convert.c:1000:
// path, so this test isolates the init-const mutant.)
bool test_m20_from_str_str_no_sign(void) {
WriteFmt("Testing int_try_from_str_str start offset with no sign (Str \"123\")\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:1004:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text = StrInitFromZstr("123", &alloc);
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromStr(&out, &text);- In
Convert.c:1031:
// value), a distinguishable caller-observable outcome.
bool test_m20_from_str_str_plus_sign(void) {
WriteFmt("Testing int_try_from_str_str leading '+' handling (Str \"+5\")\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:1035:
DefaultAllocator alloc = DefaultAllocatorInit();
Str text = StrInitFromZstr("+5", &alloc);
Int out = IntInit(&alloc.base);
bool parsed = IntTryFromStr(&out, &text);- In
Convert.c:1059:
DefaultAllocator alloc = DefaultAllocatorInit();
Str digits = StrInitFromZstr("123", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, &digits, 10);- In
Convert.c:1087:
DefaultAllocator alloc = DefaultAllocatorInit();
Str digits = StrInitFromZstr("+5", ALLOCATOR_OF(&alloc));
Int value = IntInit(ALLOCATOR_OF(&alloc));
bool ok = IntTryFromStrRadix(&value, &digits, 10);- In
Convert.c:1453:
///
static bool test_m28_from_str_str_parses(void) {
WriteFmt("Testing int_from_str_str parses Str decimal\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:1457:
DefaultAllocator alloc = DefaultAllocatorInit();
Str digits = StrInitFromZstr("12345", &alloc.base);
Int value = IntFromStr(&digits, &alloc.base);- In
Convert.c:1474:
///
static bool test_m28_from_str_radix_str_parses(void) {
WriteFmt("Testing int_from_str_radix_str parses Str hex\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:1478:
DefaultAllocator alloc = DefaultAllocatorInit();
Str digits = StrInitFromZstr("ff", &alloc.base);
Int value = IntFromStrRadix(&digits, (u8)16u, &alloc.base);- In
Convert.c:1502:
DefaultAllocator alloc = DefaultAllocatorInit();
Str hex = StrInitFromZstr("ff", &alloc.base);
Int value = IntInit(&alloc.base);- In
Convert.c:1527:
DefaultAllocator alloc = DefaultAllocatorInit();
Str hex = StrInitFromZstr("12g3", &alloc.base);
Int value = IntInit(&alloc.base);- In
Convert.c:1573:
// (1583/1584) and int_mod_u64 (1630).
Int v = IntFrom(1234567u, a);
Str s = IntToStrRadix(&v, 10, false, a);
bool ok = StrLen(&s) == 7;
u64 rem = 0;- In
Convert.c:1625:
Int value = IntFromStr("123456789012345678901234567890", alloc);
Str hex = IntToStrRadix(&value, 16, false, alloc);
Int parsed = IntFromStrRadix(&hex, 16, alloc);- In
UserTypes.c:11:
// seen. Log.h pulls Io.h, so it lives below the include of Io.h.
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Types.h>- In
UserTypes.c:53:
// nested expansions from inside an outer writer's own body. Pattern A in
// 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);- In
UserTypes.c:55:
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);
bool _write_Region(Str *o, FmtInfo *info, Region *r);- In
UserTypes.c:57:
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:60:
Zstr _read_Region(Zstr i, FmtInfo *info, Region *r);
bool _write_Point2D(Str *o, FmtInfo *info, Point2D *p) {
(void)info;
if (!o || !p) {- In
UserTypes.c:80:
// `_Generic` arm for `Point2D` resolves correctly from inside another
// user-type writer.
bool _write_Bounds(Str *o, FmtInfo *info, Bounds *b) {
(void)info;
if (!o || !b) {- In
UserTypes.c:100:
// a standalone Point2D plus an in-tree i32. Exercises a writer that mixes
// nested user types, repeated user types, and built-ins in one call.
bool _write_Region(Str *o, FmtInfo *info, Region *r) {
(void)info;
if (!o || !r) {- In
UserTypes.c:131:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Point2D p = {.x = 3, .y = 4};- In
UserTypes.c:146:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Point2D p = {.x = -1, .y = 2};- In
UserTypes.c:173:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Point2D src = {.x = 100, .y = -200};- In
UserTypes.c:192:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Bounds b = {- In
UserTypes.c:210:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Bounds src = {- In
UserTypes.c:234:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Region r = {- In
UserTypes.c:253:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Region src = {- In
UserTypes.c:280:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Region region = {- In
Write.c:4:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Int.h>- In
Write.c:42:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:70:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:95:
StrClear(&output);
Str s = StrInitFromZstr("World", &alloc);
StrAppendFmt(&output, "{}", s);
success = success && (ZstrCompare(StrBegin(&output), "World") == 0);- In
Write.c:110:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:182:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:203:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:220:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:237:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:259:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:285:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:312:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:350:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:374:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:390:
StrClear(&output);
Str s = StrInitFromZstr("MiXeD CaSe", &alloc);
StrAppendFmt(&output, "{c}", s);- In
Write.c:534:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:598:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool success = true;- In
Write.c:644:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool success = true;
Float exact = FloatFromStr("1234567890.012345", alloc_base);- In
Write.c:682:
bool test_str_write_fmt_clears(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "old prefix ");
StrWriteFmt(&s, "fresh {}", LVAL(42));- In
Write.c:697:
bool test_str_patch_fmt(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "AAAAAAAA");
size before_length = StrLen(&s);- In
Write.c:720:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Buf b = BufInit(&alloc);- In
Write.c:743:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:890:
}
// Same, but the trailing literal is an escaped '{'.
StrClear((Str *)&b);
ok = ok && BufWriteFmt(&b, "{>1r}{{", (u8)'Q');
{- In
Write.c:910:
bool test_datetime_iso_write(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
bool ok = true;
u64 base = 1609459200ull * 1000000000ull; // 2021-01-01T00:00:00Z
- In
Write.c:971:
// File (positioned at 0) and stashing the path in `*out_path` so the
// caller can FileRemove + StrDeinit it afterwards.
static File m4_make_temp(DefaultAllocator *alloc, Str *out_path, const char *content, u64 len) {
File f = FileOpenTemp(out_path, alloc);
if (!FileIsOpen(&f))- In
Write.c:980:
}
static void m4_cleanup(File *f, Str *path) {
FileClose(f);
FileRemove(path);- In
Write.c:999:
StrReadFmt(input, "{}", f);
Str text = FloatToStr(&f);
bool ok = (ZstrCompare(StrBegin(&text), expected) == 0);- In
Write.c:1013:
bool ok = false;
if (FileIsOpen(&f)) {
Str back = StrInit(&alloc);
FileRead(&f, &back);
ok = (ZstrCompare(StrBegin(&back), expect) == 0);- In
Write.c:1085:
Zstr in = "\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"";
Str s = StrInit(&alloc);
Zstr out = READ1(in, "{s}", TO_TYPE_SPECIFIC_IO(Str, &s));- 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:1185:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1188:
bool ok = true;
Str s = StrInitFromZstr("xyz", &alloc);
StrAppendFmt(&output, "AB");- In
Write.c:1210:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1213:
bool ok = true;
Str s = StrInitFromZstr("hi", &alloc);
StrAppendFmt(&output, "{<5}", s);
ok = ok && (ZstrCompare(StrBegin(&output), "hi ") == 0);- In
Write.c:1229:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1232:
bool ok = true;
Str s = StrInit(&alloc);
StrPushBackR(&s, (char)0x0F); // single byte 0x0F -> "f"
- In
Write.c:1249:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1252:
bool ok = true;
Str s = StrInit(&alloc);
StrPushBackR(&s, (char)0x0F);- In
Write.c:1270:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1273:
bool ok = true;
Str s = StrInit(&alloc);
StrPushBackR(&s, (char)0x01);
StrPushBackR(&s, (char)0x02);- In
Write.c:1292:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1295:
bool ok = true;
Str s = StrInit(&alloc);
StrPushBackR(&s, (char)0x05);- In
Write.c:1312:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1315:
bool ok = true;
Str s = StrInitFromZstr("hello", &alloc);
StrAppendFmt(&output, "{.3}", s);
ok = ok && (ZstrCompare(StrBegin(&output), "hel") == 0);- In
Write.c:1330:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:1333:
bool ok = true;
Str s = StrInitFromZstr("hello", &alloc);
StrAppendFmt(&output, "{.0}", s);
ok = ok && (StrLen(&output) == 0);- In
Write.c:1519:
static bool test_m13_zstr_hex_multibyte(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "AB"; // 0x41 0x42
- In
Write.c:1535:
static bool test_m13_zstr_hex_single_byte(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Z"; // 0x5a
- In
Write.c:1552:
static bool test_m13_zstr_hex_lowercase_letters(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "\xab"; // single byte 0xab
- In
Write.c:1569:
static bool test_m13_zstr_hex_uppercase_letters(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "\xab";- In
Write.c:1585:
static bool test_m13_zstr_hex_zero_pad_nibble(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "\x05"; // single byte 0x05
- In
Write.c:1600:
static bool test_m13_zstr_hex_no_pad_two_digits(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "\xfe";- In
Write.c:1616:
static bool test_m13_zstr_precision_truncate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hello";- In
Write.c:1632:
static bool test_m13_zstr_precision_longer_noop(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hi";- In
Write.c:1649:
static bool test_m13_zstr_precision_zero_empty(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hello";- In
Write.c:1665:
static bool test_m13_zstr_precision_one(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hello";- In
Write.c:1684:
static bool test_m13_zstr_pad_after_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hi";- In
Write.c:1699:
static bool test_m13_zstr_left_pad_after_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "Hi";- In
Write.c:1714:
static bool test_m13_zstr_empty_padded(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
Zstr s = "";- In
Write.c:1979:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("1.0", alloc_base);- In
Write.c:1999:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("0.0", alloc_base);- In
Write.c:2021:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("0.0", alloc_base);- In
Write.c:2042:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("12.0", alloc_base);- In
Write.c:2062:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
bool ok = true;
Float v = FloatFromStr("12345.67", alloc_base);- In
Write.c:2394:
success = success && (ZstrLen(z) == 0);
Str text = FloatToStr(&val);
success = success && (ZstrCompare(StrBegin(&text), "3.5") == 0);
StrDeinit(&text);- In
Write.c:2422:
success = success && (ZstrLen(z) == 0);
Str text = FloatToStr(&val);
success = success && (ZstrCompare(StrBegin(&text), "12.25") == 0);
StrDeinit(&text);- In
Write.c:2449:
// 1.5e2 == 150
Str text = FloatToStr(&val);
success = success && (ZstrCompare(StrBegin(&text), "150") == 0);
StrDeinit(&text);- In
Write.c:2474:
success = success && (ZstrLen(z) == 0);
Str text = FloatToStr(&val);
success = success && (ZstrCompare(StrBegin(&text), "-0.25") == 0);
StrDeinit(&text);- In
Write.c:2557:
static bool test_m24_zero_pad_positive_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2579:
static bool test_m24_zero_pad_width_equals_content_no_pad(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2605:
static bool test_m24_zero_pad_negative_sign_kept_ahead(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2634:
static bool test_m24_zero_pad_positive_no_sign_shift(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2662:
static bool test_m24_zero_pad_negative_wide(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2687:
static bool test_m24_zero_pad_hex_width16_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:2716:
Float val = FloatFromStr("12", alloc_base);
Str out;
success = success && float_try_to_decimal_str(&out, &val, 3, true, alloc_base);
success = success && (ZstrCompare(StrBegin(&out), "12.000") == 0);- In
Write.c:2738:
Float val = FloatFromStr("12", alloc_base);
Str out;
success = success && float_try_to_decimal_str(&out, &val, 0, true, alloc_base);
success = success && (ZstrCompare(StrBegin(&out), "12") == 0);- In
Write.c:2761:
Float val = FloatFromStr("1.5", alloc_base);
Str out;
success = success && float_try_to_decimal_str(&out, &val, 3, true, alloc_base);
success = success && (ZstrCompare(StrBegin(&out), "1.500") == 0);- In
Write.c:2783:
Float val = FloatFromStr("1.5", alloc_base);
Str out;
success = success && float_try_to_decimal_str(&out, &val, 0, true, alloc_base);
success = success && (ZstrCompare(StrBegin(&out), "1") == 0);- In
Write.c:2805:
Float val = FloatFromStr("1.25", alloc_base);
Str out;
success = success && float_try_to_decimal_str(&out, &val, 1, true, alloc_base);
success = success && (ZstrCompare(StrBegin(&out), "1.2") == 0);- In
Write.c:2823:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2843:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2861:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2883:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2906:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2927:
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
bool ok = true;- In
Write.c:2950:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.0", &alloc.base);- In
Write.c:2970:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Float v = FloatFromStr("0.001", &alloc.base);- In
Write.c:2989:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Float v = FloatFromStr("1e12", &alloc.base);- In
Write.c:3079:
static bool test_m28_i64_hex_lower(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 255; // 0xff
- In
Write.c:3094:
static bool test_m28_i64_hex_upper(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 255;- In
Write.c:3108:
static bool test_m28_i64_binary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 5; // 0b101
- In
Write.c:3121:
static bool test_m28_i64_octal(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 8; // 0o10
- In
Write.c:3135:
static bool test_m28_i64_decimal_negative(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = -42;- In
Write.c:3148:
static bool test_m28_i64_width_after_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 42;- In
Write.c:3163:
static bool test_m28_i64_zeropad_after_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 42;- In
Write.c:3228:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
Int a = IntFrom(0x41, alloc_base); // 'A'
bool success = true;- In
Write.c:3247:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
Int a = IntFrom(0x7a, alloc_base); // 'z'
bool success = true;- In
Write.c:3272:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
Int seven = IntFrom(7, alloc_base);
bool success = true;- In
Write.c:3294:
static bool test_m3_unclosed_brace_fails(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i32 v = 5;- In
Write.c:3312:
static bool test_m3_raw_u8(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u8 v = 200;- In
Write.c:3332:
static bool test_m3_raw_u16(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u16 v = 258;- In
Write.c:3352:
static bool test_m3_raw_u32(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u32 v = 65538;- In
Write.c:3372:
static bool test_m3_raw_u64(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u64 v = 4294967298ULL;- In
Write.c:3391:
static bool test_m3_raw_i64(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = 4294967298LL;- In
Write.c:3410:
static bool test_m3_raw_f64(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
f64 v = 1.5;- In
Write.c:3432:
static bool test_m30_u64_width_pad_with_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:3453:
static bool test_m30_u64_width_pad_no_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:3475:
static bool test_m30_u64_zero_pad_with_prefix(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:3632:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", alloc_base);- In
Write.c:3651:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", alloc_base);- In
Write.c:3676:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.2", alloc_base);- In
Write.c:3717:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
BitVec bv = BitVecFromStr("1", alloc_base);- In
Write.c:3750:
static bool test_m33_patch_fmt_malformed_returns_false(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str o = StrInitFromZstr("-----", &alloc);
// "AB{" pushes "AB" into the scratch then hits an unclosed spec ->
- In
Write.c:3768:
static bool test_m33_patch_fmt_empty_at_end(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str o = StrInitFromZstr("hello", &alloc);
bool r = StrPatchFmt(&o, StrLen(&o), ""); // offset == length, empty render
- In
Write.c:3784:
static bool test_m33_patch_fmt_exact_fit(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str o = StrInitFromZstr("-----", &alloc); // length 5
bool r = StrPatchFmt(&o, 0, "12345"); // renders exactly 5 chars
- In
Write.c:3825:
StrReadFmt(z, "{o}", oct);
Str oct_text = IntToOctStr(&oct);
bool ok = (ZstrCompare(StrBegin(&oct_text), "7") == 0);- In
Write.c:3840:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str output = StrInit(&alloc);
Zstr name = "hello";- In
Write.c:3856:
static bool test_m33_i8_char_emits(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
i8 v = (i8)'Q';- In
Write.c:3873:
static bool test_m33_f32_char_emits_four_bytes(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
// Choose a bit pattern whose 4 bytes are all printable: 0x42434445 -> "BCDE".
- In
Write.c:3958:
bool test_if_1230_hex_low_nibble_digit_selection(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:3965:
// write_int_as_chars path instead), so render a Str holding the byte 0x1A.
// 0x1A: hi nibble 0x01 (<10 -> '1'), low nibble 0x0A (>=10 -> 'a') => "\x1a".
Str src = StrInit(&alloc);
StrPushBackR(&src, 0x1A);
StrAppendFmt(&out, "{c}", src);- In
Write.c:3996:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4026:
bool test_if_238_zero_pad_exact_width_boundary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4052:
bool test_if_257_space_pad_exact_width_boundary(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4114:
bool test_if_514_patch_fmt_behaviour(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
bool ok = true;- In
Write.c:4139:
bool test_if_1703_str_zero_width_no_pad(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4142:
bool ok = true;
Str s = StrInitFromZstr("hello", &alloc);
StrAppendFmt(&out, "{}", s); // width defaults to 0 -> no padding
ok = ok && (ZstrCompare(StrBegin(&out), "hello") == 0);- In
Write.c:4163:
bool test_if_2067_f64_default_and_explicit_precision(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4190:
static bool test_m4_seekable_position_advance(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = m4_make_temp(&alloc, &path, "42 zzzzzzz", 10);
bool ok = FileIsOpen(&f);- In
Write.c:4215:
static bool test_m4_cur_pos_from_probe(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = m4_make_temp(&alloc, &path, "7", 1);
bool ok = FileIsOpen(&f);- In
Write.c:4240:
static bool test_m4_consumed_offset_exact(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = m4_make_temp(&alloc, &path, "53 and more text", 16);
bool ok = FileIsOpen(&f);- In
Write.c:4655:
static bool test_m8_zero_pad_width5(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4675:
static bool test_m8_zero_pad_width7_double_zero(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4692:
static bool test_m8_zero_pad_width9(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4714:
static bool test_m8_width9_space_pad(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4739:
static bool test_m8_precision9_string(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Write.c:4771:
#define DBG_BEGIN(dbg, out) \
DebugAllocator dbg = DebugAllocatorInit(); \
Str out = StrInit(&dbg)
#define LEAK_CFG \- In
Write.c:4779:
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG); \
Allocator *adbg = ALLOCATOR_OF(&dbg); \
Str out = StrInit(adbg); \
bool ok = true- In
Write.c:4793:
// ===========================================================================
// Tear down `out`, then assert no scratch leaked, then deinit the allocator.
static bool dbg_no_leak(DebugAllocator *dbg, Str *out) {
StrDeinit(out);
bool ok = (DebugAllocatorLiveCount(dbg) == 0);- In
Write.c:4806:
static bool test_pfs_zero_pad_detect(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u32 v = 7;
StrAppendFmt(&out, "{05}", v);- In
Write.c:4820:
static bool test_pfs_width_parse(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Zstr s = "ab";
StrAppendFmt(&out, "{4}", s);- In
Write.c:4839:
static bool test_pfs_precision_parse(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
f64 v = 3.14159;
StrAppendFmt(&out, "{.2}", v);- In
Write.c:4856:
static bool test_pfs_dot_no_digit_rejected(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
StrAppendFmt(&out, "literal");
i32 v = 5;- In
Write.c:4874:
static bool test_pad_zeros_signed(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i32 v = -7;
StrAppendFmt(&out, "{05}", v);- In
Write.c:4891:
static bool test_pad_zeros_exact_and_under(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u32 v = 123;
StrAppendFmt(&out, "{03}", v);- In
Write.c:4907:
static bool test_strpad_exact_and_under(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Zstr s = "abc";
StrAppendFmt(&out, "{3}", s);- In
Write.c:4923:
static bool test_brace_escape_open(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
StrAppendFmt(&out, "a{{b");
bool ok = (ZstrCompare(StrBegin(&out), "a{b") == 0);- In
Write.c:4934:
static bool test_brace_escape_close(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
StrAppendFmt(&out, "a}}b");
bool ok = (ZstrCompare(StrBegin(&out), "a}b") == 0);- In
Write.c:4946:
static bool test_brace_scan_close(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u32 v = 0xAB;
StrAppendFmt(&out, "{x}", v);- In
Write.c:4962:
static bool test_raw_write_u16_value(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u16 v = 0x1234; // 4660
bool rc = StrAppendFmt(&out, "{<2r}", v);- In
Write.c:4975:
static bool test_raw_write_u64_value(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u64 v = 0x0102030405060708ULL; // 72623859790382856
bool rc = StrAppendFmt(&out, "{>8r}", v);- In
Write.c:4990:
static bool test_fwrite_roundtrip(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = FileOpenTemp(&path, &alloc);
bool ok = FileIsOpen(&f);- In
Write.c:4998:
File r = FileOpen(StrBegin(&path), "r");
if (FileIsOpen(&r)) {
Str back = StrInit(&alloc);
FileRead(&r, &back);
ok = ok && (ZstrCompare(StrBegin(&back), "n=42\n") == 0);- In
Write.c:5019:
static bool test_fwrite_empty_skipped(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = FileOpenTemp(&path, &alloc);
bool ok = FileIsOpen(&f);- In
Write.c:5029:
File r = FileOpen(StrBegin(&path), "r");
if (FileIsOpen(&r)) {
Str back = StrInit(&alloc);
FileRead(&r, &back);
ok = ok && (ZstrCompare(StrBegin(&back), "X") == 0);- In
Write.c:5066:
static bool test_str_hex_no_leak(void) {
DBG_BEGIN(dbg, out);
Str s = StrInit(&dbg);
StrPushBackR(&s, (char)0x01);
StrPushBackR(&s, (char)0x4F); // multi-digit so StrLen(&hex)!=1 path
- In
Write.c:5079:
static bool test_str_hex_nibble_no_leak(void) {
DBG_BEGIN(dbg, out);
Str s = StrInit(&dbg);
StrPushBackR(&s, (char)0x05);
StrAppendFmt(&out, "{x}", s);- In
Write.c:5108:
static bool test_str_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Str s = StrInitFromZstr("hi", &alloc);
StrAppendFmt(&out, "{}", s); // width 0 default
- In
Write.c:5109:
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Str s = StrInitFromZstr("hi", &alloc);
StrAppendFmt(&out, "{}", s); // width 0 default
bool ok = (ZstrCompare(StrBegin(&out), "hi") == 0);- In
Write.c:5123:
static bool test_zstr_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
Zstr s = "hi";
StrAppendFmt(&out, "{}", s);- In
Write.c:5158:
static bool test_u64_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
u64 v = 42;
StrAppendFmt(&out, "{}", v);- In
Write.c:5172:
static bool test_i64_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
i64 v = -42;
StrAppendFmt(&out, "{}", v);- In
Write.c:5188:
static bool test_f64_char_bytes(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
// Build a double whose 8 BE bytes are all printable ASCII: "ABCDEFGH".
f64 v;- In
Write.c:5204:
static bool test_f64_inf_sign(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
f64 ninf = -F64_INFINITY;
StrAppendFmt(&out, "{}", ninf);- In
Write.c:5223:
static bool test_f64_default_precision(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
f64 v = 1.5;
StrAppendFmt(&out, "{}", v);- In
Write.c:5248:
static bool test_f64_width_gate(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
f64 v = 1.5;
StrAppendFmt(&out, "{.1}", v);- In
Write.c:5265:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("12345.67", ab);
StrAppendFmt(&out, "{e}", v);- In
Write.c:5289:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.0", ab);
StrAppendFmt(&out, "{e}", v);- In
Write.c:5304:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("2.0", ab);
StrAppendFmt(&out, "{e}", v);- In
Write.c:5330:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("3.14159", ab);
StrAppendFmt(&out, "{.2}", v);- In
Write.c:5349:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("5", ab);
StrAppendFmt(&out, "{.3}", v);- In
Write.c:5373:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.5", ab);
StrAppendFmt(&out, "{}", v);- In
Write.c:5392:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Float v = FloatFromStr("1.5", ab);
StrAppendFmt(&out, "AB");- In
Write.c:5419:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
BitVec bv = BitVecFromStr("101", ab);
StrAppendFmt(&out, "{}", bv);- In
Write.c:5448:
DefaultAllocator alloc = DefaultAllocatorInit();
Allocator *ab = ALLOCATOR_OF(&alloc);
Str out = StrInit(&alloc);
Int v = IntFrom(42, ab);
StrAppendFmt(&out, "{}", v);- In
Write.c:5468:
bool test_leak_write_str_hex_per_byte_freed(void) {
HeapAllocator sa = HeapAllocatorInit();
Str s = StrInit(ALLOCATOR_OF(&sa));
for (int i = 0; i < 8; ++i)
StrPushBackR(&s, (char)0xAB);- In
Write.c:5472:
StrPushBackR(&s, (char)0xAB);
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str out = StrInit(ALLOCATOR_OF(&dbg));
bool ok = StrAppendFmt(&out, "{x}", s) && (StrLen(&out) > 0);
StrDeinit(&out);- In
Write.c:5519:
Float v = FloatFromStr("12345.67", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{e}", v);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5545:
Float v = FloatFromStr("0.0", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{.3e}", v);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5571:
Float v = FloatFromStr("3.14159", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{.2}", v);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5598:
Float v = FloatFromStr("42", ALLOCATOR_OF(&fa));
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{.2}", v);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5625:
Zstr s = "AB"; // multi-byte Zstr -> hex loop runs per byte
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{x}", s);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5649:
i32 v = -123456;
Str out = StrInit(adbg);
bool ok = StrAppendFmt(&out, "{}", v);
ok = ok && (StrLen(&out) > 0);- In
Write.c:5675:
bool test_leak_write_str_freed(void) {
HeapAllocator va = HeapAllocatorInit();
Str s = StrInit(ALLOCATOR_OF(&va));
StrAppendFmt(&s, "payload");
LEAK_WRITE_PRELUDE();- In
Read.c:4:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Int.h>- In
Read.c:39:
// File (positioned at 0) and stashing the path in `*out_path` so the
// caller can FileRemove + StrDeinit it afterwards.
static File m4_make_temp(DefaultAllocator *alloc, Str *out_path, const char *content, u64 len) {
File f = FileOpenTemp(out_path, alloc);
if (!FileIsOpen(&f))- In
Read.c:48:
}
static void m4_cleanup(File *f, Str *path) {
FileClose(f);
FileRemove(path);- In
Read.c:351:
bool success = true;
Str s = StrInit(&alloc);
z = "Hello";
StrReadFmt(z, "{}", s);- In
Read.c:355:
StrReadFmt(z, "{}", s);
Str expected = StrInitFromZstr("Hello", &alloc);
success = success && (StrCmp(&s, &expected) == 0);
StrDeinit(&expected);- In
Read.c:396:
i32 num = 0;
Str name = StrInit(&alloc);
z = "Count: 42, Name: Alice";
StrReadFmt(z, "Count: {}, Name: {}", num, name);- In
Read.c:402:
success = success && (num == 42);
Str expected = StrInitFromZstr("Alice", &alloc);
success = success && (StrCmp(&name, &expected) == 0);
StrDeinit(&expected);- In
Read.c:603:
success = success && abc_pass;
Str str_val = StrInit(&alloc);
z = "Hello";
StrReadFmt(z, "{c}", str_val);- In
Read.c:606:
z = "Hello";
StrReadFmt(z, "{c}", str_val);
Str expected = StrInitFromZstr("Hello", &alloc);
bool str_pass = (StrCmp(&str_val, &expected) == 0);
WriteFmt("str_val test: comparing with 'Hello', pass = {}\n", str_pass ? "true" : "false");- In
Read.c:639:
// Test 1: :a (lowercase) conversion
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";- In
Read.c:653:
// Should read "hello" (stops at first space)
Str expected = StrInitFromZstr("hello world", &alloc);
bool test1_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'hello', Pass: {}\n\n", test1_pass ? "true" : "false");- In
Read.c:664:
// Test 1.1: :a (lowercase) conversion
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";- In
Read.c:678:
// Should read "hello" (stops at first space)
Str expected = StrInitFromZstr("hello", &alloc);
bool test1_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'hello', Pass: {}\n\n", test1_pass ? "true" : "false");- In
Read.c:689:
// Test 2: :A (uppercase) conversion
{
Str result = StrInit(&alloc);
Zstr in = "hello world";- In
Read.c:703:
// Should read "HELLO" (stops at first space)
Str expected = StrInitFromZstr("HELLO WORLD", &alloc);
bool test2_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'HELLO', Pass: {}\n\n", test2_pass ? "true" : "false");- In
Read.c:714:
// Test 2.1: :A (uppercase) conversion
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world";- In
Read.c:715:
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world";- In
Read.c:735:
// Test 2.2: :A (uppercase) conversion
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world mighty misra";- In
Read.c:736:
{
Str result1 = StrInit(&alloc);
Str result2 = StrInit(&alloc);
Zstr in = "hello world mighty misra";- In
Read.c:758:
// Test 3: :a with quoted string
{
Str result = StrInit(&alloc);
Zstr in = "\"MiXeD CaSe\"";- In
Read.c:772:
// Should read "mixed case" (converts the entire quoted string)
Str expected = StrInitFromZstr("mixed case", &alloc);
bool test3_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'mixed case', Pass: {}\n\n", test3_pass ? "true" : "false");- In
Read.c:783:
// Test 4: :A with quoted string containing special characters
{
Str result = StrInit(&alloc);
Zstr in = "\"abc123XYZ\"";- In
Read.c:797:
// Should read "ABC123XYZ" (only letters are converted, numbers unchanged)
Str expected = StrInitFromZstr("ABC123XYZ", &alloc);
bool test4_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'ABC123XYZ', Pass: {}\n\n", test4_pass ? "true" : "false");- In
Read.c:808:
// Test 5: Regular :c format (no case conversion) for comparison
{
Str result = StrInit(&alloc);
Zstr in = "Hello World";- In
Read.c:822:
// Should read "Hello" (stops at first space, no case conversion)
Str expected = StrInitFromZstr("Hello World", &alloc);
bool test5_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'Hello World', Pass: {}\n\n", test5_pass ? "true" : "false");- In
Read.c:849:
z = "10110";
StrReadFmt(z, "{}", bv1);
Str result1 = BitVecToStr(&bv1);
success = success && (ZstrCompare(StrBegin(&result1), "10110") == 0);
WriteFmt(- In
Read.c:878:
z = " 1101";
StrReadFmt(z, "{}", bv4);
Str result4 = BitVecToStr(&bv4);
success = success && (ZstrCompare(StrBegin(&result4), "1101") == 0);
WriteFmt(- In
Read.c:891:
z = "0";
StrReadFmt(z, "{}", bv5);
Str result5 = BitVecToStr(&bv5);
success = success && (ZstrCompare(StrBegin(&result5), "0") == 0);
WriteFmt(- In
Read.c:920:
Int oct = IntInit(alloc_base);
Str dec_text = StrInit(&alloc);
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);- In
Read.c:921:
Str dec_text = StrInit(&alloc);
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);
Str oct_text = StrInit(&alloc);- In
Read.c:922:
Str dec_text = StrInit(&alloc);
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);
Str oct_text = StrInit(&alloc);- In
Read.c:923:
Str hex_text = StrInit(&alloc);
Str bin_text = StrInit(&alloc);
Str oct_text = StrInit(&alloc);
z = "123456789012345678901234567890";- In
Read.c:971:
Float neg = FloatInit(alloc_base);
Str dec_text = StrInit(&alloc);
Str sci_text = StrInit(&alloc);
Str neg_text = StrInit(&alloc);- In
Read.c:972:
Str dec_text = StrInit(&alloc);
Str sci_text = StrInit(&alloc);
Str neg_text = StrInit(&alloc);- In
Read.c:973:
Str dec_text = StrInit(&alloc);
Str sci_text = StrInit(&alloc);
Str neg_text = StrInit(&alloc);
z = "1234567890.012345";- In
Read.c:1433:
static bool test_m3_double_close_brace_escape(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = StrAppendFmt(&out, "}}");- In
Read.c:1562:
static bool test_m33_char_hex_escape_nibbles(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str output = StrInit(&alloc);
u16 v = (u16)0x1AE0; // big-endian bytes: 0x1A, 0xE0
- In
Read.c:1644:
static bool test_m4_end_pos_sizes_full_read(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
// 50 leading spaces, then the number well past byte index 42.
- In
Read.c:1673:
static bool test_m4_empty_file_no_parse(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = m4_make_temp(&alloc, &path, "", 0);
bool ok = FileIsOpen(&f);- In
Read.c:1722:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
Zstr z = "\\x41BC"; // backslash, x, 4, 1, B, C -> 'A', 'B', 'C'
StrReadFmt(z, "{}", s);- In
Read.c:1726:
StrReadFmt(z, "{}", s);
Str expected = StrInitFromZstr("ABC", &alloc);
bool ok = (StrLen(&s) == 3) && (StrCmp(&s, &expected) == 0);- In
Read.c:1743:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
Zstr z = "\\x41"; // -> 'A'
StrReadFmt(z, "{}", s);- In
Read.c:1747:
StrReadFmt(z, "{}", s);
Str expected = StrInitFromZstr("A", &alloc);
bool ok = (StrLen(&s) == 1) && (StrCmp(&s, &expected) == 0);- In
Read.c:1764:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
Zstr z = "\\x61"; // -> 'a'
StrReadFmt(z, "{A}", s);- In
Read.c:1768:
StrReadFmt(z, "{A}", s);
Str expected = StrInitFromZstr("A", &alloc); // uppercased
bool ok = (StrLen(&s) == 1) && (StrCmp(&s, &expected) == 0);- In
Read.c:1787:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
// "\x41BC" inside double quotes -> decoded "ABC"
Zstr z = "\"\\x41BC\"";- In
Read.c:1792:
StrReadFmt(z, "{s}", s);
Str expected = StrInitFromZstr("ABC", &alloc);
bool ok = (StrLen(&s) == 3) && (StrCmp(&s, &expected) == 0);- In
Read.c:1808:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
Zstr z = "\"\\x41\""; // quoted -> 'A'
StrReadFmt(z, "{s}", s);- In
Read.c:1812:
StrReadFmt(z, "{s}", s);
Str expected = StrInitFromZstr("A", &alloc);
bool ok = (StrLen(&s) == 1) && (StrCmp(&s, &expected) == 0);- In
Read.c:1828:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
Zstr z = "\"\\x61\""; // quoted -> 'a'
StrReadFmt(z, "{As}", s);- In
Read.c:1832:
StrReadFmt(z, "{As}", s);
Str expected = StrInitFromZstr("A", &alloc); // uppercased
bool ok = (StrLen(&s) == 1) && (StrCmp(&s, &expected) == 0);- In
Read.c:1853:
static bool test_m9_escape_both_digit_nibbles(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1871:
static bool test_m9_escape_high_digit_nonzero(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1892:
static bool test_m9_escape_letter_boundary_lowercase(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1912:
static bool test_m9_escape_letter_above_boundary_lowercase(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1932:
static bool test_m9_escape_letter_boundary_uppercase(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1950:
static bool test_m9_escape_letter_above_boundary_uppercase(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:1969:
static bool test_m9_escape_mixed_nibbles(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str out = StrInit(&alloc);
bool ok = true;- In
Read.c:2044:
static bool test_read_escape_budget_anchor(void) {
DefaultAllocator a = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&a));
Zstr p = "\\n\\n#rest";
StrReadFmt(p, "{}#", out);- In
Read.c:2083:
static bool test_read_long_string_no_cap(void) {
DefaultAllocator a = DefaultAllocatorInit();
Str out = StrInit(ALLOCATOR_OF(&a));
// 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.
- In
Read.c:2117:
(void)FloatTryFromStr(&f, "99"); // sentinel
StrReadFmt(in, "{}", f);
Str t = FloatToStr(&f);
bool ok = (ZstrCompare(StrBegin(&t), expect) == 0);
StrDeinit(&t);- In
Read.c:2159:
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));
bool ok = (out != NULL) && (StrLen(&s) == 50);- 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:2568:
Zstr z = "12345";
StrReadFmt(z, "{}", v);
Str t = IntToStr(&v);
bool ok = (ZstrCompare(StrBegin(&t), "12345") == 0);
StrDeinit(&t);- In
Read.c:2583:
Zstr z = "+99";
StrReadFmt(z, "{}", v);
Str t = IntToStr(&v);
bool ok = (ZstrCompare(StrBegin(&t), "99") == 0);
StrDeinit(&t);- In
Read.c:2599:
Zstr z = "ff";
StrReadFmt(z, "{x}", v);
Str t = IntToStr(&v);
bool ok = (ZstrCompare(StrBegin(&t), "255") == 0);
StrDeinit(&t);- In
Read.c:2617:
// Real: '_' rejected -> returns start (==z) -> str_read_fmt sees next==in ->
// NULL; v unchanged (still 777).
Str t = IntToStr(&v);
bool ok = (out == NULL) && (ZstrCompare(StrBegin(&t), "777") == 0);
StrDeinit(&t);- In
Read.c:2635:
Zstr z = "3.14159";
StrReadFmt(z, "{}", f);
Str t = FloatToStr(&f);
bool ok = (ZstrCompare(StrBegin(&t), "3.14159") == 0);
StrDeinit(&t);- In
Read.c:2652:
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);
StrDeinit(&t);- In
Read.c:2682:
static bool test_fread_seekable(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = FileOpenTemp(&path, &alloc);
bool ok = FileIsOpen(&f);- In
Read.c:2704:
static bool test_fread_rollback(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str path = StrInit(&alloc);
File f = FileOpenTemp(&path, &alloc);
bool ok = FileIsOpen(&f);- In
Read.c:2731:
static bool leak_quoted_unterminated(Zstr input, Zstr fmt) {
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
- In
Read.c:2771:
bool test_leak_read_unquoted_bad_escape_freed(void) {
DebugAllocator dbg = DebugAllocatorInitWith(LEAK_CFG);
Str s = StrInit(ALLOCATOR_OF(&dbg));
Zstr p = "aaaaaaaaaaaaaaaaaaaaaaaa\\q"; // 24 'a' + invalid \q
StrReadFmt(p, "{}", s);- In
Ops.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>- In
Ops.c:27:
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr("Hello", &alloc);
Str s3 = StrInitFromZstr("World", &alloc);- In
Ops.c:28:
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr("Hello", &alloc);
Str s3 = StrInitFromZstr("World", &alloc);
Str s4 = StrInitFromZstr("Hello World", &alloc);- In
Ops.c:29:
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr("Hello", &alloc);
Str s3 = StrInitFromZstr("World", &alloc);
Str s4 = StrInitFromZstr("Hello World", &alloc);- In
Ops.c:30:
Str s2 = StrInitFromZstr("Hello", &alloc);
Str s3 = StrInitFromZstr("World", &alloc);
Str s4 = StrInitFromZstr("Hello World", &alloc);
// Test StrCmp with equal strings
- In
Ops.c:65:
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str needle1 = StrInitFromZstr("World", &alloc);
Str needle2 = StrInitFromZstr("Hello", &alloc);- In
Ops.c:66:
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str needle1 = StrInitFromZstr("World", &alloc);
Str needle2 = StrInitFromZstr("Hello", &alloc);
Str needle3 = StrInitFromZstr("NotFound", &alloc);- In
Ops.c:67:
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str needle1 = StrInitFromZstr("World", &alloc);
Str needle2 = StrInitFromZstr("Hello", &alloc);
Str needle3 = StrInitFromZstr("NotFound", &alloc);- In
Ops.c:68:
Str needle1 = StrInitFromZstr("World", &alloc);
Str needle2 = StrInitFromZstr("Hello", &alloc);
Str needle3 = StrInitFromZstr("NotFound", &alloc);
// Test StrFind (Str * key) with match at end
- In
Ops.c:104:
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str needle = StrInitFromZstr("World", &alloc);- In
Ops.c:105:
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str needle = StrInitFromZstr("World", &alloc);
bool result = StrContains(&haystack, &needle);- In
Ops.c:130:
Str s = StrInitFromZstr("Hello World", &alloc);
Str prefix = StrInitFromZstr("Hello", &alloc);
Str suffix = StrInitFromZstr("World", &alloc);- In
Ops.c:131:
Str s = StrInitFromZstr("Hello World", &alloc);
Str prefix = StrInitFromZstr("Hello", &alloc);
Str suffix = StrInitFromZstr("World", &alloc);- In
Ops.c:132:
Str s = StrInitFromZstr("Hello World", &alloc);
Str prefix = StrInitFromZstr("Hello", &alloc);
Str suffix = StrInitFromZstr("World", &alloc);
// Test Str-form
- In
Ops.c:170:
// Test Zstr-form (string literals)
Str s1 = StrInitFromZstr("Hello World", &alloc);
StrReplace(&s1, "World", "Universe", 1);
bool result = (ZstrCompare(StrBegin(&s1), "Hello Universe") == 0);- In
Ops.c:189:
StrDeinit(&s1);
s1 = StrInitFromZstr("Hello World", &alloc);
Str find = StrInitFromZstr("World", &alloc);
Str replace = StrInitFromZstr("Universe", &alloc);
StrReplace(&s1, &find, &replace, 1);- In
Ops.c:190:
s1 = StrInitFromZstr("Hello World", &alloc);
Str find = StrInitFromZstr("World", &alloc);
Str replace = StrInitFromZstr("Universe", &alloc);
StrReplace(&s1, &find, &replace, 1);
result = result && (ZstrCompare(StrBegin(&s1), "Hello Universe") == 0);- In
Ops.c:208:
// Test StrSplit
Str s = StrInitFromZstr("Hello,World,Test", &alloc);
Strs split = StrSplit(&s, ",");- In
Ops.c:257:
// Test StrLStrip
Str s1 = StrInitFromZstr(" Hello ", &alloc);
Str stripped = StrLStrip(&s1, NULL);
bool result = (ZstrCompare(StrBegin(&stripped), "Hello ") == 0);- In
Ops.c:258:
// Test StrLStrip
Str s1 = StrInitFromZstr(" Hello ", &alloc);
Str stripped = StrLStrip(&s1, NULL);
bool result = (ZstrCompare(StrBegin(&stripped), "Hello ") == 0);
StrDeinit(&stripped);- In
Ops.c:297:
DefaultAllocator alloc = DefaultAllocatorInit();
Str hello_lc = StrInitFromZstr("hello", &alloc);
Str hello_uc = StrInitFromZstr("HELLO", &alloc);
Str hello_mc = StrInitFromZstr("HeLLo", &alloc);- In
Ops.c:298:
Str hello_lc = StrInitFromZstr("hello", &alloc);
Str hello_uc = StrInitFromZstr("HELLO", &alloc);
Str hello_mc = StrInitFromZstr("HeLLo", &alloc);
Str world = StrInitFromZstr("world", &alloc);- In
Ops.c:299:
Str hello_lc = StrInitFromZstr("hello", &alloc);
Str hello_uc = StrInitFromZstr("HELLO", &alloc);
Str hello_mc = StrInitFromZstr("HeLLo", &alloc);
Str world = StrInitFromZstr("world", &alloc);
Str hello_x = StrInitFromZstr("HelloX", &alloc); // longer
- In
Ops.c:300:
Str hello_uc = StrInitFromZstr("HELLO", &alloc);
Str hello_mc = StrInitFromZstr("HeLLo", &alloc);
Str world = StrInitFromZstr("world", &alloc);
Str hello_x = StrInitFromZstr("HelloX", &alloc); // longer
- In
Ops.c:301:
Str hello_mc = StrInitFromZstr("HeLLo", &alloc);
Str world = StrInitFromZstr("world", &alloc);
Str hello_x = StrInitFromZstr("HelloX", &alloc); // longer
// Equal under ASCII case folding.
- In
Ops.c:322:
// Non-ASCII bytes pass through verbatim (no Unicode folding).
Str non_ascii_a = StrInitFromZstr("ABC\xC0", &alloc);
Str non_ascii_b = StrInitFromZstr("abc\xC0", &alloc);
ok = ok && StrCmpIgnoreCase(&non_ascii_a, &non_ascii_b) == 0;- In
Ops.c:323:
// Non-ASCII bytes pass through verbatim (no Unicode folding).
Str non_ascii_a = StrInitFromZstr("ABC\xC0", &alloc);
Str non_ascii_b = StrInitFromZstr("abc\xC0", &alloc);
ok = ok && StrCmpIgnoreCase(&non_ascii_a, &non_ascii_b) == 0;- In
Ops.c:352:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("Hello World", &alloc);
// A genuine suffix must report true...
Str suffix = StrInitFromZstr("World", &alloc);- In
Ops.c:354:
Str s = StrInitFromZstr("Hello World", &alloc);
// A genuine suffix must report true...
Str suffix = StrInitFromZstr("World", &alloc);
bool match = StrEndsWith(&s, &suffix); // Str* -> str_ends_with_str
// ...and a non-suffix must report false. The replace_scalar_call mutant
- In
Ops.c:355:
// A genuine suffix must report true...
Str suffix = StrInitFromZstr("World", &alloc);
bool match = StrEndsWith(&s, &suffix); // Str* -> str_ends_with_str
// ...and a non-suffix must report false. The replace_scalar_call mutant
// forces the return to the constant 42 (true), so this false case is what
- In
Ops.c:359:
// forces the return to the constant 42 (true), so this false case is what
// actually pins the call's result.
Str nonsuffix = StrInitFromZstr("Hello", &alloc);
bool no_match = StrEndsWith(&s, &nonsuffix);- In
Ops.c:381:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("***", &alloc);
Str stripped = StrLStrip(&s, "*");
bool result = (StrLen(&stripped) == 0);- In
Ops.c:382:
Str s = StrInitFromZstr("***", &alloc);
Str stripped = StrLStrip(&s, "*");
bool result = (StrLen(&stripped) == 0);- In
Ops.c:398:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("***", &alloc);
Str stripped = StrRStrip(&s, "*");
bool result = (StrLen(&stripped) == 0);- In
Ops.c:399:
Str s = StrInitFromZstr("***", &alloc);
Str stripped = StrRStrip(&s, "*");
bool result = (StrLen(&stripped) == 0);- In
Ops.c:415:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("x", &alloc);
Str stripped = StrStrip(&s, "*");
bool result = (StrLen(&stripped) == 1) && (ZstrCompare(StrBegin(&stripped), "x") == 0);- In
Ops.c:416:
Str s = StrInitFromZstr("x", &alloc);
Str stripped = StrStrip(&s, "*");
bool result = (StrLen(&stripped) == 1) && (ZstrCompare(StrBegin(&stripped), "x") == 0);- In
Ops.c:429:
// not a substring must report false via the Str* path.
static bool test_contains_str_absent_key_false(void) {
WriteFmt("Testing StrContains(Str*) absent key is false\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Ops.c:432:
DefaultAllocator alloc = DefaultAllocatorInit();
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str needle = StrInitFromZstr("missing", &alloc);
bool result = (StrContains(&haystack, &needle) == false);- In
Ops.c:433:
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str needle = StrInitFromZstr("missing", &alloc);
bool result = (StrContains(&haystack, &needle) == false);- In
Ops.c:447:
// constant replacement.
static bool test_contains_str_present_and_absent(void) {
WriteFmt("Testing StrContains(Str*) present vs absent\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Ops.c:450:
DefaultAllocator alloc = DefaultAllocatorInit();
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str present = StrInitFromZstr("World", &alloc);
Str absent = StrInitFromZstr("missing", &alloc);- In
Ops.c:451:
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str present = StrInitFromZstr("World", &alloc);
Str absent = StrInitFromZstr("missing", &alloc);
bool result = (StrContains(&haystack, &present) == true) && (StrContains(&haystack, &absent) == false);- In
Ops.c:452:
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str present = StrInitFromZstr("World", &alloc);
Str absent = StrInitFromZstr("missing", &alloc);
bool result = (StrContains(&haystack, &present) == true) && (StrContains(&haystack, &absent) == false);- In
Ops.c:469:
DefaultAllocator alloc = DefaultAllocatorInit();
Str haystack = StrInitFromZstr("Hello World", &alloc);
bool result = (StrContains(&haystack, "missing") == false);- In
Ops.c:485:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("a,b,", &alloc);
StrIters iters = StrSplitToIters(&s, ",");- In
Ops.c:512:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("ab", &alloc);
Strs split = StrSplit(&s, "abc");- In
Ops.c:535:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("ab", &alloc);
Strs split = StrSplit(&s, "abc");- In
Ops.c:556:
DefaultAllocator alloc = DefaultAllocatorInit();
Str hello = StrInitFromZstr("Hello", &alloc);
bool result = (StrCmp(&hello, "Hello") == 0);- In
Ops.c:576:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("abc", &alloc);
bool result = (StrIndexOf(&s, "abc", 3) == 0);- In
Ops.c:595:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("Hello", &alloc);
bool result = (StrStartsWith(&s, "Hello") == true);- In
Ops.c:624:
DefaultAllocator alloc = DefaultAllocatorInit();
Str a = StrInitFromCstr("ab", 2, &alloc);
StrReserve(&a, 8);
// Plant bytes beyond `a`'s logical length (still inside capacity 8) that
- In
Ops.c:631:
StrBegin(&a)[3] = (char)0xFF;
Str b = StrInitFromZstr("abYY", &alloc); // length 4
// Call the mutated function directly: the public StrCmp wrapper
- In
Ops.c:657:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("Hello World", &alloc);
Str prefix = StrInitFromZstr("Hello", &alloc);- In
Ops.c:658:
Str s = StrInitFromZstr("Hello World", &alloc);
Str prefix = StrInitFromZstr("Hello", &alloc);
bool result = (StrStartsWith(&s, &prefix) == true);- In
Ops.c:680:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("World", &alloc);
bool result = (StrEndsWith(&s, "World") == true);- In
Ops.c:701:
static bool test_replace_zstr_null_aborts(void) {
WriteFmt("Testing str_replace_zstr NULL aborts\n");
Str *null_str = NULL;
StrReplace(null_str, "a", "b", 1);
return false;- In
Ops.c:709:
static bool test_find_zstr_validates(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("hello", &alloc);
s.__magic = 0; // corrupt: validate_vec must LOG_FATAL.
(void)str_find_zstr(&s, "x");- In
Ops.c:721:
static bool test_starts_with_zstr_validates(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("hello", &alloc);
s.__magic = 0; // corrupt: validate_vec must LOG_FATAL.
(void)str_starts_with_zstr(&s, "he");- In
Ops.c:733:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("haystack", &alloc);
Str key = StrInitFromZstr("stack", &alloc);- In
Ops.c:734:
Str s = StrInitFromZstr("haystack", &alloc);
Str key = StrInitFromZstr("stack", &alloc);
// intentional bypass: corrupt s only.
- In
Ops.c:753:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("haystack", &alloc);
Str key = StrInitFromZstr("stack", &alloc);- In
Ops.c:754:
Str s = StrInitFromZstr("haystack", &alloc);
Str key = StrInitFromZstr("stack", &alloc);
// intentional bypass: corrupt key only.
- In
Ops.c:772:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("Hello World", &alloc);
Str suffix = StrInitFromZstr("World", &alloc);- In
Ops.c:773:
Str s = StrInitFromZstr("Hello World", &alloc);
Str suffix = StrInitFromZstr("World", &alloc);
// intentional bypass: corrupt s only.
- In
Ops.c:791:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("Hello", &alloc);
// intentional bypass: corrupt s only.
- In
Ops.c:809:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("haystack", &alloc);
Str key = StrInitFromZstr("stack", &alloc);- In
Ops.c:810:
Str s = StrInitFromZstr("haystack", &alloc);
Str key = StrInitFromZstr("stack", &alloc);
// intentional bypass: corrupt key only.
- In
Ops.c:817:
MAGIC_MARK_DIRTY(&key);
(void)StrIndexOf(&s, &key); // Str* -> str_index_of_str; should abort here
return false; // unreachable on real code
- 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:838:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr(" x ", &alloc);
GENERIC_VEC(&s)->__magic ^= 0x1;
Str stripped = StrStrip(&s, NULL);- In
Ops.c:840:
Str s = StrInitFromZstr(" x ", &alloc);
GENERIC_VEC(&s)->__magic ^= 0x1;
Str stripped = StrStrip(&s, NULL);
StrDeinit(&stripped);- In
Ops.c:855:
DefaultAllocator alloc = DefaultAllocatorInit();
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str key = StrInitFromZstr("World", &alloc);
GENERIC_VEC(&key)->__magic ^= 0x1;- In
Ops.c:856:
Str haystack = StrInitFromZstr("Hello World", &alloc);
Str key = StrInitFromZstr("World", &alloc);
GENERIC_VEC(&key)->__magic ^= 0x1;
(void)StrContains(&haystack, &key);- In
Ops.c:873:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("a,b,c", &alloc);
GENERIC_VEC(&s)->__magic ^= 0x1;
StrIters iters = StrSplitToIters(&s, ",");- In
Ops.c:888:
// than dereferencing a bogus header (Str.Mutants6).
static bool test_str_hash_uninitialized_aborts(void) {
WriteFmt("Testing str_hash aborts on uninitialized Str\n");
Str bogus = {0};- In
Ops.c:890:
WriteFmt("Testing str_hash aborts on uninitialized Str\n");
Str bogus = {0};
(void)str_hash(&bogus, (u32)sizeof(Str));- In
Ops.c:891:
Str bogus = {0};
(void)str_hash(&bogus, (u32)sizeof(Str));
return false;- In
Ops.c:902:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("hello", &alloc);
GENERIC_VEC(&s)->__magic ^= 0x1;
(void)StrCmpIgnoreCase(&s, "HELLO");- In
Ops.c:916:
// (Str.Mutants6).
static bool test_starts_with_cstr_null_aborts(void) {
WriteFmt("Testing StrStartsWith(Cstr) aborts on NULL Str\n");
(void)StrStartsWith((Str *)NULL, "x", (size)1);- In
Ops.c:918:
WriteFmt("Testing StrStartsWith(Cstr) aborts on NULL Str\n");
(void)StrStartsWith((Str *)NULL, "x", (size)1);
return false;- In
Ops.c:930:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("a,b,c", &alloc);
Strs strs = StrSplit(&s, ",");
GENERIC_VEC(VecPtrAt(&strs, 0))->__magic ^= 0x1;- In
Ops.c:945:
// (Str.Mutants7).
static bool test_split_validates(void) {
WriteFmt("Testing StrSplit validates its Str (deadend)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Ops.c:948:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("a,b", &alloc);
s.__magic = 0; // corrupt the magic so ValidateStr aborts
Strs split = StrSplit(&s, ",");- 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
Ops.c:962:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("Hello", &alloc);
s.__magic = 0;
int cmp = StrCmp(&s, "x");- In
Ops.c:973:
// abort (Str.Mutants7).
static bool test_index_of_validates(void) {
WriteFmt("Testing StrIndexOf validates its Str (deadend)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Ops.c:976:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("abc", &alloc);
s.__magic = 0;
size idx = StrIndexOf(&s, "x", 1);- In
Ops.c:987:
// must abort (Str.Mutants7).
static bool test_cmp_cstr_ignore_case_validates(void) {
WriteFmt("Testing StrCmpIgnoreCase (Cstr form) validates its Str (deadend)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Ops.c:990:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("Hello", &alloc);
s.__magic = 0;
int cmp = StrCmpIgnoreCase(&s, "x", 1);- In
Ops.c:1001:
// the validator's NULL check rather than dereferencing s->data (Str.Mutants7).
static bool test_ends_with_cstr_validates(void) {
WriteFmt("Testing StrEndsWith (Cstr form) validates its Str (deadend)\n");
bool ends = StrEndsWith((const Str *)NULL, "x", 1);- In
Ops.c:1003:
WriteFmt("Testing StrEndsWith (Cstr form) validates its Str (deadend)\n");
bool ends = StrEndsWith((const Str *)NULL, "x", 1);
(void)ends;- In
Ops.c:1017:
DefaultAllocator alloc = DefaultAllocatorInit();
Str a = StrInitFromZstr("alpha", &alloc);
Str b = StrInitFromZstr("beta", &alloc);
a.__magic = 0; // corrupt: magic mismatch, data/length still valid
- In
Ops.c:1018:
Str a = StrInitFromZstr("alpha", &alloc);
Str b = StrInitFromZstr("beta", &alloc);
a.__magic = 0; // corrupt: magic mismatch, data/length still valid
- In
Ops.c:1034:
DefaultAllocator alloc = DefaultAllocatorInit();
Str a = StrInitFromZstr("alpha", &alloc);
Str b = StrInitFromZstr("beta", &alloc);
b.__magic = 0;- In
Ops.c:1035:
Str a = StrInitFromZstr("alpha", &alloc);
Str b = StrInitFromZstr("beta", &alloc);
b.__magic = 0;- In
Ops.c:1051:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("HELLO", &alloc);
Str other = StrInitFromZstr("hello", &alloc);
s.__magic = 0;- In
Ops.c:1052:
Str s = StrInitFromZstr("HELLO", &alloc);
Str other = StrInitFromZstr("hello", &alloc);
s.__magic = 0;- In
Ops.c:1068:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("HELLO", &alloc);
Str other = StrInitFromZstr("hello", &alloc);
other.__magic = 0;- In
Ops.c:1069:
Str s = StrInitFromZstr("HELLO", &alloc);
Str other = StrInitFromZstr("hello", &alloc);
other.__magic = 0;- In
Ops.c:1085:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("Hello World", &alloc);
Str prefix = StrInitFromZstr("Hello", &alloc);
s.__magic = 0;- In
Ops.c:1086:
Str s = StrInitFromZstr("Hello World", &alloc);
Str prefix = StrInitFromZstr("Hello", &alloc);
s.__magic = 0;- In
Ops.c:1102:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("haystack", &alloc);
s.__magic = 0;- In
Ops.c:1118:
// 6-arg form maps directly to str_replace_cstr(NULL, ...).
StrReplace((Str *)NULL, "a", (size)1, "b", (size)1, (size)1);
return false;- In
Ops.c:1125:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Ops tests\n\n");
// Array of test functions
- In
Ops.c:1161:
// Array of deadend test functions (relocated from Str.Mutants*)
TestFunction deadend_tests[] = {
test_replace_zstr_null_aborts, // Str.Mutants3
test_find_zstr_validates, // Str.Mutants4
test_starts_with_zstr_validates, // Str.Mutants4
- In
Ops.c:1162:
TestFunction deadend_tests[] = {
test_replace_zstr_null_aborts, // Str.Mutants3
test_find_zstr_validates, // Str.Mutants4
test_starts_with_zstr_validates, // Str.Mutants4
test_str_find_str_corrupt_s_aborts, // Str.Mutants5
- In
Ops.c:1163:
test_replace_zstr_null_aborts, // Str.Mutants3
test_find_zstr_validates, // Str.Mutants4
test_starts_with_zstr_validates, // Str.Mutants4
test_str_find_str_corrupt_s_aborts, // Str.Mutants5
test_str_find_str_corrupt_key_aborts, // Str.Mutants5
- In
Ops.c:1164:
test_find_zstr_validates, // Str.Mutants4
test_starts_with_zstr_validates, // Str.Mutants4
test_str_find_str_corrupt_s_aborts, // Str.Mutants5
test_str_find_str_corrupt_key_aborts, // Str.Mutants5
test_str_ends_with_str_corrupt_s_aborts, // Str.Mutants5
- In
Ops.c:1165:
test_starts_with_zstr_validates, // Str.Mutants4
test_str_find_str_corrupt_s_aborts, // Str.Mutants5
test_str_find_str_corrupt_key_aborts, // Str.Mutants5
test_str_ends_with_str_corrupt_s_aborts, // Str.Mutants5
test_str_cmp_cstr_corrupt_s_aborts, // Str.Mutants5
- In
Ops.c:1166:
test_str_find_str_corrupt_s_aborts, // Str.Mutants5
test_str_find_str_corrupt_key_aborts, // Str.Mutants5
test_str_ends_with_str_corrupt_s_aborts, // Str.Mutants5
test_str_cmp_cstr_corrupt_s_aborts, // Str.Mutants5
test_str_index_of_str_corrupt_key_aborts, // Str.Mutants5
- In
Ops.c:1167:
test_str_find_str_corrupt_key_aborts, // Str.Mutants5
test_str_ends_with_str_corrupt_s_aborts, // Str.Mutants5
test_str_cmp_cstr_corrupt_s_aborts, // Str.Mutants5
test_str_index_of_str_corrupt_key_aborts, // Str.Mutants5
test_str_ends_with_zstr_null_aborts, // Str.Mutants5
- In
Ops.c:1168:
test_str_ends_with_str_corrupt_s_aborts, // Str.Mutants5
test_str_cmp_cstr_corrupt_s_aborts, // Str.Mutants5
test_str_index_of_str_corrupt_key_aborts, // Str.Mutants5
test_str_ends_with_zstr_null_aborts, // Str.Mutants5
test_strip_str_corrupt_magic_aborts, // Str.Mutants6
- In
Ops.c:1169:
test_str_cmp_cstr_corrupt_s_aborts, // Str.Mutants5
test_str_index_of_str_corrupt_key_aborts, // Str.Mutants5
test_str_ends_with_zstr_null_aborts, // Str.Mutants5
test_strip_str_corrupt_magic_aborts, // Str.Mutants6
test_contains_str_corrupt_key_magic_aborts, // Str.Mutants6
- In
Ops.c:1170:
test_str_index_of_str_corrupt_key_aborts, // Str.Mutants5
test_str_ends_with_zstr_null_aborts, // Str.Mutants5
test_strip_str_corrupt_magic_aborts, // Str.Mutants6
test_contains_str_corrupt_key_magic_aborts, // Str.Mutants6
test_split_to_iters_corrupt_magic_aborts, // Str.Mutants6
- In
Ops.c:1171:
test_str_ends_with_zstr_null_aborts, // Str.Mutants5
test_strip_str_corrupt_magic_aborts, // Str.Mutants6
test_contains_str_corrupt_key_magic_aborts, // Str.Mutants6
test_split_to_iters_corrupt_magic_aborts, // Str.Mutants6
test_str_hash_uninitialized_aborts, // Str.Mutants6
- In
Ops.c:1172:
test_strip_str_corrupt_magic_aborts, // Str.Mutants6
test_contains_str_corrupt_key_magic_aborts, // Str.Mutants6
test_split_to_iters_corrupt_magic_aborts, // Str.Mutants6
test_str_hash_uninitialized_aborts, // Str.Mutants6
test_cmp_zstr_ignore_case_corrupt_magic_aborts, // Str.Mutants6
- In
Ops.c:1173:
test_contains_str_corrupt_key_magic_aborts, // Str.Mutants6
test_split_to_iters_corrupt_magic_aborts, // Str.Mutants6
test_str_hash_uninitialized_aborts, // Str.Mutants6
test_cmp_zstr_ignore_case_corrupt_magic_aborts, // Str.Mutants6
test_starts_with_cstr_null_aborts, // Str.Mutants6
- In
Ops.c:1174:
test_split_to_iters_corrupt_magic_aborts, // Str.Mutants6
test_str_hash_uninitialized_aborts, // Str.Mutants6
test_cmp_zstr_ignore_case_corrupt_magic_aborts, // Str.Mutants6
test_starts_with_cstr_null_aborts, // Str.Mutants6
test_validate_strs_corrupt_element_aborts, // Str.Mutants6
- In
Ops.c:1175:
test_str_hash_uninitialized_aborts, // Str.Mutants6
test_cmp_zstr_ignore_case_corrupt_magic_aborts, // Str.Mutants6
test_starts_with_cstr_null_aborts, // Str.Mutants6
test_validate_strs_corrupt_element_aborts, // Str.Mutants6
test_split_validates, // Str.Mutants7
- In
Ops.c:1176:
test_cmp_zstr_ignore_case_corrupt_magic_aborts, // Str.Mutants6
test_starts_with_cstr_null_aborts, // Str.Mutants6
test_validate_strs_corrupt_element_aborts, // Str.Mutants6
test_split_validates, // Str.Mutants7
test_cmp_zstr_validates, // Str.Mutants7
- In
Ops.c:1177:
test_starts_with_cstr_null_aborts, // Str.Mutants6
test_validate_strs_corrupt_element_aborts, // Str.Mutants6
test_split_validates, // Str.Mutants7
test_cmp_zstr_validates, // Str.Mutants7
test_index_of_validates, // Str.Mutants7
- In
Ops.c:1178:
test_validate_strs_corrupt_element_aborts, // Str.Mutants6
test_split_validates, // Str.Mutants7
test_cmp_zstr_validates, // Str.Mutants7
test_index_of_validates, // Str.Mutants7
test_cmp_cstr_ignore_case_validates, // Str.Mutants7
- In
Ops.c:1179:
test_split_validates, // Str.Mutants7
test_cmp_zstr_validates, // Str.Mutants7
test_index_of_validates, // Str.Mutants7
test_cmp_cstr_ignore_case_validates, // Str.Mutants7
test_ends_with_cstr_validates, // Str.Mutants7
- In
Ops.c:1180:
test_cmp_zstr_validates, // Str.Mutants7
test_index_of_validates, // Str.Mutants7
test_cmp_cstr_ignore_case_validates, // Str.Mutants7
test_ends_with_cstr_validates, // Str.Mutants7
test_compare_validates_a, // Str.Mutants8
- In
Ops.c:1181:
test_index_of_validates, // Str.Mutants7
test_cmp_cstr_ignore_case_validates, // Str.Mutants7
test_ends_with_cstr_validates, // Str.Mutants7
test_compare_validates_a, // Str.Mutants8
test_compare_validates_b, // Str.Mutants8
- In
Ops.c:1182:
test_cmp_cstr_ignore_case_validates, // Str.Mutants7
test_ends_with_cstr_validates, // Str.Mutants7
test_compare_validates_a, // Str.Mutants8
test_compare_validates_b, // Str.Mutants8
test_cmp_ignore_case_validates_s, // Str.Mutants8
- In
Ops.c:1183:
test_ends_with_cstr_validates, // Str.Mutants7
test_compare_validates_a, // Str.Mutants8
test_compare_validates_b, // Str.Mutants8
test_cmp_ignore_case_validates_s, // Str.Mutants8
test_cmp_ignore_case_validates_other, // Str.Mutants8
- In
Ops.c:1184:
test_compare_validates_a, // Str.Mutants8
test_compare_validates_b, // Str.Mutants8
test_cmp_ignore_case_validates_s, // Str.Mutants8
test_cmp_ignore_case_validates_other, // Str.Mutants8
test_starts_with_validates_s, // Str.Mutants8
- In
Ops.c:1185:
test_compare_validates_b, // Str.Mutants8
test_cmp_ignore_case_validates_s, // Str.Mutants8
test_cmp_ignore_case_validates_other, // Str.Mutants8
test_starts_with_validates_s, // Str.Mutants8
test_find_cstr_validates_s, // Str.Mutants8
- In
Ops.c:1186:
test_cmp_ignore_case_validates_s, // Str.Mutants8
test_cmp_ignore_case_validates_other, // Str.Mutants8
test_starts_with_validates_s, // Str.Mutants8
test_find_cstr_validates_s, // Str.Mutants8
test_replace_cstr_validates_s // Str.Mutants8
- In
Ops.c:1187:
test_cmp_ignore_case_validates_other, // Str.Mutants8
test_starts_with_validates_s, // Str.Mutants8
test_find_cstr_validates_s, // Str.Mutants8
test_replace_cstr_validates_s // Str.Mutants8
};- In
Ops.c:1188:
test_starts_with_validates_s, // Str.Mutants8
test_find_cstr_validates_s, // Str.Mutants8
test_replace_cstr_validates_s // Str.Mutants8
};- In
Ops.c:1195:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Str.Ops");
}- In
Memory.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>- In
Memory.c:23:
Str s = StrInit(&alloc);
// Reserve more space than needed
- In
Memory.c:51:
Str s = StrInitFromZstr("Hello", &alloc);
// Swap 'H' and 'o'
- In
Memory.c:76:
Str s = StrInitFromZstr("Hello", &alloc);
// Initial length should be 5
- In
Memory.c:105:
Str s = StrInit(&alloc);
// Reserve more space
- In
Memory.c:133:
Str s = StrInitFromZstr("Hello, World!", &alloc);
// Initial length should be 13
- In
Memory.c:158:
Str s = StrInitFromZstr("Hello", &alloc);
// Reverse the string
- In
Memory.c:203:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Memory tests\n\n");
// Array of test functions
- In
Memory.c:218:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Memory");
}- In
Init.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>- In
Init.c:29:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
// Validate the string
- In
Init.c:51:
Zstr test_str = "Hello, World!";
size len = 5; // Just "Hello"
Str s = StrInitFromCstr(test_str, len, &alloc);
// Validate the string
- In
Init.c:71:
Zstr test_str = "Hello, World!";
Str s = StrInitFromZstr(test_str, &alloc);
// Validate the string
- In
Init.c:91:
Zstr test_str = "Alias Test";
Str s = StrZ(test_str, &alloc);
ValidateStr(&s);- In
Init.c:108:
DefaultAllocator alloc = DefaultAllocatorInit();
Str src = StrInitFromZstr("Hello, World!", &alloc);
Str dst = StrInitFromStr(&src, &alloc);- In
Init.c:109:
Str src = StrInitFromZstr("Hello, World!", &alloc);
Str dst = StrInitFromStr(&src, &alloc);
// Validate both strings
- In
Init.c:130:
DefaultAllocator alloc = DefaultAllocatorInit();
Str src = StrInitFromZstr("Hello, World!", &alloc);
Str dst = StrDup(&src, &alloc);- In
Init.c:131:
Str src = StrInitFromZstr("Hello, World!", &alloc);
Str dst = StrDup(&src, &alloc);
// Validate both strings
- In
Init.c:152:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "Hello, {}!", &"World"[0]);- In
Init.c:200:
DefaultAllocator alloc = DefaultAllocatorInit();
Str src = StrInitFromZstr("Hello, World!", &alloc);
Str dst = StrInit(&alloc);- In
Init.c:201:
Str src = StrInitFromZstr("Hello, World!", &alloc);
Str dst = StrInit(&alloc);
// Copy src to dst
- In
Init.c:221:
// Test that Str clones inherit the source allocator pointer
bool test_str_clone_inherits_allocator_config(void) {
WriteFmt("Testing Str clone allocator inheritance\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Init.c:225:
DefaultAllocator alloc = DefaultAllocatorInit();
Str src = StrInitFromCstr("Hello, World!", ZstrLen("Hello, World!"), &alloc);
Str dup = StrInitFromStr(&src, &alloc);- In
Init.c:227:
Str src = StrInitFromCstr("Hello, World!", ZstrLen("Hello, World!"), &alloc);
Str dup = StrInitFromStr(&src, &alloc);
Str dst = StrInit(&alloc);
bool copied = StrInitCopy(&dst, &src);- In
Init.c:228:
Str dup = StrInitFromStr(&src, &alloc);
Str dst = StrInit(&alloc);
bool copied = StrInitCopy(&dst, &src);- In
Init.c:255:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("Hello, World!", &alloc);
// Validate the string before deinit
- In
Init.c:284:
// Each piece is long enough to force its own heap buffer.
Str s = StrInitFromZstr("alphaaa,betaaaa,gammaaa,deltaaa", &dbg);
size before = DebugAllocatorLiveCount(&dbg);- In
Init.c:313:
Allocator *adbg = ALLOCATOR_OF(&dbg);
Str s = StrInitFromZstr("hello world", adbg);
StrDeinit(&s);- In
Init.c:331:
DefaultAllocator alloc = DefaultAllocatorInit();
Str src = StrInitFromZstr("source", &alloc);
src.__magic = 0;- In
Init.c:334:
src.__magic = 0;
Str dst = StrInit(&alloc);
(void)StrInitCopy(&dst, &src); // ValidateStr(src) must abort on real code
- In
Init.c:343:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Init tests\n\n");
// Array of test functions
- In
Init.c:370:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Str.Init");
}- In
Insert.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>- In
Insert.c:33:
Str s = StrInitFromZstr("Hello", &alloc);
// Insert a character in the middle
- In
Insert.c:64:
Str s = StrInitFromZstr("Hello", &alloc);
// Insert a string in the middle: (cstr, cstr_len) adjacent, then idx
- In
Insert.c:83:
Str s = StrInitFromZstr("Hello", &alloc);
// Insert a string in the middle
- In
Insert.c:103:
Str s = StrInitFromZstr("Hello", &alloc);
// Push a string at position 2
- In
Insert.c:122:
Str s = StrInitFromZstr("Hello", &alloc);
// Push a string at position 2
- In
Insert.c:141:
Str s = StrInitFromZstr("Hello", &alloc);
// Push a string at the back
- In
Insert.c:160:
Str s = StrInitFromZstr("Hello", &alloc);
// Push a string at the back
- In
Insert.c:179:
Str s = StrInitFromZstr("World", &alloc);
// Push a string at the front
- In
Insert.c:198:
Str s = StrInitFromZstr("World", &alloc);
// Push a string at the front
- In
Insert.c:217:
Str s = StrInitFromZstr("Hello", &alloc);
// Push characters at the back
- In
Insert.c:241:
Str s = StrInitFromZstr("World", &alloc);
// Push characters at the front
- In
Insert.c:265:
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr(" World", &alloc);- In
Insert.c:266:
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr(" World", &alloc);
// Merge s2 into s1 (L-value semantics)
- In
Insert.c:293:
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr(" World", &alloc);- In
Insert.c:294:
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr(" World", &alloc);
// Merge s2 into s1 (R-value semantics)
- In
Insert.c:317:
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr(" World", &alloc);- In
Insert.c:318:
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr(" World", &alloc);
// Merge s2 into s1 (L-form; ownership of s2's storage transfers to s1)
- In
Insert.c:342:
Str s = StrInitFromZstr("Hello", &alloc);
// Append formatted suffix.
- In
Insert.c:357:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Insert tests\n\n");
// Array of test functions
- In
Insert.c:381:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Insert");
}- In
Type.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>- In
Type.c:22:
// Test Str type definition
bool test_str_type(void) {
WriteFmt("Testing Str type definition\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Type.c:27:
// Create a Str object
Str s = StrInit(&alloc);
// Check that it behaves like a Vec of chars
- In
Type.c:53:
// Add some strings
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr("World", &alloc);- In
Type.c:54:
// Add some strings
Str s1 = StrInitFromZstr("Hello", &alloc);
Str s2 = StrInitFromZstr("World", &alloc);
VecPushBack(&sv, s1);- In
Type.c:64:
// Check the content of the strings
if (result) {
Str *str1 = &VecAt(&sv, 0);
Str *str2 = &VecAt(&sv, 1);- In
Type.c:65:
if (result) {
Str *str1 = &VecAt(&sv, 0);
Str *str2 = &VecAt(&sv, 1);
result = result && (ZstrCompare(StrBegin(str1), "Hello") == 0);- In
Type.c:83:
// Create a valid Str
Str s = StrInit(&alloc);
// This should not crash
- In
Type.c:128:
// Create an invalid Str by corrupting its fields
Str s = StrInit(&alloc);
// Corrupt the string to make it invalid
- In
Type.c:178:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Type tests\n\n");
// Array of normal test functions
- In
Type.c:190:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, deadend_count, "Str.Type");
}- In
Remove.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>- In
Remove.c:26:
Str s = StrInitFromZstr("Hello", &alloc);
// Pop a character from the back
- In
Remove.c:53:
Str s = StrInitFromZstr("Hello", &alloc);
// Pop a character from the front
- In
Remove.c:80:
Str s = StrInitFromZstr("Hello", &alloc);
// Remove a character from the middle
- In
Remove.c:107:
Str s = StrInitFromZstr("Hello World", &alloc);
// Create a buffer to store the removed characters
- In
Remove.c:137:
Str s = StrInitFromZstr("Hello", &alloc);
// Delete the last character
- In
Remove.c:162:
Str s = StrInitFromZstr("Hello", &alloc);
// Delete a character from the middle
- In
Remove.c:187:
Str s = StrInitFromZstr("Hello World", &alloc);
// Delete a range of characters
- In
Remove.c:208:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Remove tests\n\n");
// Array of test functions
- In
Remove.c:224:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Remove");
}- In
Convert.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>- In
Convert.c:35:
Str s = StrInit(&alloc);
// Test decimal conversion
- In
Convert.c:101:
Str s = StrInit(&alloc);
// Test positive decimal conversion
- In
Convert.c:160:
Str s = StrInit(&alloc);
// Test integer conversion
- In
Convert.c:245:
// Test decimal conversion
Str s = StrInitFromZstr("12345", &alloc);
u64 value = 0;
bool success = StrToU64(&s, &value, NULL);- In
Convert.c:305:
// Test positive decimal conversion
Str s = StrInitFromZstr("12345", &alloc);
i64 value = 0;
bool success = StrToI64(&s, &value, NULL);- In
Convert.c:352:
// Test integer conversion
Str s = StrInitFromZstr("123", &alloc);
f64 value = 0.0;
bool success = StrToF64(&s, &value, NULL);- In
Convert.c:412:
// Round-trip conversion tests
bool test_str_round_trip_conversions(void) {
WriteFmt("Testing Str round-trip conversions\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:435:
for (size i = 0; i < sizeof(u64_values) / sizeof(u64_values[0]); i++) {
Str s = StrInit(&alloc);
// Test decimal round-trip
- In
Convert.c:456:
for (size i = 0; i < sizeof(i64_values) / sizeof(i64_values[0]); i++) {
Str s = StrInit(&alloc);
// Test decimal round-trip
- In
Convert.c:473:
for (size i = 0; i < sizeof(f64_values) / sizeof(f64_values[0]); i++) {
for (u8 precision = 1; precision <= 6; precision++) {
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false};- In
Convert.c:494:
// Edge case conversion tests
bool test_str_edge_case_conversions(void) {
WriteFmt("Testing Str edge case conversions\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:502:
// Test base boundary conditions
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
// Test with base value itself
- In
Convert.c:518:
// Test extreme values
Str s = StrInit(&alloc);
// Test maximum u64
- In
Convert.c:568:
for (size i = 0; i < sizeof(prefix_tests) / sizeof(prefix_tests[0]); i++) {
Str test_str = StrInitFromZstr(prefix_tests[i].input, &alloc);
u64 value = 0;
StrParseConfig config = {.base = prefix_tests[i].base};- In
Convert.c:582:
// Precision limits testing
bool test_str_precision_limits(void) {
WriteFmt("Testing Str precision limits\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:592:
for (u8 precision = 1; precision <= 17; precision++) {
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false};- In
Convert.c:612:
for (size i = 0; i < sizeof(sci_values) / sizeof(sci_values[0]); i++) {
Str s = StrInit(&alloc);
// Force scientific notation
- In
Convert.c:634:
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
StrIntFormat config = {.base = base, .uppercase = false};- In
Convert.c:652:
// Large-scale conversion tests
bool test_str_all_base_support(void) {
WriteFmt("Testing Str all bases 2-36 support\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:663:
// Test each base from 2 to 36
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
// Test StrFromU64
- In
Convert.c:681:
// Test uppercase digits for bases that use letters (11-36)
for (u8 base = 11; base <= 36; base++) {
Str s = StrInit(&alloc);
StrIntFormat config = {.base = base, .uppercase = true, .use_prefix = false};- In
Convert.c:700:
for (size i = 0; i < sizeof(test_values) / sizeof(test_values[0]); i++) {
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit(&alloc);
StrIntFormat config = {.base = base, .uppercase = false, .use_prefix = false};- In
Convert.c:725:
bool test_str_large_scale_conversions(void) {
WriteFmt("Testing Str large-scale conversions\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:735:
u64 test_value = i * 1000007; // Large prime multiplier
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 10, .uppercase = false};
StrFromU64(&s, test_value, &config);- In
Convert.c:754:
f64 test_value = mantissa * F64Pow((10.0), (i32)(exp));
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 6, .force_sci = false, .uppercase = false};
StrFromF64(&s, test_value, &config);- In
Convert.c:781:
MemCopy(long_number, "12345678901234567890123456789012345678901234567890", 51);
Str long_str = StrInitFromZstr(long_number, &alloc);
u64 long_value = 0;
bool success = StrToU64(&long_str, &long_value, NULL);- In
Convert.c:795:
// Deadend tests for NULL pointer handling
bool test_str_conversion_null_failures(void) {
WriteFmt("Testing Str conversion NULL pointer handling\n");
// Test NULL string pointer - should abort
- In
Convert.c:805:
bool test_str_conversion_bounds_failures(void) {
WriteFmt("Testing Str conversion bounds failures\n");
// Test StrFromI64 with NULL pointer - should abort
- In
Convert.c:815:
bool test_str_conversion_invalid_input_failures(void) {
WriteFmt("Testing Str conversion invalid input failures\n");
// Test StrFromF64 with NULL pointer - should abort
- In
Convert.c:834:
// an uninitialized Str; the mutant skips validation and parses garbage.
static bool test_validate_str_guard(void) {
Str s = {0}; // zero magic -> ValidateStr LOG_FATALs
f64 value = 0.0;
// Should abort inside ValidateStr; the return is never reached on real code.
- In
Convert.c:845:
static bool test_leading_space_skip_condition(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr(" 1.5", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:858:
static bool test_leading_space_advances(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr(" 1.0", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:872:
static bool test_nan_exact_accept_with_offset(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr(" nan", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:885:
static bool test_inf_exact_accept_with_offset(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr(" inf", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:940:
static bool test_minus_sign_makes_negative(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("-5", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:953:
static bool test_plus_sign_advances(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("+5", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:966:
static bool test_integer_digits_set_flag(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("42", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:979:
static bool test_fractional_digits_set_flag(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr(".5", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:993:
static bool test_exponent_gate_not_widened(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("5x", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL); // non-strict default
- In
Convert.c:1006:
static bool test_negative_exponent_sign(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("1e-2", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:1019:
static bool test_exponent_digits_set_flag(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("1e5", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:1033:
static bool test_trailing_space_skip_condition(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("5 ", &alloc);
f64 value = 0.0;
StrParseConfig config = {.strict = true, .trim_space = true, .base = 0};- In
Convert.c:1048:
static bool test_trailing_space_advances(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("5 ", &alloc);
f64 value = 0.0;
StrParseConfig config = {.strict = true, .trim_space = true, .base = 0};- In
Convert.c:1063:
static bool test_strict_trailing_check_ge(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("5", &alloc);
f64 value = 0.0;
StrParseConfig config = {.strict = true, .trim_space = true, .base = 0};- In
Convert.c:1077:
static bool test_strict_trailing_check_le(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("42", &alloc);
f64 value = 0.0;
StrParseConfig config = {.strict = true, .trim_space = true, .base = 0};- In
Convert.c:1098:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("5", &alloc);
u64 value = 0;
StrParseConfig config = {.base = 99};- In
Convert.c:1116:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("ff", &alloc);
u64 value = 0;
StrParseConfig config = {.base = 16};- In
Convert.c:1134:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr(" 42", &alloc);
u64 value = 0;
bool ok = StrToU64(&s, &value, NULL);- In
Convert.c:1151:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr(" 42", &alloc);
u64 value = 0;
bool ok = StrToU64(&s, &value, NULL);- In
Convert.c:1169:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("05", &alloc);
u64 value = 0;
bool ok = StrToU64(&s, &value, NULL);- In
Convert.c:1186:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x", &alloc);
u64 value = 0;
bool ok = StrToU64(&s, &value, NULL);- In
Convert.c:1203:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("18446744073709551616", &alloc);
u64 value = 0;
bool ok = StrToU64(&s, &value, NULL);- In
Convert.c:1220:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("42", &alloc);
u64 value = 0;
bool ok = StrToU64(&s, &value, NULL);- In
Convert.c:1237:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("42 ", &alloc);
u64 value = 0;
StrParseConfig config = {.strict = true};- In
Convert.c:1255:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("42 ", &alloc);
u64 value = 0;
StrParseConfig config = {.strict = true};- In
Convert.c:1273:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("42x", &alloc);
u64 value = 0;
StrParseConfig config = {.strict = true};- In
Convert.c:1291:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("42", &alloc);
u64 value = 0;
StrParseConfig config = {.strict = true};- In
Convert.c:1306:
// mutant the barrier is gone and the corruption is not caught at entry.
static bool test_str_to_u64_validate_barrier(void) {
WriteFmt("Testing StrToU64 validate barrier aborts on corrupt Str\n");
Str bad = {0}; // zeroed magic: ValidateStr must LOG_FATAL
- In
Convert.c:1308:
WriteFmt("Testing StrToU64 validate barrier aborts on corrupt Str\n");
Str bad = {0}; // zeroed magic: ValidateStr must LOG_FATAL
u64 value = 0;
StrParseConfig config = {.base = 10};- In
Convert.c:1324:
WriteFmt("Testing StrFromF64 NaN emits exactly 3 bytes\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = false, .uppercase = false};- In
Convert.c:1343:
WriteFmt("Testing StrFromF64 inf emits exactly 3 bytes\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = false, .uppercase = false};- In
Convert.c:1363:
WriteFmt("Testing StrFromF64 0.0001 stays fixed notation\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 6, .force_sci = false, .uppercase = false};- In
Convert.c:1383:
WriteFmt("Testing StrFromF64 1e7 uses scientific notation\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = false, .uppercase = false};- In
Convert.c:1403:
WriteFmt("Testing StrFromF64 scientific precision 0 omits dot\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 0, .force_sci = true, .uppercase = false};- In
Convert.c:1422:
WriteFmt("Testing StrFromF64 zero exponent prints +00\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = true, .uppercase = false};- In
Convert.c:1443:
WriteFmt("Testing StrFromF64 scientific success returns handle\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = true, .uppercase = false};- In
Convert.c:1446:
StrFloatFormat config = {.precision = 2, .force_sci = true, .uppercase = false};
Str *r = StrFromF64(&s, 123.456, &config);
bool result = (r == &s) && (ZstrCompare(StrBegin(&s), "1.23e+02") == 0);- In
Convert.c:1463:
WriteFmt("Testing StrFromF64 fixed success returns handle\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 2, .force_sci = false, .uppercase = false};- In
Convert.c:1466:
StrFloatFormat config = {.precision = 2, .force_sci = false, .uppercase = false};
Str *r = StrFromF64(&s, 123.0, &config);
bool result = (r == &s) && (ZstrCompare(StrBegin(&s), "123.00") == 0);- In
Convert.c:1483:
WriteFmt("Testing StrFromF64 fixed precision 0 omits dot\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 0, .force_sci = false, .uppercase = false};- In
Convert.c:1503:
WriteFmt("Testing StrFromF64 fixed fraction scale seed\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 3, .force_sci = false, .uppercase = false};- In
Convert.c:1524:
WriteFmt("Testing StrFromF64 fixed half-up rounding\n");
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 3, .force_sci = false, .uppercase = false};- In
Convert.c:1561:
static bool test_skip_prefix_len_guard_hex(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x1F", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;- In
Convert.c:1576:
static bool test_skip_prefix_char_init_hex(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x5", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;- In
Convert.c:1591:
static bool test_skip_prefix_char_index_hex(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x5", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;- In
Convert.c:1604:
static bool test_skip_prefix_bin_lower(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0b1", &alloc);
StrParseConfig cfg = {.base = 2};
u64 out = 0;- In
Convert.c:1618:
static bool test_skip_prefix_bin_return(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0b1", &alloc);
StrParseConfig cfg = {.base = 2};
u64 out = 0;- In
Convert.c:1631:
static bool test_skip_prefix_oct_lower(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0o7", &alloc);
StrParseConfig cfg = {.base = 8};
u64 out = 0;- In
Convert.c:1644:
static bool test_skip_prefix_oct_upper(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0O7", &alloc);
StrParseConfig cfg = {.base = 8};
u64 out = 0;- In
Convert.c:1657:
static bool test_skip_prefix_oct_return(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0o7", &alloc);
StrParseConfig cfg = {.base = 8};
u64 out = 0;- In
Convert.c:1670:
static bool test_skip_prefix_hex_lower(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x1F", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;- In
Convert.c:1683:
static bool test_skip_prefix_hex_upper(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0X1F", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;- In
Convert.c:1696:
static bool test_skip_prefix_hex_return(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0x1F", &alloc);
StrParseConfig cfg = {.base = 16};
u64 out = 0;- In
Convert.c:1715:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr(" -5", &alloc);
i64 value = 0;
bool success = StrToI64(&s, &value, NULL);- In
Convert.c:1732:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr(" 5", &alloc);
i64 value = 0;
bool success = StrToI64(&s, &value, NULL);- In
Convert.c:1748:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("-5", &alloc);
i64 value = 0;
bool success = StrToI64(&s, &value, NULL);- In
Convert.c:1764:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("+5", &alloc);
i64 value = 0;
bool success = StrToI64(&s, &value, NULL);- In
Convert.c:1787:
// 43 '0' characters: a valid parse (value 0) whose length exceeds the
// mutated constant capacity of 42.
Str s = StrInitFromZstr("0000000000000000000000000000000000000000000", &alloc);
i64 value = 7; // sentinel that must be overwritten to 0
- In
Convert.c:1805:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("-9223372036854775808", &alloc);
i64 value = 0;
bool success = StrToI64(&s, &value, NULL);- In
Convert.c:1822:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("2", &alloc);
u64 value = 999; // sentinel
StrParseConfig config = {.base = 2};- In
Convert.c:1838:
// StrToI64. A corrupted Str (length > capacity, dirty magic) must abort.
static bool test_str_to_i64_corrupt_str_aborts(void) {
WriteFmt("Testing StrToI64 validates its Str argument (should abort)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:1841:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("123", &alloc);
// intentional bypass: plant an inconsistent (length, capacity) pair that
// ValidateStr must reject; mark dirty so the body re-runs.
- In
Convert.c:1864:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 10, .uppercase = false};
StrFromI64(&s, INT64_MIN, &config);- In
Convert.c:1884:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 1, .force_sci = false, .uppercase = false};
StrFromF64(&s, 2.25, &config);- In
Convert.c:1904:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrFloatFormat config = {.precision = 1, .force_sci = false, .uppercase = false};
StrFromF64(&s, 2.25, &config);- In
Convert.c:1928:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 37, .uppercase = false};
Str *ret = StrFromU64(&s, 5, &config);- In
Convert.c:1930:
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 37, .uppercase = false};
Str *ret = StrFromU64(&s, 5, &config);
bool result = (ret == NULL);- In
Convert.c:1950:
// is what kills the mutant.
static bool test_from_u64_success_returns_str(void) {
WriteFmt("Testing StrFromU64 returns the Str pointer on success (595:14)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Convert.c:1953:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 10, .uppercase = false};
Str *ret = StrFromU64(&s, 12345, &config);- In
Convert.c:1955:
Str s = StrInit(&alloc);
StrIntFormat config = {.base = 10, .uppercase = false};
Str *ret = StrFromU64(&s, 12345, &config);
bool result = (ret == &s) && (ZstrCompare(StrBegin(&s), "12345") == 0);- In
Convert.c:1985:
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), 8);
Str s = StrInit(&bp);
StrIntFormat config = {.base = 10, .uppercase = false};
// 10-digit value: any growth request exceeds the 8-byte slot.
- In
Convert.c:1988:
StrIntFormat config = {.base = 10, .uppercase = false};
// 10-digit value: any growth request exceeds the 8-byte slot.
Str *ret = StrFromU64(&s, 9999999999ULL, &config);
bool result = (ret == NULL);- In
Convert.c:2014:
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), 8);
Str s = StrInit(&bp);
StrFloatFormat config = {.precision = 0, .force_sci = false, .uppercase = false};
// Positive 15-digit value, precision 0 -> the integer digits are the only
- In
Convert.c:2022:
// push needs a 9-byte buffer and fails inside the integer-digit loop. No
// later direct-return push can mask the mutated `ok`.
Str *ret = StrFromF64(&s, 123456789012345.0, &config);
bool result = (ret == NULL);- In
Convert.c:2056:
BudgetAllocator bp = BudgetAllocatorInit(buf, sizeof(buf), 8);
Str s = StrInit(&bp);
StrFloatFormat config = {.precision = 2, .force_sci = true, .uppercase = false};
Str *ret = StrFromF64(&s, 1.23e150, &config);- In
Convert.c:2058:
Str s = StrInit(&bp);
StrFloatFormat config = {.precision = 2, .force_sci = true, .uppercase = false};
Str *ret = StrFromF64(&s, 1.23e150, &config);
bool result = (ret == NULL);- In
Convert.c:2079:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("0B101", &alloc);
StrParseConfig config = {.base = 2};
u64 value = 0;- In
Convert.c:2101:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInitFromZstr("1e", &alloc);
f64 value = 0.0;
bool ok = StrToF64(&s, &value, NULL);- In
Convert.c:2115:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Convert tests\n\n");
// Array of normal test functions
- In
Convert.c:2214:
test_str_conversion_bounds_failures,
test_str_conversion_invalid_input_failures,
test_validate_str_guard, // StrToF64 (Str.Mutants1)
test_str_to_u64_validate_barrier, // StrToU64 (Str.Mutants2)
test_from_f64_null_aborts, // StrFromF64 (Str.Mutants3)
- In
Convert.c:2215:
test_str_conversion_invalid_input_failures,
test_validate_str_guard, // StrToF64 (Str.Mutants1)
test_str_to_u64_validate_barrier, // StrToU64 (Str.Mutants2)
test_from_f64_null_aborts, // StrFromF64 (Str.Mutants3)
test_from_f64_null_aborts_high_precision,- In
Convert.c:2216:
test_validate_str_guard, // StrToF64 (Str.Mutants1)
test_str_to_u64_validate_barrier, // StrToU64 (Str.Mutants2)
test_from_f64_null_aborts, // StrFromF64 (Str.Mutants3)
test_from_f64_null_aborts_high_precision,
test_str_to_i64_corrupt_str_aborts // StrToI64 (Str.Mutants5)
- In
Convert.c:2218:
test_from_f64_null_aborts, // StrFromF64 (Str.Mutants3)
test_from_f64_null_aborts_high_precision,
test_str_to_i64_corrupt_str_aborts // StrToI64 (Str.Mutants5)
};- In
Convert.c:2225:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Str.Convert");
}- In
Foreach.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Allocator/Default.h>- In
Foreach.c:39:
Str s = StrInitFromZstr("Hello", &alloc);
// Build a new string by iterating through each character with its index
- In
Foreach.c:42:
// Build a new string by iterating through each character with its index
Str result = StrInit(&alloc);
StrForeachIdx(&s, chr, idx) {
StrAppendFmt(&result, "{c}{}", chr, idx);- In
Foreach.c:62:
Str s = StrInitFromZstr("Hello", &alloc);
// Build a new string by iterating through each character in reverse with its index
- In
Foreach.c:65:
// Build a new string by iterating through each character in reverse with its index
Str result = StrInit(&alloc);
StrForeachReverseIdx(&s, chr, idx) {- In
Foreach.c:87:
Str s = StrInitFromZstr("Hello", &alloc);
// Build a new string by iterating through each character pointer with its index
- In
Foreach.c:90:
// Build a new string by iterating through each character pointer with its index
Str result = StrInit(&alloc);
StrForeachPtrIdx(&s, chrptr, idx) {
// Append the character (via pointer) and its index to the result string
- In
Foreach.c:119:
Str s = StrInitFromZstr("Hello", &alloc);
// Build a new string by iterating through each character pointer in reverse with its index
- In
Foreach.c:122:
// Build a new string by iterating through each character pointer in reverse with its index
Str result = StrInit(&alloc);
StrForeachReversePtrIdx(&s, chrptr, idx) {- In
Foreach.c:151:
Str s = StrInitFromZstr("Hello", &alloc);
// Build a new string by iterating through each character
- In
Foreach.c:154:
// Build a new string by iterating through each character
Str result = StrInit(&alloc);
StrForeach(&s, chr) {
// Append the character to the result string
- In
Foreach.c:175:
Str s = StrInitFromZstr("Hello", &alloc);
// Build a new string by iterating through each character in reverse
- In
Foreach.c:178:
// Build a new string by iterating through each character in reverse
Str result = StrInit(&alloc);
size char_count = 0;- In
Foreach.c:209:
Str s = StrInitFromZstr("Hello", &alloc);
// Build a new string by iterating through each character pointer
- In
Foreach.c:212:
// Build a new string by iterating through each character pointer
Str result = StrInit(&alloc);
StrForeachPtr(&s, chrptr) {
// Append the character (via pointer) to the result string
- In
Foreach.c:241:
Str s = StrInitFromZstr("Hello", &alloc);
// Build a new string by iterating through each character pointer in reverse
- In
Foreach.c:244:
// Build a new string by iterating through each character pointer in reverse
Str result = StrInit(&alloc);
size char_count = 0;- In
Foreach.c:283:
Str s = StrInitFromZstr("Hello World", &alloc);
// Build a new string by iterating through a range of characters with indices
- In
Foreach.c:286:
// Build a new string by iterating through a range of characters with indices
Str result = StrInit(&alloc);
StrForeachInRangeIdx(&s, chr, idx, 6, 11) {
// Append the character and its index to the result string
- In
Foreach.c:296:
// Test with empty range
Str empty_result = StrInit(&alloc);
StrForeachInRangeIdx(&s, chr, idx, 3, 3) {
// This block should not execute
- In
Foreach.c:318:
Str s = StrInitFromZstr("Hello World", &alloc);
// Build a new string by iterating through a range of characters
- In
Foreach.c:321:
// Build a new string by iterating through a range of characters
Str result = StrInit(&alloc);
StrForeachInRange(&s, chr, 0, 5) {
// Append the character to the result string
- In
Foreach.c:331:
// Test with range at the end of the string
Str end_result = StrInit(&alloc);
StrForeachInRange(&s, chr, 6, 11) {
// Append the character to the result string
- In
Foreach.c:353:
Str s = StrInitFromZstr("Hello World", &alloc);
// Build a new string by iterating through a range of character pointers with indices
- In
Foreach.c:356:
// Build a new string by iterating through a range of character pointers with indices
Str result = StrInit(&alloc);
StrForeachPtrInRangeIdx(&s, chrptr, idx, 6, 11) {
// Append the character and its index to the result string
- In
Foreach.c:385:
Str s = StrInitFromZstr("Hello World", &alloc);
// Build a new string by iterating through a range of character pointers
- In
Foreach.c:388:
// Build a new string by iterating through a range of character pointers
Str result = StrInit(&alloc);
StrForeachPtrInRange(&s, chrptr, 0, 5) {
// Append the character to the result string
- In
Foreach.c:417:
Str s = StrInitFromZstr("Hello World!", &alloc); // 12 characters
// Use StrForeachInRangeIdx which captures the 'end' parameter at the start
- In
Foreach.c:454:
Str s = StrInitFromZstr("Programming", &alloc); // 11 characters
// Use StrForeachInRangeIdx with a fixed range that will become invalid
- In
Foreach.c:491:
Str s = StrInitFromZstr("Beautiful Weather", &alloc); // 17 characters
// StrForeachReverseIdx (VecForeachReverseIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
- In
Foreach.c:526:
Str s = StrInitFromZstr("Programming Test", &alloc); // 16 characters
// StrForeachPtrIdx (VecForeachPtrIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
- In
Foreach.c:561:
Str s = StrInitFromZstr("Excellent Example", &alloc); // 17 characters
// StrForeachReversePtrIdx (VecForeachPtrReverseIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
- In
Foreach.c:595:
Str s = StrInitFromZstr("Comprehensive Testing Framework", &alloc); // 31 characters
// Use StrForeachPtrInRangeIdx with a fixed range that becomes invalid when we modify the string
- In
Foreach.c:630:
Str s = StrInitFromZstr("Testing Basic", &alloc); // 13 characters
// Basic StrForeachIdx (VecForeachIdx) now has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
- In
Foreach.c:665:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Foreach.Simple tests\n\n");
// Array of normal test functions
- In
Foreach.c:694:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Foreach.Simple");
}- In
Access.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Log.h>- In
Access.c:24:
Str s = StrInit(&alloc);
bool result = (StrLen(&s) == 0);- In
Access.c:50:
Str s = StrInitFromZstr("Hello", &alloc);
// Get the first character
- In
Access.c:69:
Str s = StrInitFromZstr("Hello", &alloc);
// Get the last character
- In
Access.c:88:
Str s = StrInitFromZstr("Hello", &alloc);
// Get a pointer to the first character using StrBegin
- In
Access.c:107:
Str s = StrInitFromZstr("Hello", &alloc);
// Get a pointer to one past the last character using StrEnd
- In
Access.c:127:
Str s = StrInitFromZstr("Hello", &alloc);
// Access characters at different indices
- In
Access.c:151:
Str s = StrInitFromZstr("Hello", &alloc);
// Access character pointers at different indices
- In
Access.c:171:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Access tests\n\n");
// Array of test functions
- In
Access.c:187:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Access");
}- In
Ops.c:4:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Log.h>- In
Init.c:4:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include "../../Util/TestRunner.h"- In
Type.c:4:
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include "../../Util/TestRunner.h" si = JSkipWhitespace(si); \
} \
Str key = StrInit(&alloc); \
UNPL(read_si) = JReadString(si, &key); \
if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) { \
#define JR_STR(si, str) \
do { \
Str UNPL(my_str) = StrInit(&alloc); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \ do { \
if (!StrCmp(&key, (k))) { \
Str UNPL(my_str) = StrInit(&alloc); \
si = JReadString((si), &UNPL(my_str)); \
(str) = UNPL(my_str); \
- In
Backtrace.c:35:
size n = bt_capture_outer(frames, 32);
Str rendered = StrInit(alloc_base);
FormatStackTrace(&rendered, frames, n, alloc_base);- In
Backtrace.c:77:
ok = ok && VecLen(&frames) >= 2;
Str rendered = StrInit(alloc_base);
FormatStackTrace(&rendered, &frames, alloc_base);- In
Backtrace.c:107:
size n = bt_capture_outer(frames, 16);
Str out = StrInit(alloc_base);
FormatStackTraceWith(&out, frames, n, &res);- In
Backtrace.c:147:
size n = cfi_capture_outer(&res, frames, 32);
Str rendered = StrInit(alloc_base);
FormatStackTraceWith(&rendered, frames, n, &res);- In
SysDns.c:17:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Str/Init.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Log.h>- In
SysDns.c:80:
return false;
}
Str s = SocketAddrFormat(ad, a);
bool ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), expect) == 0;
StrDeinit(&s);- In
SysDns.c:90:
return false;
}
Str s = SocketAddrFormat(ad, a);
bool ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), expect) == 0;
StrDeinit(&s);- 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:99:
// 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);
if (FileIsOpen(&f)) {- In
SysDns.c:111:
}
static void drop_temp(Str *path) {
FileRemove(path);
StrDeinit(path);- In
SysDns.c:134:
return false;
}
Str s = SocketAddrFormat(VecPtrAt(&r->nameservers, i), a);
bool ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), expect) == 0;
StrDeinit(&s);- In
SysDns.c:222:
bool ok = got && VecLen(&out) == 1 && VecPtrAt(&out, 0)->family == SOCKET_FAMILY_INET;
if (ok) {
Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);
ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "203.0.113.7:9999") == 0;
StrDeinit(&s);- In
SysDns.c:246:
bool ok = got && VecLen(&out) == 1 && VecPtrAt(&out, 0)->family == SOCKET_FAMILY_INET6;
if (ok) {
Str s = SocketAddrFormat(VecPtrAt(&out, 0), a);
ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "[::1]:443") == 0;
StrDeinit(&s);- In
SysDns.c:271:
if (ok) {
VecForeachPtr(&out, ad) {
Str s = SocketAddrFormat(ad, a);
u64 L = StrLen(&s);
if (L < 3 || StrBegin(&s)[L - 1] != '3' || StrBegin(&s)[L - 2] != '5' || StrBegin(&s)[L - 3] != ':') {- In
SysDns.c:299:
bool ok = got && one.family == SOCKET_FAMILY_INET;
if (ok) {
Str s = SocketAddrFormat(&one, a);
ok = (StrLen(&s) > 0) && ZstrCompare(StrBegin(&s), "127.0.0.1:80") == 0;
StrDeinit(&s);- In
SysDns.c:358:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "127.0.0.1 localhost\n");
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:377:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "192.168.1.5 host.example alias1 alias2 alias3\n");
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:398:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"# a comment line\n"- In
SysDns.c:424:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "10.0.0.2 namex # trailing comment words\n");
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:444:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "10.0.0.2 namex#tail\n");
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:463:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, " \t 172.16.0.9\thostt\talt\n");
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:483:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "10.1.1.1 MixedCaseHost\n");
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:504:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "10.1.1.2 @AZ[`M\n");
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:524:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "10.0.0.1 a\n8.8.8.8 dns");
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:545:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "10.0.0.1 a\n# trailing comment no newline");
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:564:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"1.1.1.1 one\n"- In
SysDns.c:589:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "::1 ip6-localhost\n");
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:618:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"notanip somename morestuff\n"- In
SysDns.c:641:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"10.0.0.8\n"- In
SysDns.c:676:
buf[k] = '\0';
Str path = write_temp(a, (Zstr)buf);
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:696:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"bad 10.0.0.5 x\n"- In
SysDns.c:734:
Allocator *a = ALLOCATOR_OF(&alloc);
Str body = StrInit(a);
Zstr pad = "# padding line to push the fixture past the four kilobyte chunk\n";
u64 padlen = ZstrLen(pad);- In
SysDns.c:744:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, StrBegin(&body));
DnsResolverAddHostsPath(&r, &path);- In
SysDns.c:767:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"nameserver 8.8.8.8\n"- In
SysDns.c:793:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "nameserver ::1\n");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:812:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "# nameserver 9.9.9.9\n");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:830:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "; nameserver 9.9.9.9\n");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:848:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "search 8.8.8.8\n");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:866:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "nameserverx 8.8.8.8\n");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:884:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "nameserver\t8.8.4.4\n");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:902:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, " nameserver 8.8.8.8\n");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:920:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "nameserver not.an.ip.999\n");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:938:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "nameserver 8.8.8.8#note\n");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:956:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "nameserver \n");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:974:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"nameserver 10.0.0.1\n"- In
SysDns.c:998:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "nameserver 8.8.8.8");
DnsResolverAddResolvPath(&r, &path);- In
SysDns.c:1221:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"1.2.3.4 hostrow\n"- In
SysDns.c:1245:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"1.2.3.4 hostrow\n"- In
SysDns.c:1268:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"1.2.3.4 hostrow\n"- In
SysDns.c:1293:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "1.2.3.4 lenhost\n");
u64 plen = StrLen(&path);- In
SysDns.c:1296:
u64 plen = StrLen(&path);
Str smeared = StrInitFromStr(&path, a);
StrPushBackMany(&smeared, "ZZZ", 3);- In
SysDns.c:1315:
Allocator *a = ALLOCATOR_OF(&alloc);
Str path = write_temp(a, "1.2.3.4 leakhost\n");
u64 plen = StrLen(&path);- In
SysDns.c:1340:
resolver_init_empty(&r, a);
Str p0 = write_temp(a, "1.1.1.1 alpha\n");
Str p1 = write_temp(a, "2.2.2.2 beta\n");- In
SysDns.c:1341:
Str p0 = write_temp(a, "1.1.1.1 alpha\n");
Str p1 = write_temp(a, "2.2.2.2 beta\n");
Strs paths = VecInitT(paths, a);- In
SysDns.c:1371:
resolver_init_empty(&r, a);
Str p0 = write_temp(a, "nameserver 10.0.0.1\n");
Str p1 = write_temp(a, "nameserver 10.0.0.2\n");- In
SysDns.c:1372:
Str p0 = write_temp(a, "nameserver 10.0.0.1\n");
Str p1 = write_temp(a, "nameserver 10.0.0.2\n");
Strs paths = VecInitT(paths, a);- In
SysDns.c:1402:
resolver_init_empty(&r, a);
Str p0 = write_temp(a, "1.2.3.4 hh\n");
Str p1 = write_temp(a, "nameserver 9.9.9.9\n");- In
SysDns.c:1403:
Str p0 = write_temp(a, "1.2.3.4 hh\n");
Str p1 = write_temp(a, "nameserver 9.9.9.9\n");
Strs paths = VecInitT(paths, a);- In
SysDns.c:1433:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(
a,
"1.2.3.4 zlhost\n"- In
SysDns.c:1457:
DnsResolver r;
resolver_init_empty(&r, a);
Str path = write_temp(a, "nameserver 4.3.2.1\n");
bool added = DnsResolverAddResolvPath(&r, StrBegin(&path), StrLen(&path));- In
SysDns.c:1703:
resolver_init_crafted(&r, a);
Str name = StrInitFromZstr("multi", a);
DnsAddrs out = VecInitT(out, a);
bool got = dns_resolve_5_str(&r, &name, 7000, SOCKET_KIND_TCP, &out);- In
SysDns.c:1896:
resolver_init_crafted(&r, a);
Str spec = StrInitFromZstr("multi:8080", a);
DnsAddrs out = VecInitT(out, a);
bool got = dns_resolve_4_vec_str(&r, &spec, SOCKET_KIND_TCP, &out);- In
SysDns.c:1968:
resolver_init_crafted(&r, a);
Str spec = StrInitFromZstr("multi:80", a);
SocketAddr one;
bool got = dns_resolve_4_one_str(&r, &spec, SOCKET_KIND_TCP, &one);- In
Socket.c:46:
return false;
}
Str local_str = SocketAddrFormat(&local, a);
SocketAddr connect_addr;
bool parsed = SocketAddrParse(&connect_addr, (Zstr)StrBegin(&local_str), SOCKET_KIND_TCP);- In
Socket.c:102:
return false;
}
Str rendered = SocketAddrFormat(&addr, alloc_base);
ok = ok && StrLen(&rendered) > 0 && ZstrCompare(StrBegin(&rendered), "127.0.0.1:8080") == 0;
StrDeinit(&rendered);- In
Socket.c:113:
return false;
}
Str rendered = SocketAddrFormat(&addr, alloc_base);
ok = ok && StrLen(&rendered) > 0 && ZstrCompare(StrBegin(&rendered), "[::1]:8080") == 0;
StrDeinit(&rendered);- In
Socket.c:164:
}
Str local_str = SocketAddrFormat(&local, a);
SocketAddr connect_addr;
bool parsed = SocketAddrParse(&connect_addr, (Zstr)StrBegin(&local_str), SOCKET_KIND_TCP);- In
Socket.c:646:
bool ok = SocketAddrParse(&addr, spec, SOCKET_KIND_TCP);
if (ok) {
Str r = SocketAddrFormat(&addr, a);
ok = StrLen(&r) > 0 && ZstrCompare(StrBegin(&r), expect) == 0;
StrDeinit(&r);- In
Socket.c:785:
ok = ok && addr.length == 16u;
Str s = SocketAddrFormat(&addr, a);
ok = ok && StrLen(&s) > 0 && ZstrCompare(StrBegin(&s), "1.2.3.4:80") == 0;
StrDeinit(&s);- In
Socket.c:802:
bool ok = SocketAddrParse(&addr, "10.0.0.1:4660", SOCKET_KIND_TCP);
Str s = SocketAddrFormat(&addr, a);
ok = ok && StrLen(&s) > 0 && ZstrCompare(StrBegin(&s), "10.0.0.1:4660") == 0;
StrDeinit(&s);- In
Socket.c:831:
#endif
Str s = SocketAddrFormat(&addr, a);
ok = ok && StrLen(&s) > 0 && ZstrCompare(StrBegin(&s), "[2001:db8::1]:443") == 0;
StrDeinit(&s);- In
Socket.c:848:
ok = ok && addr.family == SOCKET_FAMILY_INET6;
Str s = SocketAddrFormat(&addr, a);
ok = ok && StrLen(&s) > 0 && ZstrCompare(StrBegin(&s), "[::1]:8080") == 0;
StrDeinit(&s);- In
Socket.c:934:
ok = ok && local.length == 16u;
Str s = SocketAddrFormat(&local, a);
ok = ok && StrLen(&s) > 0 && ZstrCompare(StrBegin(&s), "127.0.0.1:4660") == 0;
StrDeinit(&s);- In
Socket.c:968:
// Rendered "127.0.0.1:<port>" with a nonzero ephemeral port.
Str s = SocketAddrFormat(&local, a);
ok = ok && StrLen(&s) > 0;
if (ok) {- In
Socket.c:1008:
return false;
}
Str local_str = SocketAddrFormat(&local, a);
SocketAddr connect_addr;
bool parsed = SocketAddrParse(&connect_addr, (Zstr)StrBegin(&local_str), SOCKET_KIND_TCP);- In
Socket.c:1116:
*local_out = local;
Str local_str = SocketAddrFormat(&local, a);
SocketAddr connect_addr;
bool parsed = SocketAddrParse(&connect_addr, (Zstr)StrBegin(&local_str), SOCKET_KIND_TCP);- In
Socket.c:1170:
// the *len_io capture). Format and check the loopback host prefix.
{
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] == '.';- In
Socket.c:1263:
// local must be a usable IPv4 address with a kernel-picked port that
// formats to "127.0.0.1:<port>" with port in 1..65535.
Str rendered = SocketAddrFormat(&local, a);
bool ok = StrLen(&rendered) > 0;
// must start with the loopback host and a colon, then a non-"0" port.
- In
Socket.c:1483:
ok = ok && p;
if (p) {
Str r = SocketAddrFormat(&addr, a);
ok = ok && ZstrCompare(StrBegin(&r), "127.0.0.1:65535") == 0;
StrDeinit(&r);- In
Socket.c:1495:
ok = ok && p;
if (p) {
Str r = SocketAddrFormat(&addr, a);
ok = ok && ZstrCompare(StrBegin(&r), "127.0.0.1:0") == 0;
StrDeinit(&r);- In
Socket.c:1507:
ok = ok && p;
if (p) {
Str r = SocketAddrFormat(&addr, a);
ok = ok && ZstrCompare(StrBegin(&r), "1.2.3.4:4660") == 0;
StrDeinit(&r);- In
Socket.c:1540:
bool ok = true;
Str spec = StrInit(a);
StrAppendFmt(&spec, "{}", (Zstr) "1.2.3.4:4660");- In
Socket.c:1547:
ok = ok && p;
if (p) {
Str r = SocketAddrFormat(&addr, a);
ok = ok && ZstrCompare(StrBegin(&r), "1.2.3.4:4660") == 0;
StrDeinit(&r);- In
Socket.c:1577:
{
SocketAddr empty = {0};
Str r = SocketAddrFormat(&empty, a);
ok = ok && StrLen(&r) == 0;
StrDeinit(&r);- In
Socket.c:1588:
ok = ok && p;
if (p) {
Str r = SocketAddrFormat(&addr, a);
ok = ok && ZstrCompare(StrBegin(&r), "[::1]:4660") == 0;
StrDeinit(&r);- In
Socket.c:1615:
bool ok = SocketAddrParse(&addr, spec, SOCKET_KIND_TCP);
if (ok) {
Str r = SocketAddrFormat(&addr, a);
ok = StrLen(&r) > 0 && ZstrCompare(StrBegin(&r), expect) == 0;
StrDeinit(&r);- In
Socket.c:1674:
ok = ok && local.length == 16u;
Str s = SocketAddrFormat(&local, a);
ok = ok && StrLen(&s) > 0 && ZstrCompareN(StrBegin(&s), "127.0.0.1:", 10u) == 0;
StrDeinit(&s);- In
MachoCache.c:867:
MachoCache cache = MachoCacheInit(base);
Str mod = StrInit(base);
StrPushBackMany(&mod, bin_path);- In
Pe.c:15:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Memory.h>- In
Pe.c:1650:
build_blob(blob, secs, 1);
Str path = StrInit(base);
File f = FileOpenTemp(&path, base);
if (!FileIsOpen(&f)) {- In
Pe.c:1692:
junk[1] = 'Y';
Str path = StrInit(base);
File f = FileOpenTemp(&path, base);
if (!FileIsOpen(&f)) {- In
Dns.c:3:
#include <Misra/Parsers/Dns.h>
#include <Misra/Std/Zstr.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>- In
Dns.c:471:
Allocator *a = ALLOCATOR_OF(&alloc);
Str name = StrInitFromZstr("example.com", a);
DnsWireBuf buf = VecInitT(buf, a);
bool ok = DnsBuildQuery(&buf, 0x1234, &name, DNS_TYPE_A);- In
ProcMaps.c:4:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Zstr.h>- In
ProcMaps.c:570:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path;
File f = FileOpenTemp(&path, alloc_base);
if (!FileIsOpen(&f)) {- In
Http.c:44:
HttpResponse response = HttpResponseInit(alloc_base);
Str body = StrInit(alloc_base);
StrAppendFmt(&body, "<h1>hi</h1>");
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &body);- In
Http.c:49:
StrDeinit(&body);
Str wire = HttpResponseSerialize(&response, alloc_base);
// Spot-check the wire format:
- In
Http.c:157:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str raw = StrInit(alloc_base);
StrAppendFmt(&raw, "GET / HTTP/1.1\r\n");
// 101 headers -- one past the cap of 100.
- In
Http.c:185:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str raw = StrInit(alloc_base);
StrAppendFmt(&raw, "GET / HTTP/1.1\r\n");
for (u64 i = 0; i < 100; i++) {- In
Http.c:213:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path = StrInit(alloc_base);
File f = FileOpenTemp(&path, alloc_base);
bool ok = FileIsOpen(&f);- In
Http.c:243:
Allocator *alloc_base = ALLOCATOR_OF(&alloc);
Str path = StrInit(alloc_base);
File f = FileOpenTemp(&path, alloc_base);
bool ok = FileIsOpen(&f);- In
Http.c:350:
Allocator *adbg = ALLOCATOR_OF(&dbg);
Str first = StrInit(adbg);
StrAppendFmt(&first, "<h1>first-body-long-enough-to-heap-allocate</h1>");- In
Http.c:356:
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &first);
Str second = StrInit(adbg);
StrAppendFmt(&second, "<h1>second-body-also-long-enough-to-heap</h1>");
// Second call must free the first body before installing the second.
- In
Http.c:380:
// Pre-fill body with a heap-backed string.
Str first = StrInit(adbg);
StrAppendFmt(&first, "<h1>old-body-long-enough-to-force-heap-here</h1>");
HttpResponse response = HttpResponseInit(adbg);- In
Http.c:387:
// Create a temp file with content.
Str path = StrInit(adbg);
File f = FileOpenTemp(&path, adbg);
bool ok = FileIsOpen(&f);- In
MachO.c:11:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/File.h>
#include <Misra/Std/Memory.h>- In
MachO.c:1406:
// Mint a unique temp path, then write a minimal valid Mach-O to it.
Str path;
File seed = FileOpenTemp(&path, base);
if (!FileIsOpen(&seed)) {- In
MachO.c:1448:
Allocator *base = ALLOCATOR_OF(&alloc);
Str path;
File seed = FileOpenTemp(&path, base);
if (!FileIsOpen(&seed)) {- In
Read.Simple.c:17:
typedef struct Person {
u64 id;
Str name;
u32 age;
bool is_active;- In
Read.Simple.c:26:
bool debug_mode;
u32 timeout;
Str log_level;
} Config;- In
Read.Simple.c:31:
typedef struct SimpleProduct {
u64 id;
Str name;
f64 price;
Vec(Str) tags;- In
Read.Simple.c:33:
Str name;
f64 price;
Vec(Str) tags;
} SimpleProduct;- In
Read.Simple.c:67:
bool success = true;
Str json = StrInitFromZstr("{\"name\": \"Alice\", \"city\": \"New York\"}", &alloc);
StrIter si = StrIterFromStr(json);- In
Read.Simple.c:70:
StrIter si = StrIterFromStr(json);
Str name = StrInit(&alloc);
Str city = StrInit(&alloc);- In
Read.Simple.c:71:
Str name = StrInit(&alloc);
Str city = StrInit(&alloc);
JR_OBJ(si, {
bool success = true;
Str json = StrInitFromZstr("{\"count\": 42, \"score\": 95.5, \"year\": 2024}", &alloc);
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr("{\"enabled\": true, \"visible\": false}", &alloc);
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr(
"{\"id\": 1001, \"name\": \"Bob\", \"age\": 25, \"is_active\": true, \"salary\": 50000.0}",
&alloc
bool success = true;
Str json = StrInitFromZstr("{\"debug_mode\": false, \"timeout\": 30, \"log_level\": \"INFO\"}", &alloc);
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr("{\"languages\": [\"C\", \"Python\", \"Rust\"]}", &alloc);
StrIter si = StrIterFromStr(json); StrIter si = StrIterFromStr(json);
Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
JR_OBJ(si, { JR_OBJ(si, {
JR_ARR_KV(si, "languages", {
Str lang = StrInit(&alloc);
JR_STR(si, lang);
VecPushBack(&languages, lang);
if (VecLen(&languages) >= 3) {
Str *lang1 = &VecAt(&languages, 0);
Str *lang2 = &VecAt(&languages, 1);
Str *lang3 = &VecAt(&languages, 2); if (VecLen(&languages) >= 3) {
Str *lang1 = &VecAt(&languages, 0);
Str *lang2 = &VecAt(&languages, 1);
Str *lang3 = &VecAt(&languages, 2); Str *lang1 = &VecAt(&languages, 0);
Str *lang2 = &VecAt(&languages, 1);
Str *lang3 = &VecAt(&languages, 2);
if (StrCmp(lang1, "C", 1) != 0) {
bool success = true;
Str json = StrInitFromZstr(
"{\"user\": {\"name\": \"Charlie\", \"email\": \"charlie@example.com\"}, \"active\": true}",
&alloc struct {
struct {
Str name;
Str email;
} user; struct {
Str name;
Str email;
} user;
bool active;
bool success = true;
Str json = StrInitFromZstr(
"{\"id\": 12345, \"name\": \"Laptop\", \"price\": 999.99, \"tags\": [\"electronics\", \"computers\", "
"\"portable\"]}", JR_FLT_KV(si, "price", product.price);
JR_ARR_KV(si, "tags", {
Str tag = StrInit(&alloc);
JR_STR(si, tag);
VecPushBack(&product.tags, tag);
if (VecLen(&product.tags) >= 3) {
Str *tag1 = &VecAt(&product.tags, 0);
Str *tag2 = &VecAt(&product.tags, 1);
Str *tag3 = &VecAt(&product.tags, 2); if (VecLen(&product.tags) >= 3) {
Str *tag1 = &VecAt(&product.tags, 0);
Str *tag2 = &VecAt(&product.tags, 1);
Str *tag3 = &VecAt(&product.tags, 2); Str *tag1 = &VecAt(&product.tags, 0);
Str *tag2 = &VecAt(&product.tags, 1);
Str *tag3 = &VecAt(&product.tags, 2);
if (StrCmp(tag1, "electronics", 11) != 0) {
// 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); 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);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); // Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc);
// Remove spaces and newlines from both strings for comparison
bool success = true;
Str json = StrInit(&alloc);
// Write completely empty object
bool success = true;
Str json = StrInit(&alloc);
Vec(i32) empty_numbers = VecInit(&alloc);
Vec(i32) empty_numbers = VecInit(&alloc);
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
JW_OBJ(json, {
bool success = true;
Str json = StrInit(&alloc);
Str empty_name = StrInit(&alloc); Str json = StrInit(&alloc);
Str empty_name = StrInit(&alloc);
Str empty_desc = StrInit(&alloc);
Str empty_name = StrInit(&alloc);
Str empty_desc = StrInit(&alloc);
JW_OBJ(json, {
bool success = true;
Str json = StrInit(&alloc);
i32 temp = -25;
bool success = true;
Str json = StrInit(&alloc);
i64 big_int = 9223372036854775807LL;
bool success = true;
Str json = StrInit(&alloc);
i32 int_zero = 0;
bool success = true;
Str json = StrInit(&alloc);
// Note: These are the actual characters, not escape sequences
// Note: These are the actual characters, not escape sequences
Str path = StrInitFromZstr("C:\\Program Files\\App", &alloc);
Str message = StrInitFromZstr("Hello, \"World\"!", &alloc);
Str data = StrInitFromZstr("line1\nline2\ttab", &alloc); // Note: These are the actual characters, not escape sequences
Str path = StrInitFromZstr("C:\\Program Files\\App", &alloc);
Str message = StrInitFromZstr("Hello, \"World\"!", &alloc);
Str data = StrInitFromZstr("line1\nline2\ttab", &alloc); Str path = StrInitFromZstr("C:\\Program Files\\App", &alloc);
Str message = StrInitFromZstr("Hello, \"World\"!", &alloc);
Str data = StrInitFromZstr("line1\nline2\ttab", &alloc);
JW_OBJ(json, {
bool success = true;
Str json = StrInit(&alloc);
// These contain actual special characters that should be escaped
// These contain actual special characters that should be escaped
Str quotes = StrInitFromZstr("\"quotes\"", &alloc);
Str backslash = StrInitFromZstr("\\", &alloc);
Str newline = StrInitFromZstr("\n", &alloc); // These contain actual special characters that should be escaped
Str quotes = StrInitFromZstr("\"quotes\"", &alloc);
Str backslash = StrInitFromZstr("\\", &alloc);
Str newline = StrInitFromZstr("\n", &alloc);
Str tab = StrInitFromZstr("\t", &alloc); Str quotes = StrInitFromZstr("\"quotes\"", &alloc);
Str backslash = StrInitFromZstr("\\", &alloc);
Str newline = StrInitFromZstr("\n", &alloc);
Str tab = StrInitFromZstr("\t", &alloc); Str backslash = StrInitFromZstr("\\", &alloc);
Str newline = StrInitFromZstr("\n", &alloc);
Str tab = StrInitFromZstr("\t", &alloc);
JW_OBJ(json, {
bool success = true;
Str json = StrInit(&alloc);
Vec(i32) empty_list = VecInit(&alloc);
bool success = true;
Str json = StrInit(&alloc);
Vec(i32) empty_arr = VecInit(&alloc);
bool success = true;
Str json = StrInit(&alloc);
i64 max_int = 2147483647LL;
bool success = true;
Str json = StrInit(&alloc);
f64 tiny = 0.000001;
bool success = true;
Str json1 = StrInit(&alloc);
Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc); bool success = true;
Str json1 = StrInit(&alloc);
Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc);
Str json4 = StrInit(&alloc); Str json1 = StrInit(&alloc);
Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc);
Str json4 = StrInit(&alloc); Str json2 = StrInit(&alloc);
Str json3 = StrInit(&alloc);
Str json4 = StrInit(&alloc);
// Single integer
// Single string
Str single_str = StrInitFromZstr("hello", &alloc);
JW_OBJ(json2, { JW_STR_KV(json2, "text", single_str); }); u64 analysis_id;
u64 binary_id;
Str analysis_name;
Str function_name;
Str sha256; u64 binary_id;
Str analysis_name;
Str function_name;
Str sha256;
bool debug; Str analysis_name;
Str function_name;
Str sha256;
bool debug;
Str function_mangled_name; Str sha256;
bool debug;
Str function_mangled_name;
} AnnSymbol; typedef struct ApiResponse {
bool status;
Str message;
AnnSymbols data;
} ApiResponse; typedef struct FunctionInfo {
u64 id;
Str name;
u64 size;
u64 vaddr; typedef struct SearchResult {
u64 binary_id;
Str binary_name;
u64 analysis_id;
Str sha256; Str binary_name;
u64 analysis_id;
Str sha256;
Vec(Str) tags;
Str created_at; u64 analysis_id;
Str sha256;
Vec(Str) tags;
Str created_at;
u64 model_id; Str sha256;
Vec(Str) tags;
Str created_at;
u64 model_id;
Str model_name; Str created_at;
u64 model_id;
Str model_name;
Str owned_by;
} SearchResult; u64 model_id;
Str model_name;
Str owned_by;
} SearchResult;
// 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); // 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);
Str expected_clean = StrInit(alloc); bool compare_json_output(const Str *output, Zstr expected, DefaultAllocator *alloc) {
Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc);
// Remove whitespace from both strings for comparison
bool success = true;
Str json = StrInit(&alloc);
struct { u64 id;
struct {
Str name;
u64 age;
} profile; } profile;
} user;
Str status;
} data = {
{123, {StrInitFromZstr("Alice", &alloc), 30}},
bool success = true;
Str json = StrInit(&alloc);
struct { struct {
struct {
Str head;
u64 count;
f64 budget; } engineering;
} departments;
Str name;
} company;
} data = {
bool success = true;
Str json = StrInit(&alloc);
ApiResponse response = { JW_OBJ_KV(json, "data", {
// Write dynamic key for source function ID
Str source_key = StrInit(&alloc);
u64 source_id = VecLen(&response.data) > 0 ? VecAt(&response.data, 0).source_function_id : 0;
StrAppendFmt(&source_key, "{}", source_id); if (VecLen(&response.data) > 0) {
AnnSymbol *s = &VecAt(&response.data, 0);
Str target_key = StrInit(&alloc);
StrAppendFmt(&target_key, "{}", s->target_function_id);
bool success = true;
Str json = StrInit(&alloc);
Vec(FunctionInfo) functions = VecInitWithDeepCopy(NULL, FunctionInfoDeinit, &alloc);
bool success = true;
Str json = StrInit(&alloc);
SearchResult result = {0};
// Create strings and push them properly
Str tag1 = StrInitFromZstr("malware", &alloc);
Str tag2 = StrInitFromZstr("x86", &alloc); // Create strings and push them properly
Str tag1 = StrInitFromZstr("malware", &alloc);
Str tag2 = StrInitFromZstr("x86", &alloc);
VecPushBack(&result.tags, tag1);
bool success = true;
Str json = StrInit(&alloc);
Vec(AnnSymbol) symbols = VecInitWithDeepCopy(NULL, AnnSymbolDeinit, &alloc); JW_OBJ_KV(json, "functions", {
VecForeach(&symbols, symbol) {
Str source_key = StrInit(&alloc);
StrAppendFmt(&source_key, "{}", symbol.source_function_id);
JW_OBJ_KV(json, StrBegin(&source_key), {
Str target_key = StrInit(&alloc);
StrAppendFmt(&target_key, "{}", symbol.target_function_id);
bool success = true;
Str json = StrInit(&alloc);
// Create strings for the nested structure
// Create strings for the nested structure
Str deep_message = StrInitFromZstr("deep", &alloc);
Str test_name = StrInitFromZstr("test", &alloc); // Create strings for the nested structure
Str deep_message = StrInitFromZstr("deep", &alloc);
Str test_name = StrInitFromZstr("test", &alloc);
JW_OBJ(json, {
bool success = true;
Str json = StrInit(&alloc);
Vec(u32) numbers = VecInit(&alloc); VecPushBack(&numbers, num3);
Vec(Str) strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
// Create strings and push them properly
// Create strings and push them properly
Str str1 = StrInitFromZstr("a", &alloc);
Str str2 = StrInitFromZstr("b", &alloc);
Str str3 = StrInitFromZstr("c", &alloc); // Create strings and push them properly
Str str1 = StrInitFromZstr("a", &alloc);
Str str2 = StrInitFromZstr("b", &alloc);
Str str3 = StrInitFromZstr("c", &alloc); Str str1 = StrInitFromZstr("a", &alloc);
Str str2 = StrInitFromZstr("b", &alloc);
Str str3 = StrInitFromZstr("c", &alloc);
VecPushBack(&strings, str1);- In
Read.Nested.c:21:
u64 analysis_id;
u64 binary_id;
Str analysis_name;
Str function_name;
Str sha256;- In
Read.Nested.c:22:
u64 binary_id;
Str analysis_name;
Str function_name;
Str sha256;
bool debug;- In
Read.Nested.c:23:
Str analysis_name;
Str function_name;
Str sha256;
bool debug;
Str function_mangled_name;- In
Read.Nested.c:25:
Str sha256;
bool debug;
Str function_mangled_name;
} AnnSymbol;- In
Read.Nested.c:32:
typedef struct ApiResponse {
bool status;
Str message;
AnnSymbols data;
} ApiResponse;- In
Read.Nested.c:46:
typedef struct FunctionInfo {
u64 id;
Str name;
u64 size;
u64 vaddr;- In
Read.Nested.c:55:
typedef struct ModelInfo {
u64 id;
Str name;
} ModelInfo;- In
Read.Nested.c:62:
typedef struct SearchResult {
u64 binary_id;
Str binary_name;
u64 analysis_id;
Str sha256;- In
Read.Nested.c:64:
Str binary_name;
u64 analysis_id;
Str sha256;
Vec(Str) tags;
Str created_at;- In
Read.Nested.c:65:
u64 analysis_id;
Str sha256;
Vec(Str) tags;
Str created_at;
u64 model_id;- In
Read.Nested.c:66:
Str sha256;
Vec(Str) tags;
Str created_at;
u64 model_id;
Str model_name;- In
Read.Nested.c:68:
Str created_at;
u64 model_id;
Str model_name;
Str owned_by;
} SearchResult;- In
Read.Nested.c:69:
u64 model_id;
Str model_name;
Str owned_by;
} SearchResult; DefaultAllocator alloc = DefaultAllocatorInit();
Str json = StrInitFromZstr("{\"test\": \"value\"}", &alloc);
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr("{\"id\": 12345, \"name\": \"test\", \"active\": true, \"score\": 98.5}", &alloc);
StrIter si = StrIterFromStr(json); struct {
u64 id;
Str name;
bool active;
f64 score;
bool success = true;
Str json = StrInitFromZstr(
"{\"user\": {\"id\": 123, \"profile\": {\"name\": \"Alice\", \"age\": 30}}, \"status\": \"active\"}",
&alloc u64 id;
struct {
Str name;
u64 age;
} profile; } profile;
} user;
Str status;
} data = {
{0, {StrInit(&alloc), 0}},
bool success = true;
Str json = StrInitFromZstr(
"{\"company\": {\"departments\": {\"engineering\": {\"head\": \"John\", \"count\": 25, \"budget\": 150000.0}}, "
"\"name\": \"TechCorp\"}}", struct {
struct {
Str head;
u64 count;
f64 budget; } engineering;
} departments;
Str name;
} company;
} data = {
bool success = true;
Str json = StrInitFromZstr(
"{\"functions\": {\"12345\": {\"67890\": {\"distance\": 0.85, \"name\": \"main\"}}, \"54321\": {\"98765\": "
"{\"distance\": 0.92, \"name\": \"helper\"}}}}",
bool success = true;
Str json = StrInitFromZstr(
"{\"status\": true, \"message\": \"Success\", \"data\": {\"12345\": {\"67890\": {\"distance\": 0.85, "
"\"nearest_neighbor_analysis_id\": 999, \"nearest_neighbor_binary_id\": 888, "
bool success = true;
Str json = StrInitFromZstr("{\"id\": 12345, \"name\": \"test_func\", \"size\": 1024, \"vaddr\": 4096}", &alloc);
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr("{\"id\": 54321, \"name\": \"test_model\"}", &alloc);
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr(
"{\"binary_id\": 888, \"binary_name\": \"test_binary\", \"analysis_id\": 999, \"sha256\": \"abc123\", "
"\"created_at\": \"2024-04-01\", \"model_id\": 12345, \"model_name\": \"test_model\", \"owned_by\": \"user1\"}",
bool success = true;
Str json = StrInitFromZstr(
"{\"status\": true, \"message\": \"Success\", \"data\": {\"12345\": {\"67890\": {\"distance\": 0.85, "
"\"nearest_neighbor_analysis_id\": 999, \"nearest_neighbor_binary_id\": 888, "
bool success = true;
Str json = StrInitFromZstr(
"{\"status\": true, \"message\": \"Success\", \"data\": {\"12345\": {\"67890\": {\"distance\": 0.85, "
"\"nearest_neighbor_analysis_id\": 999, \"nearest_neighbor_binary_id\": 888, " typedef struct Person {
u64 id;
Str name;
u32 age;
bool is_active; bool debug_mode;
u32 timeout;
Str log_level;
} Config; typedef struct SimpleProduct {
u64 id;
Str name;
f64 price;
Vec(Str) tags; Str name;
f64 price;
Vec(Str) tags;
} SimpleProduct;
// 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); 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);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); // Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc); Str expected_str = StrInitFromZstr(expected, alloc);
Str output_clean = StrInit(alloc);
Str expected_clean = StrInit(alloc);
// Remove spaces and newlines from both strings for comparison
bool success = true;
Str json = StrInit(&alloc);
Str name = StrInitFromZstr("Alice", &alloc); Str json = StrInit(&alloc);
Str name = StrInitFromZstr("Alice", &alloc);
Str city = StrInitFromZstr("New York", &alloc);
Str name = StrInitFromZstr("Alice", &alloc);
Str city = StrInitFromZstr("New York", &alloc);
JW_OBJ(json, {
bool success = true;
Str json = StrInit(&alloc);
u32 count = 42;
bool success = true;
Str json = StrInit(&alloc);
bool enabled = true;
bool success = true;
Str json = StrInit(&alloc);
Person person = {1001, StrInitFromZstr("Bob", &alloc), 25, true, 50000.0};
bool success = true;
Str json = StrInit(&alloc);
Config config = {false, 30, StrInitFromZstr("INFO", &alloc)};
bool success = true;
Str json = StrInit(&alloc);
Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit, &alloc); Str json = StrInit(&alloc);
Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
// Create strings and push them properly
// Create strings and push them properly
Str lang1 = StrInitFromZstr("C", &alloc);
Str lang2 = StrInitFromZstr("Python", &alloc);
Str lang3 = StrInitFromZstr("Rust", &alloc); // Create strings and push them properly
Str lang1 = StrInitFromZstr("C", &alloc);
Str lang2 = StrInitFromZstr("Python", &alloc);
Str lang3 = StrInitFromZstr("Rust", &alloc); Str lang1 = StrInitFromZstr("C", &alloc);
Str lang2 = StrInitFromZstr("Python", &alloc);
Str lang3 = StrInitFromZstr("Rust", &alloc);
VecPushBack(&languages, lang1);
bool success = true;
Str json = StrInit(&alloc);
struct { struct {
struct {
Str name;
Str email;
} user; struct {
Str name;
Str email;
} user;
bool active;
bool success = true;
Str json = StrInit(&alloc);
SimpleProduct product = {0};
// Create strings and push them properly
Str tag1 = StrInitFromZstr("electronics", &alloc);
Str tag2 = StrInitFromZstr("computers", &alloc);
Str tag3 = StrInitFromZstr("portable", &alloc); // Create strings and push them properly
Str tag1 = StrInitFromZstr("electronics", &alloc);
Str tag2 = StrInitFromZstr("computers", &alloc);
Str tag3 = StrInitFromZstr("portable", &alloc); Str tag1 = StrInitFromZstr("electronics", &alloc);
Str tag2 = StrInitFromZstr("computers", &alloc);
Str tag3 = StrInitFromZstr("portable", &alloc);
VecPushBack(&product.tags, tag1); // Test structures for edge cases
typedef struct EdgeCaseData {
Str empty_string;
i64 negative_int;
f64 large_float; f64 small_float;
bool is_valid;
Vec(Str) empty_array;
Vec(i64) numbers;
} EdgeCaseData;
// Test completely empty object
Str json1 = StrInitFromZstr("{}", &alloc);
StrIter si1 = StrIterFromStr(json1);
// Test empty object with whitespace
Str json2 = StrInitFromZstr(" { } ", &alloc);
StrIter si2 = StrIterFromStr(json2);
// Test completely empty array
Str json1 = StrInitFromZstr("{\"items\":[]}", &alloc);
StrIter si1 = StrIterFromStr(json1);
// Test empty array with whitespace
Str json2 = StrInitFromZstr("{\"data\": [ ] }", &alloc);
StrIter si2 = StrIterFromStr(json2); StrIter si2 = StrIterFromStr(json2);
Vec(Str) data = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
JR_OBJ(si2, { JR_OBJ(si2, {
JR_ARR_KV(si2, "data", {
Str value = StrInit(&alloc);
JR_STR(si2, value);
VecPushBack(&data, value); bool success = true;
Str json = StrInitFromZstr("{\"name\":\"\",\"description\":\"\"}", &alloc);
StrIter si = StrIterFromStr(json);
struct {
Str name;
Str description;
} obj = {StrInit(&alloc), StrInit(&alloc)}; struct {
Str name;
Str description;
} obj = {StrInit(&alloc), StrInit(&alloc)}; bool success = true;
Str json = StrInitFromZstr("{\"temp\":-25,\"balance\":-1000.50,\"delta\":-0.001}", &alloc);
StrIter si = StrIterFromStr(json); bool success = true;
Str json = StrInitFromZstr(
"{\"big_int\":9223372036854775807,\"big_float\":1.7976931348623157e+308,\"small_float\":2.2250738585072014e-"
"308}", bool success = true;
Str json = StrInitFromZstr("{\"int_zero\":0,\"float_zero\":0.0,\"bool_false\":false}", &alloc);
StrIter si = StrIterFromStr(json);
// Test with various special characters that might be problematic
Str json = StrInitFromZstr(
"{\"path\":\"C:\\\\Program Files\\\\App\",\"message\":\"Hello, "
"\\\"World\\\"!\",\"data\":\"line1\\nline2\\ttab\"}",
struct {
Str path;
Str message;
Str data; struct {
Str path;
Str message;
Str data;
} obj = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)}; Str path;
Str message;
Str data;
} obj = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)}; // In a C source literal each backslash is doubled, so e.g. the JSON token
// `\n` is spelled "\\n" here.
Str json = StrInitFromZstr(
"{"
"\"quote\":\"\\\"\","
struct {
Str quote;
Str backslash;
Str slash; struct {
Str quote;
Str backslash;
Str slash;
Str backspace; Str quote;
Str backslash;
Str slash;
Str backspace;
Str formfeed; Str backslash;
Str slash;
Str backspace;
Str formfeed;
Str newline; Str slash;
Str backspace;
Str formfeed;
Str newline;
Str carriage; Str backspace;
Str formfeed;
Str newline;
Str carriage;
Str tab; Str formfeed;
Str newline;
Str carriage;
Str tab;
} obj = { Str newline;
Str carriage;
Str tab;
} obj = {
StrInit(&alloc), // test_truncated_unicode_escape_rejected).
struct {
const Str *got;
char want;
Zstr name;
// Test with lots of different whitespace patterns
Str json = StrInitFromZstr(" {\n\t\"name\" : \"test\" ,\n \"value\": 42\t,\"flag\"\n:\ntrue\n}\t", &alloc);
StrIter si = StrIterFromStr(json);
struct {
Str name;
i32 value;
bool flag; bool success = true;
Str json = StrInitFromZstr("{\"outer\":{},\"list\":[],\"deep\":{\"inner\":{}}}", &alloc);
StrIter si = StrIterFromStr(json); bool success = true;
Str json =
StrInitFromZstr("{\"empty_obj\":{},\"filled_obj\":{\"x\":1},\"empty_arr\":[],\"filled_arr\":[1,2]}", &alloc);
StrIter si = StrIterFromStr(json);
// Using smaller values that are safer to work with
Str json = StrInitFromZstr("{\"max_int\":2147483647,\"min_int\":-2147483648,\"one\":1,\"minus_one\":-1}", &alloc);
StrIter si = StrIterFromStr(json); bool success = true;
Str json =
StrInitFromZstr("{\"tiny\":0.000001,\"huge\":999999.999999,\"zero\":0.0,\"negative_tiny\":-0.000001}", &alloc);
StrIter si = StrIterFromStr(json); // JReadBool on a token that starts like a bool but isn't.
{
Str j = StrInitFromZstr("tru3", &alloc);
StrIter si = StrIterFromStr(j);
bool b = true; }
{
Str j = StrInitFromZstr("fXlse", &alloc);
StrIter si = StrIterFromStr(j);
bool b = true; // Input too short to spell a bool -- must fail (the >= length guard).
{
Str j = StrInitFromZstr("tr", &alloc);
StrIter si = StrIterFromStr(j);
bool b = true; // JReadNull on a 'n...' token that isn't "null".
{
Str j = StrInitFromZstr("nuXX", &alloc);
StrIter si = StrIterFromStr(j);
bool is_null = true;
{
Str j = StrInitFromZstr("true rest", &alloc);
StrIter si = StrIterFromStr(j);
bool b = false; }
{
Str j = StrInitFromZstr("false rest", &alloc);
StrIter si = StrIterFromStr(j);
bool b = true; }
{
Str j = StrInitFromZstr("null rest", &alloc);
StrIter si = StrIterFromStr(j);
bool is_null = false; // boundary case for the minimum-length guard.
{
Str j = StrInitFromZstr("true", &alloc);
StrIter si = StrIterFromStr(j);
bool b = false; }
{
Str j = StrInitFromZstr("false", &alloc);
StrIter si = StrIterFromStr(j);
bool b = true; }
{
Str j = StrInitFromZstr("null", &alloc);
StrIter si = StrIterFromStr(j);
bool is_null = false; Zstr cases[] = {"\"\\u\"", "\"\\u12\"", "\"ab\\u\""};
for (u64 i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
Str j = StrInitFromZstr(cases[i], &alloc);
StrIter si = StrIterFromStr(j);
Str out = StrInit(&alloc); Str j = StrInitFromZstr(cases[i], &alloc);
StrIter si = StrIterFromStr(j);
Str out = StrInit(&alloc);
StrIter r = JReadString(si, &out);
// Truncated escape -> failure -> iterator unchanged.
// reject -> iterator rewinds to start, output cleared.
{
Str j = StrInitFromZstr("\"a\\u00e9b\"", &alloc);
StrIter si = StrIterFromStr(j);
Str out = StrInit(&alloc); Str j = StrInitFromZstr("\"a\\u00e9b\"", &alloc);
StrIter si = StrIterFromStr(j);
Str out = StrInit(&alloc);
StrIter r = JReadString(si, &out);
if (StrIterIndex(&r) != StrIterIndex(&si)) { // is specific to \u, not a blanket failure.
{
Str j = StrInitFromZstr("\"plain\"", &alloc);
StrIter si = StrIterFromStr(j);
Str out = StrInit(&alloc); Str j = StrInitFromZstr("\"plain\"", &alloc);
StrIter si = StrIterFromStr(j);
Str out = StrInit(&alloc);
StrIter r = JReadString(si, &out);
if (StrIterIndex(&r) == StrIterIndex(&si) || StrIterIndex(&r) != StrIterLength(&r)) { bool success = true;
Str json = StrInitFromZstr(
"{"
"\"u_str\":\"ignore\","
for (u64 i = 0; i < sizeof(cases) / sizeof(cases[0]); i++) {
Str json = StrInitFromZstr(cases[i], &alloc);
StrIter si = StrIterFromStr(json);
i64 a = 0;
{
Str j = StrInitFromZstr("-12345", &alloc);
StrIter si = StrIterFromStr(j);
i64 v = 0; {
// Positive control: a sign-flip mutation would make this negative.
Str j = StrInitFromZstr("12345", &alloc);
StrIter si = StrIterFromStr(j);
i64 v = 0; }
{
Str j = StrInitFromZstr("-2.5", &alloc);
StrIter si = StrIterFromStr(j);
f64 v = 0.0; bool success = true;
Str j = StrInitFromZstr("7", &alloc);
StrIter si = StrIterFromStr(j);
f64 val = 0.0; bool success = true;
Str j = StrInitFromZstr("13", &alloc);
StrIter si = StrIterFromStr(j);
f64 val = 0.0; // 'n' lead-in but not "null": ZstrCompareN fails -> *is_null stays the
// value the unconditional clear set it to, which must be false.
Str j = StrInitFromZstr("nuII", &alloc);
StrIter si = StrIterFromStr(j);
bool is_null = true; // poison: must be overwritten to false
bool success = true;
Str j = StrInitFromZstr("null", &alloc);
StrIter si = StrIterFromStr(j);
bool is_null = false;- In
RoundTrip.c:18:
typedef struct TestPerson {
u64 id;
Str name;
u32 age;
bool is_active;- In
RoundTrip.c:27:
bool debug_mode;
u32 timeout;
Str log_level;
Vec(Str) features;
} TestConfig;- In
RoundTrip.c:28:
u32 timeout;
Str log_level;
Vec(Str) features;
} TestConfig;- In
RoundTrip.c:68:
// Helper function to compare persons
bool compare_persons(const TestPerson *a, const TestPerson *b) {
return a->id == b->id && StrCmp((Str *)&a->name, (Str *)&b->name) == 0 && a->age == b->age &&
a->is_active == b->is_active && a->salary == b->salary;
}- In
RoundTrip.c:75:
bool compare_configs(const TestConfig *a, const TestConfig *b) {
if (a->debug_mode != b->debug_mode || a->timeout != b->timeout ||
StrCmp((Str *)&a->log_level, (Str *)&b->log_level) != 0 || VecLen(&a->features) != VecLen(&b->features)) {
return false;
}- In
RoundTrip.c:80:
for (size i = 0; i < VecLen(&a->features); i++) {
if (StrCmp((Str *)&VecAt(&a->features, i), (Str *)&VecAt(&b->features, i)) != 0) {
return false;
}- In
RoundTrip.c:100:
f64 temperature;
bool enabled;
Str message;
} original = {42, 25.5, true, StrInitFromZstr("hello world", &alloc)};- In
RoundTrip.c:104:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_INT_KV(json, "count", original.count);- In
RoundTrip.c:119:
f64 temperature;
bool enabled;
Str message;
} parsed = {0, 0.0, false, StrInit(&alloc)};- In
RoundTrip.c:179:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_INT_KV(json, "big_int", original.big_int);- In
RoundTrip.c:252:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_BOOL_KV(json, "flag1", original.flag1);- In
RoundTrip.c:300:
// Original data with various string types
struct {
Str empty;
Str simple;
Str with_spaces;- In
RoundTrip.c:301:
struct {
Str empty;
Str simple;
Str with_spaces;
Str with_special;- In
RoundTrip.c:302:
Str empty;
Str simple;
Str with_spaces;
Str with_special;
} original = {- In
RoundTrip.c:303:
Str simple;
Str with_spaces;
Str with_special;
} original = {
StrInit(&alloc),- In
RoundTrip.c:312:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_STR_KV(json, "empty", original.empty);- In
RoundTrip.c:322:
// Read back from JSON
struct {
Str empty;
Str simple;
Str with_spaces;- In
RoundTrip.c:323:
struct {
Str empty;
Str simple;
Str with_spaces;
Str with_special;- In
RoundTrip.c:324:
Str empty;
Str simple;
Str with_spaces;
Str with_special;
} parsed = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};- In
RoundTrip.c:325:
Str simple;
Str with_spaces;
Str with_special;
} parsed = {StrInit(&alloc), StrInit(&alloc), StrInit(&alloc), StrInit(&alloc)};- In
RoundTrip.c:370:
// Original data
Vec(i32) original_numbers = VecInit(&alloc);
Vec(Str) original_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
// Populate arrays
- In
RoundTrip.c:379:
// Create strings and push them properly
Str str1 = StrInitFromZstr("first", &alloc);
Str str2 = StrInitFromZstr("second", &alloc);
Str str3 = StrInitFromZstr("", &alloc);- In
RoundTrip.c:380:
// Create strings and push them properly
Str str1 = StrInitFromZstr("first", &alloc);
Str str2 = StrInitFromZstr("second", &alloc);
Str str3 = StrInitFromZstr("", &alloc);
Str str4 = StrInitFromZstr("last", &alloc);- In
RoundTrip.c:381:
Str str1 = StrInitFromZstr("first", &alloc);
Str str2 = StrInitFromZstr("second", &alloc);
Str str3 = StrInitFromZstr("", &alloc);
Str str4 = StrInitFromZstr("last", &alloc);- In
RoundTrip.c:382:
Str str2 = StrInitFromZstr("second", &alloc);
Str str3 = StrInitFromZstr("", &alloc);
Str str4 = StrInitFromZstr("last", &alloc);
VecPushBack(&original_strings, str1);- In
RoundTrip.c:390:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_ARR_KV(json, "numbers", original_numbers, num, { JW_INT(json, num); });- In
RoundTrip.c:398:
// Read back from JSON
Vec(i32) parsed_numbers = VecInit(&alloc);
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
StrIter si = StrIterFromStr(json);- In
RoundTrip.c:408:
});
JR_ARR_KV(si, "strings", {
Str str = StrInit(&alloc);
JR_STR(si, str);
VecPushBack(&parsed_strings, str);- In
RoundTrip.c:478:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_OBJ_KV(json, "user", {- In
RoundTrip.c:541:
// Create strings and push them properly
Str feature1 = StrInitFromZstr("auth", &alloc);
Str feature2 = StrInitFromZstr("logging", &alloc);- In
RoundTrip.c:542:
// Create strings and push them properly
Str feature1 = StrInitFromZstr("auth", &alloc);
Str feature2 = StrInitFromZstr("logging", &alloc);
VecPushBack(&original.config.features, feature1);- In
RoundTrip.c:560:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_OBJ_KV(json, "user", {- In
RoundTrip.c:605:
JR_STR_KV(si, "log_level", parsed.config.log_level);
JR_ARR_KV(si, "features", {
Str feature = StrInit(&alloc);
JR_STR(si, feature);
VecPushBack(&parsed.config.features, feature);- In
RoundTrip.c:675:
// Original empty data
Vec(i32) empty_numbers = VecInit(&alloc);
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
Str empty_str = StrInit(&alloc);- In
RoundTrip.c:676:
Vec(i32) empty_numbers = VecInit(&alloc);
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
Str empty_str = StrInit(&alloc);
// Write to JSON
- In
RoundTrip.c:679:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_STR_KV(json, "empty_string", empty_str);- In
RoundTrip.c:695:
// Read back from JSON
Vec(i32) parsed_numbers = VecInit(&alloc);
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
Str parsed_str = StrInit(&alloc);
bool found_empty_object = false;- In
RoundTrip.c:696:
Vec(i32) parsed_numbers = VecInit(&alloc);
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit, &alloc);
Str parsed_str = StrInit(&alloc);
bool found_empty_object = false;- In
RoundTrip.c:708:
});
JR_ARR_KV(si, "empty_strings", {
Str str = StrInit(&alloc);
JR_STR(si, str);
VecPushBack(&parsed_strings, str);- In
RoundTrip.c:762:
// Write to JSON
Str json = StrInit(&alloc);
JW_OBJ(json, {
JW_INT_KV(json, "max_int", original.max_int);- In
Parse.c:5:
#include <Misra/Std/Allocator/Debug.h>
#include <Misra/Std/Allocator/Default.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Io.h>
#include <Misra/Std/Utility/StrIter.h>- In
Parse.c:16:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str text = StrInitFromZstr(src, &alloc);
StrIter input = StrIterFromStr(text);
Str *got = NULL;- In
Parse.c:18:
Str text = StrInitFromZstr(src, &alloc);
StrIter input = StrIterFromStr(text);
Str *got = NULL;
bool ok = false;- In
Parse.c:38:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr("flag = yes\n", &alloc);
StrIter input = StrIterFromStr(src);
bool v = false;- In
Parse.c:64:
static bool test_kv_skipline_consumes_lf(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str src = StrInitFromZstr("xy\nZ", &alloc);
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigSkipLine(input);- In
Parse.c:86:
static bool test_kv_skipline_consumes_one_line_end(void) {
DefaultAllocator alloc = DefaultAllocatorInit();
Str src = StrInitFromZstr("a\n\nZ", &alloc);
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigSkipLine(input);- In
Parse.c:107:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr("a=1\r\nb=2\r\n", &alloc);
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);- In
Parse.c:170:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr("k = # just a comment\n", &alloc);
StrIter input = StrIterFromStr(src);
Str *v = NULL;- In
Parse.c:172:
Str src = StrInitFromZstr("k = # just a comment\n", &alloc);
StrIter input = StrIterFromStr(src);
Str *v = NULL;
bool result = true;- In
Parse.c:198:
// skipped (fine) but the branch also mis-handles the bare-newline
// case. Pair with a trailing-comment line so both branches matter.
Str src = StrInitFromZstr("a = 1 # c\nb = 2\n", &alloc);
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);- In
Parse.c:223:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr("k = \"v\" junk\n", &alloc);
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);- In
Parse.c:246:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr(" k = v\n", &alloc);
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);- In
Parse.c:249:
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);
Str *v = NULL;
bool result = true;- In
Parse.c:271:
KvConfig cfg = KvConfigInit(&alloc);
// A line with only spaces, then a real pair.
Str src = StrInitFromZstr(" \nk = v\n", &alloc);
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);- In
Parse.c:274:
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);
Str *v = NULL;
bool result = true;- In
Parse.c:294:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr("k = v\n \n", &alloc);
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);- In
Parse.c:312:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr(
"host = localhost\n"
"port = 8080\n"- In
Parse.c:320:
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);
Str *host = KvConfigGetPtr(&cfg, "host");
i64 port = 0;
bool debug = false;- In
Parse.c:341:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr(
"# comment line\n"
"path = \"/srv/my app\" # keep spaces in quotes\n"- In
Parse.c:353:
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);
Str *path = KvConfigGetPtr(&cfg, "path");
Str *user = KvConfigGetPtr(&cfg, "user");
Str *greet = KvConfigGetPtr(&cfg, "greeting");- In
Parse.c:354:
StrIter si = KvConfigParse(input, &cfg);
Str *path = KvConfigGetPtr(&cfg, "path");
Str *user = KvConfigGetPtr(&cfg, "user");
Str *greet = KvConfigGetPtr(&cfg, "greeting");
Str *empty = KvConfigGetPtr(&cfg, "empty");- In
Parse.c:355:
Str *path = KvConfigGetPtr(&cfg, "path");
Str *user = KvConfigGetPtr(&cfg, "user");
Str *greet = KvConfigGetPtr(&cfg, "greeting");
Str *empty = KvConfigGetPtr(&cfg, "empty");
bool result = true;- In
Parse.c:356:
Str *user = KvConfigGetPtr(&cfg, "user");
Str *greet = KvConfigGetPtr(&cfg, "greeting");
Str *empty = KvConfigGetPtr(&cfg, "empty");
bool result = true;- In
Parse.c:375:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr("host = localhost\n", &alloc);
StrIter input = StrIterFromStr(src);
Str host_copy = StrInit(&alloc);- In
Parse.c:377:
Str src = StrInitFromZstr("host = localhost\n", &alloc);
StrIter input = StrIterFromStr(src);
Str host_copy = StrInit(&alloc);
Str *stored_host = NULL;
bool result = true;- In
Parse.c:378:
StrIter input = StrIterFromStr(src);
Str host_copy = StrInit(&alloc);
Str *stored_host = NULL;
bool result = true;- In
Parse.c:408:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr(
"workers = 16\n"
"pi = 3.14159\n"- In
Parse.c:442:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr(
"valid = yes\n"
"broken line\n"- In
Parse.c:469:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr(
"t1 = true\n"
"t2 = YES\n"- In
Parse.c:512:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr(
"name = misra\n"
"workers = 16\n"- In
Parse.c:524:
(void)KvConfigParse(input, &cfg);
Str k_name = StrInitFromZstr("name", &alloc);
Str k_missing = StrInitFromZstr("missing", &alloc);
Str k_workers = StrInitFromZstr("workers", &alloc);- In
Parse.c:525:
Str k_name = StrInitFromZstr("name", &alloc);
Str k_missing = StrInitFromZstr("missing", &alloc);
Str k_workers = StrInitFromZstr("workers", &alloc);
Str k_ratio = StrInitFromZstr("ratio", &alloc);- In
Parse.c:526:
Str k_name = StrInitFromZstr("name", &alloc);
Str k_missing = StrInitFromZstr("missing", &alloc);
Str k_workers = StrInitFromZstr("workers", &alloc);
Str k_ratio = StrInitFromZstr("ratio", &alloc);
Str k_enabled = StrInitFromZstr("enabled", &alloc);- In
Parse.c:527:
Str k_missing = StrInitFromZstr("missing", &alloc);
Str k_workers = StrInitFromZstr("workers", &alloc);
Str k_ratio = StrInitFromZstr("ratio", &alloc);
Str k_enabled = StrInitFromZstr("enabled", &alloc);- In
Parse.c:528:
Str k_workers = StrInitFromZstr("workers", &alloc);
Str k_ratio = StrInitFromZstr("ratio", &alloc);
Str k_enabled = StrInitFromZstr("enabled", &alloc);
// contains via Str*
- In
Parse.c:535:
// get copy via Str*
Str got = KvConfigGet(&cfg, &k_name);
result = result && (StrCmp(&got, "misra") == 0);
StrDeinit(&got);- In
Parse.c:563:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr(
"a = value one # trailing comment\n"
"b = value two\t\t; tab-spaced comment\n"- In
Parse.c:570:
);
StrIter input = StrIterFromStr(src);
Str *a = NULL;
Str *b = NULL;
Str *c = NULL;- In
Parse.c:571:
StrIter input = StrIterFromStr(src);
Str *a = NULL;
Str *b = NULL;
Str *c = NULL;
bool result = true;- In
Parse.c:572:
Str *a = NULL;
Str *b = NULL;
Str *c = NULL;
bool result = true;- In
Parse.c:596:
DefaultAllocator alloc = DefaultAllocatorInit();
KvConfig cfg = KvConfigInit(&alloc);
Str src = StrInitFromZstr(
"host = localhost\r\n"
"port = 8080\r\n"- In
Parse.c:604:
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);
Str *host = NULL;
Str *name = NULL;
i64 port = 0;- In
Parse.c:605:
StrIter si = KvConfigParse(input, &cfg);
Str *host = NULL;
Str *name = NULL;
i64 port = 0;
bool result = true;- In
Parse.c:643:
KvConfig cfg = KvConfigInit(base);
Str text = StrInitFromZstr(src, base);
StrIter input = StrIterFromStr(text);- In
Parse.c:705:
// NEW buffer and the old one to be released at L215. A long-ish value
// keeps both buffers off any small-string fast path.
Str text = StrInitFromZstr("key = spaced-out-value-here \n", adbg);
StrIter input = StrIterFromStr(text);- In
Parse.c:710:
(void)KvConfigParse(input, &cfg);
Str *got = KvConfigGetPtr(&cfg, "key");
bool ok = got && (StrCmp(got, "spaced-out-value-here") == 0);- In
Parse.c:736:
KvConfig cfg = KvConfigInit(adbg);
Str text = StrInitFromZstr("a-reasonably-long-config-key = v\n", adbg);
StrIter input = StrIterFromStr(text);- In
Parse.c:741:
(void)KvConfigParse(input, &cfg);
Str *got = KvConfigGetPtr(&cfg, "a-reasonably-long-config-key");
bool ok = got && (StrCmp(got, "v") == 0);- In
Parse.c:766:
KvConfig cfg = KvConfigInit(adbg);
Str text = StrInitFromZstr("k = a-reasonably-long-config-value\n", adbg);
StrIter input = StrIterFromStr(text);- In
Parse.c:771:
(void)KvConfigParse(input, &cfg);
Str *got = KvConfigGetPtr(&cfg, "k");
bool ok = got && (StrCmp(got, "a-reasonably-long-config-value") == 0);- In
Parse.c:798:
KvConfig cfg = KvConfigInit(adbg);
Str text = StrInitFromZstr("present-config-key = value\n", adbg);
StrIter input = StrIterFromStr(text);- In
Parse.c:806:
// Each KvConfigGetPtr with a Zstr key routes through kvconfig_get_ptr_zstr,
// building and (at L351) freeing a temp lookup Str.
Str *hit = KvConfigGetPtr(&cfg, "present-config-key");
ok = ok && (hit != NULL) && (StrCmp(hit, "value") == 0);
Last updated on