diff options
author | Håvard Pettersen <havardpe@oath.com> | 2022-03-31 11:44:10 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@oath.com> | 2022-04-01 10:24:32 +0000 |
commit | d71f76a73fe54558f613e75a3a8cfd70fc46a7e8 (patch) | |
tree | 7d170e5b792dbf5fed06ff7c7b2db398b6cb64c7 /searchlib/src/apps/vespa-attribute-inspect | |
parent | 1bb3dd192f4bcb91e710fe19ca54b2b8935ffb83 (diff) |
use getopt/getopt_long directly
Diffstat (limited to 'searchlib/src/apps/vespa-attribute-inspect')
-rw-r--r-- | searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp b/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp index 2d722a53adf..5cf7528ff1c 100644 --- a/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp +++ b/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp @@ -9,6 +9,7 @@ #include <vespa/fastlib/io/bufferedfile.h> #include <vespa/fastos/app.h> +#include <unistd.h> namespace search { @@ -112,11 +113,9 @@ LoadAttribute::Main() bool doFastSearch = false; bool doHuge = false; - int idx = 1; int opt; - const char * arg; bool optError = false; - while ((opt = GetOpt("pasf:h", arg, idx)) != -1) { + while ((opt = getopt(_argc, _argv, "pasf:h")) != -1) { switch (opt) { case 'p': doPrintContent = true; @@ -128,11 +127,11 @@ LoadAttribute::Main() doHuge = true; break; case 'f': - if (strcmp(arg, "search") == 0) { + if (strcmp(optarg, "search") == 0) { doFastSearch = true; } else { std::cerr << "Expected 'search' or 'aggregate', got '" << - arg << "'" << std::endl; + optarg << "'" << std::endl; optError = true; } break; @@ -145,12 +144,12 @@ LoadAttribute::Main() } } - if (_argc != (idx + 1) || optError) { + if (_argc != (optind + 1) || optError) { usage(); return -1; } - vespalib::string fileName(_argv[idx]); + vespalib::string fileName(_argv[optind]); vespalib::FileHeader fh; { vespalib::string datFileName(fileName + ".dat"); |