Open nagius opened 3 years ago
List.nth
won't keep only the right part but only the nth element of the split string. This works because there are no simple options containing an '-'.
And String.split_on_char
is only available since 4.04.0 so will fail compiling with older 3.x versions?
May be you could use instead something like this that will address both issues:
let name = String.sub oi.M.option_name (String.index oi.M.option_name '-' + 1) (String.length oi.M.option_name - 1 - String.index oi.M.option_name '-')
But don't ask me to make it less ugly because I'm clueless about OCaml.
Yes indeed, List.nth
will keep de second element of the string, but there is only one -
in every option names. The separator used in the option names is _
, so that seems to be a reasonable shortcut.
No idea about the OCaml version, I compiled it with the last version available on Ubuntu 20.20 using docker (see https://github.com/ygrek/mldonkey/pull/65). Do we want to keep compatibility with older OCaml ?
TBH, OCaml looks alien to me, I'm surprised I succeeded to compile this patch.
This PR fix the option parsing issue reported in https://github.com/ygrek/mldonkey/issues/34.
It basically split the option name in two with the separator
-
to keep only the right part. Fall back on previous way in case of error.