StrPushBack
- Macro
- August 22, 2025
Table of Contents
StrPushBack
StrPushBack
Description
Push char into string.
Parameters
Name | Direction | Description |
---|---|---|
str | in | Str to push char into |
chr | in | Pointer to value to be pushed |
Success
Returns str
the string itself on success.
Failure
Returns NULL
otherwise.
Usage example (Cross-references)
- In
JSON.h:675
:
bool ___is_first___ = true; \
(void)___is_first___; \
StrPushBack(&(j), '{'); \
{writer}; \
StrPushBack(&(j), '}'); \
- In
JSON.h:677
:
StrPushBack(&(j), '{'); \
{writer}; \
StrPushBack(&(j), '}'); \
} while (0)
- In
JSON.h:703
:
___is_first___ = false; \
} else { \
StrPushBack(&(j), ','); \
} \
StrAppendf(&(j), "\"%s\":", k); \
- In
JSON.h:732
:
bool ___is_first___ = true; \
(void)___is_first___; \
StrPushBack(&(j), '['); \
VecForeach(&(arr), item, { \
if (___is_first___) { \
- In
JSON.h:737
:
___is_first___ = false; \
} else { \
StrPushBack(&(j), ','); \
} \
{ writer } \
- In
JSON.h:741
:
{ writer } \
}); \
StrPushBack(&(j), ']'); \
} while (0)
- In
JSON.h:769
:
___is_first___ = false; \
} else { \
StrPushBack(&(j), ','); \
} \
StrAppendf(&(j), "\"%s\":", k); \
- In
JSON.h:815
:
___is_first___ = false; \
} else { \
StrPushBack(&(j), ','); \
} \
StrAppendf(&(j), "\"%s\":", k); \
- In
JSON.h:861
:
___is_first___ = false; \
} else { \
StrPushBack(&(j), ','); \
} \
StrAppendf(&(j), "\"%s\":", k); \
- In
JSON.h:906
:
___is_first___ = false; \
} else { \
StrPushBack(&(j), ','); \
} \
StrAppendf(&(j), "\"%s\":", k); \
- In
JSON.h:951
:
___is_first___ = false; \
} else { \
StrPushBack(&(j), ','); \
} \
StrAppendf(&(j), "\"%s\":", k); \
- In
JSON.c:207
:
// escape sequence
case '\\' :
StrPushBack(str, '\\');
StrIterNext(&si);
break;
- In
JSON.c:212
:
case '"' :
StrPushBack(str, '"');
StrIterNext(&si);
break;
- In
JSON.c:217
:
case '/' :
StrPushBack(str, '/');
StrIterNext(&si);
break;
- In
JSON.c:222
:
case 'b' :
StrPushBack(str, '\b');
StrIterNext(&si);
break;
- In
JSON.c:227
:
case 'f' :
StrPushBack(str, '\f');
StrIterNext(&si);
break;
- In
JSON.c:232
:
case 'n' :
StrPushBack(str, '\n');
StrIterNext(&si);
break;
- In
JSON.c:237
:
case 'r' :
StrPushBack(str, '\r');
StrIterNext(&si);
break;
- In
JSON.c:242
:
case 't' :
StrPushBack(str, '\t');
StrIterNext(&si);
break;
- In
JSON.c:264
:
// default allowed characters
default :
StrPushBack(str, StrIterPeek(&si));
StrIterNext(&si);
break;
- In
JSON.c:310
:
has_exp = true;
is_flt = true;
StrPushBack(&ns, StrIterPeek(&si));
StrIterNext(&si);
break;
- In
JSON.c:321
:
}
is_flt = true;
StrPushBack(&ns, StrIterPeek(&si));
StrIterNext(&si);
break;
- In
JSON.c:335
:
case '8' :
case '9' :
StrPushBack(&ns, StrIterPeek(&si));
StrIterNext(&si);
break;
- In
JSON.c:359
:
}
has_exp_plus_minus = true;
StrPushBack(&ns, StrIterPeek(&si));
StrIterNext(&si);
break;
- In
Io.c:199
:
// Pad on right
for (size i = 0; i < pad_len; i++) {
StrPushBack(o, ' ');
}
} else { // ALIGN_CENTER
- In
Io.c:212
:
// Pad on right
for (size i = 0; i < right_pad; i++) {
StrPushBack(o, ' ');
}
}
- In
Io.c:232
:
// Check for escaped brace
if (i + 1 < fmt_len && fmt[i + 1] == '{') {
StrPushBack(o, '{');
i++; // Skip next brace
continue;
- In
Io.c:375
:
// Check for escaped brace
if (i + 1 < fmt_len && fmt[i + 1] == '}') {
StrPushBack(o, '}');
i++; // Skip next brace
continue;
- In
Io.c:382
:
return false;
} else {
StrPushBack(o, fmt[i]);
}
}
- In
Io.c:664
:
// For 'c' format specifier, preserve the original case
if (force_case) {
StrPushBack(o, is_caps ? TO_UPPER(byte) : TO_LOWER(byte));
} else {
StrPushBack(o, byte);
- In
Io.c:666
:
StrPushBack(o, is_caps ? TO_UPPER(byte) : TO_LOWER(byte));
} else {
StrPushBack(o, byte);
}
} else {
- In
Io.c:676
:
StrPushBackZstr(o, "\\x");
StrPushBack(o, c1);
StrPushBack(o, c2);
}
- In
Io.c:677
:
StrPushBackZstr(o, "\\x");
StrPushBack(o, c1);
StrPushBack(o, c2);
}
}
- In
Io.c:695
:
// For 'c' format specifier, preserve the original case
if (force_case) {
StrPushBack(o, is_caps ? TO_UPPER(*vs) : TO_LOWER(*vs));
} else {
StrPushBack(o, *vs);
- In
Io.c:697
:
StrPushBack(o, is_caps ? TO_UPPER(*vs) : TO_LOWER(*vs));
} else {
StrPushBack(o, *vs);
}
} else {
- In
Io.c:794
:
StrForeachIdx(s, c, i, {
if (i > 0) {
StrPushBack(o, ' ');
}
// Create hex string for each character
- In
Io.c:825
:
StrForeachInRange(s, c, 0, len, {
if (IS_PRINTABLE(c)) {
StrPushBack(o, c);
} else {
const char* digits = "0123456789abcdef";
- In
Io.c:829
:
const char* digits = "0123456789abcdef";
StrPushBackZstr(o, "\\x");
StrPushBack(o, digits[c >> 4]);
StrPushBack(o, digits[c & 0xf]);
}
- In
Io.c:830
:
StrPushBackZstr(o, "\\x");
StrPushBack(o, digits[c >> 4]);
StrPushBack(o, digits[c & 0xf]);
}
});
- In
Io.c:863
:
while (xs[i]) {
if (i > 0) {
StrPushBack(o, ' ');
}
// Create hex string for each character
- In
Io.c:898
:
for (size i = 0; i < len; i++) {
if (IS_PRINTABLE(xs[i])) {
StrPushBack(o, xs[i]);
} else {
const char* digits = "0123456789abcdef";
- In
Io.c:902
:
const char* digits = "0123456789abcdef";
StrPushBackZstr(o, "\\x");
StrPushBack(o, digits[xs[i] >> 4]);
StrPushBack(o, digits[xs[i] & 0xf]);
}
- In
Io.c:903
:
StrPushBackZstr(o, "\\x");
StrPushBack(o, digits[xs[i] >> 4]);
StrPushBack(o, digits[xs[i] & 0xf]);
}
}
- In
Io.c:1130
:
// Direct string append for infinity
if (*v < 0) {
StrPushBack(o, '-');
}
- In
Io.c:1294
:
}
StrPushBack(s, c);
} else if (*i == quote) {
i++; // Skip closing quote
- In
Io.c:1306
:
}
StrPushBack(s, c);
}
} else {
- In
Io.c:1328
:
}
StrPushBack(s, c);
} else {
char c = *i++;
- In
Io.c:1337
:
}
StrPushBack(s, c);
}
}
- In
Io.c:2527
:
}
StrPushBack(o, *v);
}
- In
Io.c:2543
:
switch (fmt_info->endian) {
case ENDIAN_BIG : {
StrPushBack(o, (x >> 8));
StrPushBack(o, (x & 0xff));
break;
- In
Io.c:2544
:
case ENDIAN_BIG : {
StrPushBack(o, (x >> 8));
StrPushBack(o, (x & 0xff));
break;
}
- In
Io.c:2548
:
}
case ENDIAN_LITTLE : {
StrPushBack(o, (x & 0xff));
StrPushBack(o, (x >> 8));
break;
- In
Io.c:2549
:
case ENDIAN_LITTLE : {
StrPushBack(o, (x & 0xff));
StrPushBack(o, (x >> 8));
break;
}
- In
Io.c:2573
:
switch (fmt_info->endian) {
case ENDIAN_BIG : {
StrPushBack(o, (x >> 24));
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 8) & 0xff);
- In
Io.c:2574
:
case ENDIAN_BIG : {
StrPushBack(o, (x >> 24));
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x & 0xff));
- In
Io.c:2575
:
StrPushBack(o, (x >> 24));
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x & 0xff));
break;
- In
Io.c:2576
:
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x & 0xff));
break;
}
- In
Io.c:2580
:
}
case ENDIAN_LITTLE : {
StrPushBack(o, (x & 0xff));
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
- In
Io.c:2581
:
case ENDIAN_LITTLE : {
StrPushBack(o, (x & 0xff));
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 24));
- In
Io.c:2582
:
StrPushBack(o, (x & 0xff));
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 24));
break;
- In
Io.c:2583
:
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 24));
break;
}
- In
Io.c:2607
:
switch (fmt_info->endian) {
case ENDIAN_BIG : {
StrPushBack(o, (x >> 56));
StrPushBack(o, (x >> 48) & 0xff);
StrPushBack(o, (x >> 40) & 0xff);
- In
Io.c:2608
:
case ENDIAN_BIG : {
StrPushBack(o, (x >> 56));
StrPushBack(o, (x >> 48) & 0xff);
StrPushBack(o, (x >> 40) & 0xff);
StrPushBack(o, (x >> 32) & 0xff);
- In
Io.c:2609
:
StrPushBack(o, (x >> 56));
StrPushBack(o, (x >> 48) & 0xff);
StrPushBack(o, (x >> 40) & 0xff);
StrPushBack(o, (x >> 32) & 0xff);
StrPushBack(o, (x >> 24) & 0xff);
- In
Io.c:2610
:
StrPushBack(o, (x >> 48) & 0xff);
StrPushBack(o, (x >> 40) & 0xff);
StrPushBack(o, (x >> 32) & 0xff);
StrPushBack(o, (x >> 24) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
- In
Io.c:2611
:
StrPushBack(o, (x >> 40) & 0xff);
StrPushBack(o, (x >> 32) & 0xff);
StrPushBack(o, (x >> 24) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 8) & 0xff);
- In
Io.c:2612
:
StrPushBack(o, (x >> 32) & 0xff);
StrPushBack(o, (x >> 24) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x & 0xff));
- In
Io.c:2613
:
StrPushBack(o, (x >> 24) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x & 0xff));
break;
- In
Io.c:2614
:
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x & 0xff));
break;
}
- In
Io.c:2618
:
}
case ENDIAN_LITTLE : {
StrPushBack(o, (x & 0xff));
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
- In
Io.c:2619
:
case ENDIAN_LITTLE : {
StrPushBack(o, (x & 0xff));
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 24) & 0xff);
- In
Io.c:2620
:
StrPushBack(o, (x & 0xff));
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 24) & 0xff);
StrPushBack(o, (x >> 32) & 0xff);
- In
Io.c:2621
:
StrPushBack(o, (x >> 8) & 0xff);
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 24) & 0xff);
StrPushBack(o, (x >> 32) & 0xff);
StrPushBack(o, (x >> 40) & 0xff);
- In
Io.c:2622
:
StrPushBack(o, (x >> 16) & 0xff);
StrPushBack(o, (x >> 24) & 0xff);
StrPushBack(o, (x >> 32) & 0xff);
StrPushBack(o, (x >> 40) & 0xff);
StrPushBack(o, (x >> 48) & 0xff);
- In
Io.c:2623
:
StrPushBack(o, (x >> 24) & 0xff);
StrPushBack(o, (x >> 32) & 0xff);
StrPushBack(o, (x >> 40) & 0xff);
StrPushBack(o, (x >> 48) & 0xff);
StrPushBack(o, (x >> 56));
- In
Io.c:2624
:
StrPushBack(o, (x >> 32) & 0xff);
StrPushBack(o, (x >> 40) & 0xff);
StrPushBack(o, (x >> 48) & 0xff);
StrPushBack(o, (x >> 56));
break;
- In
Io.c:2625
:
StrPushBack(o, (x >> 40) & 0xff);
StrPushBack(o, (x >> 48) & 0xff);
StrPushBack(o, (x >> 56));
break;
}
- In
BitVec.c:738
:
for (u64 i = 0; i < bv->length; i++) {
char bit_char = BitVecGet(bv, i) ? '1' : '0';
StrPushBack(&result, bit_char);
}
- In
Str.c:344
:
// Add prefix if requested
if (config->use_prefix) {
StrPushBack(str, '0');
if (config->base == 2) {
StrPushBack(str, 'b');
- In
Str.c:346
:
StrPushBack(str, '0');
if (config->base == 2) {
StrPushBack(str, 'b');
} else if (config->base == 8) {
StrPushBack(str, 'o');
- In
Str.c:348
:
StrPushBack(str, 'b');
} else if (config->base == 8) {
StrPushBack(str, 'o');
} else if (config->base == 16) {
StrPushBack(str, 'x');
- In
Str.c:350
:
StrPushBack(str, 'o');
} else if (config->base == 16) {
StrPushBack(str, 'x');
}
}
- In
Str.c:356
:
// Convert number to string
if (value == 0) {
StrPushBack(str, '0');
} else {
char buffer[65];
- In
Str.c:368
:
// Add digits in correct order
while (pos > 0) {
StrPushBack(str, buffer[--pos]);
}
}
- In
Str.c:427
:
const char* nan_str = config->uppercase ? "NAN" : "nan";
for (size_t i = 0; i < 3; i++) {
StrPushBack(str, nan_str[i]);
}
return str;
- In
Str.c:434
:
if (isinf(value)) {
if (value < 0) {
StrPushBack(str, '-');
} else if (config->always_sign) {
StrPushBack(str, '+');
- In
Str.c:436
:
StrPushBack(str, '-');
} else if (config->always_sign) {
StrPushBack(str, '+');
}
const char* inf_str = config->uppercase ? "INF" : "inf";
- In
Str.c:440
:
const char* inf_str = config->uppercase ? "INF" : "inf";
for (size_t i = 0; i < 3; i++) {
StrPushBack(str, inf_str[i]);
}
return str;
- In
Str.c:447
:
// Handle sign
if (value < 0) {
StrPushBack(str, '-');
value = -value;
} else if (config->always_sign) {
- In
Str.c:450
:
value = -value;
} else if (config->always_sign) {
StrPushBack(str, '+');
}
- In
Str.c:474
:
// Format mantissa with proper rounding
i64 int_part = (i64)mantissa;
StrPushBack(str, '0' + int_part);
if (config->precision > 0) {
- In
Str.c:477
:
if (config->precision > 0) {
StrPushBack(str, '.');
f64 frac_part = mantissa - int_part;
- In
Str.c:485
:
if (digit >= 10)
digit = 9; // Clamp to prevent overflow
StrPushBack(str, '0' + digit);
frac_part -= (int)frac_part; // Remove the integer part
}
- In
Str.c:491
:
// Add exponent
StrPushBack(str, config->uppercase ? 'E' : 'e');
if (exp >= 0) {
StrPushBack(str, '+');
- In
Str.c:493
:
StrPushBack(str, config->uppercase ? 'E' : 'e');
if (exp >= 0) {
StrPushBack(str, '+');
} else {
StrPushBack(str, '-');
- In
Str.c:495
:
StrPushBack(str, '+');
} else {
StrPushBack(str, '-');
exp = -exp;
}
- In
Str.c:501
:
// Format exponent digits (always at least 2 digits)
if (exp == 0) {
StrPushBack(str, '0');
StrPushBack(str, '0');
} else {
- In
Str.c:502
:
if (exp == 0) {
StrPushBack(str, '0');
StrPushBack(str, '0');
} else {
char exp_buf[8];
- In
Str.c:515
:
}
while (exp_pos > 0) {
StrPushBack(str, exp_buf[--exp_pos]);
}
}
- In
Str.c:524
:
// Format integer part
if (int_part == 0) {
StrPushBack(str, '0');
} else {
char int_buf[32];
- In
Str.c:533
:
}
while (int_pos > 0) {
StrPushBack(str, int_buf[--int_pos]);
}
}
- In
Str.c:539
:
// Format fractional part
if (config->precision > 0) {
StrPushBack(str, '.');
// Apply rounding to the entire fractional part first
- In
Str.c:558
:
}
StrPushBack(str, '0' + digit);
frac_part -= digit;
}
- In
MisraDoc.c:142
:
Str path = StrInit();
StrMerge(&path, ¤t_path);
StrPushBack(&path, '/');
StrMerge(&path, &dir_entry.name);
- In
MisraDoc.c:151
:
Str path = StrInit();
StrMerge(&path, ¤t_path);
StrPushBack(&path, '/');
StrMerge(&path, &dir_entry.name);
char c = output->data[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') {
StrPushBack(&output_clean, c);
}
}
char c = expected_str.data[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') {
StrPushBack(&expected_clean, c);
}
}
char c = output->data[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') {
StrPushBack(&output_clean, c);
}
}
char c = expected_str.data[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') {
StrPushBack(&expected_clean, c);
}
}
char c = output->data[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') {
StrPushBack(&output_clean, c);
}
}
char c = expected_str.data[i];
if (c != ' ' && c != '\n' && c != '\r' && c != '\t') {
StrPushBack(&expected_clean, c);
}
}
- In
Str.Type.c:28
:
// Check that it behaves like a Vec of chars
StrPushBack(&s, 'H');
StrPushBack(&s, 'e');
StrPushBack(&s, 'l');
- In
Str.Type.c:29
:
// Check that it behaves like a Vec of chars
StrPushBack(&s, 'H');
StrPushBack(&s, 'e');
StrPushBack(&s, 'l');
StrPushBack(&s, 'l');
- In
Str.Type.c:30
:
StrPushBack(&s, 'H');
StrPushBack(&s, 'e');
StrPushBack(&s, 'l');
StrPushBack(&s, 'l');
StrPushBack(&s, 'o');
- In
Str.Type.c:31
:
StrPushBack(&s, 'e');
StrPushBack(&s, 'l');
StrPushBack(&s, 'l');
StrPushBack(&s, 'o');
- In
Str.Type.c:32
:
StrPushBack(&s, 'l');
StrPushBack(&s, 'l');
StrPushBack(&s, 'o');
bool result = (s.length == 5 && ZstrCompare(s.data, "Hello") == 0);
- In
Str.Insert.c:204
:
// Test StrPushBack function
bool test_str_push_back(void) {
printf("Testing StrPushBack\n");
Str s = StrInitFromZstr("Hello");
- In
Str.Insert.c:209
:
// Push characters at the back
StrPushBack(&s, ' ');
StrPushBack(&s, 'W');
StrPushBack(&s, 'o');
- In
Str.Insert.c:210
:
// Push characters at the back
StrPushBack(&s, ' ');
StrPushBack(&s, 'W');
StrPushBack(&s, 'o');
StrPushBack(&s, 'r');
- In
Str.Insert.c:211
:
StrPushBack(&s, ' ');
StrPushBack(&s, 'W');
StrPushBack(&s, 'o');
StrPushBack(&s, 'r');
StrPushBack(&s, 'l');
- In
Str.Insert.c:212
:
StrPushBack(&s, 'W');
StrPushBack(&s, 'o');
StrPushBack(&s, 'r');
StrPushBack(&s, 'l');
StrPushBack(&s, 'd');
- In
Str.Insert.c:213
:
StrPushBack(&s, 'o');
StrPushBack(&s, 'r');
StrPushBack(&s, 'l');
StrPushBack(&s, 'd');
- In
Str.Insert.c:214
:
StrPushBack(&s, 'r');
StrPushBack(&s, 'l');
StrPushBack(&s, 'd');
// Check that the characters were inserted correctly
StrForeach(&s, chr, {
// Append the character to the result string
StrPushBack(&result, chr);
});
StrForeachReverse(&s, chr, {
// Append the character to the result string
StrPushBack(&result, chr);
char_count++;
});
StrForeachPtr(&s, chrptr, {
// Append the character (via pointer) to the result string
StrPushBack(&result, *chrptr);
// Modify the original string by converting to uppercase
StrForeachPtrReverse(&s, chrptr, {
// Append the character (via pointer) to the result string
StrPushBack(&result, *chrptr);
// Modify the original string by converting to uppercase
StrForeachInRangeIdx(&s, chr, idx, 3, 3, {
// This block should not execute
StrPushBack(&empty_result, chr);
});
StrForeachInRange(&s, chr, 0, 5, {
// Append the character to the result string
StrPushBack(&result, chr);
});
StrForeachInRange(&s, chr, 6, 11, {
// Append the character to the result string
StrPushBack(&end_result, chr);
});
StrForeachPtrInRange(&s, chrptr, 0, 5, {
// Append the character to the result string
StrPushBack(&result, *chrptr);
// Modify the original string by converting to uppercase