StrAppendFmt
Description
Append a formatted string to out. Existing contents are preserved; new content lands at the end of the buffer.
Parameters
| Name | Direction | Description |
|---|---|---|
out |
out | Destination Str. Existing bytes are kept. |
fmtstr |
in | Format string with {} placeholders. |
Success
out extended with the formatted content; returns true.
Failure
Returns false. May log diagnostics; out may be left partially extended on allocation failure mid-write.
Usage example (Cross-references)
Usage examples (Cross-references)
Str source_key = StrInit(&alloc);
u64 source_id = response.data.length > 0 ? VecAt(&response.data, 0).source_function_id : 0;
StrAppendFmt(&source_key, "{}", source_id);
JW_OBJ_KV(json, source_key.data, { AnnSymbol *s = &VecAt(&response.data, 0);
Str target_key = StrInit(&alloc);
StrAppendFmt(&target_key, "{}", s->target_function_id);
JW_OBJ_KV(json, target_key.data, { VecForeach(&symbols, symbol) {
Str source_key = StrInit(&alloc);
StrAppendFmt(&source_key, "{}", symbol.source_function_id);
JW_OBJ_KV(json, source_key.data, { JW_OBJ_KV(json, source_key.data, {
Str target_key = StrInit(&alloc);
StrAppendFmt(&target_key, "{}", symbol.target_function_id);
JW_OBJ_KV(json, target_key.data, {- In
Str.Init.c:149:
// Test StrAppendFmt function
bool test_str_WriteFmt(void) {
WriteFmt("Testing StrAppendFmt\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Str.Init.c:154:
Str s = StrInit(&alloc);
StrAppendFmt(&s, "Hello, {}!", &"World"[0]);
// Validate the string
- In
Http.c:40:
HttpResponse response = HttpResponseInit(alloc_base);
Str body = StrInit(alloc_base);
StrAppendFmt(&body, "<h1>hi</h1>");
HttpRespondWithHtml(&response, HTTP_RESPONSE_CODE_OK, &body);
StrDeinit(&body);- In
Str.Foreach.c:44:
Str result = StrInit(&alloc);
StrForeachIdx(&s, chr, idx) {
StrAppendFmt(&result, "{c}{}", chr, idx);
}- In
Str.Foreach.c:69:
StrForeachReverseIdx(&s, chr, idx) {
// Append the character and its index to the result string
StrAppendFmt(&result, "{c}{}", chr, idx);
}- In
Str.Foreach.c:93:
StrForeachPtrIdx(&s, chrptr, idx) {
// Append the character (via pointer) and its index to the result string
StrAppendFmt(&result, "{c}{}", *chrptr, idx);
// Modify the original string by converting to uppercase
StrForeachReversePtrIdx(&s, chrptr, idx) {
// Append the character (via pointer) and its index to the result string
StrAppendFmt(&result, "{c}{}", *chrptr, idx);
// Modify the original string by converting to uppercase
StrForeachInRangeIdx(&s, chr, idx, 6, 11) {
// Append the character and its index to the result string
StrAppendFmt(&result, "{c}{}", chr, idx);
} StrForeachPtrInRangeIdx(&s, chrptr, idx, 6, 11) {
// Append the character and its index to the result string
StrAppendFmt(&result, "{c}{}", *chrptr, idx);
// Modify the original string by converting to uppercase
- In
Io.Write.c:44:
// Test empty format string
StrAppendFmt(&output, "");
success = success && (output.length == 0);
StrClear(&output);- In
Io.Write.c:49:
// Test literal text
StrAppendFmt(&output, "Hello, world!");
success = success && (ZstrCompare(output.data, "Hello, world!") == 0);
StrClear(&output);- In
Io.Write.c:54:
// Test escaped braces
StrAppendFmt(&output, "{{Hello}}");
success = success && (ZstrCompare(output.data, "{Hello}") == 0);
StrClear(&output);- In
Io.Write.c:59:
// Test double escaped braces
StrAppendFmt(&output, "{{{{");
success = success && (ZstrCompare(output.data, "{{") == 0);- In
Io.Write.c:78:
// Test basic string
const char *str = "Hello";
StrAppendFmt(&output, "{}", str);
success = success && (ZstrCompare(output.data, "Hello") == 0);
StrClear(&output);- In
Io.Write.c:84:
// Test empty string
const char *empty = "";
StrAppendFmt(&output, "{}", empty);
success = success && (output.length == 0);
StrClear(&output);- In
Io.Write.c:89:
// Test string with width and alignment
StrAppendFmt(&output, "{>10}", str);
success = success && (ZstrCompare(output.data, " Hello") == 0);
StrClear(&output);- In
Io.Write.c:93:
StrClear(&output);
StrAppendFmt(&output, "{<10}", str);
success = success && (ZstrCompare(output.data, "Hello ") == 0);
StrClear(&output);- In
Io.Write.c:97:
StrClear(&output);
StrAppendFmt(&output, "{^10}", str);
success = success && (ZstrCompare(output.data, " Hello ") == 0);
StrClear(&output);- In
Io.Write.c:103:
// Test Str object
Str s = StrInitFromZstr("World", &alloc);
StrAppendFmt(&output, "{}", s);
success = success && (ZstrCompare(output.data, "World") == 0);
StrDeinit(&s);- In
Io.Write.c:123:
// Test signed integers
i8 i8_val = -42;
StrAppendFmt(&output, "{}", i8_val);
success = success && (ZstrCompare(output.data, "-42") == 0);
StrClear(&output);- In
Io.Write.c:128:
i16 i16_val = -1234;
StrAppendFmt(&output, "{}", i16_val);
success = success && (ZstrCompare(output.data, "-1234") == 0);
StrClear(&output);- In
Io.Write.c:133:
i32 i32_val = -123456;
StrAppendFmt(&output, "{}", i32_val);
success = success && (ZstrCompare(output.data, "-123456") == 0);
StrClear(&output);- In
Io.Write.c:138:
i64 i64_val = -1234567890LL;
StrAppendFmt(&output, "{}", i64_val);
success = success && (ZstrCompare(output.data, "-1234567890") == 0);
StrClear(&output);- In
Io.Write.c:144:
// Test unsigned integers
u8 u8_val = 42;
StrAppendFmt(&output, "{}", u8_val);
success = success && (ZstrCompare(output.data, "42") == 0);
StrClear(&output);- In
Io.Write.c:149:
u16 u16_val = 1234;
StrAppendFmt(&output, "{}", u16_val);
success = success && (ZstrCompare(output.data, "1234") == 0);
StrClear(&output);- In
Io.Write.c:154:
u32 u32_val = 123456;
StrAppendFmt(&output, "{}", u32_val);
success = success && (ZstrCompare(output.data, "123456") == 0);
StrClear(&output);- In
Io.Write.c:159:
u64 u64_val = 1234567890ULL;
StrAppendFmt(&output, "{}", u64_val);
success = success && (ZstrCompare(output.data, "1234567890") == 0);
StrClear(&output);- In
Io.Write.c:165:
// Test edge cases
i8 i8_max = 127;
StrAppendFmt(&output, "{}", i8_max);
success = success && (ZstrCompare(output.data, "127") == 0);
StrClear(&output);- In
Io.Write.c:170:
i8 i8_min = -128;
StrAppendFmt(&output, "{}", i8_min);
success = success && (ZstrCompare(output.data, "-128") == 0);
StrClear(&output);- In
Io.Write.c:175:
u8 u8_max = 255;
StrAppendFmt(&output, "{}", u8_max);
success = success && (ZstrCompare(output.data, "255") == 0);
StrClear(&output);- In
Io.Write.c:180:
u8 u8_min = 0;
StrAppendFmt(&output, "{}", u8_min);
success = success && (ZstrCompare(output.data, "0") == 0);- In
Io.Write.c:198:
u32 val = 0xDEADBEEF;
StrAppendFmt(&output, "{x}", val);
success = success && (ZstrCompare(output.data, "0xdeadbeef") == 0);
StrClear(&output);- In
Io.Write.c:202:
StrClear(&output);
StrAppendFmt(&output, "{X}", val);
success = success && (ZstrCompare(output.data, "0xDEADBEEF") == 0);- In
Io.Write.c:220:
u8 val = 0xA5; // 10100101 in binary
StrAppendFmt(&output, "{b}", val);
success = success && (ZstrCompare(output.data, "0b10100101") == 0);- In
Io.Write.c:238:
u16 val = 0777;
StrAppendFmt(&output, "{o}", val);
success = success && (ZstrCompare(output.data, "0o777") == 0);- In
Io.Write.c:256:
f32 f32_val = 3.14159f;
StrAppendFmt(&output, "{}", f32_val);
success = success && (ZstrCompare(output.data, "3.141590") == 0);
StrClear(&output);- In
Io.Write.c:261:
f64 f64_val = 2.71828;
StrAppendFmt(&output, "{}", f64_val);
success = success && (ZstrCompare(output.data, "2.718280") == 0);- In
Io.Write.c:281:
// Test different precisions
StrAppendFmt(&output, "{.2}", val);
success = success && (ZstrCompare(output.data, "3.14") == 0);
StrClear(&output);- In
Io.Write.c:285:
StrClear(&output);
StrAppendFmt(&output, "{.0}", val);
success = success && (ZstrCompare(output.data, "3") == 0);
StrClear(&output);- In
Io.Write.c:289:
StrClear(&output);
StrAppendFmt(&output, "{.10}", val);
success = success && (ZstrCompare(output.data, "3.1415926536") == 0);- In
Io.Write.c:308:
// Test infinity
f64 pos_inf = INFINITY;
StrAppendFmt(&output, "{}", pos_inf);
success = success && (ZstrCompare(output.data, "inf") == 0);
StrClear(&output);- In
Io.Write.c:313:
f64 neg_inf = -INFINITY;
StrAppendFmt(&output, "{}", neg_inf);
success = success && (ZstrCompare(output.data, "-inf") == 0);
StrClear(&output);- In
Io.Write.c:319:
// Test NaN
f64 nan_val = NAN;
StrAppendFmt(&output, "{}", nan_val);
success = success && (ZstrCompare(output.data, "nan") == 0);- In
Io.Write.c:338:
// Test with integers
i32 val = 42;
StrAppendFmt(&output, "{5}", val);
success = success && (ZstrCompare(output.data, " 42") == 0);
StrClear(&output);- In
Io.Write.c:342:
StrClear(&output);
StrAppendFmt(&output, "{<5}", val);
success = success && (ZstrCompare(output.data, "42 ") == 0);
StrClear(&output);- In
Io.Write.c:346:
StrClear(&output);
StrAppendFmt(&output, "{^5}", val);
success = success && (ZstrCompare(output.data, " 42 ") == 0);
StrClear(&output);- In
Io.Write.c:352:
// Test with strings
const char *str = "abc";
StrAppendFmt(&output, "{5}", str);
success = success && (ZstrCompare(output.data, " abc") == 0);
StrClear(&output);- In
Io.Write.c:356:
StrClear(&output);
StrAppendFmt(&output, "{<5}", str);
success = success && (ZstrCompare(output.data, "abc ") == 0);
StrClear(&output);- In
Io.Write.c:360:
StrClear(&output);
StrAppendFmt(&output, "{^5}", str);
success = success && (ZstrCompare(output.data, " abc ") == 0);- In
Io.Write.c:381:
f64 pi = 3.14;
StrAppendFmt(&output, "{} {} {}", hello, num, pi);
success = success && (ZstrCompare(output.data, "Hello 42 3.140000") == 0);
StrClear(&output);- In
Io.Write.c:386:
// Instead of using positional arguments, we'll just reorder the arguments themselves
StrAppendFmt(&output, "{} {} {}", pi, hello, num);
success = success && (ZstrCompare(output.data, "3.140000 Hello 42") == 0);- In
Io.Write.c:405:
// Test mixed case string with :c (preserve case)
const char *mixed_case = "MiXeD CaSe";
StrAppendFmt(&output, "{c}", mixed_case);
success = success && (ZstrCompare(output.data, "MiXeD CaSe") == 0);
StrClear(&output);- In
Io.Write.c:410:
// Test mixed case string with :a (lowercase)
StrAppendFmt(&output, "{a}", mixed_case);
success = success && (ZstrCompare(output.data, "mixed case") == 0);
StrClear(&output);- In
Io.Write.c:415:
// Test mixed case string with :A (uppercase)
StrAppendFmt(&output, "{A}", mixed_case);
success = success && (ZstrCompare(output.data, "MIXED CASE") == 0);
StrClear(&output);- In
Io.Write.c:423:
// Test with :c (preserve case)
StrAppendFmt(&output, "{c}", s);
success = success && (ZstrCompare(output.data, "MiXeD CaSe") == 0);
StrClear(&output);- In
Io.Write.c:428:
// Test with :a (lowercase)
StrAppendFmt(&output, "{a}", s);
success = success && (ZstrCompare(output.data, "mixed case") == 0);
StrClear(&output);- In
Io.Write.c:433:
// Test with :A (uppercase)
StrAppendFmt(&output, "{A}", s);
success = success && (ZstrCompare(output.data, "MIXED CASE") == 0);
StrClear(&output);- In
Io.Write.c:442:
// Test uppercase char with :c (preserve case)
StrAppendFmt(&output, "{c}", upper_char);
success = success && (ZstrCompare(output.data, "M") == 0);
StrClear(&output);- In
Io.Write.c:447:
// Test uppercase char with :a (lowercase)
StrAppendFmt(&output, "{a}", upper_char);
success = success && (ZstrCompare(output.data, "m") == 0);
StrClear(&output);- In
Io.Write.c:452:
// Test lowercase char with :A (uppercase)
StrAppendFmt(&output, "{A}", lower_char);
success = success && (ZstrCompare(output.data, "M") == 0);
StrClear(&output);- In
Io.Write.c:460:
// Test u16 with :c (preserve case)
StrAppendFmt(&output, "{c}", u16_value);
success = success && (output.length == 2 && output.data[0] == 'A' && output.data[1] == 'B');
StrClear(&output);- In
Io.Write.c:465:
// Test u16 with :a (lowercase)
StrAppendFmt(&output, "{a}", u16_value);
success = success && (output.length == 2 && output.data[0] == 'a' && output.data[1] == 'b');
StrClear(&output);- In
Io.Write.c:470:
// Test u16 with :A (uppercase)
StrAppendFmt(&output, "{A}", u16_value);
success = success && (output.length == 2 && output.data[0] == 'A' && output.data[1] == 'B');
StrClear(&output);- In
Io.Write.c:478:
// Test i16 with :c (preserve case)
StrAppendFmt(&output, "{c}", i16_value);
success = success && (output.length == 2 && output.data[0] == 'C' && output.data[1] == 'd');
StrClear(&output);- In
Io.Write.c:483:
// Test i16 with :a (lowercase)
StrAppendFmt(&output, "{a}", i16_value);
success = success && (output.length == 2 && output.data[0] == 'c' && output.data[1] == 'd');
StrClear(&output);- In
Io.Write.c:488:
// Test i16 with :A (uppercase)
StrAppendFmt(&output, "{A}", i16_value);
success = success && (output.length == 2 && output.data[0] == 'C' && output.data[1] == 'D');
StrClear(&output);- In
Io.Write.c:496:
// Test u32 with :c (preserve case)
StrAppendFmt(&output, "{c}", u32_value);
success = success && (output.length == 4 && output.data[0] == 'E' && output.data[1] == 'f' &&
output.data[2] == 'G' && output.data[3] == 'h');- In
Io.Write.c:502:
// Test u32 with :a (lowercase)
StrAppendFmt(&output, "{a}", u32_value);
success = success && (output.length == 4 && output.data[0] == 'e' && output.data[1] == 'f' &&
output.data[2] == 'g' && output.data[3] == 'h');- In
Io.Write.c:508:
// Test u32 with :A (uppercase)
StrAppendFmt(&output, "{A}", u32_value);
success = success && (output.length == 4 && output.data[0] == 'E' && output.data[1] == 'F' &&
output.data[2] == 'G' && output.data[3] == 'H');- In
Io.Write.c:517:
// Test i32 with :c (preserve case)
StrAppendFmt(&output, "{c}", i32_value);
success = success && (output.length == 4 && output.data[0] == 'I' && output.data[1] == 'j' &&
output.data[2] == 'K' && output.data[3] == 'l');- In
Io.Write.c:523:
// Test i32 with :a (lowercase)
StrAppendFmt(&output, "{a}", i32_value);
success = success && (output.length == 4 && output.data[0] == 'i' && output.data[1] == 'j' &&
output.data[2] == 'k' && output.data[3] == 'l');- In
Io.Write.c:529:
// Test i32 with :A (uppercase)
StrAppendFmt(&output, "{A}", i32_value);
success = success && (output.length == 4 && output.data[0] == 'I' && output.data[1] == 'J' &&
output.data[2] == 'K' && output.data[3] == 'L');- In
Io.Write.c:539:
// Test u64 with :c (preserve case)
StrAppendFmt(&output, "{c}", u64_value);
success = success && (output.length == 8 && output.data[0] == 'M' && output.data[1] == 'n' &&
output.data[2] == 'O' && output.data[3] == 'p' && output.data[4] == 'Q' &&- In
Io.Write.c:546:
// Test u64 with :a (lowercase)
StrAppendFmt(&output, "{a}", u64_value);
success = success && (output.length == 8 && output.data[0] == 'm' && output.data[1] == 'n' &&
output.data[2] == 'o' && output.data[3] == 'p' && output.data[4] == 'q' &&- In
Io.Write.c:553:
// Test u64 with :A (uppercase)
StrAppendFmt(&output, "{A}", u64_value);
success = success && (output.length == 8 && output.data[0] == 'M' && output.data[1] == 'N' &&
output.data[2] == 'O' && output.data[3] == 'P' && output.data[4] == 'Q' &&- In
Io.Write.c:564:
// Test i64 with :c (preserve case)
StrAppendFmt(&output, "{c}", i64_value);
success = success && (output.length == 8 && output.data[0] == 'U' && output.data[1] == 'v' &&
output.data[2] == 'W' && output.data[3] == 'x' && output.data[4] == 'Y' &&- In
Io.Write.c:571:
// Test i64 with :a (lowercase)
StrAppendFmt(&output, "{a}", i64_value);
success = success && (output.length == 8 && output.data[0] == 'u' && output.data[1] == 'v' &&
output.data[2] == 'w' && output.data[3] == 'x' && output.data[4] == 'y' &&- In
Io.Write.c:578:
// Test i64 with :A (uppercase)
StrAppendFmt(&output, "{A}", i64_value);
success = success && (output.length == 8 && output.data[0] == 'U' && output.data[1] == 'V' &&
output.data[2] == 'W' && output.data[3] == 'X' && output.data[4] == 'Y' &&- In
Io.Write.c:601:
// Test 1: Basic binary formatting
BitVec bv1 = BitVecFromStr("10110", alloc_base);
StrAppendFmt(&output, "{}", bv1);
success = success && (ZstrCompare(output.data, "10110") == 0);
StrClear(&output);- In
Io.Write.c:607:
// Test 2: Empty BitVec
BitVec bv_empty = BitVecInit(alloc_base);
StrAppendFmt(&output, "{}", bv_empty);
success = success && (output.length == 0);
StrClear(&output);- In
Io.Write.c:613:
// Test 3: Hex formatting
BitVec bv2 = BitVecFromInteger(0xABCD, 16, alloc_base);
StrAppendFmt(&output, "{x}", bv2);
success = success && (ZstrCompare(output.data, "0xabcd") == 0);
StrClear(&output);- In
Io.Write.c:618:
// Test 4: Uppercase hex formatting
StrAppendFmt(&output, "{X}", bv2);
success = success && (ZstrCompare(output.data, "0xABCD") == 0);
StrClear(&output);- In
Io.Write.c:624:
// Test 5: Octal formatting
BitVec bv3 = BitVecFromInteger(0755, 10, alloc_base);
StrAppendFmt(&output, "{o}", bv3);
success = success && (ZstrCompare(output.data, "0o755") == 0);
StrClear(&output);- In
Io.Write.c:629:
// Test 6: Width and alignment
StrAppendFmt(&output, "{>10}", bv1);
success = success && (ZstrCompare(output.data, " 10110") == 0);
StrClear(&output);- In
Io.Write.c:633:
StrClear(&output);
StrAppendFmt(&output, "{<10}", bv1);
success = success && (ZstrCompare(output.data, "10110 ") == 0);
StrClear(&output);- In
Io.Write.c:637:
StrClear(&output);
StrAppendFmt(&output, "{^10}", bv1);
success = success && (ZstrCompare(output.data, " 10110 ") == 0);
StrClear(&output);- In
Io.Write.c:643:
// Test 7: Zero value
BitVec bv_zero = BitVecFromInteger(0, 1, alloc_base);
StrAppendFmt(&output, "{x}", bv_zero);
success = success && (ZstrCompare(output.data, "0x0") == 0);
StrClear(&output);- In
Io.Write.c:647:
StrClear(&output);
StrAppendFmt(&output, "{o}", bv_zero);
success = success && (ZstrCompare(output.data, "0o0") == 0);
StrClear(&output);- In
Io.Write.c:676:
Int oct_val = IntFrom(493, alloc_base);
StrAppendFmt(&output, "{}", big_dec);
success = success && (ZstrCompare(output.data, "123456789012345678901234567890") == 0);
StrClear(&output);- In
Io.Write.c:680:
StrClear(&output);
StrAppendFmt(&output, "{x}", hex_val);
success = success && (ZstrCompare(output.data, "deadbeefcafebabe1234") == 0);
StrClear(&output);- In
Io.Write.c:684:
StrClear(&output);
StrAppendFmt(&output, "{X}", hex_val);
success = success && (ZstrCompare(output.data, "DEADBEEFCAFEBABE1234") == 0);
StrClear(&output);- In
Io.Write.c:688:
StrClear(&output);
StrAppendFmt(&output, "{b}", bin_val);
success = success && (ZstrCompare(output.data, "10100011") == 0);
StrClear(&output);- In
Io.Write.c:692:
StrClear(&output);
StrAppendFmt(&output, "{o}", oct_val);
success = success && (ZstrCompare(output.data, "755") == 0);
StrClear(&output);- In
Io.Write.c:696:
StrClear(&output);
StrAppendFmt(&output, "{>34}", big_dec);
success = success && (ZstrCompare(output.data, " 123456789012345678901234567890") == 0);- In
Io.Write.c:720:
Float short_v = FloatFromStr("1.2", alloc_base);
StrAppendFmt(&output, "{}", exact);
success = success && (ZstrCompare(output.data, "1234567890.012345") == 0);
StrClear(&output);- In
Io.Write.c:724:
StrClear(&output);
StrAppendFmt(&output, "{e}", sci);
success = success && (ZstrCompare(output.data, "1.234567e+04") == 0);
StrClear(&output);- In
Io.Write.c:728:
StrClear(&output);
StrAppendFmt(&output, "{E}", sci);
success = success && (ZstrCompare(output.data, "1.234567E+04") == 0);
StrClear(&output);- In
Io.Write.c:732:
StrClear(&output);
StrAppendFmt(&output, "{.3}", short_v);
success = success && (ZstrCompare(output.data, "1.200") == 0);
StrClear(&output);- In
Io.Write.c:736:
StrClear(&output);
StrAppendFmt(&output, "{>18}", sci);
success = success && (ZstrCompare(output.data, " 12345.67") == 0);- In
Io.Write.c:771:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "old prefix ");
StrWriteFmt(&s, "fresh {}", LVAL(42));
bool ok = (s.length == 8) && (s.data[0] == 'f') && (s.data[s.length - 1] == '2');- In
Io.Write.c:786:
DefaultAllocator alloc = DefaultAllocatorInit();
Str s = StrInit(&alloc);
StrAppendFmt(&s, "AAAAAAAA");
size before_length = s.length;
bool ok = StrPatchFmt(&s, 2, "{}", LVAL(1234));- In
Str.Insert.c:360:
// StrAppendf printf-style formatter.
bool test_str_write_fmt_append(void) {
WriteFmt("Testing StrAppendFmt append\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Str.Insert.c:367:
// Append formatted suffix.
StrAppendFmt(&s, " {} {}", (const char *)"World", (u32)2023);
// Check that the string was appended correctly
- In
Sys.c:248:
Allocator *alloc = err_str->allocator;
Str out = StrInit(alloc);
StrAppendFmt(&out, "{} (errno {})", errno_description(eno), eno);
StrDeinit(err_str);
*err_str = out;- In
Backtrace.c:216:
if (named) {
StrAppendFmt(out, " #{} {}+{x} [{x}]", (u32)i, sym_name, (u64)sym_off, (u64)ip);
} else {
StrAppendFmt(out, " #{} {x}", (u32)i, (u64)ip);- In
Backtrace.c:218:
StrAppendFmt(out, " #{} {}+{x} [{x}]", (u32)i, sym_name, (u64)sym_off, (u64)ip);
} else {
StrAppendFmt(out, " #{} {x}", (u32)i, (u64)ip);
}- In
Backtrace.c:224:
if (g_dbghelp_initialized && SymGetLineFromAddr64(proc, ip, &line_disp, &line) && line.FileName) {
const char *fname = basename_of(line.FileName);
StrAppendFmt(out, " ({}:{})", fname, (u32)line.LineNumber);
}
StrPushBack(out, '\n');- In
Backtrace.c:416:
if (named) {
const char *mod = basename_of(mod_path);
StrAppendFmt(out, " #{} {}!{}+{x} [{x}]\n", (u32)i, mod, sym_name, (u64)sym_off, ip);
} else if (mod_path) {
const char *mod = basename_of(mod_path);- In
Backtrace.c:419:
} else if (mod_path) {
const char *mod = basename_of(mod_path);
StrAppendFmt(out, " #{} {}+? [{x}]\n", (u32)i, mod, ip);
} else {
StrAppendFmt(out, " #{} {x}\n", (u32)i, ip);- In
Backtrace.c:421:
StrAppendFmt(out, " #{} {}+? [{x}]\n", (u32)i, mod, ip);
} else {
StrAppendFmt(out, " #{} {x}\n", (u32)i, ip);
}
}- In
Backtrace.c:502:
if (r->symbol_name) {
const char *mod = basename_of(r->module_path);
StrAppendFmt(out, " #{} {}!{}+{x} [{x}]", idx, mod, r->symbol_name, r->offset, (u64)(uintptr_t)ip);
} else if (r->module_path) {
const char *mod = basename_of(r->module_path);- In
Backtrace.c:505:
} else if (r->module_path) {
const char *mod = basename_of(r->module_path);
StrAppendFmt(out, " #{} {}+{x} [{x}]", idx, mod, r->offset, (u64)(uintptr_t)ip);
} else {
StrAppendFmt(out, " #{} {x}", idx, (u64)(uintptr_t)ip);- In
Backtrace.c:507:
StrAppendFmt(out, " #{} {}+{x} [{x}]", idx, mod, r->offset, (u64)(uintptr_t)ip);
} else {
StrAppendFmt(out, " #{} {x}", idx, (u64)(uintptr_t)ip);
}
if (r->source_file) {- In
Backtrace.c:512:
const char *file = basename_of(r->source_file);
if (r->source_line > 0) {
StrAppendFmt(out, " ({}:{})", file, r->source_line);
} else {
StrAppendFmt(out, " ({})", file);- In
Backtrace.c:514:
StrAppendFmt(out, " ({}:{})", file, r->source_line);
} else {
StrAppendFmt(out, " ({})", file);
}
}- In
Backtrace.c:526:
emit_resolved_line(out, (u32)i, &r, frames[i].ip);
} else {
StrAppendFmt(out, " #{} {x}\n", (u32)i, (u64)(uintptr_t)frames[i].ip);
}
}- In
Backtrace.c:535:
if (!SymbolResolverInit(&res, alloc)) {
for (size i = 0; i < count; ++i) {
StrAppendFmt(out, " #{} {x}\n", (u32)i, (u64)(uintptr_t)frames[i].ip);
}
return;- In
Socket.c:630:
}
port = FROM_BIG_ENDIAN2(sa->sin_port);
StrAppendFmt(&out, "{}:{}", host_p, (u32)port);
} else if (addr->family == SOCKET_FAMILY_INET6) {
const struct sockaddr_in6 *sa = (const struct sockaddr_in6 *)addr->raw;- In
Socket.c:640:
}
port = FROM_BIG_ENDIAN2(sa->sin6_port);
StrAppendFmt(&out, "[{}]:{}", host_p, (u32)port);
} else {
LOG_ERROR("SocketAddrFormat: unknown family {}", (u32)addr->family);- In
Dir.c:307:
Str entry_path = StrInit(alloc);
const char *dir_name = &entry->d_name[0];
StrAppendFmt(&entry_path, "{}/{}", path, dir_name);
struct stat path_stat;- In
Http.c:440:
}
StrAppendFmt(
&out,
"HTTP/1.1 {}\r\n"- In
Http.c:451:
VecForeachPtr(&response->headers, header) {
StrAppendFmt(&out, "{}: {}\r\n", header->key, header->value);
}- In
Http.c:454:
}
StrAppendFmt(&out, "\r\n");
if (response->body.length) {- In
Log.c:54:
Allocator *a = ALLOCATOR_OF(&h);
Str full = StrInit(a);
StrAppendFmt(&full, "[{}] [{}:{}] {}\n", (const char *)NAMES[type], (const char *)tag, line, (const char *)msg);
File out = (type == LOG_MESSAGE_TYPE_INFO) ? FileFromFd(1) : FileFromFd(2);- In
Debug.c:409:
return;
StrAppendFmt(out, "DebugAllocator: {} live allocation(s):\n", (u64)self->live.length);
MapForeachPairPtr(&self->live, key_ptr, val_ptr) {
StrAppendFmt(out, " leak: {x} ({} bytes)\n", (u64)(uintptr_t)*key_ptr, (u64)val_ptr->requested_size);- In
Debug.c:411:
StrAppendFmt(out, "DebugAllocator: {} live allocation(s):\n", (u64)self->live.length);
MapForeachPairPtr(&self->live, key_ptr, val_ptr) {
StrAppendFmt(out, " leak: {x} ({} bytes)\n", (u64)(uintptr_t)*key_ptr, (u64)val_ptr->requested_size);
if (val_ptr->alloc_trace_n > 0) {
FormatStackTrace(out, val_ptr->alloc_trace, val_ptr->alloc_trace_n, ALLOCATOR_OF(&self->meta));- In
Proc.h:206:
do { \
Str b_ = StrInit(); \
StrAppendFmt(&b_, __VA_ARGS__); \
ProcWriteToStdin((p), &b_); \
StrDeinit(&b_); \
- In
Proc.h:214:
do { \
Str b_ = StrInit(); \
StrAppendFmt(&b_, __VA_ARGS__); \
StrPushBack(&b_, '\n'); \
ProcWriteToStdin((p), &b_); \
- In
JSON.h:706:
StrPushBack(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (const char *)(k)); \
JW_OBJ(j, writer); \
} while (0)- In
JSON.h:772:
StrPushBack(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (const char *)(k)); \
JW_ARR(j, arr, item, writer); \
} while (0)- In
JSON.h:793:
do { \
i64 my_int = (i); \
StrAppendFmt(&(j), "{}", my_int); \
} while (0)- In
JSON.h:818:
StrPushBack(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (const char *)(k)); \
JW_INT(j, i); \
} while (0)- In
JSON.h:839:
do { \
f64 my_flt = (f); \
StrAppendFmt(&(j), "{}", my_flt); \
} while (0)- In
JSON.h:864:
StrPushBack(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (const char *)(k)); \
JW_FLT(j, f); \
} while (0)- In
JSON.h:884:
#define JW_STR(j, s) \
do { \
StrAppendFmt(&(j), "\"{}\"", (const char *)((s).length ? (s).data : "")); \
} while (0)- In
JSON.h:909:
StrPushBack(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (const char *)(k)); \
JW_STR(j, s); \
} while (0)- In
JSON.h:929:
#define JW_BOOL(j, b) \
do { \
StrAppendFmt(&(j), "{}", (const char *)((b) ? "true" : "false")); \
} while (0)- In
JSON.h:954:
StrPushBack(&(j), ','); \
} \
StrAppendFmt(&(j), "\"{}\":", (const char *)(k)); \
JW_BOOL(j, b); \
} while (0)- In
Log.h:45:
HeapAllocator log_alloc_ = HeapAllocatorInit(); \
Str m_ = StrInit(&log_alloc_); \
StrAppendFmt(&m_, __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, m_.data); \
StrDeinit(&m_); \
- In
Log.h:59:
HeapAllocator log_alloc_ = HeapAllocatorInit(); \
Str m_ = StrInit(&log_alloc_); \
StrAppendFmt(&m_, __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, m_.data); \
StrDeinit(&m_); \
- In
Log.h:72:
HeapAllocator log_alloc_ = HeapAllocatorInit(); \
Str m_ = StrInit(&log_alloc_); \
StrAppendFmt(&m_, __VA_ARGS__); \
LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, m_.data); \
StrDeinit(&m_); \
- In
Log.h:95:
HeapAllocator log_alloc_ = HeapAllocatorInit(); \
Str m_ = StrInit(&log_alloc_); \
StrAppendFmt(&m_, __VA_ARGS__); \
Str syserr_; \
StrInitStack(syserr_, &log_alloc_, 256, { \
- In
Log.h:99:
StrInitStack(syserr_, &log_alloc_, 256, { \
StrError(sys_eno_, &syserr_); \
StrAppendFmt(&m_, " : {}", syserr_); \
}); \
LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, m_.data); \
- In
Log.h:117:
HeapAllocator log_alloc_ = HeapAllocatorInit(); \
Str m_ = StrInit(&log_alloc_); \
StrAppendFmt(&m_, __VA_ARGS__); \
Str syserr_; \
StrInitStack(syserr_, &log_alloc_, 256, { \
- In
Log.h:121:
StrInitStack(syserr_, &log_alloc_, 256, { \
StrError(sys_eno_, &syserr_); \
StrAppendFmt(&m_, " : {}", syserr_); \
}); \
LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, m_.data); \
- In
Log.h:137:
HeapAllocator log_alloc_ = HeapAllocatorInit(); \
Str m_ = StrInit(&log_alloc_); \
StrAppendFmt(&m_, __VA_ARGS__); \
Str syserr_; \
StrInitStack(syserr_, &log_alloc_, 256, { \
- In
Log.h:141:
StrInitStack(syserr_, &log_alloc_, 256, { \
StrError(sys_eno_, &syserr_); \
StrAppendFmt(&m_, " : {}", syserr_); \
}); \
LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, m_.data); \
Last updated on