summaryrefslogtreecommitdiffstats
path: root/arg_parser.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-09 05:52:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-09 05:53:03 +0000
commit882d8d8da4a8b4a332458c4f01b03d81c2c08c78 (patch)
treed7acd130c7201183b14adfa8e095e79eb1f49bbe /arg_parser.cc
parentReleasing debian version 0.21-3. (diff)
downloadtarlz-882d8d8da4a8b4a332458c4f01b03d81c2c08c78.tar.xz
tarlz-882d8d8da4a8b4a332458c4f01b03d81c2c08c78.zip
Merging upstream version 0.22.
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 2e40a13..59998ac 100644
--- a/arg_parser.cc
+++ b/arg_parser.cc
@@ -1,5 +1,5 @@
/* Arg_parser - POSIX/GNU command line argument parser. (C++ version)
- Copyright (C) 2006-2021 Antonio Diaz Diaz.
+ Copyright (C) 2006-2022 Antonio Diaz Diaz.
This library is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided
@@ -35,9 +35,10 @@ bool Arg_parser::parse_long_option( const char * const opt, const char * const a
// Test all long options for either exact match or abbreviated matches.
for( int i = 0; options[i].code != 0; ++i )
- if( options[i].name && std::strncmp( options[i].name, &opt[2], len ) == 0 )
+ if( options[i].long_name &&
+ std::strncmp( options[i].long_name, &opt[2], len ) == 0 )
{
- if( std::strlen( options[i].name ) == len ) // Exact match found
+ if( std::strlen( options[i].long_name ) == len ) // Exact match found
{ index = i; exact = true; break; }
else if( index < 0 ) index = i; // First nonexact match found
else if( options[index].code != options[i].code ||
@@ -58,19 +59,19 @@ bool Arg_parser::parse_long_option( const char * const opt, const char * const a
}
++argind;
- data.push_back( Record( options[index].code ) );
+ data.push_back( Record( options[index].code, options[index].long_name ) );
if( opt[len+2] ) // '--<long_option>=<argument>' syntax
{
if( options[index].has_arg == no )
{
- error_ = "option '--"; error_ += options[index].name;
+ error_ = "option '--"; error_ += options[index].long_name;
error_ += "' doesn't allow an argument";
return false;
}
if( options[index].has_arg == yes && !opt[len+3] )
{
- error_ = "option '--"; error_ += options[index].name;
+ error_ = "option '--"; error_ += options[index].long_name;
error_ += "' requires an argument";
return false;
}
@@ -82,7 +83,7 @@ bool Arg_parser::parse_long_option( const char * const opt, const char * const a
{
if( !arg || !arg[0] )
{
- error_ = "option '--"; error_ += options[index].name;
+ error_ = "option '--"; error_ += options[index].long_name;
error_ += "' requires an argument";
return false;
}