From: jsing Date: Sun, 28 Dec 2014 16:10:33 +0000 (+0000) Subject: Teach option parsing that a single hyphen denotes the end of named options X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=024f118435cd539ad938944c39130ad9ff9d3417;p=openbsd Teach option parsing that a single hyphen denotes the end of named options (as currently only implemented by some of the openssl(1) applications). --- diff --git a/usr.bin/openssl/apps.c b/usr.bin/openssl/apps.c index 7c774e40776..4640519cf1d 100644 --- a/usr.bin/openssl/apps.c +++ b/usr.bin/openssl/apps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.c,v 1.18 2014/12/28 15:48:52 jsing Exp $ */ +/* $OpenBSD: apps.c,v 1.19 2014/12/28 16:10:33 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -2271,8 +2271,20 @@ options_parse(int argc, char **argv, struct option *opts, char **unnamed, continue; } - if (*p == '\0') /* XXX - end of named options. */ + /* End of named options (single hyphen). */ + if (*p == '\0') { + if (++i >= argc) + goto done; + if (argsused != NULL) + goto done; + if (unnamed != NULL && i == argc - 1) { + if (*unnamed != NULL) + goto toomany; + *unnamed = argv[i]; + continue; + } goto unknown; + } for (j = 0; opts[j].name != NULL; j++) { opt = &opts[j];