Skip to content

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)

Usage examples (Cross-references)
                if (*offset + 1 <= size) {
                    char ch = (char)extract_u8(data, offset, size);
                    StrPushBack(str, ch);
                }
                break;
                if (*offset + 1 <= size) {
                    char ch = (char)extract_u8(data, offset, size);
                    StrPushBack(str, ch);
                }
                break;
                ch = (char)('A' + (i % 26));              // Fallback pattern
            }
            StrPushBack(&str, ch);
        }
            // Pad on right
            for (size i = 0; i < pad_len; i++) {
                StrPushBack(o, ' ');
            }
        } else { // ALIGN_CENTER
            // Pad on right
            for (size i = 0; i < right_pad; i++) {
                StrPushBack(o, ' ');
            }
        }
                // Check for escaped brace
                if (i + 1 < fmt_len && fmt[i + 1] == '{') {
                    StrPushBack(o, '{');
                    i++; // Skip next brace
                    continue;
                // Check for escaped brace
                if (i + 1 < fmt_len && fmt[i + 1] == '}') {
                    StrPushBack(o, '}');
                    i++; // Skip next brace
                    continue;
                return false;
            } else {
                StrPushBack(o, fmt[i]);
            }
        }
            FILE *source_stream = fd == STDIN_FILENO ? stdin : fd == STDOUT_FILENO ? stdout : stderr;
            while (!feof(source_stream) && fread(&in, 1, 1, source_stream)) {
                StrPushBack(&buffer, in);
            }
            StrReadFmtInternal(buffer.data, fmtstr, argv, argc);
                // 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);
                    StrPushBack(o, is_caps ? TO_UPPER(byte) : TO_LOWER(byte));
                } else {
                    StrPushBack(o, byte);
                }
            } else {
    
                StrPushBackZstr(o, "\\x");
                StrPushBack(o, c1);
                StrPushBack(o, c2);
            }
                StrPushBackZstr(o, "\\x");
                StrPushBack(o, c1);
                StrPushBack(o, c2);
            }
        }
                // 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);
                    StrPushBack(o, is_caps ? TO_UPPER(*vs) : TO_LOWER(*vs));
                } else {
                    StrPushBack(o, *vs);
                }
            } else {
        }
    
        StrPushBack(out, uppercase ? 'E' : 'e');
        StrPushBack(out, sign);
    
        StrPushBack(out, uppercase ? 'E' : 'e');
        StrPushBack(out, sign);
    
        if (digit_count < 2) {
    
        if (digit_count < 2) {
            StrPushBack(out, '0');
        }
    
        while (digit_count > 0) {
            StrPushBack(out, digits[--digit_count]);
        }
    }
    
            if (canonical.data[0] == '-') {
                StrPushBack(&result, '-');
                body++;
            }
    
                if (precision > 0) {
                    StrPushBack(&result, '.');
                    for (u32 i = 0; i < precision; i++) {
                        StrPushBack(&result, '0');
                    StrPushBack(&result, '.');
                    for (u32 i = 0; i < precision; i++) {
                        StrPushBack(&result, '0');
                    }
                }
            StrPushBackCstr(&result, body, prefix);
            if (precision > 0) {
                StrPushBack(&result, '.');
                StrPushBackCstr(&result, dot + 1, MIN2(frac, (u64)precision));
                for (u32 i = (u32)MIN2(frac, (u64)precision); i < precision; i++) {
                StrPushBackCstr(&result, dot + 1, MIN2(frac, (u64)precision));
                for (u32 i = (u32)MIN2(frac, (u64)precision); i < precision; i++) {
                    StrPushBack(&result, '0');
                }
            }
        if (FloatIsZero(value)) {
            if (value->negative) {
                StrPushBack(&result, '-');
            }
            StrPushBack(&result, '0');
                StrPushBack(&result, '-');
            }
            StrPushBack(&result, '0');
            if (has_precision && precision > 0) {
                StrPushBack(&result, '.');
            StrPushBack(&result, '0');
            if (has_precision && precision > 0) {
                StrPushBack(&result, '.');
                for (u32 i = 0; i < precision; i++) {
                    StrPushBack(&result, '0');
                StrPushBack(&result, '.');
                for (u32 i = 0; i < precision; i++) {
                    StrPushBack(&result, '0');
                }
            }
    
        if (value->negative) {
            StrPushBack(&result, '-');
        }
    
        exponent = value->exponent + (i64)digits.length - 1;
        StrPushBack(&result, digits.data[0]);
    
        frac_digits = has_precision ? precision : (digits.length > 0 ? digits.length - 1 : 0);
        frac_digits = has_precision ? precision : (digits.length > 0 ? digits.length - 1 : 0);
        if (frac_digits > 0) {
            StrPushBack(&result, '.');
            for (u64 i = 0; i < frac_digits; i++) {
                if (i + 1 < digits.length) {
            for (u64 i = 0; i < frac_digits; i++) {
                if (i + 1 < digits.length) {
                    StrPushBack(&result, digits.data[i + 1]);
                } else {
                    StrPushBack(&result, '0');
                    StrPushBack(&result, digits.data[i + 1]);
                } else {
                    StrPushBack(&result, '0');
                }
            }
                StrForeachIdx(s, c, i) {
                    if (i > 0) {
                        StrPushBack(o, ' ');
                    }
                    // Create hex string for each character
                    StrForeachInRange(s, c, 0, len) {
                        if (IS_PRINTABLE(c)) {
                            StrPushBack(o, c);
                        } else {
                            const char *digits = "0123456789abcdef";
                            const char *digits = "0123456789abcdef";
                            StrPushBackZstr(o, "\\x");
                            StrPushBack(o, digits[(c >> 4) & 0xf]);
                            StrPushBack(o, digits[c & 0xf]);
                        }
                            StrPushBackZstr(o, "\\x");
                            StrPushBack(o, digits[(c >> 4) & 0xf]);
                            StrPushBack(o, digits[c & 0xf]);
                        }
                    }
                while (xs[i]) {
                    if (i > 0) {
                        StrPushBack(o, ' ');
                    }
                    // Create hex string for each character
                    for (size i = 0; i < len; i++) {
                        if (IS_PRINTABLE(xs[i])) {
                            StrPushBack(o, xs[i]);
                        } else {
                            const char *digits = "0123456789abcdef";
                            const char *digits = "0123456789abcdef";
                            StrPushBackZstr(o, "\\x");
                            StrPushBack(o, digits[(xs[i] >> 4) & 0xf]);
                            StrPushBack(o, digits[xs[i] & 0xf]);
                        }
                            StrPushBackZstr(o, "\\x");
                            StrPushBack(o, digits[(xs[i] >> 4) & 0xf]);
                            StrPushBack(o, digits[xs[i] & 0xf]);
                        }
                    }
            // Direct string append for infinity
            if (*v < 0) {
                StrPushBack(o, '-');
            }
                    }
    
                    StrPushBack(s, c);
                } else if (*i == quote) {
                    i++;      // Skip closing quote
                    }
    
                    StrPushBack(s, c);
                }
            } else {
                    }
    
                    StrPushBack(s, c);
                } else {
                    char c = *i++;
                    }
    
                    StrPushBack(s, c);
                }
            }
        }
    
        StrPushBack(o, *v);
    }
        switch (fmt_info->endian) {
            case ENDIAN_BIG : {
                StrPushBack(o, ((x >> 8) & 0xff));
                StrPushBack(o, (x & 0xff));
                break;
            case ENDIAN_BIG : {
                StrPushBack(o, ((x >> 8) & 0xff));
                StrPushBack(o, (x & 0xff));
                break;
            }
            }
            case ENDIAN_LITTLE : {
                StrPushBack(o, (x & 0xff));
                StrPushBack(o, ((x >> 8) & 0xff));
                break;
            case ENDIAN_LITTLE : {
                StrPushBack(o, (x & 0xff));
                StrPushBack(o, ((x >> 8) & 0xff));
                break;
            }
        switch (fmt_info->endian) {
            case ENDIAN_BIG : {
                StrPushBack(o, ((x >> 24) & 0xff));
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, (x >> 8) & 0xff);
            case ENDIAN_BIG : {
                StrPushBack(o, ((x >> 24) & 0xff));
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x & 0xff));
                StrPushBack(o, ((x >> 24) & 0xff));
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x & 0xff));
                break;
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x & 0xff));
                break;
            }
            }
            case ENDIAN_LITTLE : {
                StrPushBack(o, (x & 0xff));
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x >> 16) & 0xff);
            case ENDIAN_LITTLE : {
                StrPushBack(o, (x & 0xff));
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, ((x >> 24) & 0xff));
                StrPushBack(o, (x & 0xff));
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, ((x >> 24) & 0xff));
                break;
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, ((x >> 24) & 0xff));
                break;
            }
        switch (fmt_info->endian) {
            case ENDIAN_BIG : {
                StrPushBack(o, ((x >> 56) & 0xff));
                StrPushBack(o, (x >> 48) & 0xff);
                StrPushBack(o, (x >> 40) & 0xff);
            case ENDIAN_BIG : {
                StrPushBack(o, ((x >> 56) & 0xff));
                StrPushBack(o, (x >> 48) & 0xff);
                StrPushBack(o, (x >> 40) & 0xff);
                StrPushBack(o, (x >> 32) & 0xff);
                StrPushBack(o, ((x >> 56) & 0xff));
                StrPushBack(o, (x >> 48) & 0xff);
                StrPushBack(o, (x >> 40) & 0xff);
                StrPushBack(o, (x >> 32) & 0xff);
                StrPushBack(o, (x >> 24) & 0xff);
                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);
                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);
                StrPushBack(o, (x >> 32) & 0xff);
                StrPushBack(o, (x >> 24) & 0xff);
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x & 0xff));
                StrPushBack(o, (x >> 24) & 0xff);
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x & 0xff));
                break;
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x & 0xff));
                break;
            }
            }
            case ENDIAN_LITTLE : {
                StrPushBack(o, (x & 0xff));
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x >> 16) & 0xff);
            case ENDIAN_LITTLE : {
                StrPushBack(o, (x & 0xff));
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, (x >> 24) & 0xff);
                StrPushBack(o, (x & 0xff));
                StrPushBack(o, (x >> 8) & 0xff);
                StrPushBack(o, (x >> 16) & 0xff);
                StrPushBack(o, (x >> 24) & 0xff);
                StrPushBack(o, (x >> 32) & 0xff);
                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);
                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);
                StrPushBack(o, (x >> 24) & 0xff);
                StrPushBack(o, (x >> 32) & 0xff);
                StrPushBack(o, (x >> 40) & 0xff);
                StrPushBack(o, (x >> 48) & 0xff);
                StrPushBack(o, ((x >> 56) & 0xff));
                StrPushBack(o, (x >> 32) & 0xff);
                StrPushBack(o, (x >> 40) & 0xff);
                StrPushBack(o, (x >> 48) & 0xff);
                StrPushBack(o, ((x >> 56) & 0xff));
                break;
                StrPushBack(o, (x >> 40) & 0xff);
                StrPushBack(o, (x >> 48) & 0xff);
                StrPushBack(o, ((x >> 56) & 0xff));
                break;
            }
        // Add prefix if requested
        if (config->use_prefix) {
            StrPushBack(str, '0');
            if (config->base == 2) {
                StrPushBack(str, 'b');
            StrPushBack(str, '0');
            if (config->base == 2) {
                StrPushBack(str, 'b');
            } else if (config->base == 8) {
                StrPushBack(str, 'o');
                StrPushBack(str, 'b');
            } else if (config->base == 8) {
                StrPushBack(str, 'o');
            } else if (config->base == 16) {
                StrPushBack(str, 'x');
                StrPushBack(str, 'o');
            } else if (config->base == 16) {
                StrPushBack(str, 'x');
            }
        }
        // Convert number to string
        if (value == 0) {
            StrPushBack(str, '0');
        } else {
            char   buffer[65];
            // Add digits in correct order
            while (pos > 0) {
                StrPushBack(str, buffer[--pos]);
            }
        }
            const char *nan_str = config->uppercase ? "NAN" : "nan";
            for (size_t i = 0; i < 3; i++) {
                StrPushBack(str, nan_str[i]);
            }
            return str;
        if (isinf(value)) {
            if (value < 0) {
                StrPushBack(str, '-');
            } else if (config->always_sign) {
                StrPushBack(str, '+');
                StrPushBack(str, '-');
            } else if (config->always_sign) {
                StrPushBack(str, '+');
            }
            const char *inf_str = config->uppercase ? "INF" : "inf";
            const char *inf_str = config->uppercase ? "INF" : "inf";
            for (size_t i = 0; i < 3; i++) {
                StrPushBack(str, inf_str[i]);
            }
            return str;
        // Handle sign
        if (value < 0) {
            StrPushBack(str, '-');
            value = -value;
        } else if (config->always_sign) {
            value = -value;
        } else if (config->always_sign) {
            StrPushBack(str, '+');
        }
            // Format mantissa with proper rounding
            i64 int_part = (i64)mantissa;
            StrPushBack(str, '0' + int_part);
    
            if (config->precision > 0) {
    
            if (config->precision > 0) {
                StrPushBack(str, '.');
                f64 frac_part = mantissa - int_part;
                    if (digit >= 10)
                        digit = 9;                       // Clamp to prevent overflow
                    StrPushBack(str, '0' + digit);
                    frac_part -= (int)frac_part;         // Remove the integer part
                }
    
            // Add exponent
            StrPushBack(str, config->uppercase ? 'E' : 'e');
            if (exp >= 0) {
                StrPushBack(str, '+');
            StrPushBack(str, config->uppercase ? 'E' : 'e');
            if (exp >= 0) {
                StrPushBack(str, '+');
            } else {
                StrPushBack(str, '-');
                StrPushBack(str, '+');
            } else {
                StrPushBack(str, '-');
                exp = -exp;
            }
            // Format exponent digits (always at least 2 digits)
            if (exp == 0) {
                StrPushBack(str, '0');
                StrPushBack(str, '0');
            } else {
            if (exp == 0) {
                StrPushBack(str, '0');
                StrPushBack(str, '0');
            } else {
                char   exp_buf[8];
                }
                while (exp_pos > 0) {
                    StrPushBack(str, exp_buf[--exp_pos]);
                }
            }
            // Format integer part
            if (int_part == 0) {
                StrPushBack(str, '0');
            } else {
                char   int_buf[32];
                }
                while (int_pos > 0) {
                    StrPushBack(str, int_buf[--int_pos]);
                }
            }
            // Format fractional part
            if (config->precision > 0) {
                StrPushBack(str, '.');
    
                // Apply rounding to the entire fractional part first
                    }
    
                    StrPushBack(str, '0' + digit);
                    frac_part -= digit;
                }
    
            if (ch >= '0' && ch <= '9') {
                StrPushBack(&digits, ch);
                saw_digit = true;
                if (saw_decimal) {
    
        if (value->negative) {
            StrPushBack(&result, '-');
        }
    
            for (i64 i = 0; i < value->exponent; i++) {
                StrPushBack(&result, '0');
            }
        } else {
            if (split > 0) {
                for (i64 i = 0; i < split; i++) {
                    StrPushBack(&result, digits.data[i]);
                }
                }
    
                StrPushBack(&result, '.');
    
                for (u64 i = (u64)split; i < digits.length; i++) {
    
                for (u64 i = (u64)split; i < digits.length; i++) {
                    StrPushBack(&result, digits.data[i]);
                }
            } else {
    
                for (i64 i = 0; i < -split; i++) {
                    StrPushBack(&result, '0');
                }
    
            digit = MISRA_PRIV_IntDivU64Rem(&quotient, &current, radix);
            StrPushBack(&result, int_radix_char((u8)digit, uppercase));
    
            IntDeinit(&current);
        for (u64 i = 0; i < bv->length; i++) {
            char bit_char = BitVecGet(bv, i) ? '1' : '0';
            StrPushBack(&result, bit_char);
        }
            }
    
            StrPushBack(key, c);
            StrIterNext(&si);
        }
                    switch (c) {
                        case 'n' :
                            StrPushBack(value, '\n');
                            break;
                        case 'r' :
                            break;
                        case 'r' :
                            StrPushBack(value, '\r');
                            break;
                        case 't' :
                            break;
                        case 't' :
                            StrPushBack(value, '\t');
                            break;
                        case '\\' :
                        case '"' :
                        case '\'' :
                            StrPushBack(value, c);
                            break;
                        default :
                            break;
                        default :
                            StrPushBack(value, c);
                            break;
                    }
                }
    
                StrPushBack(value, c);
                StrIterNext(&si);
            }
            }
    
            StrPushBack(value, c);
            StrIterNext(&si);
        }
                            // escape sequence
                            case '\\' :
                                StrPushBack(str, '\\');
                                StrIterNext(&si);
                                break;
    
                            case '"' :
                                StrPushBack(str, '"');
                                StrIterNext(&si);
                                break;
    
                            case '/' :
                                StrPushBack(str, '/');
                                StrIterNext(&si);
                                break;
    
                            case 'b' :
                                StrPushBack(str, '\b');
                                StrIterNext(&si);
                                break;
    
                            case 'f' :
                                StrPushBack(str, '\f');
                                StrIterNext(&si);
                                break;
    
                            case 'n' :
                                StrPushBack(str, '\n');
                                StrIterNext(&si);
                                break;
    
                            case 'r' :
                                StrPushBack(str, '\r');
                                StrIterNext(&si);
                                break;
    
                            case 't' :
                                StrPushBack(str, '\t');
                                StrIterNext(&si);
                                break;
                    // default allowed characters
                    default :
                        StrPushBack(str, StrIterPeek(&si));
                        StrIterNext(&si);
                        break;
                    has_exp = true;
                    is_flt  = true;
                    StrPushBack(&ns, StrIterPeek(&si));
                    StrIterNext(&si);
                    break;
                    }
                    is_flt = true;
                    StrPushBack(&ns, StrIterPeek(&si));
                    StrIterNext(&si);
                    break;
                case '8' :
                case '9' :
                    StrPushBack(&ns, StrIterPeek(&si));
                    StrIterNext(&si);
                    break;
                    }
                    has_exp_plus_minus = true;
                    StrPushBack(&ns, StrIterPeek(&si));
                    StrIterNext(&si);
                    break;
        StrPushBackZstr(&cmdline, filepath);
        for (char **arg = argv + 1; *arg; ++arg) {
            StrPushBack(&cmdline, ' ');
            StrPushBackZstr(&cmdline, *arg);
        }
                                    Str path = StrInit();
                                    StrMerge(&path, &current_path);
                                    StrPushBack(&path, '/');
                                    StrMerge(&path, &dir_entry.name);
                        Str path = StrInit();
                        StrMerge(&path, &current_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);
            }
        }
    // Test StrPushBack function
    bool test_str_push_back(void) {
        WriteFmt("Testing StrPushBack\n");
    
        Str s = StrInitFromZstr("Hello");
    
        // Push characters at the back
        StrPushBack(&s, ' ');
        StrPushBack(&s, 'W');
        StrPushBack(&s, 'o');
        // Push characters at the back
        StrPushBack(&s, ' ');
        StrPushBack(&s, 'W');
        StrPushBack(&s, 'o');
        StrPushBack(&s, 'r');
        StrPushBack(&s, ' ');
        StrPushBack(&s, 'W');
        StrPushBack(&s, 'o');
        StrPushBack(&s, 'r');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'W');
        StrPushBack(&s, 'o');
        StrPushBack(&s, 'r');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'd');
        StrPushBack(&s, 'o');
        StrPushBack(&s, 'r');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'd');
        StrPushBack(&s, 'r');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'd');
    
        // Check that the characters were inserted correctly
    
        // Check that it behaves like a Vec of chars
        StrPushBack(&s, 'H');
        StrPushBack(&s, 'e');
        StrPushBack(&s, 'l');
        // Check that it behaves like a Vec of chars
        StrPushBack(&s, 'H');
        StrPushBack(&s, 'e');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'H');
        StrPushBack(&s, 'e');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'o');
        StrPushBack(&s, 'e');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'o');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'l');
        StrPushBack(&s, 'o');
    
        bool result = (s.length == 5 && ZstrCompare(s.data, "Hello") == 0);
        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
            bool ___is_first___ = true;                                                                                    \
            (void)___is_first___;                                                                                          \
            StrPushBack(&(j), '{');                                                                                        \
            {writer};                                                                                                      \
            StrPushBack(&(j), '}');                                                                                        \
            StrPushBack(&(j), '{');                                                                                        \
            {writer};                                                                                                      \
            StrPushBack(&(j), '}');                                                                                        \
        } while (0)
                ___is_first___ = false;                                                                                    \
            } else {                                                                                                       \
                StrPushBack(&(j), ',');                                                                                    \
            }                                                                                                              \
            StrAppendf(&(j), "\"%s\":", k);                                                                                \
            bool ___is_first___ = true;                                                                                    \
            (void)___is_first___;                                                                                          \
            StrPushBack(&(j), '[');                                                                                        \
            VecForeach(&(arr), item) {                                                                                     \
                if (___is_first___) {                                                                                      \
                    ___is_first___ = false;                                                                                \
                } else {                                                                                                   \
                    StrPushBack(&(j), ',');                                                                                \
                }                                                                                                          \
                { writer }                                                                                                 \
                { writer }                                                                                                 \
            }                                                                                                              \
            StrPushBack(&(j), ']');                                                                                        \
        } while (0)
                ___is_first___ = false;                                                                                    \
            } else {                                                                                                       \
                StrPushBack(&(j), ',');                                                                                    \
            }                                                                                                              \
            StrAppendf(&(j), "\"%s\":", k);                                                                                \
                ___is_first___ = false;                                                                                    \
            } else {                                                                                                       \
                StrPushBack(&(j), ',');                                                                                    \
            }                                                                                                              \
            StrAppendf(&(j), "\"%s\":", k);                                                                                \
                ___is_first___ = false;                                                                                    \
            } else {                                                                                                       \
                StrPushBack(&(j), ',');                                                                                    \
            }                                                                                                              \
            StrAppendf(&(j), "\"%s\":", k);                                                                                \
                ___is_first___ = false;                                                                                    \
            } else {                                                                                                       \
                StrPushBack(&(j), ',');                                                                                    \
            }                                                                                                              \
            StrAppendf(&(j), "\"%s\":", k);                                                                                \
                ___is_first___ = false;                                                                                    \
            } else {                                                                                                       \
                StrPushBack(&(j), ',');                                                                                    \
            }                                                                                                              \
            StrAppendf(&(j), "\"%s\":", k);                                                                                \
            Str b_ = StrInit();                                                                                            \
            StrWriteFmt(&b_, __VA_ARGS__);                                                                                 \
            StrPushBack(&b_, '\n');                                                                                        \
            SysProcWriteToStdin((p), &b_);                                                                                 \
            StrDeinit(&b_);                                                                                                \
Last updated on