Skip to content

Conversation

GabrielBuica
Copy link
Contributor

I missed a few cases...

Signed-off-by: Gabriel Buica <[email protected]>
|> List.map (fun (k, v) -> Printf.sprintf "%s: %s" k v)
|> String.concat ","

let version_numbers_of_string version_string =
Copy link
Contributor

@lindig lindig Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if parsing this using sscanf with a couple of expected formats would be better. Here is a similar tactic that I used in C code to parse hours:minutes:seconds:

static float hms_to_sec(const char *duration)
{
    int hours = 0, minutes = 0;
    float seconds = 0.0;
    int items;

    items = sscanf(duration, "%u:%u:%f", &hours, &minutes, &seconds);
    if (items == 3) {
        return (float) hours *3600.0 + (float) minutes *60.0 + seconds;
    }
    items = sscanf(duration, "%u:%f", &minutes, &seconds);
    if (items == 2) {
        return (float) minutes *60.0 + seconds;
    }
    items = sscanf(duration, "%f", &seconds);
    if (items == 1) {
        return seconds;
    }
    return -1.0;
}

@GabrielBuica GabrielBuica added this pull request to the merge queue Oct 13, 2025
Merged via the queue into xapi-project:master with commit 9903379 Oct 13, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants