mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
sysprep: Make a common Utils.compare_command_line_args function.
This isn't quite code motion, since the new function also ignores case (which previously we didn't ignore).
This commit is contained in:
@@ -138,10 +138,8 @@ let dump_pod_options () =
|
||||
| Arg.Rest _ -> assert false (* XXX not implemented *)
|
||||
) args in
|
||||
|
||||
let args = List.sort (
|
||||
fun (a, _) (b, _) ->
|
||||
compare (skip_dashes a) (skip_dashes b)
|
||||
) args in
|
||||
let args =
|
||||
List.sort (fun (a, _) (b, _) -> compare_command_line_args a b) args in
|
||||
|
||||
List.iter (
|
||||
fun (arg_name, (op_name, heading, pod)) ->
|
||||
|
||||
@@ -81,3 +81,6 @@ let skip_dashes str =
|
||||
let i = loop 0 in
|
||||
if i = 0 then str
|
||||
else String.sub str i (n-i)
|
||||
|
||||
let compare_command_line_args a b =
|
||||
compare (String.lowercase (skip_dashes a)) (String.lowercase (skip_dashes b))
|
||||
|
||||
@@ -44,3 +44,8 @@ val skip_dashes : string -> string
|
||||
|
||||
If the string contains only dash characters, this raises
|
||||
[Invalid_argument "skip_dashes"]. *)
|
||||
|
||||
val compare_command_line_args : string -> string -> int
|
||||
(** Compare two command line arguments (eg. ["-a"] and ["--V"]),
|
||||
ignoring leading dashes and case. Note this assumes the
|
||||
strings are 7 bit ASCII. *)
|
||||
|
||||
Reference in New Issue
Block a user