diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-02-21 12:11:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-02-21 12:11:58 +0000 |
commit | 2bdc2226d245a24c948c4c98364d7da2adc6c860 (patch) | |
tree | 98c0d79abbdcf18b8509c29bacee7e75314732e9 /arg_parser.cc | |
parent | Adding upstream version 1.22. (diff) | |
download | lzip-20d7d2ff0d5f330fe0a9e6247282d986e0a835c7.tar.xz lzip-20d7d2ff0d5f330fe0a9e6247282d986e0a835c7.zip |
Adding upstream version 1.23.upstream/1.23
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'arg_parser.cc')
-rw-r--r-- | arg_parser.cc | 15 |
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; } |