summaryrefslogtreecommitdiffstats
path: root/arg_parser.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-12-04 03:34:45 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-12-04 03:34:45 +0000
commitb1aab60d515050a32bc5764d0106aa01c10a4c0d (patch)
treef8704120bc97b8080b0d88a478dbaf665cb5145a /arg_parser.cc
parentReleasing debian version 1.24.1-2. (diff)
downloadlzip-b1aab60d515050a32bc5764d0106aa01c10a4c0d.tar.xz
lzip-b1aab60d515050a32bc5764d0106aa01c10a4c0d.zip
Merging upstream version 1.25~rc1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'arg_parser.cc')
-rw-r--r--arg_parser.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/arg_parser.cc b/arg_parser.cc
index 0c04d8e..0c528b2 100644
--- a/arg_parser.cc
+++ b/arg_parser.cc
@@ -75,19 +75,19 @@ bool Arg_parser::parse_long_option( const char * const opt, const char * const a
error_ += "' requires an argument";
return false;
}
- data.back().argument = &opt[len+3];
+ data.back().argument = &opt[len+3]; // argument may be empty
return true;
}
- if( options[index].has_arg == yes )
+ if( options[index].has_arg == yes || options[index].has_arg == yme )
{
- if( !arg || !arg[0] )
+ if( !arg || ( options[index].has_arg == yes && !arg[0] ) )
{
error_ = "option '--"; error_ += options[index].long_name;
error_ += "' requires an argument";
return false;
}
- ++argind; data.back().argument = arg;
+ ++argind; data.back().argument = arg; // argument may be empty
return true;
}
@@ -123,15 +123,16 @@ bool Arg_parser::parse_short_option( const char * const opt, const char * const
{
data.back().argument = &opt[cind]; ++argind; cind = 0;
}
- else if( options[index].has_arg == yes )
+ else if( options[index].has_arg == yes || options[index].has_arg == yme )
{
- if( !arg || !arg[0] )
+ if( !arg || ( options[index].has_arg == yes && !arg[0] ) )
{
error_ = "option requires an argument -- '"; error_ += c;
error_ += '\'';
return false;
}
- data.back().argument = arg; ++argind; cind = 0;
+ ++argind; cind = 0;
+ data.back().argument = arg; // argument may be empty
}
}
return true;