StrInit
StrInit
Description
Initialize given string.
str : Pointer to string memory that needs to be initialized.
Success
str
Failure
NULL
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Str.c:31:
void init_str(Str *str) {
*str = StrInit();
}- In
Str.c:43:
// Reinitialize the string
StrDeinit(str);
*str = StrInit();
break;
}- In
Str.c:91:
case STR_DEINIT : {
StrDeinit(str);
*str = StrInit(); // Reinitialize for continued fuzzing
break;
}- In
VecStr.c:21:
// Create Str with capacity
Str str = StrInit();
// Fill with data or generate simple pattern if not enough input
- In
Sys.c:53:
getenv_s(&requiredSize, env_var, requiredSize, name);
*value = StrInit();
value->data = env_var;
value->length = requiredSize;- In
Io.c:650:
}
Str buffer = StrInit();
int fd = FILENO(file);- In
Io.c:851:
{
Str result = StrInit();
const char *body = canonical.data;
const char *dot = NULL;- 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:1082:
}
// Create hex string for each character
Str hex = StrInit();
StrFromU64(&hex, c, &config);
// Ensure 2 digits with leading zero
- 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:1218:
// Create temporary buffer for number formatting
Str temp = StrInit();
// Determine base based on format flags
- In
Io.c:1310:
// Create temporary buffer for number formatting
Str temp = StrInit();
// Determine base based on format flags
- 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: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: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:2635:
size start_len = o->length;
Str temp = StrInit();
u8 radix = IntFmtRadixFromFlags(fmt_info);- In
Io.c:2846:
size token_len = 0;
const char *start = NULL;
Str temp = StrInit();
Float parsed = FloatInit();- 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
Str.c:74:
MemSet(dst, 0, sizeof(Str));
*dst = StrInit();
dst->copy_init = src->copy_init;
dst->copy_deinit = src->copy_deinit;- In
Str.c:90:
FREE(copy->data);
}
*copy = StrInit();
}- 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
Float.c:265:
Float FloatFromStr(const char *text) {
Float result = FloatInit();
Str digits = StrInit();
size pos = 0;
bool negative = false;- 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:521:
Int current = IntClone(value);
Str result = StrInit();
while (!IntIsZero(¤t)) {- In
BitVec.c:727:
ValidateBitVec(bv);
Str result = StrInit();
if (bv->length == 0) {
return result;- 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:427:
if (!value) {
return StrInit();
}- In
JSON.c:39:
}
Str key = StrInit();
// key start
- 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
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: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: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:67:
Str src = StrInitFromZstr("host = localhost\n");
StrIter input = StrIterFromStr(src);
Str host_copy = StrInit();
Str *stored_host = NULL;
bool result = true; 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 {
bool success = true;
Str json = StrInit();
struct {
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};
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
bool success = true;
Str json = StrInit();
Vec(u32) numbers = VecInit();- 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, {
Person person = {0};
person.name = StrInit();
JR_OBJ(si, {
Config config = {0};
config.log_level = StrInit();
JR_OBJ(si, { JR_OBJ(si, {
JR_ARR_KV(si, "languages", {
Str lang = StrInit();
JR_STR(si, lang);
VecPushBack(&languages, lang); bool active;
} data = {
{StrInit(), StrInit()},
false
};
SimpleProduct product = {0};
product.name = StrInit();
product.tags = VecInitWithDeepCopyT(product.tags, NULL, StrDeinit); JR_FLT_KV(si, "price", product.price);
JR_ARR_KV(si, "tags", {
Str tag = StrInit();
JR_STR(si, tag);
VecPushBack(&product.tags, tag); bool active;
f64 score;
} data = {0, StrInit(), false, 0.0};
JR_OBJ(si, { Str status;
} data = {
{0, {StrInit(), 0}},
StrInit()
}; } data = {
{0, {StrInit(), 0}},
StrInit()
}; } company;
} data = {
{{{StrInit(), 0, 0.0}}, StrInit()}
}; // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit(); AnnSymbol sym = {0};
sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit(); sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit();
sym.source_function_id = source_function_id; sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit();
sym.source_function_id = source_function_id;
sym.target_function_id = target_function_id; StrIter si = StrIterFromStr(json);
ApiResponse response = {false, StrInit(), VecInitWithDeepCopy(NULL, AnnSymbolDeinit)};
JR_OBJ(si, { // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit(); AnnSymbol sym = {0};
sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit(); sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit();
sym.source_function_id = source_function_id; sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit();
sym.source_function_id = source_function_id;
sym.target_function_id = strtoull(key.data, NULL, 10);
FunctionInfo info = {0};
info.name = StrInit();
JR_OBJ(si, {
ModelInfo info = {0};
info.name = StrInit();
JR_OBJ(si, {
SearchResult result = {0};
result.binary_name = StrInit();
result.sha256 = StrInit();
result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit); SearchResult result = {0};
result.binary_name = StrInit();
result.sha256 = StrInit();
result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit);
result.created_at = StrInit(); result.sha256 = StrInit();
result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit);
result.created_at = StrInit();
result.model_name = StrInit();
result.owned_by = StrInit(); result.tags = VecInitWithDeepCopyT(result.tags, NULL, StrDeinit);
result.created_at = StrInit();
result.model_name = StrInit();
result.owned_by = StrInit(); result.created_at = StrInit();
result.model_name = StrInit();
result.owned_by = StrInit();
JR_OBJ(si, { StrIter si = StrIterFromStr(json);
ApiResponse response = {false, StrInit(), VecInitWithDeepCopy(NULL, AnnSymbolDeinit)};
WriteFmt("[DEBUG] About to parse JSON...\n"); // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit(); AnnSymbol sym = {0};
sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit(); sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit();
sym.source_function_id = source_function_id; sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit();
sym.source_function_id = source_function_id;
sym.target_function_id = strtoull(key.data, NULL, 10); StrIter si = StrIterFromStr(json);
ApiResponse response = {false, StrInit(), VecInitWithDeepCopy(NULL, AnnSymbolDeinit)};
WriteFmt("[DEBUG] About to parse JSON...\n"); // Properly initialize all Str fields
AnnSymbol sym = {0};
sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit(); AnnSymbol sym = {0};
sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit(); sym.analysis_name = StrInit();
sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit();
sym.source_function_id = source_function_id; sym.function_name = StrInit();
sym.sha256 = StrInit();
sym.function_mangled_name = StrInit();
sym.source_function_id = source_function_id;
sym.target_function_id = strtoull(key.data, NULL, 10); // 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();
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
bool success = true;
Str json = StrInit();
// These contain actual special characters that should be escaped
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
// 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");
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);
bool success = true;
Str json = StrInit();
struct {
bool success = true;
Str json = StrInit();
SimpleProduct product = {0};- In
RoundTrip.c:99:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_INT_KV(json, "count", original.count);- In
RoundTrip.c:115:
bool enabled;
Str message;
} parsed = {0, 0.0, false, StrInit()};
StrIter si = StrIterFromStr(json);- 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:291:
Str with_special;
} original = {
StrInit(),
StrInitFromZstr("hello"),
StrInitFromZstr("hello world with spaces"),- In
RoundTrip.c:298:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_STR_KV(json, "empty", original.empty);- In
RoundTrip.c:312:
Str with_spaces;
Str with_special;
} parsed = {StrInit(), StrInit(), StrInit(), StrInit()};
StrIter si = StrIterFromStr(json);- 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: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:470:
// Read back from JSON
TestPerson parsed_person = {0, StrInit(), 0, false, 0.0};
StrIter si = StrIterFromStr(json);- In
RoundTrip.c:537:
// Write to JSON
Str json = StrInit();
JW_OBJ(json, {
JW_OBJ_KV(json, "user", {- In
RoundTrip.c:560:
// Read back from JSON
ComplexData parsed = {0};
parsed.user = (TestPerson) {0, StrInit(), 0, false, 0.0};
parsed.config.debug_mode = true; // opposite of original
parsed.config.timeout = 0;- In
RoundTrip.c:563:
parsed.config.debug_mode = true; // opposite of original
parsed.config.timeout = 0;
parsed.config.log_level = StrInit();
parsed.config.features = VecInitWithDeepCopyT(parsed.config.features, NULL, StrDeinit);
parsed.numbers = VecInitT(parsed.numbers);- 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: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: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); JR_OBJ(si2, {
JR_ARR_KV(si2, "data", {
Str value = StrInit();
JR_STR(si2, value);
VecPushBack(&data, value); Str name;
Str description;
} obj = {StrInit(), StrInit()};
JR_OBJ(si, { Str message;
Str data;
} obj = {StrInit(), StrInit(), StrInit()};
JR_OBJ(si, { Str newline;
Str tab;
} obj = {StrInit(), StrInit(), StrInit(), StrInit()};
JR_OBJ(si, { i32 value;
bool flag;
} obj = {StrInit(), 0, false};
JR_OBJ(si, {- 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
Io.Read.c:342:
// Test basic string reading
Str s = StrInit();
z = "Hello";
StrReadFmt(z, "{}", s);- 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:588:
success = success && abc_pass;
Str str_val = StrInit();
z = "Hello";
StrReadFmt(z, "{c}", str_val);- In
Io.Read.c:598:
StrDeinit(&str_val);
str_val = StrInit();
z = "\"World\"";
StrReadFmt(z, "{cs}", str_val);- In
Io.Read.c:622:
// Test 1: :a (lowercase) conversion
{
Str result = StrInit();
const char *in = "Hello World";- In
Io.Read.c:647:
// Test 1.1: :a (lowercase) conversion
{
Str result = StrInit();
const char *in = "Hello World";- In
Io.Read.c:672:
// Test 2: :A (uppercase) conversion
{
Str result = StrInit();
const char *in = "hello world";- 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:766:
// Test 4: :A with quoted string containing special characters
{
Str result = StrInit();
const char *in = "\"abc123XYZ\"";- 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: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:25:
// Create a Str object
Str s = StrInit();
// Check that it behaves like a Vec of chars
- 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
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: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: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: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: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: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
// Build a new string by iterating through each character pointer in reverse with its index
Str result = StrInit();
StrForeachReversePtrIdx(&s, chrptr, idx) {
// Build a new string by iterating through each character
Str result = StrInit();
StrForeach(&s, chr) {
// Append the character to the result string
// Build a new string by iterating through each character in reverse
Str result = StrInit();
size char_count = 0;
// 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
// Build a new string by iterating through each character pointer in reverse
Str result = StrInit();
size char_count = 0;
// 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
// 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
// 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
// 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
- 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
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}; // 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 (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}; // 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}; 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);- In
Str.Memory.c:21:
WriteFmt("Testing StrTryReduceSpace\n");
Str s = StrInit();
// Reserve more space than needed
- In
Str.Memory.c:94:
WriteFmt("Testing StrReserve\n");
Str s = StrInit();
// Reserve more space
- In
Str.Memory.c:171:
// Test with an empty string
StrDeinit(&s);
s = StrInit();
// Reverse the string
Float value = FloatFromStr("1234500e-2");
Int result_value = IntInit();
Str text = StrInit();
bool result = FloatToInt(&result_value, &value);- 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
Str.Init.c:23:
// Test StrInit function
bool test_str_init(void) {
WriteFmt("Testing StrInit\n");
Str s = StrInit();- In
Str.Init.c:25:
WriteFmt("Testing StrInit\n");
Str s = StrInit();
// Validate the string
- In
Str.Init.c:115:
WriteFmt("Testing StrWriteFmt\n");
Str s = StrInit();
StrWriteFmt(&s, "Hello, {}!", &"World"[0]);- In
Str.Init.c:167:
Str src = StrInitFromZstr("Hello, World!");
Str dst = StrInit();
// Copy src to dst
- 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
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:119:
#define LOG_SYS_ERROR(...) \
do { \
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
Str syserr_; \- In
Log.h:145:
#define LOG_SYS_INFO(...) \
do { \
Str m_ = StrInit(); \
StrWriteFmt(&m_, __VA_ARGS__); \
Str syserr_; \- In
Init.h:96:
#ifdef __cplusplus
# define StrInit() (Str VecInit())
#else
///
- 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
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'); \
Last updated on