diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/getopt/small/opt.cpp | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/getopt/small/opt.cpp')
-rw-r--r-- | library/cpp/getopt/small/opt.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/library/cpp/getopt/small/opt.cpp b/library/cpp/getopt/small/opt.cpp index 744501765c..36b083ce2a 100644 --- a/library/cpp/getopt/small/opt.cpp +++ b/library/cpp/getopt/small/opt.cpp @@ -1,13 +1,13 @@ -#include "opt.h" - -#include <util/system/progname.h> +#include "opt.h" +#include <util/system/progname.h> + #include <ctype.h> using namespace NLastGetopt; namespace { - struct TOptsNoDefault: public TOpts { + struct TOptsNoDefault: public TOpts { TOptsNoDefault(const TStringBuf& optstring = TStringBuf()) : TOpts(optstring) { @@ -48,7 +48,7 @@ Opt::Opt(int argc, char* argv[], const char* optString, const Ion* longOptions, } Opt::Opt(int argc, const char* argv[], const char* optString, const Ion* longOptions, bool longOnly, bool isOpen) { - Init(argc, (char**)argv, optString, longOptions, longOnly, isOpen); + Init(argc, (char**)argv, optString, longOptions, longOnly, isOpen); } int Opt::Get() { @@ -58,7 +58,7 @@ int Opt::Get() { int Opt::Get(int* longOptionIndex) { if (GotError_) return EOF; - + Arg = nullptr; try { @@ -67,12 +67,12 @@ int Opt::Get(int* longOptionIndex) { if (!r) { return EOF; } else { - Arg = (char*)OptsParser_->CurVal(); + Arg = (char*)OptsParser_->CurVal(); if (!OptsParser_->CurOpt()) { // possible if RETURN_IN_ORDER return 1; } else { - const Ion* ion = (const Ion*)OptsParser_->CurOpt()->UserValue(); + const Ion* ion = (const Ion*)OptsParser_->CurOpt()->UserValue(); if (longOptionIndex) { *longOptionIndex = int(ion - Ions_); } @@ -100,20 +100,20 @@ const char** Opt::GetArgV() const { return OptsParser_->Argv_; } -int opt_get_number(int& argc, char* argv[]) { - int num = -1; - for (int a = 1; a < argc; a++) { - if (*argv[a] == '-' && isdigit((ui8)argv[a][1])) { - char* ne; - num = strtol(argv[a] + 1, &ne, 10); - if (*ne) { - memmove(argv[a] + 1, ne, strlen(ne) + 1); - } else { - for (argc--; a < argc; a++) - argv[a] = argv[a + 1]; - } - break; - } - } - return num; +int opt_get_number(int& argc, char* argv[]) { + int num = -1; + for (int a = 1; a < argc; a++) { + if (*argv[a] == '-' && isdigit((ui8)argv[a][1])) { + char* ne; + num = strtol(argv[a] + 1, &ne, 10); + if (*ne) { + memmove(argv[a] + 1, ne, strlen(ne) + 1); + } else { + for (argc--; a < argc; a++) + argv[a] = argv[a + 1]; + } + break; + } + } + return num; } |