StrPushBackZstr

Table of Contents

StrPushBackZstr

Description

Push a null-terminated string to the back of string.

Parameters

NameDirectionDescription
strin,outStr to insert array chars into.
zstrinNull-terminated string to be appended.

Success

str

Failure

NULL

Usage example (Cross-references)

    char c2  = low < 10 ? '0' + low : is_caps ? 'A' + (low - 10) : 'a' + (low - 10);
    
    StrPushBackZstr(o, "\\x");
    StrPushBack(o, c1);
    StrPushBack(o, c2);
    }
    } else {
    StrPushBackZstr(o, "\\x");
    u8   c     = *vs;
    u8   low   = c & 0xf;
    StrPushFront(&hex, '0');
    }
    StrPushBackZstr(o, "0x");
    StrMerge(o, &hex);
    StrDeinit(&hex);
    } else {
    const char* digits = "0123456789abcdef";
    StrPushBackZstr(o, "\\x");
    StrPushBack(o, digits[c >> 4]);
    StrPushBack(o, digits[c & 0xf]);
    StrPushFront(&hex, '0');
    }
    StrPushBackZstr(o, "0x");
    StrMerge(o, &hex);
    StrDeinit(&hex);
    } else {
    const char* digits = "0123456789abcdef";
    StrPushBackZstr(o, "\\x");
    StrPushBack(o, digits[xs[i] >> 4]);
    StrPushBack(o, digits[xs[i] & 0xf]);
    // Direct string append for NaN
    if (fmt_info->flags & FMT_FLAG_CAPS) {
    StrPushBackZstr(o, "NAN");
    } else {
    StrPushBackZstr(o, "nan");
    StrPushBackZstr(o, "NAN");
    } else {
    StrPushBackZstr(o, "nan");
    }
    } else if (isinf(*v)) {
    
    if (fmt_info->flags & FMT_FLAG_CAPS) {
    StrPushBackZstr(o, "INF");
    } else {
    StrPushBackZstr(o, "inf");
    StrPushBackZstr(o, "INF");
    } else {
    StrPushBackZstr(o, "inf");
    }
    } else {
    // Format as hexadecimal
    if (bv->length == 0) {
    StrPushBackZstr(o, "0x0");
    } else {
    // Convert to integer (up to 64 bits) and format as hex
    // Format as octal
    if (bv->length == 0) {
    StrPushBackZstr(o, "0o0");
    } else {
    u64          value  = BitVecToInteger(bv);
    
    // Add some data
    StrPushBackZstr(&s, "Hello");
    
    // Original capacity should be at least 100
    // Test StrPushBackZstr function
    bool test_str_push_back_zstr(void) {
    printf("Testing StrPushBackZstr\n");
    
    Str s = StrInitFromZstr("Hello");
    
    // Push a string at the back
    StrPushBackZstr(&s, " World");
    
    // Check that the string was inserted correctly
    StrInitStack(stack_str, 20, {
    // Inside the scope where the stack string is valid
    StrPushBackZstr(&stack_str, "Hello, Stack!");
    
    // Validate the string

Share :