Skip to content

ZstrToI64

Description

Parse a signed decimal integer from a null-terminated string. Skips ASCII whitespace, accepts an optional leading sign, then consumes the longest run of 0..9. Base-10 only; callers that need radix-aware parsing reach for the typed StrToI64 / StrToU64 family with a StrParseConfig.

Success

Returns the parsed value as i64. Overflow saturates to INT64_MAX / INT64_MIN.

Failure

Returns 0 when no digits are present.

Usage example (Cross-references)

Usage examples (Cross-references)
            return false;
        Zstr end = NULL;
        i64  v   = ZstrToI64(s, &end);
        if (!end || end == s || *end != '\0')
            return false;
    }
    
    i64 ZstrToI64(Zstr s, Zstr *endptr) {
        if (!s) {
            if (endptr)
                // for validity.
                exp_start = text + pos;
                parsed    = ZstrToI64(exp_start, &endptr);
                if (endptr == exp_start) {
                    LOG_ERROR("Invalid Float exponent");
        }
    
        parsed = ZstrToI64(StrBegin(value), &endptr);
    
        if (!endptr || endptr == StrBegin(value) || *endptr != '\0') {
            num->f = ZstrToF64(StrBegin(&ns), &end);
        } else {
            num->i = ZstrToI64(StrBegin(&ns), &end);
        }
        if (end == StrBegin(&ns)) {
            JR_OBJ_KV(si, "functions", {
                // First level: source function ID from key
                u64 source_function_id = (u64)ZstrToI64(StrBegin(&key), NULL);
                JR_OBJ(si, {
                    // Second level: target function ID from key
                JR_OBJ(si, {
                    // Second level: target function ID from key
                    u64 target_function_id = (u64)ZstrToI64(StrBegin(&key), NULL);
    
                    // Properly initialize all Str fields
            if (response.status) {
                JR_OBJ_KV(si, "data", {
                    u64 source_function_id = (u64)ZstrToI64(StrBegin(&key), NULL);
                    JR_OBJ(si, {
                        // Properly initialize all Str fields
                        sym.function_mangled_name = StrInit(&alloc);
                        sym.source_function_id    = source_function_id;
                        sym.target_function_id    = (u64)ZstrToI64(StrBegin(&key), NULL);
    
                        JR_OBJ(si, {
                WriteFmt("[DEBUG] Status is true, parsing data...\n");
                JR_OBJ_KV(si, "data", {
                    u64 source_function_id = (u64)ZstrToI64(StrBegin(&key), NULL);
                    WriteFmt("[DEBUG] Source function ID from key: {}\n", source_function_id);
                    JR_OBJ(si, {
                        sym.function_mangled_name = StrInit(&alloc);
                        sym.source_function_id    = source_function_id;
                        sym.target_function_id    = (u64)ZstrToI64(StrBegin(&key), NULL);
    
                        WriteFmt("[DEBUG] Target function ID from key: {}\n", sym.target_function_id);
                WriteFmt("[DEBUG] Status is true, parsing data...\n");
                JR_OBJ_KV(si, "data", {
                    u64 source_function_id = (u64)ZstrToI64(StrBegin(&key), NULL);
                    WriteFmt("[DEBUG] Source function ID from key: {}\n", source_function_id);
                    JR_OBJ(si, {
                        sym.function_mangled_name = StrInit(&alloc);
                        sym.source_function_id    = source_function_id;
                        sym.target_function_id    = (u64)ZstrToI64(StrBegin(&key), NULL);
    
                        WriteFmt("[DEBUG] Target function ID from key: {}\n", sym.target_function_id);
Last updated on