Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
const char *argument_name;
size_t offset;
const char *help_msg;
const char *argument_name;
size_t offset;
const char *help_msg;
+#define ISL_ARG_SINGLE_DASH (1 << 0)
unsigned flags;
union {
struct {
unsigned flags;
union {
struct {
+ if (decl->short_name) {
printf(" -%c, --", decl->short_name);
printf(" -%c, --", decl->short_name);
+ len += 8;
+ } else if (decl->flags & ISL_ARG_SINGLE_DASH) {
+ printf(" -");
+ len += 3;
+ } else {
if (prefix) {
printf("%s-", prefix);
if (prefix) {
printf("%s-", prefix);
+static const char *skip_dash_dash(struct isl_arg *decl, const char *arg)
+{
+ if (!strncmp(arg, "--", 2))
+ return arg + 2;
+ if ((decl->flags & ISL_ARG_SINGLE_DASH) && arg[0] == '-')
+ return arg + 1;
+ return NULL;
+}
+
static const char *skip_name(struct isl_arg *decl, const char *arg,
const char *prefix, int need_argument, int *has_argument)
{
static const char *skip_name(struct isl_arg *decl, const char *arg,
const char *prefix, int need_argument, int *has_argument)
{
if (!decl->long_name)
return NULL;
if (!decl->long_name)
return NULL;
- if (strncmp(arg, "--", 2))
+ name = skip_dash_dash(decl, arg);
+ if (!name)
equal = strchr(name, '=');
if (need_argument && !equal)
return NULL;
equal = strchr(name, '=');
if (need_argument && !equal)
return NULL;
if (!decl->long_name)
return 0;
if (!decl->long_name)
return 0;
- if (strncmp(arg, "--", 2))
+ arg = skip_dash_dash(decl, arg);
+ if (!arg)
if (prefix) {
size_t prefix_len = strlen(prefix);
if (prefix) {
size_t prefix_len = strlen(prefix);