From 10a455f2bacf499f8f78cc4b0ad58f58130076d5 Mon Sep 17 00:00:00 2001 From: Nicholas Niro Date: Sat, 21 Oct 2023 15:59:00 -0400 Subject: [PATCH] option-parser: Add support for the '--' options This toggles parse_options to ignore the rest of the remaining options. Signed-off-by: Nicholas Niro --- shared/option-parser.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/shared/option-parser.c b/shared/option-parser.c index 55be1b5f..767f13c5 100644 --- a/shared/option-parser.c +++ b/shared/option-parser.c @@ -167,10 +167,17 @@ parse_options(const struct weston_option *options, int count, int *argc, char *argv[]) { int i, j; + int ignore_options = 0; for (i = 1, j = 1; i < *argc; i++) { - if (argv[i][0] == '-') { + if (argv[i][0] == '-' && ignore_options == 0) { if (argv[i][1] == '-') { + if (strlen(argv[i]) == 2) { + /* '--' to ignore the remaining options */ + i--; /* reinsert the '--' entry */ + ignore_options = 1; + continue; + } /* Long option, e.g. --foo or --foo=bar */ if (long_option(options, count, argv[i])) continue;