Str
Str
Description
The Str type is a specialization of Vec for characters
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Str.c:8:
#include "../Harness.h"
#include "Str.h"
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>- In
Str.c:9:
#include "../Harness.h"
#include "Str.h"
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <string.h>- In
Str.c:18:
// Generate a Str from fuzz input data
static Str generate_str_from_input(const uint8_t *data, size_t *offset, size_t size, size_t max_len) {
// Extract length (limit to max_len for sanity)
uint8_t len = extract_u8(data, offset, size);- In
Str.c:24:
// Create Str from input data
Str str = StrInitFromCstr((const char *)(data + *offset), len);
*offset += len;- In
Str.c:30:
}
void init_str(Str *str) {
*str = StrInit();
}- In
Str.c:34:
}
void deinit_str(Str *str) {
StrDeinit(str);
}- In
Str.c:38:
}
void fuzz_str(Str *str, StrFunction func, const uint8_t *data, size_t *offset, size_t size) {
switch (func) {
case STR_INIT : {- In
Str.c:73:
case STR_INIT_FROM_STR : {
if (VecLen(str) > 0) {
Str temp = StrInitFromStr(str);
StrDeinit(str);
*str = temp;- In
Str.c:82:
case STR_DUP : {
if (VecLen(str) > 0) {
Str temp = StrDup(str);
StrDeinit(str);
*str = temp;- In
Str.c:184:
case STR_CMP : {
if (VecLen(str) > 0) {
Str temp = generate_str_from_input(data, offset, size, 20);
int result = StrCmp(str, &temp);
(void)result; // Suppress unused variable warning
- In
Str.c:218:
case STR_FIND_STR : {
if (VecLen(str) > 0) {
Str temp = generate_str_from_input(data, offset, size, 10);
char *found = StrFindStr(str, &temp);
(void)found; // Suppress unused variable warning
- In
Str.c:287:
if (*offset + 2 <= size) {
size_t idx = extract_u16(data, offset, size) % (VecLen(str) + 1);
Str temp = generate_str_from_input(data, offset, size, 20);
StrInsert(str, &temp, idx);
StrDeinit(&temp);- In
Str.c:341:
case STR_APPEND_STR : {
Str temp = generate_str_from_input(data, offset, size, 20);
StrMerge(str, &temp);
StrDeinit(&temp);- In
Str.c:423:
case STR_MERGE : {
Str temp = generate_str_from_input(data, offset, size, 20);
StrMerge(str, &temp);
StrDeinit(&temp);- In
Str.c:452:
case STR_MERGE_STR : {
Str temp = generate_str_from_input(data, offset, size, 20);
StrMerge(str, &temp);
StrDeinit(&temp);- In
Str.h:10:
#define FUZZ_STR_H
#include <Misra/Std/Container/Str.h>
#include <stdint.h>
#include <stdbool.h>- In
Str.h:99:
// Function prototypes
void init_str(Str *str);
void deinit_str(Str *str);
void fuzz_str(Str *str, StrFunction func, const uint8_t *data, size_t *offset, size_t size);- In
Str.h:100:
// Function prototypes
void init_str(Str *str);
void deinit_str(Str *str);
void fuzz_str(Str *str, StrFunction func, const uint8_t *data, size_t *offset, size_t size);- In
Str.h:101:
void init_str(Str *str);
void deinit_str(Str *str);
void fuzz_str(Str *str, StrFunction func, const uint8_t *data, size_t *offset, size_t size);
#endif // FUZZ_STR_H
- In
VecStr.h:11:
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Types.h>- In
VecStr.h:15:
// 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>
#include <string.h> // For strlen- In
VecStr.c:15:
// Generate a Str from fuzz input data
static Str generate_str_from_input(const uint8_t *data, size_t *offset, size_t size, size_t max_len) {
// Extract length (limit to max_len for sanity)
uint8_t len = extract_u8(data, offset, size);- In
VecStr.c:21:
// Create Str with capacity
Str str = StrInit();
// Fill with data or generate simple pattern if not enough input
- In
VecStr.c:49:
switch (func) {
case VEC_STR_PUSH_BACK : {
Str str = generate_str_from_input(data, offset, size, 32);
VecPushBack(vec, str);
break;- In
VecStr.c:55:
case VEC_STR_PUSH_FRONT : {
Str str = generate_str_from_input(data, offset, size, 32);
VecPushFront(vec, str);
break;- In
VecStr.c:62:
case VEC_STR_POP_BACK : {
if (VecLen(vec) > 0) {
Str str;
VecPopBack(vec, &str);
// StrDeinit is called automatically by the vector
- In
VecStr.c:71:
case VEC_STR_POP_FRONT : {
if (VecLen(vec) > 0) {
Str str;
VecPopFront(vec, &str);
// StrDeinit is called automatically by the vector
- In
VecStr.c:81:
if (*offset + 4 <= size) {
size_t index = extract_u32(data, offset, size) % (VecLen(vec) + 1);
Str str = generate_str_from_input(data, offset, size, 32);
VecInsert(vec, str, index);
}- In
VecStr.c:90:
if (VecLen(vec) > 0 && *offset + 4 <= size) {
size_t index = extract_u32(data, offset, size) % VecLen(vec);
Str str;
VecRemove(vec, &str, index);
// StrDeinit is called automatically by the vector
- In
VecStr.c:109:
if (VecLen(vec) > 0 && *offset + 4 <= size) {
size_t index = extract_u32(data, offset, size) % VecLen(vec);
Str str = VecAt(vec, index);
(void)str; // Use the result to avoid warnings
}- In
VecStr.c:123:
case VEC_STR_FIRST : {
if (VecLen(vec) > 0) {
Str first = VecFirst(vec);
(void)first; // Use the result to avoid warnings
}- In
VecStr.c:131:
case VEC_STR_LAST : {
if (VecLen(vec) > 0) {
Str last = VecLast(vec);
(void)last; // Use the result to avoid warnings
}- In
VecStr.c:155:
if (new_size > old_size) {
for (size_t i = old_size; i < new_size; i++) {
Str str = generate_str_from_input(data, offset, size, 16);
VecAt(vec, i) = str;
}- In
VecStr.c:202:
// Create temporary array of Str objects
Str temp_strings[10];
for (size_t i = 0; i < count; i++) {
temp_strings[i] = generate_str_from_input(data, offset, size, 16);- In
VecStr.c:217:
size_t index = extract_u32(data, offset, size) % VecLen(vec);
size_t count = extract_u32(data, offset, size) % (VecLen(vec) - index + 1);
VecRemoveRange(vec, (Str *)NULL, index, count);
}
break;- In
VecStr.c:234:
if (*offset + 4 <= size) {
size_t index = extract_u32(data, offset, size) % (VecLen(vec) + 1);
Str str = generate_str_from_input(data, offset, size, 32);
VecInsertFast(vec, str, index);
}- In
VecStr.c:243:
if (VecLen(vec) > 0 && *offset + 4 <= size) {
size_t index = extract_u32(data, offset, size) % VecLen(vec);
Str str;
VecRemoveFast(vec, &str, index);
// StrDeinit is called automatically by the vector
- In
VecStr.c:254:
size_t index = extract_u32(data, offset, size) % VecLen(vec);
size_t count = extract_u32(data, offset, size) % (VecLen(vec) - index + 1);
VecRemoveRangeFast(vec, (Str *)NULL, index, count);
}
break;- In
VecStr.c:273:
// Create temporary array of Str objects
Str temp_strings[10];
for (size_t i = 0; i < count; i++) {
temp_strings[i] = generate_str_from_input(data, offset, size, 16);- In
VecStr.c:289:
// Create temporary array of Str objects
Str temp_strings[10];
for (size_t i = 0; i < count; i++) {
temp_strings[i] = generate_str_from_input(data, offset, size, 16);- In
VecStr.c:305:
// Create temporary array of Str objects
Str temp_strings[10];
for (size_t i = 0; i < count; i++) {
temp_strings[i] = generate_str_from_input(data, offset, size, 16);- In
VecStr.c:324:
case VEC_STR_BEGIN : {
if (VecLen(vec) > 0) {
Str *begin = VecBegin(vec);
(void)begin; // Use the result to avoid warnings
}- In
VecStr.c:341:
if (VecLen(vec) > 0 && *offset + 4 <= size) {
size_t index = extract_u32(data, offset, size) % VecLen(vec);
Str *ptr = VecPtrAt(vec, index);
(void)ptr; // Use the result to avoid warnings
}- In
VecStr.c:355:
size_t count = extract_u32(data, offset, size) % 5;
for (size_t i = 0; i < count; i++) {
Str str = generate_str_from_input(data, offset, size, 16);
VecPushBack(&temp, str);
}- In
VecStr.c:371:
// Create temporary array of Str objects
Str temp_strings[10];
for (size_t i = 0; i < count; i++) {
temp_strings[i] = generate_str_from_input(data, offset, size, 16);- In
VecStr.c:415:
size_t count = extract_u32(data, offset, size) % 5;
for (size_t i = 0; i < count; i++) {
Str str = generate_str_from_input(data, offset, size, 16);
VecPushBack(&temp, str);
}- In
Sys.c:35:
#include <string.h>
Str *SysGetEnv(const char *name, Str *value) {
#ifdef _WIN32
char *env_var;- In
Sys.c:68:
}
Str *SysStrError(i32 eno, Str *err_str) {
char buf[1024] = {0};
#if _WIN32- In
Io.c:43:
static void _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
static void _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
static void _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);- In
Io.c:44:
static void _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
static void _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
static void _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
static void _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);- In
Io.c:45:
static void _write_r8(Str *o, FmtInfo *fmt_info, u8 *v);
static void _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
static void _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
static void _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);- In
Io.c:46:
static void _write_r16(Str *o, FmtInfo *fmt_info, u16 *v);
static void _write_r32(Str *o, FmtInfo *fmt_info, u32 *v);
static void _write_r64(Str *o, FmtInfo *fmt_info, u64 *v);
static const char *_read_r8(const char *i, FmtInfo *fmt_info, u8 *v);- In
Io.c:210:
// Helper function to pad string with spaces
static void PadString(Str *o, size width, Alignment align, size content_len) {
if (content_len >= width)
return;- In
Io.c:242:
}
bool StrWriteFmtInternal(Str *o, const char *fmt, TypeSpecificIO *args, u64 argc) {
if (!o || !fmt) {
LOG_FATAL("Invalid arguments");- In
Io.c:650:
}
Str buffer = StrInit();
int fd = FILENO(file);- In
Io.c:707:
// Helper function to write integer values as character sequences in a consistent order
// regardless of system endianness (big-endian order: most significant byte first)
static inline void write_int_as_chars(Str *o, FormatFlags flags, u64 value, size num_bytes) {
if (!o || !num_bytes || num_bytes > 8) {
LOG_FATAL("Invalid arguments to write_int_as_chars");- In
Io.c:742:
}
static inline void write_char_internal(Str *o, FormatFlags flags, const char *vs, size len) {
if (!o || !vs || !len) {
LOG_FATAL("Invalid arguments");- In
Io.c:812:
}
static void FloatFmtAppendExponent(Str *out, i64 exponent, bool uppercase) {
char sign = exponent < 0 ? '-' : '+';
u64 magnitude = exponent < 0 ? (u64)(-(exponent + 1)) + 1 : (u64)exponent;- In
Io.c:843:
}
static Str FloatFmtToDecimalStr(Float *value, u32 precision, bool has_precision) {
Str canonical = FloatToStr(value);- In
Io.c:844:
static Str FloatFmtToDecimalStr(Float *value, u32 precision, bool has_precision) {
Str canonical = FloatToStr(value);
if (!has_precision) {- In
Io.c:851:
{
Str result = StrInit();
const char *body = canonical.data;
const char *dot = NULL;- In
Io.c:898:
}
static Str FloatFmtToScientificStr(Float *value, u32 precision, bool has_precision, bool uppercase) {
Str digits = IntToStr(&value->significand);
Str result = StrInit();- In
Io.c:899:
static Str FloatFmtToScientificStr(Float *value, u32 precision, bool has_precision, bool uppercase) {
Str digits = IntToStr(&value->significand);
Str result = StrInit();
u64 frac_digits = 0;- In
Io.c:900:
static Str FloatFmtToScientificStr(Float *value, u32 precision, bool has_precision, bool uppercase) {
Str digits = IntToStr(&value->significand);
Str result = StrInit();
u64 frac_digits = 0;
i64 exponent = 0;- In
Io.c:1061:
}
void _write_Str(Str *o, FmtInfo *fmt_info, Str *s) {
if (!o || !s || !fmt_info) {
LOG_FATAL("Invalid arguments");- In
Io.c:1082:
}
// Create hex string for each character
Str hex = StrInit();
StrFromU64(&hex, c, &config);
// Ensure 2 digits with leading zero
- In
Io.c:1129:
}
void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s) {
if (!o || !s || !*s || !fmt_info) {
LOG_FATAL("Invalid arguments");- In
Io.c:1151:
}
// Create hex string for each character
Str hex = StrInit();
StrIntFormat config = {.base = 16, .uppercase = (fmt_info->flags & FMT_FLAG_CAPS) != 0};
StrFromU64(&hex, (u8)xs[i], &config);- In
Io.c:1202:
}
void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1218:
// Create temporary buffer for number formatting
Str temp = StrInit();
// Determine base based on format flags
- In
Io.c:1246:
}
void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1262:
}
void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1278:
}
void _write_u8(Str *o, FmtInfo *fmt_info, u8 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1294:
}
void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1310:
// Create temporary buffer for number formatting
Str temp = StrInit();
// Determine base based on format flags
- In
Io.c:1338:
}
void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1354:
}
void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1370:
}
void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1386:
}
void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1426:
// Normal case - use StrFromF64
// Create temporary buffer for number formatting
Str temp = StrInit();
// Use StrFromF64 directly with the appropriate parameters
- In
Io.c:1449:
}
void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:1468:
}
void _write_Float(Str *o, FmtInfo *fmt_info, Float *value) {
size start_len = 0;
Str temp = StrInit();- In
Io.c:1470:
void _write_Float(Str *o, FmtInfo *fmt_info, Float *value) {
size start_len = 0;
Str temp = StrInit();
if (!o || !fmt_info || !value) {- In
Io.c:1573:
}
const char *_read_Str(const char *i, FmtInfo *fmt_info, Str *s) {
if (!i || !s)
LOG_FATAL("Invalid arguments");- In
Io.c:1720:
// Create a helper function to check if the parsed string contains only valid numeric characters
static bool IsValidNumericString(const Str *str, bool allow_float) {
if (!str || !str->data)
return false;- In
Io.c:1869:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, i - start);
// Try to parse as special value
- In
Io.c:1927:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, pos);
// Validate the string is a proper floating point number
- In
Io.c:1982:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, pos);
// Check for special prefixes with no digits
- In
Io.c:2057:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, pos);
// Check for special prefixes with no digits
- In
Io.c:2131:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, pos);
// Check for special prefixes with no digits
- In
Io.c:2206:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, pos);
// Check for special prefixes with no digits
- In
Io.c:2271:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, pos);
// Check for special prefixes with no digits
- In
Io.c:2346:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, pos);
// Check for special prefixes with no digits
- In
Io.c:2421:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, pos);
// Check for special prefixes with no digits
- In
Io.c:2496:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, pos);
// Check for special prefixes with no digits
- In
Io.c:2531:
// For string types, :c has no effect - work like regular string reading
Str temp = StrInit();
FmtInfo default_fmt = {.align = ALIGN_RIGHT, .width = 0, .precision = 6, .flags = FMT_FLAG_NONE};
const char *next = _read_Str(i, &default_fmt, &temp);- In
Io.c:2557:
}
void _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv) {
if (!o || !fmt_info || !bv) {
LOG_FATAL("Invalid arguments");- In
Io.c:2593:
// Empty BitVec - don't output anything
} else {
Str bit_str = BitVecToStr(bv);
StrMerge(o, &bit_str);
StrDeinit(&bit_str);- In
Io.c:2606:
}
void _write_Int(Str *o, FmtInfo *fmt_info, Int *value) {
if (!o || !fmt_info || !value) {
LOG_FATAL("Invalid arguments");- In
Io.c:2635:
size start_len = o->length;
Str temp = StrInit();
u8 radix = IntFmtRadixFromFlags(fmt_info);- In
Io.c:2653:
}
void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s) {
(void)o;
(void)fmt_info;- In
Io.c:2698:
// Parse hex string
Str hex_str = StrInitFromCstr(hex_start, i - hex_start);
u64 value;
StrParseConfig config = {.base = 16};- In
Io.c:2734:
// Parse octal string
Str oct_str = StrInitFromCstr(oct_start, i - oct_start);
u64 value;
StrParseConfig config = {.base = 8};- In
Io.c:2767:
// Create string from binary digits (already null-terminated by StrInitFromCstr)
Str bin_str = StrInitFromCstr(bin_start, i - bin_start);
// Convert to BitVec using the null-terminated string
- In
Io.c:2833:
}
Str temp = StrInitFromCstr(start, i - start);
Int parsed = IntFromStrRadix(temp.data, radix);- In
Io.c:2846:
size token_len = 0;
const char *start = NULL;
Str temp = StrInit();
Float parsed = FloatInit();- In
Io.c:2924:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, i - start);
// Try to parse as special value
- In
Io.c:2984:
// Create a temporary Str for parsing
Str temp = StrInitFromCstr(start, pos);
// Validate the string is a proper floating point number
- In
Io.c:3006:
}
static void _write_r8(Str *o, FmtInfo *fmt_info, u8 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:3014:
}
static void _write_r16(Str *o, FmtInfo *fmt_info, u16 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:3043:
}
static void _write_r32(Str *o, FmtInfo *fmt_info, u32 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Io.c:3078:
static void _write_r64(Str *o, FmtInfo *fmt_info, u64 *v) {
if (!o || !fmt_info || !v) {
LOG_FATAL("Invalid arguments");- In
Log.c:38:
if (!localtime_r(&raw_time, &time_info)) {
#endif
Str syserr;
StrInitStack(syserr, SYS_ERROR_STR_MAX_LENGTH, {
SysStrError(errno, &syserr);- In
Log.c:49:
// Get path to temp directory
Str log_dir = StrInit();
if (!SysGetEnv("TMP", &log_dir) && !SysGetEnv("TEMP", &log_dir) && !SysGetEnv("TMPDIR", &log_dir) &&
!SysGetEnv("TEMPDIR", &log_dir) && !SysGetEnv("PWD", &log_dir)) {- In
Log.c:56:
// generate log file name
Str file_name = StrInit();
StrWriteFmt(&file_name, "{}/misra-{}-{}", log_dir, SysGetCurrentProcessId(), &time_buffer[0]);
FWriteFmtLn(stderr, "storing logs in {}", file_name.data);- In
Log.c:85:
LOG_STREAM_FALLBACK: {
Str syserr;
StrInitStack(syserr, SYS_ERROR_STR_MAX_LENGTH, {
FWriteFmtLn(stderr, "Error opening log file, will write logs to stderr");- In
Str.c:11:
#include <stdio.h>
#include <stdlib.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <Misra/Types.h>- In
Str.c:17:
#include "Misra/Std/Utility/StrIter.h"
static Str *string_va_printf(Str *str, const char *fmt, va_list args);
Str *StrPrintf(Str *str, const char *fmt, ...) {- In
Str.c:19:
static Str *string_va_printf(Str *str, const char *fmt, va_list args);
Str *StrPrintf(Str *str, const char *fmt, ...) {
ValidateStr(str);- In
Str.c:32:
}
Str *StrAppendf(Str *str, const char *fmt, ...) {
ValidateStr(str);- In
Str.c:43:
}
static Str *string_va_printf(Str *str, const char *fmt, va_list args) {
ValidateStr(str);- In
Str.c:70:
}
bool StrInitCopy(Str *dst, const Str *src) {
ValidateStr(src);- In
Str.c:73:
ValidateStr(src);
MemSet(dst, 0, sizeof(Str));
*dst = StrInit();
dst->copy_init = src->copy_init;- In
Str.c:85:
}
void StrDeinit(Str *copy) {
ValidateStr(copy);
if (copy->data) {- In
Str.c:93:
}
StrIters StrSplitToIters(Str *s, const char *key) {
ValidateStr(s);- In
Str.c:118:
}
Strs StrSplit(Str *s, const char *key) {
ValidateStr(s);- In
Str.c:131:
const char *next = ZstrFindSubstring(prev, key);
if (next) {
Str tmp = StrInitFromCstr(prev, next - prev);
VecPushBack(&sv, tmp); // exclude delimiter
prev = next + keylen; // skip past delimiter
- In
Str.c:136:
} else {
if (ZstrCompareN(prev, key, end - prev)) {
Str tmp = StrInitFromCstr(prev, end - prev);
VecPushBack(&sv, tmp); // remaining part
}- In
Str.c:161:
// = -1 means from left
// = 1 means from right
Str strip_str(Str *s, const char *chars_to_strip, int split_direction) {
ValidateStr(s);- In
Str.c:194:
}
bool StrStartsWithZstr(const Str *s, const char *prefix) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix, ZstrLen(prefix));- In
Str.c:199:
}
bool StrEndsWithZstr(const Str *s, const char *suffix) {
ValidateStr(s);
return ends_with(s->data, s->length, suffix, ZstrLen(suffix));- In
Str.c:204:
}
bool StrStartsWithCstr(const Str *s, const char *prefix, size prefix_len) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix, prefix_len);- In
Str.c:209:
}
bool StrEndsWithCstr(const Str *s, const char *suffix, size suffix_len) {
ValidateStr(s);
return ends_with(s->data, s->length, suffix, suffix_len);- In
Str.c:214:
}
bool StrStartsWith(const Str *s, const Str *prefix) {
ValidateStr(s);
return starts_with(s->data, s->length, prefix->data, prefix->length);- In
Str.c:219:
}
bool StrEndsWith(const Str *s, const Str *suffix) {
ValidateStr(s);
return ends_with(s->data, s->length, suffix->data, suffix->length);- In
Str.c:226:
// Helper: replace in-place all `match` → `replacement` up to `count`
static void
str_replace(Str *s, const char *match, size match_len, const char *replacement, size replacement_len, size count) {
ValidateStr(s);
size i = 0;- In
Str.c:243:
}
void StrReplaceZstr(Str *s, const char *match, const char *replacement, size count) {
ValidateStr(s);
str_replace(s, match, ZstrLen(match), replacement, ZstrLen(replacement), count);- In
Str.c:249:
void StrReplaceCstr(
Str *s,
const char *match,
size match_len,- In
Str.c:260:
}
void StrReplace(Str *s, const Str *match, const Str *replacement, size count) {
ValidateStr(s);
str_replace(s, match->data, match->length, replacement->data, replacement->length, count);- In
Str.c:292:
// Helper function to skip prefixes for explicit bases
static inline size_t skip_prefix(const Str *str, size_t pos, u8 base) {
if (pos + 2 > str->length || str->data[pos] != '0') {
return pos;- In
Str.c:329:
// ======================================
Str *StrFromU64(Str *str, u64 value, const StrIntFormat *config) {
ValidateStr(str);- In
Str.c:376:
}
Str *StrFromI64(Str *str, i64 value, const StrIntFormat *config) {
ValidateStr(str);- In
Str.c:410:
}
Str *StrFromF64(Str *str, f64 value, const StrFloatFormat *config) {
ValidateStr(str);- In
Str.c:568:
}
bool StrToU64(const Str *str, u64 *value, const StrParseConfig *config) {
ValidateStr(str);- In
Str.c:658:
}
bool StrToI64(const Str *str, i64 *value, const StrParseConfig *config) {
ValidateStr(str);- In
Str.c:690:
// Create substring without sign
Str temp_str = StrInit();
temp_str.data = str->data + pos;
temp_str.length = str->length - pos;- In
Str.c:718:
}
bool StrToF64(const Str *str, f64 *value, const StrParseConfig *config) {
ValidateStr(str);- In
Str.c:858:
}
void ValidateStr(const Str *s) {
return ValidateVec(s);
}- In
Vec.c:8:
// ct
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Log.h>- In
Float.c:265:
Float FloatFromStr(const char *text) {
Float result = FloatInit();
Str digits = StrInit();
size pos = 0;
bool negative = false;- In
Float.c:339:
}
Str FloatToStr(Float *value) {
Str digits = StrInit();
Str result = StrInit();- In
Float.c:340:
Str FloatToStr(Float *value) {
Str digits = StrInit();
Str result = StrInit();- In
Float.c:341:
Str FloatToStr(Float *value) {
Str digits = StrInit();
Str result = StrInit();
ValidateFloat(value);- In
Int.c:495:
}
Str IntToStr(Int *value) {
return IntToStrRadix(value, 10, false);
}- In
Int.c:512:
}
Str IntToStrRadix(Int *value, u8 radix, bool uppercase) {
ValidateInt(value);
int_validate_radix(radix);- In
Int.c:521:
Int current = IntClone(value);
Str result = StrInit();
while (!IntIsZero(¤t)) {- In
Int.c:559:
}
Str IntToBinary(Int *value) {
return IntToStrRadix(value, 2, false);
}- In
Int.c:578:
}
Str IntToOctStr(Int *value) {
return IntToStrRadix(value, 8, false);
}- In
Int.c:590:
}
Str IntToHexStr(Int *value) {
return IntToStrRadix(value, 16, false);
}- In
BitVec.c:8:
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Log.h>- In
BitVec.c:724:
// Conversion functions
Str BitVecToStr(BitVec *bv) {
ValidateBitVec(bv);- In
BitVec.c:727:
ValidateBitVec(bv);
Str result = StrInit();
if (bv->length == 0) {
return result;- In
BitVec.c:1596:
// Convert bitvector to string for regex matching
Str bv_str = BitVecToStr(bv);
bool result = false;- In
KvConfig.c:25:
}
static bool kvconfig_equals_ignore_case(const Str *value, const char *zstr) {
size idx = 0;- In
KvConfig.c:40:
}
static bool kvconfig_parse_bool_value(const Str *value, bool *out) {
if (!out) {
LOG_ERROR("Expected valid bool output pointer");- In
KvConfig.c:61:
}
static bool kvconfig_parse_i64_value(const Str *value, i64 *out) {
char *endptr = NULL;
long long parsed;- In
KvConfig.c:81:
}
static bool kvconfig_parse_f64_value(const Str *value, f64 *out) {
char *endptr = NULL;
double parsed;- In
KvConfig.c:114:
u64 KvConfigHash(const void *data, u32 ignored_size) {
const Str *str = data;
u64 hash = 1469598103934665603ULL;
size idx;- In
KvConfig.c:130:
i32 KvConfigCompare(const void *lhs, const void *rhs) {
const Str *a = lhs;
const Str *b = rhs;
size min = 0;- In
KvConfig.c:131:
i32 KvConfigCompare(const void *lhs, const void *rhs) {
const Str *a = lhs;
const Str *b = rhs;
size min = 0;
i32 cmp = 0;- In
KvConfig.c:168:
}
StrIter KvConfigReadKey(StrIter si, Str *key) {
StrIter saved_si = si;- In
KvConfig.c:198:
}
StrIter KvConfigReadValue(StrIter si, Str *value) {
StrIter saved_si = si;
char quote = '\0';- In
KvConfig.c:288:
if (value->length > 0) {
Str stripped = StrStrip(value, NULL);
StrDeinit(value);
*value = stripped;- In
KvConfig.c:296:
}
StrIter KvConfigReadPair(StrIter si, Str *key, Str *value) {
StrIter saved_si = si;- In
KvConfig.c:353:
while (StrIterRemainingLength(&si)) {
Str key = StrInit();
Str value = StrInit();
StrIter read_si;- In
KvConfig.c:354:
while (StrIterRemainingLength(&si)) {
Str key = StrInit();
Str value = StrInit();
StrIter read_si;- In
KvConfig.c:401:
}
Str *KvConfigGetPtr(KvConfig *cfg, const char *key) {
Str lookup = {0};
Str *value = NULL;- In
KvConfig.c:402:
Str *KvConfigGetPtr(KvConfig *cfg, const char *key) {
Str lookup = {0};
Str *value = NULL;- In
KvConfig.c:403:
Str *KvConfigGetPtr(KvConfig *cfg, const char *key) {
Str lookup = {0};
Str *value = NULL;
if (!cfg || !key) {- In
KvConfig.c:423:
}
Str KvConfigGet(KvConfig *cfg, const char *key) {
Str *value = KvConfigGetPtr(cfg, key);- In
KvConfig.c:424:
Str KvConfigGet(KvConfig *cfg, const char *key) {
Str *value = KvConfigGetPtr(cfg, key);
if (!value) {- In
KvConfig.c:438:
bool KvConfigGetBool(KvConfig *cfg, const char *key, bool *value) {
Str *str = KvConfigGetPtr(cfg, key);
if (!str) {- In
KvConfig.c:448:
bool KvConfigGetI64(KvConfig *cfg, const char *key, i64 *value) {
Str *str = KvConfigGetPtr(cfg, key);
if (!str) {- In
KvConfig.c:458:
bool KvConfigGetF64(KvConfig *cfg, const char *key, f64 *value) {
Str *str = KvConfigGetPtr(cfg, key);
if (!str) {- In
JSON.c:39:
}
Str key = StrInit();
// key start
- In
JSON.c:166:
}
StrIter JReadString(StrIter si, Str *str) {
if (!StrIterRemainingLength(&si)) {
return si;- In
JSON.c:286:
StrIter saved_si = si;
si = JSkipWhitespace(si);
Str ns = StrInit();
bool is_neg = false;- In
JSON.c:590:
if (StrIterPeek(&si) == '"') {
StrIter before_si = si;
Str s = StrInit();
si = JReadString(si, &s);
StrDeinit(&s);- In
Proc.c:192:
// Build command line
Str cmdline = StrInit();
StrPushBackZstr(&cmdline, filepath);
for (char **arg = argv + 1; *arg; ++arg) {- In
Proc.c:407:
}
i32 SysProcWriteToStdin(SysProc *proc, Str *buf) {
if (!proc || !buf) {
LOG_FATAL("Invalid arguments");- In
Proc.c:422:
}
i32 sys_proc_read_internal(SysProc *proc, Str *buf, bool is_stdout) {
if (!proc || !buf) {
LOG_FATAL("Invalid argument");- In
Proc.c:506:
}
i32 SysProcReadFromStdout(SysProc *proc, Str *buf) {
return sys_proc_read_internal(proc, buf, /* is stdout*/ true);
}- In
Proc.c:510:
}
i32 SysProcReadFromStderr(SysProc *proc, Str *buf) {
return sys_proc_read_internal(proc, buf, /* is stdout*/ false);
}- In
Proc.c:578:
}
Str *SysGetCurrentExecutablePath(Str *exe_path) {
if (!exe_path) {
LOG_FATAL("Invalid arguments: exe_path is NULL");- In
Dir.c:150:
continue;
} else {
Str entry_path = StrInit();
const char *dir_name = &entry->d_name[0];
StrWriteFmt(&entry_path, "{}/{}", path, dir_name);- In
MisraDoc.c:22:
typedef struct Project {
Str build_dir;
Strs source_directories;
Strs test_directories;- In
MisraDoc.c:47:
JR_STR_KV(json, "build_dir", p.build_dir); \
JR_ARR_KV(json, "test_directories", { \
Str s = StrInit(); \
JR_STR(json, s); \
VecPushBack(&p.test_directories, s); \
- In
MisraDoc.c:52:
}); \
JR_ARR_KV(json, "source_directories", { \
Str s = StrInit(); \
JR_STR(json, s); \
VecPushBack(&p.source_directories, s); \
- In
MisraDoc.c:110:
Scope(&project, ProjectDeinit, {
// read project config
Str config = StrInit();
Scope(&config, StrDeinit, {
if (!ReadCompleteFile(config_path, &config.data, &config.length, &config.capacity)) {- In
MisraDoc.c:131:
VecForeach(&dir_paths, dir_name) {
// keep track of current path we're exploring
Str current_path = StrInit();
StrMerge(¤t_path, &dir_name);- In
MisraDoc.c:140:
if (dir_entry.type == SYS_DIR_ENTRY_TYPE_DIRECTORY) {
// create new directory path relative to current directory search path
Str path = StrInit();
StrMerge(&path, ¤t_path);
StrPushBack(&path, '/');- In
MisraDoc.c:150:
else if (dir_entry.type == SYS_DIR_ENTRY_TYPE_REGULAR_FILE) {
// create complete relative file path
Str path = StrInit();
StrMerge(&path, ¤t_path);
StrPushBack(&path, '/');- In
MisraDoc.c:166:
// go over each file and generate corresponding markdown
VecForeach(&file_paths, file_path) {
Str file_contents = StrInit();
Scope(&file_contents, StrDeinit, {
if (!ReadCompleteFile(file_path.data, &file_contents.data, &file_contents.length, &file_contents.capacity)) {- In
MisraDoc.c:173:
}
Str output_path = StrInit();
Scope(&output_path, StrDeinit, {
StrMerge(&output_path, &file_path);- In
MisraDoc.c:180:
LOG_INFO("{}", output_path);
Str md_code = StrInit();
Scope(&md_code, StrDeinit, {
// Create template strings for StrWriteFmt with escaped braces
- In
MisraEnum.c:28:
typedef struct EnumEntry {
Str name;
Str str;
i64 value;- In
MisraEnum.c:29:
typedef struct EnumEntry {
Str name;
Str str;
i64 value;
} EnumEntry;- In
MisraEnum.c:49:
}
Str code = StrInit();
ReadCompleteFile(input_filename, &code.data, &code.length, &code.capacity);- In
MisraEnum.c:55:
StrIter json = StrIterFromStr(code);
Str enum_name = StrInit();
bool to_from_str = false;- In
Main.c:4:
int main(void) {
Str file = StrInit();
if (ReadCompleteFile("Bin/Demangler/CppNameManglingGrammar", &file.data, &file.length, &file.capacity)) {
Strs lines = StrSplit(&file, "\n");- In
Main.c:11:
VecForeachPtr(&lines, line) {
if (StrStartsWithZstr(line, "[.") && StrEndsWithZstr(line, "]")) {
Str rule_name = StrInit();
StrReadFmt(line->data, "[.{}]", rule_name);- In
Parse.c:8:
static bool test_kvconfig_basic_parse(void) {
KvConfig cfg = KvConfigInit();
Str src = StrInitFromZstr(
"host = localhost\n"
"port = 8080\n"- In
Parse.c:15:
StrIter input = StrIterFromStr(src);
StrIter si = KvConfigParse(input, &cfg);
Str *host = KvConfigGetPtr(&cfg, "host");
i64 port = 0;
bool debug = false;- In
Parse.c:34:
static bool test_kvconfig_comments_quotes_and_duplicates(void) {
KvConfig cfg = KvConfigInit();
Str src = StrInitFromZstr(
"# comment line\n"
"path = \"/srv/my app\" # keep spaces in quotes\n"- In
Parse.c:45:
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:46:
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:47:
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:48:
Str *user = KvConfigGetPtr(&cfg, "user");
Str *greet = KvConfigGetPtr(&cfg, "greeting");
Str *empty = KvConfigGetPtr(&cfg, "empty");
bool result = true;- In
Parse.c:65:
static bool test_kvconfig_get_returns_copy(void) {
KvConfig cfg = KvConfigInit();
Str src = StrInitFromZstr("host = localhost\n");
StrIter input = StrIterFromStr(src);
Str host_copy = StrInit();- In
Parse.c:67:
Str src = StrInitFromZstr("host = localhost\n");
StrIter input = StrIterFromStr(src);
Str host_copy = StrInit();
Str *stored_host = NULL;
bool result = true;- In
Parse.c:68:
StrIter input = StrIterFromStr(src);
Str host_copy = StrInit();
Str *stored_host = NULL;
bool result = true;- In
Parse.c:96:
static bool test_kvconfig_numeric_and_bool_accessors(void) {
KvConfig cfg = KvConfigInit();
Str src = StrInitFromZstr(
"workers = 16\n"
"pi = 3.14159\n"- In
Parse.c:127:
static bool test_kvconfig_invalid_line_fails(void) {
KvConfig cfg = KvConfigInit();
Str src = StrInitFromZstr(
"valid = yes\n"
"broken line\n" 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, const char *expected) {
Str expected_str = StrInitFromZstr(expected);
Str output_clean = StrInit(); // Helper function to compare JSON output (removes whitespace for comparison)
bool compare_json_output(const Str *output, const char *expected) {
Str expected_str = StrInitFromZstr(expected);
Str output_clean = StrInit();
Str expected_clean = StrInit(); bool compare_json_output(const Str *output, const char *expected) {
Str expected_str = StrInitFromZstr(expected);
Str output_clean = StrInit();
Str expected_clean = StrInit(); Str expected_str = StrInitFromZstr(expected);
Str output_clean = StrInit();
Str expected_clean = StrInit();
// Remove whitespace from both strings for comparison
bool success = true;
Str json = StrInit();
struct { u64 id;
struct {
Str name;
u64 age;
} profile; } profile;
} user;
Str status;
} data = {
{123, {StrInitFromZstr("Alice"), 30}},
bool success = true;
Str json = StrInit();
struct { struct {
struct {
Str head;
u64 count;
f64 budget; } engineering;
} departments;
Str name;
} company;
} data = {
bool success = true;
Str json = StrInit();
ApiResponse response = {true, StrInitFromZstr("Success"), VecInitWithDeepCopy(NULL, AnnSymbolDeinit)}; JW_OBJ_KV(json, "data", {
// Write dynamic key for source function ID
Str source_key = StrInit();
u64 source_id = response.data.length > 0 ? VecAt(&response.data, 0).source_function_id : 0;
StrWriteFmt(&source_key, "{}", source_id); if (response.data.length > 0) {
AnnSymbol *s = &VecAt(&response.data, 0);
Str target_key = StrInit();
StrWriteFmt(&target_key, "{}", s->target_function_id);
bool success = true;
Str json = StrInit();
Vec(FunctionInfo) functions = VecInitWithDeepCopy(NULL, FunctionInfoDeinit);
bool success = true;
Str json = StrInit();
SearchResult result = {0};
// Create strings and push them properly
Str tag1 = StrInitFromZstr("malware");
Str tag2 = StrInitFromZstr("x86"); // Create strings and push them properly
Str tag1 = StrInitFromZstr("malware");
Str tag2 = StrInitFromZstr("x86");
VecPushBack(&result.tags, tag1);
bool success = true;
Str json = StrInit();
Vec(AnnSymbol) symbols = VecInitWithDeepCopy(NULL, AnnSymbolDeinit); JW_OBJ_KV(json, "functions", {
VecForeach(&symbols, symbol) {
Str source_key = StrInit();
StrWriteFmt(&source_key, "{}", symbol.source_function_id);
JW_OBJ_KV(json, source_key.data, {
Str target_key = StrInit();
StrWriteFmt(&target_key, "{}", symbol.target_function_id);
bool success = true;
Str json = StrInit();
// Create strings for the nested structure
// Create strings for the nested structure
Str deep_message = StrInitFromZstr("deep");
Str test_name = StrInitFromZstr("test"); // Create strings for the nested structure
Str deep_message = StrInitFromZstr("deep");
Str test_name = StrInitFromZstr("test");
JW_OBJ(json, {
bool success = true;
Str json = StrInit();
Vec(u32) numbers = VecInit(); VecPushBack(&numbers, num3);
Vec(Str) strings = VecInitWithDeepCopy(NULL, StrDeinit);
// Create strings and push them properly
// Create strings and push them properly
Str str1 = StrInitFromZstr("a");
Str str2 = StrInitFromZstr("b");
Str str3 = StrInitFromZstr("c"); // Create strings and push them properly
Str str1 = StrInitFromZstr("a");
Str str2 = StrInitFromZstr("b");
Str str3 = StrInitFromZstr("c"); Str str1 = StrInitFromZstr("a");
Str str2 = StrInitFromZstr("b");
Str str3 = StrInitFromZstr("c");
VecPushBack(&strings, str1);- In
Read.Simple.c:14:
typedef struct Person {
u64 id;
Str name;
u32 age;
bool is_active;- In
Read.Simple.c:23:
bool debug_mode;
u32 timeout;
Str log_level;
} Config;- In
Read.Simple.c:28:
typedef struct SimpleProduct {
u64 id;
Str name;
f64 price;
Vec(Str) tags;- In
Read.Simple.c:30:
Str name;
f64 price;
Vec(Str) tags;
} SimpleProduct;- In
Read.Simple.c:62:
bool success = true;
Str json = StrInitFromZstr("{\"name\": \"Alice\", \"city\": \"New York\"}");
StrIter si = StrIterFromStr(json);- In
Read.Simple.c:65:
StrIter si = StrIterFromStr(json);
Str name = StrInit();
Str city = StrInit();- In
Read.Simple.c:66:
Str name = StrInit();
Str city = StrInit();
JR_OBJ(si, {
bool success = true;
Str json = StrInitFromZstr("{\"count\": 42, \"score\": 95.5, \"year\": 2024}");
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr("{\"enabled\": true, \"visible\": false}");
StrIter si = StrIterFromStr(json);
bool success = true;
Str json =
StrInitFromZstr("{\"id\": 1001, \"name\": \"Bob\", \"age\": 25, \"is_active\": true, \"salary\": 50000.0}");
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr("{\"debug_mode\": false, \"timeout\": 30, \"log_level\": \"INFO\"}");
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr("{\"languages\": [\"C\", \"Python\", \"Rust\"]}");
StrIter si = StrIterFromStr(json); StrIter si = StrIterFromStr(json);
Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit);
JR_OBJ(si, { JR_OBJ(si, {
JR_ARR_KV(si, "languages", {
Str lang = StrInit();
JR_STR(si, lang);
VecPushBack(&languages, lang);
if (languages.length >= 3) {
Str *lang1 = &VecAt(&languages, 0);
Str *lang2 = &VecAt(&languages, 1);
Str *lang3 = &VecAt(&languages, 2); if (languages.length >= 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 (StrCmpCstr(lang1, "C", 1) != 0) {
bool success = true;
Str json =
StrInitFromZstr("{\"user\": {\"name\": \"Charlie\", \"email\": \"charlie@example.com\"}, \"active\": true}");
StrIter si = StrIterFromStr(json); 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();
JR_STR(si, tag);
VecPushBack(&product.tags, tag);
if (product.tags.length >= 3) {
Str *tag1 = &VecAt(&product.tags, 0);
Str *tag2 = &VecAt(&product.tags, 1);
Str *tag3 = &VecAt(&product.tags, 2); if (product.tags.length >= 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 (StrCmpCstr(tag1, "electronics", 11) != 0) {- In
Read.Nested.c:18:
u64 analysis_id;
u64 binary_id;
Str analysis_name;
Str function_name;
Str sha256;- In
Read.Nested.c:19:
u64 binary_id;
Str analysis_name;
Str function_name;
Str sha256;
bool debug;- In
Read.Nested.c:20:
Str analysis_name;
Str function_name;
Str sha256;
bool debug;
Str function_mangled_name;- In
Read.Nested.c:22:
Str sha256;
bool debug;
Str function_mangled_name;
} AnnSymbol;- In
Read.Nested.c:29:
typedef struct ApiResponse {
bool status;
Str message;
AnnSymbols data;
} ApiResponse;- In
Read.Nested.c:43:
typedef struct FunctionInfo {
u64 id;
Str name;
u64 size;
u64 vaddr;- In
Read.Nested.c:52:
typedef struct ModelInfo {
u64 id;
Str name;
} ModelInfo;- In
Read.Nested.c:59:
typedef struct SearchResult {
u64 binary_id;
Str binary_name;
u64 analysis_id;
Str sha256;- In
Read.Nested.c:61:
Str binary_name;
u64 analysis_id;
Str sha256;
Vec(Str) tags;
Str created_at;- In
Read.Nested.c:62:
u64 analysis_id;
Str sha256;
Vec(Str) tags;
Str created_at;
u64 model_id;- In
Read.Nested.c:63:
Str sha256;
Vec(Str) tags;
Str created_at;
u64 model_id;
Str model_name;- In
Read.Nested.c:65:
Str created_at;
u64 model_id;
Str model_name;
Str owned_by;
} SearchResult;- In
Read.Nested.c:66:
u64 model_id;
Str model_name;
Str owned_by;
} SearchResult; WriteFmt("Testing basic iterator functionality\n");
Str json = StrInitFromZstr("{\"test\": \"value\"}");
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr("{\"id\": 12345, \"name\": \"test\", \"active\": true, \"score\": 98.5}");
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\"}"
); u64 id;
struct {
Str name;
u64 age;
} profile; } profile;
} user;
Str status;
} data = {
{0, {StrInit(), 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}");
StrIter si = StrIterFromStr(json);
bool success = true;
Str json = StrInitFromZstr("{\"id\": 54321, \"name\": \"test_model\"}");
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, "
// Helper function to compare JSON output (removes spaces for comparison)
bool compare_json_output(const Str *output, const char *expected) {
// Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected); bool compare_json_output(const Str *output, const char *expected) {
// Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected);
Str output_clean = StrInit();
Str expected_clean = StrInit(); // Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected);
Str output_clean = StrInit();
Str expected_clean = StrInit(); Str expected_str = StrInitFromZstr(expected);
Str output_clean = StrInit();
Str expected_clean = StrInit();
// Remove spaces and newlines from both strings for comparison
bool success = true;
Str json = StrInit();
// Write completely empty object
bool success = true;
Str json = StrInit();
Vec(i32) empty_numbers = VecInit();
Vec(i32) empty_numbers = VecInit();
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
JW_OBJ(json, {
bool success = true;
Str json = StrInit();
Str empty_name = StrInit(); Str json = StrInit();
Str empty_name = StrInit();
Str empty_desc = StrInit();
Str empty_name = StrInit();
Str empty_desc = StrInit();
JW_OBJ(json, {
bool success = true;
Str json = StrInit();
i32 temp = -25;
bool success = true;
Str json = StrInit();
i64 big_int = 9223372036854775807LL;
bool success = true;
Str json = StrInit();
i32 int_zero = 0;
bool success = true;
Str json = StrInit();
// 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");
Str message = StrInitFromZstr("Hello, \"World\"!");
Str data = StrInitFromZstr("line1\nline2\ttab"); // Note: These are the actual characters, not escape sequences
Str path = StrInitFromZstr("C:\\Program Files\\App");
Str message = StrInitFromZstr("Hello, \"World\"!");
Str data = StrInitFromZstr("line1\nline2\ttab"); Str path = StrInitFromZstr("C:\\Program Files\\App");
Str message = StrInitFromZstr("Hello, \"World\"!");
Str data = StrInitFromZstr("line1\nline2\ttab");
JW_OBJ(json, {
bool success = true;
Str json = StrInit();
// These contain actual special characters that should be escaped
// These contain actual special characters that should be escaped
Str quotes = StrInitFromZstr("\"quotes\"");
Str backslash = StrInitFromZstr("\\");
Str newline = StrInitFromZstr("\n"); // These contain actual special characters that should be escaped
Str quotes = StrInitFromZstr("\"quotes\"");
Str backslash = StrInitFromZstr("\\");
Str newline = StrInitFromZstr("\n");
Str tab = StrInitFromZstr("\t"); Str quotes = StrInitFromZstr("\"quotes\"");
Str backslash = StrInitFromZstr("\\");
Str newline = StrInitFromZstr("\n");
Str tab = StrInitFromZstr("\t"); Str backslash = StrInitFromZstr("\\");
Str newline = StrInitFromZstr("\n");
Str tab = StrInitFromZstr("\t");
JW_OBJ(json, {
bool success = true;
Str json = StrInit();
Vec(i32) empty_list = VecInit();
bool success = true;
Str json = StrInit();
Vec(i32) empty_arr = VecInit();
bool success = true;
Str json = StrInit();
i64 max_int = 2147483647LL;
bool success = true;
Str json = StrInit();
f64 tiny = 0.000001;
bool success = true;
Str json1 = StrInit();
Str json2 = StrInit();
Str json3 = StrInit(); bool success = true;
Str json1 = StrInit();
Str json2 = StrInit();
Str json3 = StrInit();
Str json4 = StrInit(); Str json1 = StrInit();
Str json2 = StrInit();
Str json3 = StrInit();
Str json4 = StrInit(); Str json2 = StrInit();
Str json3 = StrInit();
Str json4 = StrInit();
// Single integer
// Single string
Str single_str = StrInitFromZstr("hello");
JW_OBJ(json2, { JW_STR_KV(json2, "text", single_str); }); 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, const char *expected) {
// Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected); bool compare_json_output(const Str *output, const char *expected) {
// Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected);
Str output_clean = StrInit();
Str expected_clean = StrInit(); // Create a copy of expected without spaces for comparison
Str expected_str = StrInitFromZstr(expected);
Str output_clean = StrInit();
Str expected_clean = StrInit(); Str expected_str = StrInitFromZstr(expected);
Str output_clean = StrInit();
Str expected_clean = StrInit();
// Remove spaces and newlines from both strings for comparison
bool success = true;
Str json = StrInit();
Str name = StrInitFromZstr("Alice"); Str json = StrInit();
Str name = StrInitFromZstr("Alice");
Str city = StrInitFromZstr("New York");
Str name = StrInitFromZstr("Alice");
Str city = StrInitFromZstr("New York");
JW_OBJ(json, {
bool success = true;
Str json = StrInit();
u32 count = 42;
bool success = true;
Str json = StrInit();
bool enabled = true;
bool success = true;
Str json = StrInit();
Person person = {1001, StrInitFromZstr("Bob"), 25, true, 50000.0};
bool success = true;
Str json = StrInit();
Config config = {false, 30, StrInitFromZstr("INFO")};
bool success = true;
Str json = StrInit();
Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit); Str json = StrInit();
Vec(Str) languages = VecInitWithDeepCopy(NULL, StrDeinit);
// Create strings and push them properly
// Create strings and push them properly
Str lang1 = StrInitFromZstr("C");
Str lang2 = StrInitFromZstr("Python");
Str lang3 = StrInitFromZstr("Rust"); // Create strings and push them properly
Str lang1 = StrInitFromZstr("C");
Str lang2 = StrInitFromZstr("Python");
Str lang3 = StrInitFromZstr("Rust"); Str lang1 = StrInitFromZstr("C");
Str lang2 = StrInitFromZstr("Python");
Str lang3 = StrInitFromZstr("Rust");
VecPushBack(&languages, lang1);
bool success = true;
Str json = StrInit();
struct { struct {
struct {
Str name;
Str email;
} user; struct {
Str name;
Str email;
} user;
bool active;
bool success = true;
Str json = StrInit();
SimpleProduct product = {0};
// Create strings and push them properly
Str tag1 = StrInitFromZstr("electronics");
Str tag2 = StrInitFromZstr("computers");
Str tag3 = StrInitFromZstr("portable"); // Create strings and push them properly
Str tag1 = StrInitFromZstr("electronics");
Str tag2 = StrInitFromZstr("computers");
Str tag3 = StrInitFromZstr("portable"); Str tag1 = StrInitFromZstr("electronics");
Str tag2 = StrInitFromZstr("computers");
Str tag3 = StrInitFromZstr("portable");
VecPushBack(&product.tags, tag1);- In
RoundTrip.c:15:
typedef struct TestPerson {
u64 id;
Str name;
u32 age;
bool is_active;- In
RoundTrip.c:24:
bool debug_mode;
u32 timeout;
Str log_level;
Vec(Str) features;
} TestConfig;- In
RoundTrip.c:25:
u32 timeout;
Str log_level;
Vec(Str) features;
} TestConfig;- In
RoundTrip.c:95:
f64 temperature;
bool enabled;
Str message;
} original = {42, 25.5, true, StrInitFromZstr("hello world")};- In
RoundTrip.c:99:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_INT_KV(json, "count", original.count);- In
RoundTrip.c:114:
f64 temperature;
bool enabled;
Str message;
} parsed = {0, 0.0, false, StrInit()};- In
RoundTrip.c:171:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_INT_KV(json, "big_int", original.big_int);- In
RoundTrip.c:241:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_BOOL_KV(json, "flag1", original.flag1);- In
RoundTrip.c:286:
// Original data with various string types
struct {
Str empty;
Str simple;
Str with_spaces;- In
RoundTrip.c:287:
struct {
Str empty;
Str simple;
Str with_spaces;
Str with_special;- In
RoundTrip.c:288:
Str empty;
Str simple;
Str with_spaces;
Str with_special;
} original = {- In
RoundTrip.c:289:
Str simple;
Str with_spaces;
Str with_special;
} original = {
StrInit(),- In
RoundTrip.c:298:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_STR_KV(json, "empty", original.empty);- In
RoundTrip.c:308:
// Read back from JSON
struct {
Str empty;
Str simple;
Str with_spaces;- In
RoundTrip.c:309:
struct {
Str empty;
Str simple;
Str with_spaces;
Str with_special;- In
RoundTrip.c:310:
Str empty;
Str simple;
Str with_spaces;
Str with_special;
} parsed = {StrInit(), StrInit(), StrInit(), StrInit()};- In
RoundTrip.c:311:
Str simple;
Str with_spaces;
Str with_special;
} parsed = {StrInit(), StrInit(), StrInit(), StrInit()};- In
RoundTrip.c:353:
// Original data
Vec(i32) original_numbers = VecInit();
Vec(Str) original_strings = VecInitWithDeepCopy(NULL, StrDeinit);
// Populate arrays
- In
RoundTrip.c:362:
// Create strings and push them properly
Str str1 = StrInitFromZstr("first");
Str str2 = StrInitFromZstr("second");
Str str3 = StrInitFromZstr("");- In
RoundTrip.c:363:
// Create strings and push them properly
Str str1 = StrInitFromZstr("first");
Str str2 = StrInitFromZstr("second");
Str str3 = StrInitFromZstr("");
Str str4 = StrInitFromZstr("last");- In
RoundTrip.c:364:
Str str1 = StrInitFromZstr("first");
Str str2 = StrInitFromZstr("second");
Str str3 = StrInitFromZstr("");
Str str4 = StrInitFromZstr("last");- In
RoundTrip.c:365:
Str str2 = StrInitFromZstr("second");
Str str3 = StrInitFromZstr("");
Str str4 = StrInitFromZstr("last");
VecPushBack(&original_strings, str1);- In
RoundTrip.c:373:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_ARR_KV(json, "numbers", original_numbers, num, { JW_INT(json, num); });- In
RoundTrip.c:381:
// Read back from JSON
Vec(i32) parsed_numbers = VecInit();
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
StrIter si = StrIterFromStr(json);- In
RoundTrip.c:391:
});
JR_ARR_KV(si, "strings", {
Str str = StrInit();
JR_STR(si, str);
VecPushBack(&parsed_strings, str);- In
RoundTrip.c:458:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_OBJ_KV(json, "user", {- In
RoundTrip.c:518:
// Create strings and push them properly
Str feature1 = StrInitFromZstr("auth");
Str feature2 = StrInitFromZstr("logging");- In
RoundTrip.c:519:
// Create strings and push them properly
Str feature1 = StrInitFromZstr("auth");
Str feature2 = StrInitFromZstr("logging");
VecPushBack(&original.config.features, feature1);- In
RoundTrip.c:537:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_OBJ_KV(json, "user", {- In
RoundTrip.c:582:
JR_STR_KV(si, "log_level", parsed.config.log_level);
JR_ARR_KV(si, "features", {
Str feature = StrInit();
JR_STR(si, feature);
VecPushBack(&parsed.config.features, feature);- In
RoundTrip.c:649:
// Original empty data
Vec(i32) empty_numbers = VecInit();
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
Str empty_str = StrInit();- In
RoundTrip.c:650:
Vec(i32) empty_numbers = VecInit();
Vec(Str) empty_strings = VecInitWithDeepCopy(NULL, StrDeinit);
Str empty_str = StrInit();
// Write to JSON
- In
RoundTrip.c:653:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_STR_KV(json, "empty_string", empty_str);- In
RoundTrip.c:669:
// Read back from JSON
Vec(i32) parsed_numbers = VecInit();
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
Str parsed_str = StrInit();
bool found_empty_object = false;- In
RoundTrip.c:670:
Vec(i32) parsed_numbers = VecInit();
Vec(Str) parsed_strings = VecInitWithDeepCopy(NULL, StrDeinit);
Str parsed_str = StrInit();
bool found_empty_object = false;- In
RoundTrip.c:682:
});
JR_ARR_KV(si, "empty_strings", {
Str str = StrInit();
JR_STR(si, str);
VecPushBack(&parsed_strings, str);- In
RoundTrip.c:733:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_INT_KV(json, "max_int", original.max_int); // 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("{}");
StrIter si1 = StrIterFromStr(json1);
// Test empty object with whitespace
Str json2 = StrInitFromZstr(" { } ");
StrIter si2 = StrIterFromStr(json2);
// Test completely empty array
Str json1 = StrInitFromZstr("{\"items\":[]}");
StrIter si1 = StrIterFromStr(json1);
// Test empty array with whitespace
Str json2 = StrInitFromZstr("{\"data\": [ ] }");
StrIter si2 = StrIterFromStr(json2); StrIter si2 = StrIterFromStr(json2);
Vec(Str) data = VecInitWithDeepCopy(NULL, StrDeinit);
JR_OBJ(si2, { JR_OBJ(si2, {
JR_ARR_KV(si2, "data", {
Str value = StrInit();
JR_STR(si2, value);
VecPushBack(&data, value); bool success = true;
Str json = StrInitFromZstr("{\"name\":\"\",\"description\":\"\"}");
StrIter si = StrIterFromStr(json);
struct {
Str name;
Str description;
} obj = {StrInit(), StrInit()}; struct {
Str name;
Str description;
} obj = {StrInit(), StrInit()}; bool success = true;
Str json = StrInitFromZstr("{\"temp\":-25,\"balance\":-1000.50,\"delta\":-0.001}");
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}");
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(), StrInit(), StrInit()}; Str path;
Str message;
Str data;
} obj = {StrInit(), StrInit(), StrInit()}; bool success = true;
Str json =
StrInitFromZstr("{\"escaped\":\"\\\"quotes\\\"\",\"backslash\":\"\\\\\",\"newline\":\"\\n\",\"tab\":\"\\t\"}");
StrIter si = StrIterFromStr(json);
struct {
Str escaped;
Str backslash;
Str newline; struct {
Str escaped;
Str backslash;
Str newline;
Str tab; Str escaped;
Str backslash;
Str newline;
Str tab;
} obj = {StrInit(), StrInit(), StrInit(), StrInit()}; Str backslash;
Str newline;
Str tab;
} obj = {StrInit(), StrInit(), StrInit(), StrInit()};
// Test with lots of different whitespace patterns
Str json = StrInitFromZstr(" {\n\t\"name\" : \"test\" ,\n \"value\": 42\t,\"flag\"\n:\ntrue\n}\t");
StrIter si = StrIterFromStr(json);
struct {
Str name;
i32 value;
bool flag; bool success = true;
Str json = StrInitFromZstr("{\"outer\":{},\"list\":[],\"deep\":{\"inner\":{}}}");
StrIter si = StrIterFromStr(json); bool success = true;
Str json = StrInitFromZstr("{\"empty_obj\":{},\"filled_obj\":{\"x\":1},\"empty_arr\":[],\"filled_arr\":[1,2]}");
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}");
StrIter si = StrIterFromStr(json); bool success = true;
Str json = StrInitFromZstr("{\"tiny\":0.000001,\"huge\":999999.999999,\"zero\":0.0,\"negative_tiny\":-0.000001}");
StrIter si = StrIterFromStr(json);- In
Str.Insert.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <stdio.h>- In
Str.Insert.c:32:
WriteFmt("Testing StrInsertCharAt\n");
Str s = StrInitFromZstr("Hello");
// Insert a character in the middle
- In
Str.Insert.c:60:
WriteFmt("Testing StrInsertCstr\n");
Str s = StrInitFromZstr("Hello");
// Insert a string in the middle
- In
Str.Insert.c:76:
WriteFmt("Testing StrInsertZstr\n");
Str s = StrInitFromZstr("Hello");
// Insert a string in the middle
- In
Str.Insert.c:92:
WriteFmt("Testing StrInsert\n");
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr(" World");- In
Str.Insert.c:93:
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr(" World");
// Insert s2 into s1 in the middle
- In
Str.Insert.c:110:
WriteFmt("Testing StrPushCstr\n");
Str s = StrInitFromZstr("Hello");
// Push a string at position 2
- In
Str.Insert.c:126:
WriteFmt("Testing StrPushZstr\n");
Str s = StrInitFromZstr("Hello");
// Push a string at position 2
- In
Str.Insert.c:142:
WriteFmt("Testing StrPushBackCstr\n");
Str s = StrInitFromZstr("Hello");
// Push a string at the back
- In
Str.Insert.c:158:
WriteFmt("Testing StrPushBackZstr\n");
Str s = StrInitFromZstr("Hello");
// Push a string at the back
- In
Str.Insert.c:174:
WriteFmt("Testing StrPushFrontCstr\n");
Str s = StrInitFromZstr("World");
// Push a string at the front
- In
Str.Insert.c:190:
WriteFmt("Testing StrPushFrontZstr\n");
Str s = StrInitFromZstr("World");
// Push a string at the front
- In
Str.Insert.c:206:
WriteFmt("Testing StrPushBack\n");
Str s = StrInitFromZstr("Hello");
// Push characters at the back
- In
Str.Insert.c:227:
WriteFmt("Testing StrPushFront\n");
Str s = StrInitFromZstr("World");
// Push characters at the front
- In
Str.Insert.c:248:
WriteFmt("Testing StrMergeL\n");
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr(" World");- In
Str.Insert.c:249:
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr(" World");
// Merge s2 into s1 (L-value semantics)
- In
Str.Insert.c:273:
WriteFmt("Testing StrMergeR\n");
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr(" World");- In
Str.Insert.c:274:
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr(" World");
// Merge s2 into s1 (R-value semantics)
- In
Str.Insert.c:294:
WriteFmt("Testing StrMerge\n");
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr(" World");- In
Str.Insert.c:295:
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr(" World");
// Merge s2 into s1
- In
Str.Insert.c:315:
WriteFmt("Testing StrAppendf\n");
Str s = StrInitFromZstr("Hello");
// Append formatted string
- In
Str.Insert.c:329:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Insert tests\n\n");
// Array of test functions
- In
Str.Insert.c:354:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Insert");
}- In
Float.Math.c:28:
Float value = FloatFromStr("12.5");
Str text = StrInit();
FloatNegate(&value);- In
Float.Math.c:51:
Float b = FloatFromStr("0.03");
Float result_value = FloatInit();
Str text = StrInit();
FloatAdd(&result_value, &a, &b);- In
Float.Math.c:71:
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_TWOS);
Float result_value = FloatInit();
Str text = StrInit();
FloatAdd(&result_value, &a, &b);- In
Float.Math.c:92:
Int whole = IntFrom(2);
Float result_value = FloatInit();
Str text = StrInit();
FloatAdd(&result_value, &a, b);- In
Float.Math.c:137:
Float b = FloatFromStr("2");
Float result_value = FloatInit();
Str text = StrInit();
FloatSub(&result_value, &a, &b);- In
Float.Math.c:157:
Float b = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES);
Float result_value = FloatInit();
Str text = StrInit();
FloatSub(&result_value, &a, &b);- In
Float.Math.c:178:
Int whole = IntFrom(2);
Float result_value = FloatInit();
Str text = StrInit();
FloatSub(&result_value, &a, b);- In
Float.Math.c:218:
Float b = FloatFromStr("-0.2");
Float result_value = FloatInit();
Str text = StrInit();
FloatMul(&result_value, &a, &b);- In
Float.Math.c:238:
Float b = FloatFromStr("2");
Float result_value = FloatInit();
Str text = StrInit();
FloatMul(&result_value, &a, &b);- In
Float.Math.c:259:
Int whole = IntFrom(2);
Float result_value = FloatInit();
Str text = StrInit();
FloatMul(&result_value, &a, b);- In
Float.Math.c:299:
Float b = FloatFromStr("8");
Float result_value = FloatInit();
Str text = StrInit();
FloatDiv(&result_value, &a, &b, 3);- In
Float.Math.c:319:
Float b = FloatFromStr("2");
Float result_value = FloatInit();
Str text = StrInit();
FloatDiv(&result_value, &a, &b, 0);- In
Float.Math.c:340:
Int whole = IntFrom(3);
Float result_value = FloatInit();
Str text = StrInit();
FloatDiv(&result_value, &a, b, 1);- In
Int.Convert.c:40:
Int value = IntFrom(13);
Str text = IntToBinary(&value);
bool result = IntBitLength(&value) == 4;- In
Int.Convert.c:58:
Int value = IntFromBytesLE(bytes, sizeof(bytes));
u64 written = IntToBytesLE(&value, out, sizeof(out));
Str text = IntToHexStr(&value);
bool result = written == 4;- In
Int.Convert.c:76:
Int value = IntFromBytesBE(bytes, sizeof(bytes));
u64 written = IntToBytesBE(&value, out, sizeof(out));
Str text = IntToHexStr(&value);
bool result = written == 4;- In
Int.Convert.c:91:
Int value = IntFromBinary("001011");
Str text = IntToBinary(&value);
bool result = IntToU64(&value) == 11; const char *digits = "123456789012345678901234567890";
Int value = IntFromStr(digits);
Str text = IntToStr(&value);
bool result = strcmp(text.data, digits) == 0;
Int value = IntFromStrRadix("zz", 36);
Str text = IntToStrRadix(&value, 36, false);
bool result = IntToU64(&value) == 1295;
Int value = IntFrom(0xBEEF);
Str text = IntToStrRadix(&value, 16, true);
bool result = strcmp(text.data, "BEEF") == 0;
Int zero = IntFromBinary("0");
Str text = IntToBinary(&zero);
bool result = IntBitLength(&zero) == 0;
Int value = IntFromOctStr("0o7_55");
Str text = IntToOctStr(&value);
bool result = IntToU64(&value) == 493; const char *hex = "deadbeefcafebabe1234";
Int value = IntFromHexStr(hex);
Str text = IntToHexStr(&value);
bool result = strcmp(text.data, hex) == 0;- In
Io.Read.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Io.h>- In
Io.Read.c:342:
// Test basic string reading
Str s = StrInit();
z = "Hello";
StrReadFmt(z, "{}", s);- In
Io.Read.c:346:
StrReadFmt(z, "{}", s);
Str expected = StrInitFromZstr("Hello");
success = success && (StrCmp(&s, &expected) == 0);
StrDeinit(&expected);- In
Io.Read.c:373:
i32 num = 0;
Str name = StrInit();
z = "Count: 42, Name: Alice";
StrReadFmt(z, "Count: {}, Name: {}", num, name);- In
Io.Read.c:379:
success = success && (num == 42);
Str expected = StrInitFromZstr("Alice");
success = success && (StrCmp(&name, &expected) == 0);
StrDeinit(&expected);- In
Io.Read.c:588:
success = success && abc_pass;
Str str_val = StrInit();
z = "Hello";
StrReadFmt(z, "{c}", str_val);- In
Io.Read.c:591:
z = "Hello";
StrReadFmt(z, "{c}", str_val);
Str expected = StrInitFromZstr("Hello");
bool str_pass = (StrCmp(&str_val, &expected) == 0);
WriteFmt("str_val test: comparing with 'Hello', pass = {}\n", str_pass ? "true" : "false");- In
Io.Read.c:622:
// Test 1: :a (lowercase) conversion
{
Str result = StrInit();
const char *in = "Hello World";- In
Io.Read.c:636:
// Should read "hello" (stops at first space)
Str expected = StrInitFromZstr("hello world");
bool test1_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'hello', Pass: {}\n\n", test1_pass ? "true" : "false");- In
Io.Read.c:647:
// Test 1.1: :a (lowercase) conversion
{
Str result = StrInit();
const char *in = "Hello World";- In
Io.Read.c:661:
// Should read "hello" (stops at first space)
Str expected = StrInitFromZstr("hello");
bool test1_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'hello', Pass: {}\n\n", test1_pass ? "true" : "false");- In
Io.Read.c:672:
// Test 2: :A (uppercase) conversion
{
Str result = StrInit();
const char *in = "hello world";- In
Io.Read.c:686:
// Should read "HELLO" (stops at first space)
Str expected = StrInitFromZstr("HELLO WORLD");
bool test2_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'HELLO', Pass: {}\n\n", test2_pass ? "true" : "false");- In
Io.Read.c:697:
// Test 2.1: :A (uppercase) conversion
{
Str result1 = StrInit();
Str result2 = StrInit();
const char *in = "hello world";- In
Io.Read.c:698:
{
Str result1 = StrInit();
Str result2 = StrInit();
const char *in = "hello world";- In
Io.Read.c:718:
// Test 2.2: :A (uppercase) conversion
{
Str result1 = StrInit();
Str result2 = StrInit();
const char *in = "hello world mighty misra";- In
Io.Read.c:719:
{
Str result1 = StrInit();
Str result2 = StrInit();
const char *in = "hello world mighty misra";- In
Io.Read.c:741:
// Test 3: :a with quoted string
{
Str result = StrInit();
const char *in = "\"MiXeD CaSe\"";- In
Io.Read.c:755:
// Should read "mixed case" (converts the entire quoted string)
Str expected = StrInitFromZstr("mixed case");
bool test3_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'mixed case', Pass: {}\n\n", test3_pass ? "true" : "false");- In
Io.Read.c:766:
// Test 4: :A with quoted string containing special characters
{
Str result = StrInit();
const char *in = "\"abc123XYZ\"";- In
Io.Read.c:780:
// Should read "ABC123XYZ" (only letters are converted, numbers unchanged)
Str expected = StrInitFromZstr("ABC123XYZ");
bool test4_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'ABC123XYZ', Pass: {}\n\n", test4_pass ? "true" : "false");- In
Io.Read.c:791:
// Test 5: Regular :c format (no case conversion) for comparison
{
Str result = StrInit();
const char *in = "Hello World";- In
Io.Read.c:805:
// Should read "Hello" (stops at first space, no case conversion)
Str expected = StrInitFromZstr("Hello World");
bool test5_pass = (StrCmp(&result, &expected) == 0);
WriteFmt("Expected: 'Hello World', Pass: {}\n\n", test5_pass ? "true" : "false");- In
Io.Read.c:830:
z = "10110";
StrReadFmt(z, "{}", bv1);
Str result1 = BitVecToStr(&bv1);
success = success && (ZstrCompare(result1.data, "10110") == 0);
WriteFmt(- In
Io.Read.c:862:
z = " 1101";
StrReadFmt(z, "{}", bv4);
Str result4 = BitVecToStr(&bv4);
success = success && (ZstrCompare(result4.data, "1101") == 0);
WriteFmt(- In
Io.Read.c:876:
z = "0";
StrReadFmt(z, "{}", bv5);
Str result5 = BitVecToStr(&bv5);
success = success && (ZstrCompare(result5.data, "0") == 0);
WriteFmt("Test 5 - Zero: {}, Success: {}\n", result5, (ZstrCompare(result5.data, "0") == 0) ? "true" : "false");- In
Io.Read.c:897:
Int oct = IntInit();
Str dec_text = StrInit();
Str hex_text = StrInit();
Str bin_text = StrInit();- In
Io.Read.c:898:
Str dec_text = StrInit();
Str hex_text = StrInit();
Str bin_text = StrInit();
Str oct_text = StrInit();- In
Io.Read.c:899:
Str dec_text = StrInit();
Str hex_text = StrInit();
Str bin_text = StrInit();
Str oct_text = StrInit();- In
Io.Read.c:900:
Str hex_text = StrInit();
Str bin_text = StrInit();
Str oct_text = StrInit();
z = "123456789012345678901234567890";- In
Io.Read.c:944:
Float neg = FloatInit();
Str dec_text = StrInit();
Str sci_text = StrInit();
Str neg_text = StrInit();- In
Io.Read.c:945:
Str dec_text = StrInit();
Str sci_text = StrInit();
Str neg_text = StrInit();- In
Io.Read.c:946:
Str dec_text = StrInit();
Str sci_text = StrInit();
Str neg_text = StrInit();
z = "1234567890.012345";- In
Str.Type.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>- In
Str.Type.c:22:
// Test Str type definition
bool test_str_type(void) {
WriteFmt("Testing Str type definition\n");
// Create a Str object
- In
Str.Type.c:25:
// Create a Str object
Str s = StrInit();
// Check that it behaves like a Vec of chars
- In
Str.Type.c:48:
// Add some strings
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr("World");- In
Str.Type.c:49:
// Add some strings
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr("World");
VecPushBack(&sv, s1);- In
Str.Type.c:59:
// Check the content of the strings
if (result) {
Str *str1 = &VecAt(&sv, 0);
Str *str2 = &VecAt(&sv, 1);- In
Str.Type.c:60:
if (result) {
Str *str1 = &VecAt(&sv, 0);
Str *str2 = &VecAt(&sv, 1);
result = result && (ZstrCompare(str1->data, "Hello") == 0);- In
Str.Type.c:75:
// Create a valid Str
Str s = StrInit();
// This should not crash
- In
Str.Type.c:114:
// Create an invalid Str by corrupting its fields
Str s = StrInit();
// Corrupt the string to make it invalid
- In
Str.Type.c:149:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Type tests\n\n");
// Array of normal test functions
- In
Str.Type.c:161:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, deadend_count, "Str.Type");
}- In
Io.Write.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Io.h>- In
Io.Write.c:35:
WriteFmt("Testing basic formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:65:
WriteFmt("Testing string formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:94:
// Test Str object
Str s = StrInitFromZstr("World");
StrWriteFmt(&output, "{}", s);
success = success && (ZstrCompare(output.data, "World") == 0);- In
Io.Write.c:107:
WriteFmt("Testing integer decimal formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:180:
WriteFmt("Testing integer hexadecimal formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:199:
WriteFmt("Testing integer binary formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:214:
WriteFmt("Testing integer octal formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:229:
WriteFmt("Testing basic floating point formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:249:
WriteFmt("Testing floating point precision formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:274:
WriteFmt("Testing special floating point values\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:301:
WriteFmt("Testing width and alignment formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:339:
WriteFmt("Testing multiple arguments\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:362:
WriteFmt("Testing character formatting specifiers\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:382:
// Test with Str object
Str s = StrInitFromZstr("MiXeD CaSe");
// Test with :c (preserve case)
- In
Io.Write.c:554:
WriteFmt("Testing BitVec formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:622:
WriteFmt("Testing Int formatting\n");
Str output = StrInit();
bool success = true;- In
Io.Write.c:664:
WriteFmt("Testing Float formatting\n");
Str output = StrInit();
bool success = true;
Float exact = FloatFromStr("1234567890.012345");- In
Str.Foreach.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Io.h>- In
Str.Foreach.c:36:
WriteFmt("Testing StrForeachIdx\n");
Str s = StrInitFromZstr("Hello");
// Build a new string by iterating through each character with its index
- In
Str.Foreach.c:39:
// Build a new string by iterating through each character with its index
Str result = StrInit();
StrForeachIdx(&s, chr, idx) {
StrWriteFmt(&result, "{c}{}", chr, idx);- In
Str.Foreach.c:56:
WriteFmt("Testing StrForeachReverseIdx\n");
Str s = StrInitFromZstr("Hello");
// Build a new string by iterating through each character in reverse with its index
- In
Str.Foreach.c:59:
// Build a new string by iterating through each character in reverse with its index
Str result = StrInit();
StrForeachReverseIdx(&s, chr, idx) {- In
Str.Foreach.c:78:
WriteFmt("Testing StrForeachPtrIdx\n");
Str s = StrInitFromZstr("Hello");
// Build a new string by iterating through each character pointer with its index
- In
Str.Foreach.c:81:
// Build a new string by iterating through each character pointer with its index
Str result = StrInit();
StrForeachPtrIdx(&s, chrptr, idx) {
// Append the character (via pointer) and its index to the result string
WriteFmt("Testing StrForeachReversePtrIdx\n");
Str s = StrInitFromZstr("Hello");
// Build a new string by iterating through each character pointer in reverse with its index
// Build a new string by iterating through each character pointer in reverse with its index
Str result = StrInit();
StrForeachReversePtrIdx(&s, chrptr, idx) { WriteFmt("Testing StrForeach\n");
Str s = StrInitFromZstr("Hello");
// Build a new string by iterating through each character
// Build a new string by iterating through each character
Str result = StrInit();
StrForeach(&s, chr) {
// Append the character to the result string
WriteFmt("Testing StrForeachReverse\n");
Str s = StrInitFromZstr("Hello");
// Build a new string by iterating through each character in reverse
// Build a new string by iterating through each character in reverse
Str result = StrInit();
size char_count = 0; WriteFmt("Testing StrForeachPtr\n");
Str s = StrInitFromZstr("Hello");
// Build a new string by iterating through each character pointer
// Build a new string by iterating through each character pointer
Str result = StrInit();
StrForeachPtr(&s, chrptr) {
// Append the character (via pointer) to the result string
WriteFmt("Testing StrForeachPtrReverse\n");
Str s = StrInitFromZstr("Hello");
// Build a new string by iterating through each character pointer in reverse
// Build a new string by iterating through each character pointer in reverse
Str result = StrInit();
size char_count = 0; WriteFmt("Testing StrForeachInRangeIdx\n");
Str s = StrInitFromZstr("Hello World");
// Build a new string by iterating through a range of characters with indices
// Build a new string by iterating through a range of characters with indices
Str result = StrInit();
StrForeachInRangeIdx(&s, chr, idx, 6, 11) {
// Append the character and its index to the result string
// Test with empty range
Str empty_result = StrInit();
StrForeachInRangeIdx(&s, chr, idx, 3, 3) {
// This block should not execute
WriteFmt("Testing StrForeachInRange\n");
Str s = StrInitFromZstr("Hello World");
// Build a new string by iterating through a range of characters
// Build a new string by iterating through a range of characters
Str result = StrInit();
StrForeachInRange(&s, chr, 0, 5) {
// Append the character to the result string
// Test with range at the end of the string
Str end_result = StrInit();
StrForeachInRange(&s, chr, 6, 11) {
// Append the character to the result string
WriteFmt("Testing StrForeachPtrInRangeIdx\n");
Str s = StrInitFromZstr("Hello World");
// Build a new string by iterating through a range of character pointers with indices
// Build a new string by iterating through a range of character pointers with indices
Str result = StrInit();
StrForeachPtrInRangeIdx(&s, chrptr, idx, 6, 11) {
// Append the character and its index to the result string
WriteFmt("Testing StrForeachPtrInRange\n");
Str s = StrInitFromZstr("Hello World");
// Build a new string by iterating through a range of character pointers
// Build a new string by iterating through a range of character pointers
Str result = StrInit();
StrForeachPtrInRange(&s, chrptr, 0, 5) {
// Append the character to the result string
WriteFmt("Testing StrForeachInRangeIdx where idx goes out of bounds\n");
Str s = StrInitFromZstr("Hello World!"); // 12 characters
// Use StrForeachInRangeIdx which captures the 'end' parameter at the start
WriteFmt("Testing StrForeachInRangeIdx with character deletion where idx goes out of bounds\n");
Str s = StrInitFromZstr("Programming"); // 11 characters
// Use StrForeachInRangeIdx with a fixed range that will become invalid
WriteFmt("Testing StrForeachReverseIdx where idx goes out of bounds\n");
Str s = StrInitFromZstr("Beautiful Weather"); // 17 characters
// StrForeachReverseIdx (VecForeachReverseIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
WriteFmt("Testing StrForeachPtrIdx where idx goes out of bounds\n");
Str s = StrInitFromZstr("Programming Test"); // 16 characters
// StrForeachPtrIdx (VecForeachPtrIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
WriteFmt("Testing StrForeachReversePtrIdx where idx goes out of bounds\n");
Str s = StrInitFromZstr("Excellent Example"); // 17 characters
// StrForeachReversePtrIdx (VecForeachPtrReverseIdx) has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
WriteFmt("Testing StrForeachPtrInRangeIdx where idx goes out of bounds\n");
Str s = StrInitFromZstr("Comprehensive Testing Framework"); // 31 characters
// Use StrForeachPtrInRangeIdx with a fixed range that becomes invalid when we modify the string
WriteFmt("Testing basic StrForeachIdx where idx goes out of bounds\n");
Str s = StrInitFromZstr("Testing Basic"); // 13 characters
// Basic StrForeachIdx (VecForeachIdx) now has explicit bounds checking: if ((idx) >= (v)->length) LOG_FATAL(...)
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Foreach.Simple tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Foreach.Simple");
}- In
Str.Convert.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <stdio.h>- In
Str.Convert.c:31:
WriteFmt("Testing StrFromU64\n");
Str s = StrInit();
// Test decimal conversion
- In
Str.Convert.c:94:
WriteFmt("Testing StrFromI64\n");
Str s = StrInit();
// Test positive decimal conversion
WriteFmt("Testing StrFromF64\n");
Str s = StrInit();
// Test integer conversion
// Test decimal conversion
Str s = StrInitFromZstr("12345");
u64 value = 0;
bool success = StrToU64(&s, &value, NULL);
// Test positive decimal conversion
Str s = StrInitFromZstr("12345");
i64 value = 0;
bool success = StrToI64(&s, &value, NULL);
// Test integer conversion
Str s = StrInitFromZstr("123");
f64 value = 0.0;
bool success = StrToF64(&s, &value, NULL); // Round-trip conversion tests
bool test_str_round_trip_conversions(void) {
WriteFmt("Testing Str round-trip conversions\n");
bool result = true;
for (size_t i = 0; i < sizeof(u64_values) / sizeof(u64_values[0]); i++) {
Str s = StrInit();
// Test decimal round-trip
for (size_t i = 0; i < sizeof(i64_values) / sizeof(i64_values[0]); i++) {
Str s = StrInit();
// Test decimal round-trip
for (size_t i = 0; i < sizeof(f64_values) / sizeof(f64_values[0]); i++) {
for (u8 precision = 1; precision <= 6; precision++) {
Str s = StrInit();
StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false}; // Edge case conversion tests
bool test_str_edge_case_conversions(void) {
WriteFmt("Testing Str edge case conversions\n");
bool result = true; // Test base boundary conditions
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit();
// Test with base value itself
// Test extreme values
Str s = StrInit();
// Test maximum u64
for (size_t i = 0; i < sizeof(prefix_tests) / sizeof(prefix_tests[0]); i++) {
Str test_str = StrInitFromZstr(prefix_tests[i].input);
u64 value = 0;
StrParseConfig config = {.base = prefix_tests[i].base}; // Precision limits testing
bool test_str_precision_limits(void) {
WriteFmt("Testing Str precision limits\n");
bool result = true;
for (u8 precision = 1; precision <= 17; precision++) {
Str s = StrInit();
StrFloatFormat config = {.precision = precision, .force_sci = false, .uppercase = false};
for (size_t i = 0; i < sizeof(sci_values) / sizeof(sci_values[0]); i++) {
Str s = StrInit();
// Force scientific notation
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit();
StrIntFormat config = {.base = base, .uppercase = false}; // Large-scale conversion tests
bool test_str_all_base_support(void) {
WriteFmt("Testing Str all bases 2-36 support\n");
bool result = true; // Test each base from 2 to 36
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit();
// Test StrFromU64
// Test uppercase digits for bases that use letters (11-36)
for (u8 base = 11; base <= 36; base++) {
Str s = StrInit();
StrIntFormat config = {.base = base, .uppercase = true, .use_prefix = false}; for (size_t i = 0; i < sizeof(test_values) / sizeof(test_values[0]); i++) {
for (u8 base = 2; base <= 36; base++) {
Str s = StrInit();
StrIntFormat config = {.base = base, .uppercase = false, .use_prefix = false};
bool test_str_large_scale_conversions(void) {
WriteFmt("Testing Str large-scale conversions\n");
bool result = true; u64 test_value = i * 1000007; // Large prime multiplier
Str s = StrInit();
StrIntFormat config = {.base = 10, .uppercase = false};
StrFromU64(&s, test_value, &config); f64 test_value = mantissa * pow(10.0, exp);
Str s = StrInit();
StrFloatFormat config = {.precision = 6, .force_sci = false, .uppercase = false};
StrFromF64(&s, test_value, &config); strcpy(long_number, "12345678901234567890123456789012345678901234567890");
Str long_str = StrInitFromZstr(long_number);
u64 long_value = 0;
bool success = StrToU64(&long_str, &long_value, NULL); // 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
bool test_str_conversion_bounds_failures(void) {
WriteFmt("Testing Str conversion bounds failures\n");
// Test StrFromI64 with NULL pointer - should abort
bool test_str_conversion_invalid_input_failures(void) {
WriteFmt("Testing Str conversion invalid input failures\n");
// Test StrFromF64 with NULL pointer - should abort
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Convert tests\n\n");
// Array of normal test functions
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, deadend_tests, total_deadend_tests, "Str.Convert");
}- In
Str.Memory.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <stdio.h>- In
Str.Memory.c:21:
WriteFmt("Testing StrTryReduceSpace\n");
Str s = StrInit();
// Reserve more space than needed
- In
Str.Memory.c:46:
WriteFmt("Testing StrSwapCharAt\n");
Str s = StrInitFromZstr("Hello");
// Swap 'H' and 'o'
- In
Str.Memory.c:68:
WriteFmt("Testing StrResize\n");
Str s = StrInitFromZstr("Hello");
// Initial length should be 5
- In
Str.Memory.c:94:
WriteFmt("Testing StrReserve\n");
Str s = StrInit();
// Reserve more space
- In
Str.Memory.c:119:
WriteFmt("Testing StrClear\n");
Str s = StrInitFromZstr("Hello, World!");
// Initial length should be 13
- In
Str.Memory.c:141:
WriteFmt("Testing StrReverse\n");
Str s = StrInitFromZstr("Hello");
// Reverse the string
- In
Str.Memory.c:185:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Memory tests\n\n");
// Array of test functions
- In
Str.Memory.c:200:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Memory");
}- In
Map.Ops.c:2:
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Memory.h>
#include <Misra/Std/Log.h>- In
Str.Ops.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>- In
Str.Ops.c:23:
WriteFmt("Testing StrCmp and StrCmpCstr\n");
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr("Hello");
Str s3 = StrInitFromZstr("World");- In
Str.Ops.c:24:
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr("Hello");
Str s3 = StrInitFromZstr("World");
Str s4 = StrInitFromZstr("Hello World");- In
Str.Ops.c:25:
Str s1 = StrInitFromZstr("Hello");
Str s2 = StrInitFromZstr("Hello");
Str s3 = StrInitFromZstr("World");
Str s4 = StrInitFromZstr("Hello World");- In
Str.Ops.c:26:
Str s2 = StrInitFromZstr("Hello");
Str s3 = StrInitFromZstr("World");
Str s4 = StrInitFromZstr("Hello World");
// Test StrCmp with equal strings
- In
Str.Ops.c:58:
WriteFmt("Testing StrFindStr, StrFindZstr, and StrFindCstr\n");
Str haystack = StrInitFromZstr("Hello World");
Str needle1 = StrInitFromZstr("World");
Str needle2 = StrInitFromZstr("Hello");- In
Str.Ops.c:59:
Str haystack = StrInitFromZstr("Hello World");
Str needle1 = StrInitFromZstr("World");
Str needle2 = StrInitFromZstr("Hello");
Str needle3 = StrInitFromZstr("NotFound");- In
Str.Ops.c:60:
Str haystack = StrInitFromZstr("Hello World");
Str needle1 = StrInitFromZstr("World");
Str needle2 = StrInitFromZstr("Hello");
Str needle3 = StrInitFromZstr("NotFound");- In
Str.Ops.c:61:
Str needle1 = StrInitFromZstr("World");
Str needle2 = StrInitFromZstr("Hello");
Str needle3 = StrInitFromZstr("NotFound");
// Test StrFindStr with match at end
- In
Str.Ops.c:94:
WriteFmt("Testing StrStartsWith and StrEndsWith variants\n");
Str s = StrInitFromZstr("Hello World");
Str prefix = StrInitFromZstr("Hello");
Str suffix = StrInitFromZstr("World");- In
Str.Ops.c:95:
Str s = StrInitFromZstr("Hello World");
Str prefix = StrInitFromZstr("Hello");
Str suffix = StrInitFromZstr("World");- In
Str.Ops.c:96:
Str s = StrInitFromZstr("Hello World");
Str prefix = StrInitFromZstr("Hello");
Str suffix = StrInitFromZstr("World");
// Test StrStartsWith
- In
Str.Ops.c:131:
// Test StrReplaceZstr
Str s1 = StrInitFromZstr("Hello World");
StrReplaceZstr(&s1, "World", "Universe", 1);
bool result = (ZstrCompare(s1.data, "Hello Universe") == 0);- In
Str.Ops.c:150:
StrDeinit(&s1);
s1 = StrInitFromZstr("Hello World");
Str find = StrInitFromZstr("World");
Str replace = StrInitFromZstr("Universe");
StrReplace(&s1, &find, &replace, 1);- In
Str.Ops.c:151:
s1 = StrInitFromZstr("Hello World");
Str find = StrInitFromZstr("World");
Str replace = StrInitFromZstr("Universe");
StrReplace(&s1, &find, &replace, 1);
result = result && (ZstrCompare(s1.data, "Hello Universe") == 0);- In
Str.Ops.c:166:
// Test StrSplit
Str s = StrInitFromZstr("Hello,World,Test");
Strs split = StrSplit(&s, ",");- In
Str.Ops.c:212:
// Test StrLStrip
Str s1 = StrInitFromZstr(" Hello ");
Str stripped = StrLStrip(&s1, NULL);
bool result = (ZstrCompare(stripped.data, "Hello ") == 0);- In
Str.Ops.c:213:
// Test StrLStrip
Str s1 = StrInitFromZstr(" Hello ");
Str stripped = StrLStrip(&s1, NULL);
bool result = (ZstrCompare(stripped.data, "Hello ") == 0);
StrDeinit(&stripped);- In
Str.Ops.c:249:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Ops tests\n\n");
// Array of test functions
- In
Str.Ops.c:258:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Ops");
} #include <Misra/Std/Container/BitVec.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <stdio.h>
// Convert to string
Str str = BitVecToStr(&bv);
// Check result
// Test converting empty bitvec
Str str_obj = BitVecToStr(&bv);
result = result && (str_obj.length == 0);
StrDeinit(&str_obj); for (size_t i = 0; i < sizeof(patterns) / sizeof(patterns[0]); i++) {
BitVec bv = BitVecFromStr(patterns[i]);
Str str = BitVecToStr(&bv);
// Should get exact same string back
BitVec empty = BitVecInit();
Str empty_str = BitVecToStr(&empty);
result = result && (empty_str.length == 0);
StrDeinit(&empty_str);
// Test string conversion consistency
Str str = BitVecToStr(&bv);
result = result && (ZstrCompare(str.data, test_cases[i].pattern) == 0);
StrDeinit(&str);
// All three should produce the same result when converted back
Str str1 = BitVecToStr(&bv1);
Str str2 = BitVecToStr(&bv2);
Str str3 = BitVecToStr(&bv3); // All three should produce the same result when converted back
Str str1 = BitVecToStr(&bv1);
Str str2 = BitVecToStr(&bv2);
Str str3 = BitVecToStr(&bv3); Str str1 = BitVecToStr(&bv1);
Str str2 = BitVecToStr(&bv2);
Str str3 = BitVecToStr(&bv3);
// At least two of them should match (bit order might affect one)
// Test string conversion
Str large_str = BitVecToStr(&large_bv);
result = result && (large_str.length == 1000);- In
Str.Access.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <stdio.h>- In
Str.Access.c:22:
WriteFmt("Testing StrFirst\n");
Str s = StrInitFromZstr("Hello");
// Get the first character
- In
Str.Access.c:38:
WriteFmt("Testing StrLast\n");
Str s = StrInitFromZstr("Hello");
// Get the last character
- In
Str.Access.c:54:
WriteFmt("Testing StrBegin\n");
Str s = StrInitFromZstr("Hello");
// Get a pointer to the first character using StrBegin
- In
Str.Access.c:70:
WriteFmt("Testing StrEnd\n");
Str s = StrInitFromZstr("Hello");
// Get a pointer to one past the last character using StrEnd
- In
Str.Access.c:86:
WriteFmt("Testing StrCharAt\n");
Str s = StrInitFromZstr("Hello");
// Access characters at different indices
- In
Str.Access.c:107:
WriteFmt("Testing StrCharPtrAt\n");
Str s = StrInitFromZstr("Hello");
// Access character pointers at different indices
- In
Str.Access.c:129:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Access tests\n\n");
// Array of test functions
- In
Str.Access.c:138:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Access");
}
Float value = FloatFrom(42);
Str text = FloatToStr(&value);
bool result = strcmp(text.data, "42") == 0;
Float value = FloatFrom(-42);
Str text = FloatToStr(&value);
bool result = strcmp(text.data, "-42") == 0; Int integer = IntFromStr("12345678901234567890");
Float value = FloatFrom(&integer);
Str text = FloatToStr(&value);
bool result = strcmp(text.data, "12345678901234567890") == 0; Float value = FloatFromStr("1234500e-2");
Int result_value = IntInit();
Str text = StrInit();
bool result = FloatToInt(&result_value, &value);
Float value = FloatFromStr("-123.45");
Str text = FloatToStr(&value);
bool result = strcmp(text.data, "-123.45") == 0;
Float value = FloatFromStr(FLOAT_TEST_VERY_LARGE_ONES);
Str text = FloatToStr(&value);
bool result = strcmp(text.data, FLOAT_TEST_VERY_LARGE_ONES) == 0;
Float value = FloatFromStr("1.2300e3");
Str text = FloatToStr(&value);
bool result = strcmp(text.data, "1230") == 0;- In
Int.Math.c:95:
Int b = IntFrom(1);
Int result_value = IntInit();
Str text = StrInit();
IntAdd(&result_value, &a, &b);- In
Int.Math.c:117:
Int result_value = IntInit();
Int huge = IntFromStr("123456789012345678901234567890");
Str text = StrInit();
IntAdd(&result_value, &base, rhs);- In
Int.Math.c:164:
Int preserved = IntFrom(99);
Int huge = IntFromStr("12345678901234567890");
Str text = StrInit();
bool result = IntSub(&result_value, &base, rhs);- In
Int.Math.c:229:
Int value = IntFromStr("12345678901234567890");
Int result_value = IntInit();
Str text = StrInit();
IntMul(&result_value, &value, 25u);- In
Int.Math.c:281:
Int exponent = IntFrom(20);
Int result_value = IntInit();
Str text = StrInit();
IntPow(&result_value, &base, 20u);- In
Int.Math.c:305:
Int quotient = IntInit();
Int remainder = IntInit();
Str qtext = StrInit();
IntDivMod("ient, &remainder, ÷nd, 97u);- In
Int.Math.c:340:
Int dividend = IntFromStr("12345678901234567890");
Int result_value = IntInit();
Str text = StrInit();
bool result = IntDivExact(&result_value, ÷nd, 90u);- In
Int.Math.c:374:
Int quotient = IntInit();
Int remainder = IntInit();
Str text = StrInit();
IntDivMod("ient, &remainder, ÷nd, 97);- In
Int.Math.c:775:
Int value = IntFromStr("1000000000");
Int next = IntInit();
Str text = StrInit();
IntNextPrime(&next, &value);- In
Float.Type.c:45:
Float clone = FloatClone(&original);
Float expected = FloatFromStr("-12.5");
Str text = FloatToStr(&clone);
FloatAbs(&original);- In
Str.Init.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <stdio.h>- In
Str.Init.c:25:
WriteFmt("Testing StrInit\n");
Str s = StrInit();
// Validate the string
- In
Str.Init.c:44:
const char *test_str = "Hello, World!";
size_t len = 5; // Just "Hello"
Str s = StrInitFromCstr(test_str, len);
// Validate the string
- In
Str.Init.c:61:
const char *test_str = "Hello, World!";
Str s = StrInitFromZstr(test_str);
// Validate the string
- In
Str.Init.c:77:
WriteFmt("Testing StrInitFromStr\n");
Str src = StrInitFromZstr("Hello, World!");
Str dst = StrInitFromStr(&src);- In
Str.Init.c:78:
Str src = StrInitFromZstr("Hello, World!");
Str dst = StrInitFromStr(&src);
// Validate both strings
- In
Str.Init.c:96:
WriteFmt("Testing StrDup\n");
Str src = StrInitFromZstr("Hello, World!");
Str dst = StrDup(&src);- In
Str.Init.c:97:
Str src = StrInitFromZstr("Hello, World!");
Str dst = StrDup(&src);
// Validate both strings
- In
Str.Init.c:115:
WriteFmt("Testing StrWriteFmt\n");
Str s = StrInit();
StrWriteFmt(&s, "Hello, {}!", &"World"[0]);- In
Str.Init.c:135:
// Test with the actual StrInitStack macro
Str stack_str;
StrInitStack(stack_str, 20, {
// Inside the scope where the stack string is valid
- In
Str.Init.c:166:
WriteFmt("Testing StrInitCopy\n");
Str src = StrInitFromZstr("Hello, World!");
Str dst = StrInit();- In
Str.Init.c:167:
Str src = StrInitFromZstr("Hello, World!");
Str dst = StrInit();
// Copy src to dst
- In
Str.Init.c:188:
WriteFmt("Testing StrDeinit\n");
Str s = StrInitFromZstr("Hello, World!");
// Validate the string before deinit
- In
Str.Init.c:205:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Init tests\n\n");
// Array of test functions
- In
Str.Init.c:223:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Init");
}- In
Str.Remove.c:1:
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Log.h>
#include <stdio.h>- In
Str.Remove.c:23:
WriteFmt("Testing StrPopBack\n");
Str s = StrInitFromZstr("Hello");
// Pop a character from the back
- In
Str.Remove.c:47:
WriteFmt("Testing StrPopFront\n");
Str s = StrInitFromZstr("Hello");
// Pop a character from the front
- In
Str.Remove.c:71:
WriteFmt("Testing StrRemove\n");
Str s = StrInitFromZstr("Hello");
// Remove a character from the middle
- In
Str.Remove.c:95:
WriteFmt("Testing StrRemoveRange\n");
Str s = StrInitFromZstr("Hello World");
// Create a buffer to store the removed characters
- In
Str.Remove.c:122:
WriteFmt("Testing StrDeleteLastChar\n");
Str s = StrInitFromZstr("Hello");
// Delete the last character
- In
Str.Remove.c:144:
WriteFmt("Testing StrDelete\n");
Str s = StrInitFromZstr("Hello");
// Delete a character from the middle
- In
Str.Remove.c:166:
WriteFmt("Testing StrDeleteRange\n");
Str s = StrInitFromZstr("Hello World");
// Delete a range of characters
- In
Str.Remove.c:186:
// Main function that runs all tests
int main(void) {
WriteFmt("[INFO] Starting Str.Remove tests\n\n");
// Array of test functions
- In
Str.Remove.c:202:
// Run all tests using the centralized test driver
return run_test_suite(tests, total_tests, NULL, 0, "Str.Remove");
}- In
Sys.h:10:
#define MISRA_SYS_H
#include <Misra/Std/Container/Str.h>
#include <errno.h>- In
Sys.h:33:
/// TAGS: System, Environment, Memory
///
Str *SysGetEnv(const char *name, Str *value);
///
- In
Sys.h:46:
/// TAGS: System, Error, String
///
Str *SysStrError(i32 eno, Str *err_str);
///
- In
File.h:14:
// decompiler
#include <Misra/Std/Container/Str.h>
#include <Misra/Sys.h>
#include <Misra/Types.h>- In
Io.h:95:
/// TAGS: I/O, Callback, Generic
///
typedef void (*TypeSpecificWriter)(Str *o, FmtInfo *fmt_info, void *data);
///
- In
Io.h:138:
(x), \
TypeSpecificIO: (x), \
Str: TO_TYPE_SPECIFIC_IO(Str, &(x)), \
Float: TO_TYPE_SPECIFIC_IO(Float, &(x)), \
Int: TO_TYPE_SPECIFIC_IO(Int, &(x)), \
- In
Io.h:174:
(x), \
TypeSpecificIO: (x), \
Str: TO_TYPE_SPECIFIC_IO(Str, (void *)&(x)), \
Float: TO_TYPE_SPECIFIC_IO(Float, (void *)&(x)), \
Int: TO_TYPE_SPECIFIC_IO(Int, (void *)&(x)), \
- In
Io.h:220:
/// TAGS: Formatting, I/O, String
///
bool StrWriteFmtInternal(Str *o, const char *fmt, TypeSpecificIO *args, u64 argc);
///
- In
Io.h:430:
TypeSpecificIO *argv_ = &(varr)[0]; \
u64 argc_ = sizeof(varr) / sizeof(TypeSpecificIO) - 1; \
Str out_ = StrInit(); \
StrWriteFmtInternal(&out_, (fmtstr), argv_, argc_); \
fwrite(out_.data, 1, out_.length, (stream)); \
- In
Io.h:468:
TypeSpecificIO *argv_ = &(varr)[0]; \
u64 argc_ = sizeof(varr) / sizeof(TypeSpecificIO) - 1; \
Str out_ = StrInit(); \
StrWriteFmtInternal(&out_, (fmtstr), argv_, argc_); \
fwrite(out_.data, 1, out_.length, (stream)); \
- In
Io.h:532:
// not for direct use
void _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
void _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);- In
Io.h:533:
// not for direct use
void _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
void _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);- In
Io.h:534:
void _write_Str(Str *o, FmtInfo *fmt_info, Str *s);
void _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);- In
Io.h:535:
void _write_u8(Str *o, FmtInfo *fmt_info, u8 *v);
void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);- In
Io.h:536:
void _write_u16(Str *o, FmtInfo *fmt_info, u16 *v);
void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);- In
Io.h:537:
void _write_u32(Str *o, FmtInfo *fmt_info, u32 *v);
void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);- In
Io.h:538:
void _write_u64(Str *o, FmtInfo *fmt_info, u64 *v);
void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);- In
Io.h:539:
void _write_i8(Str *o, FmtInfo *fmt_info, i8 *v);
void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);- In
Io.h:540:
void _write_i16(Str *o, FmtInfo *fmt_info, i16 *v);
void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);
void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);- In
Io.h:541:
void _write_i32(Str *o, FmtInfo *fmt_info, i32 *v);
void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);
void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);
void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);- In
Io.h:542:
void _write_i64(Str *o, FmtInfo *fmt_info, i64 *v);
void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);
void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);
void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);- In
Io.h:543:
void _write_Zstr(Str *o, FmtInfo *fmt_info, const char **s);
void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);
void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
void _write_Float(Str *o, FmtInfo *fmt_info, Float *value);- In
Io.h:544:
void _write_UnsupportedType(Str *o, FmtInfo *fmt_info, const char **s);
void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
void _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
void _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);- In
Io.h:545:
void _write_f32(Str *o, FmtInfo *fmt_info, f32 *v);
void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
void _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
void _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
void _write_Int(Str *o, FmtInfo *fmt_info, Int *value);- In
Io.h:546:
void _write_f64(Str *o, FmtInfo *fmt_info, f64 *v);
void _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
void _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
void _write_Int(Str *o, FmtInfo *fmt_info, Int *value);- In
Io.h:547:
void _write_Float(Str *o, FmtInfo *fmt_info, Float *value);
void _write_BitVec(Str *o, FmtInfo *fmt_info, BitVec *bv);
void _write_Int(Str *o, FmtInfo *fmt_info, Int *value);
const char *_read_Str(const char *i, FmtInfo *fmt_info, Str *s);- In
Io.h:549:
void _write_Int(Str *o, FmtInfo *fmt_info, Int *value);
const char *_read_Str(const char *i, FmtInfo *fmt_info, Str *s);
const char *_read_u8(const char *i, FmtInfo *fmt_info, u8 *v);
const char *_read_u16(const char *i, FmtInfo *fmt_info, u16 *v);- In
Container.h:16:
#define MISRA_STD_CONTAINER_H
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Container/Vec.h>
#include <Misra/Std/Container/List.h>- In
Log.h:34:
#define LOG_FATAL(...) \
do { \
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, m_.data); \- In
Log.h:53:
#define LOG_ERROR(...) \
do { \
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, m_.data); \- In
Log.h:71:
#define LOG_INFO(...) \
do { \
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, m_.data); \- In
Log.h:92:
#define LOG_SYS_FATAL(...) \
do { \
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
Str syserr_; \- In
Log.h:94:
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
Str syserr_; \
StrInitStack(syserr_, 256, { \
SysStrError(errno, &syserr_); \
- In
Log.h:119:
#define LOG_SYS_ERROR(...) \
do { \
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
Str syserr_; \- In
Log.h:121:
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
Str syserr_; \
StrInitStack(syserr_, 256, { \
SysStrError(errno, &syserr_); \
- In
Log.h:145:
#define LOG_SYS_INFO(...) \
do { \
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
Str syserr_; \- In
Log.h:147:
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
Str syserr_; \
StrInitStack(syserr_, 256, { \
SysStrError(errno, &syserr_); \
- 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"
// clang-format on
- In
Str.h:19:
#include "Str/Convert.h"
#include "Str/Foreach.h"
#include "Str/Ops.h"
// clang-format on
- In
Convert.h:56:
/// FAILURE : Returns NULL if config is invalid
///
Str *StrFromU64(Str *str, u64 value, const StrIntFormat *config);
///
- In
Convert.h:68:
/// FAILURE : Returns NULL if config is invalid
///
Str *StrFromI64(Str *str, i64 value, const StrIntFormat *config);
///
- In
Convert.h:80:
/// FAILURE : Returns NULL if config is invalid
///
Str *StrFromF64(Str *str, f64 value, const StrFloatFormat *config);
///
- In
Convert.h:92:
/// FAILURE : Returns false if conversion fails
///
bool StrToU64(const Str *str, u64 *value, const StrParseConfig *config);
///
- In
Convert.h:104:
/// FAILURE : Returns false if conversion fails
///
bool StrToI64(const Str *str, i64 *value, const StrParseConfig *config);
///
- In
Convert.h:116:
/// FAILURE : Returns false if conversion fails
///
bool StrToF64(const Str *str, f64 *value, const StrParseConfig *config);
- In
Init.h:20:
#ifdef __cplusplus
# define StrInitFromCstr(cstr, len) \
(Str { \
.data = ZstrDupN((char *)(cstr), (len)), \
.length = (len), \- In
Init.h:48:
///
# define StrInitFromCstr(cstr, len) \
((Str) {.data = ZstrDupN((char *)(cstr), (len)), \
.length = (len), \
.capacity = (len), \- In
Init.h:93:
/// FAILURE : NULL
///
Str *StrPrintf(Str *str, const char *fmt, ...) FORMAT_STRING(2, 3);
#ifdef __cplusplus- In
Init.h:96:
#ifdef __cplusplus
# define StrInit() (Str VecInit())
#else
///
- In
Init.h:106:
/// FAILURE : NULL
///
# define StrInit() ((Str)VecInit())
#endif- In
Init.h:126:
/// str : Pointer to string to be deinited
///
void StrDeinit(Str *str);
///
- In
Init.h:137:
/// FAILURE : false
///
bool StrInitCopy(Str *dst, const Str *src);
#ifdef __cplusplus- In
Ops.h:106:
/// FAILURE : Returns false.
///
bool StrStartsWithZstr(const Str *s, const char *prefix);
///
- In
Ops.h:117:
/// FAILURE : Returns false.
///
bool StrEndsWithZstr(const Str *s, const char *suffix);
///
- In
Ops.h:129:
/// FAILURE : Returns false.
///
bool StrStartsWithCstr(const Str *s, const char *prefix, size prefix_len);
///
- In
Ops.h:141:
/// FAILURE : Returns false.
///
bool StrEndsWithCstr(const Str *s, const char *suffix, size suffix_len);
///
- In
Ops.h:152:
/// FAILURE : Returns false.
///
bool StrStartsWith(const Str *s, const Str *prefix);
///
- In
Ops.h:163:
/// FAILURE : Returns false.
///
bool StrEndsWith(const Str *s, const Str *suffix);
//
- In
Ops.h:180:
/// FAILURE : No replacement if `match` not found.
///
void StrReplaceZstr(Str *s, const char *match, const char *replacement, size count);
///
- In
Ops.h:196:
///
void StrReplaceCstr(
Str *s,
const char *match,
size match_len,- In
Ops.h:215:
/// FAILURE : No replacement if `match` not found.
///
void StrReplace(Str *s, const Str *match, const Str *replacement, size count);
//
- In
Ops.h:236:
/// FAILURE : StrIters vector of zero-length
///
StrIters StrSplitToIters(Str *s, const char *key);
///
- In
Ops.h:253:
/// FAILURE : Strs vector of zero-length
///
Strs StrSplit(Str *s, const char *key);
//
- In
Ops.h:263:
/// Used by StrStrip, StrLStrip, and StrRStrip macros.
///
Str strip_str(Str *s, const char *key, int split_direction);
///
- In
Type.h:23:
/// Vector of strings
///
typedef Vec(Str) Strs;
///
- In
Type.h:35:
/// FAILURE: `abort`
///
void ValidateStr(const Str *s);
///
- In
Insert.h:228:
/// FAILURE : NULL
///
Str *StrAppendf(Str *str, const char *fmt, ...) FORMAT_STRING(2, 3);
#ifdef __cplusplus- In
Convert.h:12:
#include "Type.h"
#include <Misra/Types.h>
#include <Misra/Std/Container/Str.h>
#ifdef __cplusplus- In
Convert.h:33:
/// TAGS: BitVec, Convert, String, Export
///
Str BitVecToStr(BitVec *bv);
///
- In
Convert.h:11:
#include "Private.h"
#include <Misra/Std/Container/Str.h>
#ifdef __cplusplus- In
Convert.h:161:
/// TAGS: Int, Convert, String, Radix, Export
///
Str IntToStrRadix(Int *value, u8 radix, bool uppercase);
///
- In
Convert.h:190:
/// TAGS: Int, Convert, Decimal, String, Export
///
Str IntToStr(Int *value);
///
- In
Convert.h:219:
/// TAGS: Int, Convert, Binary, String, Export
///
Str IntToBinary(Int *value);
///
- In
Convert.h:248:
/// TAGS: Int, Convert, Octal, String, Export
///
Str IntToOctStr(Int *value);
///
- In
Convert.h:279:
/// TAGS: Int, Convert, Hex, String, Export
///
Str IntToHexStr(Int *value);
#ifdef __cplusplus- In
Convert.h:11:
#include "Private.h"
#include <Misra/Std/Container/Str.h>
#ifdef __cplusplus- In
Convert.h:95:
/// TAGS: Float, Convert, String, Format
///
Str FloatToStr(Float *value);
#ifdef __cplusplus- In
JSON.h:12:
#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:124:
/// TAGS: JSON, String, Parsing, EscapeSequences
///
StrIter JReadString(StrIter si, Str *str);
///
- In
JSON.h:218:
#define JR_STR(si, str) \
do { \
Str my_str = StrInit(); \
si = JReadString((si), &my_str); \
(str) = my_str; \- In
JSON.h:241:
do { \
if (!StrCmpZstr(&key, (k))) { \
Str my_str = StrInit(); \
si = JReadString((si), &my_str); \
(str) = my_str; \
- In
JSON.h:534:
\
\
Str key = StrInit(); \
\
/* key start */ \
- In
KvConfig.h:12:
#include <Misra/Std/Container/Map.h>
#include <Misra/Std/Container/Str.h>
#include <Misra/Std/Utility/StrIter.h>
#include <Misra/Types.h>- In
KvConfig.h:37:
/// TAGS: Parser, Config, KeyValue, Map
///
typedef Map(Str, Str) KvConfig;
///
- In
KvConfig.h:127:
/// FAILURE : Returns original iterator on invalid key.
///
StrIter KvConfigReadKey(StrIter si, Str *key);
///
- In
KvConfig.h:141:
/// FAILURE : Returns original iterator on parse error.
///
StrIter KvConfigReadValue(StrIter si, Str *value);
///
- In
KvConfig.h:155:
/// FAILURE : Returns original iterator on parse error.
///
StrIter KvConfigReadPair(StrIter si, Str *key, Str *value);
///
- In
KvConfig.h:186:
/// FAILURE : Empty `Str` if key does not exist.
///
Str KvConfigGet(KvConfig *cfg, const char *key);
///
- In
KvConfig.h:197:
/// FAILURE : `NULL` if key does not exist.
///
Str *KvConfigGetPtr(KvConfig *cfg, const char *key);
///
- In
Proc.h:12:
#include <Misra/Types.h>
#include <Misra/Std/Container/Str.h>
///
- In
Proc.h:92:
/// FAILURE: Return -1
///
i32 SysProcWriteToStdin(SysProc *proc, Str *buf);
///
- In
Proc.h:111:
/// FAILURE: Return -1
///
i32 SysProcReadFromStdout(SysProc *proc, Str *buf);
///
- In
Proc.h:122:
/// FAILURE: Return -1
///
i32 SysProcReadFromStderr(SysProc *proc, Str *buf);
///
- In
Proc.h:161:
/// TAGS: System, Process, Path
///
Str *SysGetCurrentExecutablePath(Str *exe_path);
#define SysProcReadFromStdoutFmt(p, ...) \- In
Proc.h:165:
#define SysProcReadFromStdoutFmt(p, ...) \
do { \
Str b_ = StrInit(); \
SysProcReadFromStdout((p), &b_); \
const char *in_ = b_.data; \- In
Proc.h:174:
#define SysProcReadFromStderrFmt(p, ...) \
do { \
Str b_ = StrInit(); \
SysProcReadFromStderr((p), &b_); \
const char *in_ = b_.data; \- In
Proc.h:183:
#define SysProcWriteToStdinFmt(p, ...) \
do { \
Str b_ = StrInit(); \
StrWriteFmt(&b_, __VA_ARGS__); \
SysProcWriteToStdin((p), &b_); \- In
Proc.h:191:
#define SysProcWriteToStdinFmtLn(p, ...) \
do { \
Str b_ = StrInit(); \
StrWriteFmt(&b_, __VA_ARGS__); \
StrPushBack(&b_, '\n'); \- In
Dir.h:4:
#define MISRA_SYS_DIR_H
#include <Misra/Std/Container/Str.h>
typedef enum SysDirEntryType {- In
Dir.h:36:
typedef struct SysDirEntry {
SysDirEntryType type;
Str name;
} SysDirEntry;
Last updated on