From 18c6850fe1d06a31834da340387f94a6940197b9 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 16 Jun 2016 13:27:18 +0200 Subject: btrfs-progs: new helper for option parsing, more permissive for "no options" Signed-off-by: David Sterba --- utils.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'utils.c') diff --git a/utils.c b/utils.c index 72dc7d20..578fdb04 100644 --- a/utils.c +++ b/utils.c @@ -3930,6 +3930,24 @@ void clean_args_no_options(int argc, char *argv[], const char * const *usagestr) } } +/* + * Same as clean_args_no_options but pass through arguments that could look + * like short options. Eg. reisze which takes a negative resize argument like + * '-123M' . + * + * This accepts only two forms: + * - "-- option1 option2 ..." + * - "option1 option2 ..." + */ +void clean_args_no_options_relaxed(int argc, char *argv[], const char * const *usagestr) +{ + if (argc <= 1) + return; + + if (strcmp(argv[1], "--") == 0) + optind = 2; +} + /* Subvolume helper functions */ /* * test if name is a correct subvolume name -- cgit v1.2.3