Skip to content

Make `try_parse` return original str if `endptr` is null

Zhou Qiankang requested to merge wszqkzqk/vala:return_str_when_nptr_is_null into main

For example:

void main () {
    uint64 num;
    string s;
    var a = uint64.try_parse ("1234567890", out num, out s, 1); // The base is invalid
    print (@"situation: $a\nconverted number: $num\nunparsed string: $s\n");
    if (s == null) {
        print ("s == null\n");
    }
}

And the output was:


** (process:233589): CRITICAL **: 10:25:23.808: string_to_string: assertion 'self != NULL' failed
situation: false
converted number: 0
unparsed string: s == null

Logically the whole string is not transformed here, so s may need to be original string instead of null......

Merge request reports