X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/blobdiff_plain/f4125505064e3ff346b31ab9e48f894672e5a7a7..fc5dcac1115a7112e7ad9d67ce7fe233790e0887:/options.cpp diff --git a/options.cpp b/options.cpp index 4dd5315..d51fee2 100644 --- a/options.cpp +++ b/options.cpp @@ -34,6 +34,8 @@ namespace { int opt::parse_args(int* argc, char* argv[]) { + int result = 1; + char* tmp = strrchr(argv[0], '/'); opt::program_name = (tmp ? tmp + 1 : argv[0]); @@ -54,29 +56,35 @@ int opt::parse_args(int* argc, char* argv[]) opt::version_requested = true; break; case '?': - WARN1("invalid option -- '%c'", optopt); + ERROR1("invalid option -- '%c'", optopt); + result = 0; break; } } if (opt::version_requested || opt::help_requested) return 1; - switch (*argc - optind) { + int rem_args = *argc - optind; + switch (rem_args) { case 0: ERROR0("missing parameter -- "); case 1: ERROR0("missing parameter -- "); - return 0; + result = 0; + break; default: opt::platform_file = argv[optind]; opt::application_file = argv[optind + 1]; + if (rem_args == 2) + break; for (int i = optind + 2 ; i < *argc ; ++i) - WARN1("unused parameter -- \"%s\"", argv[i]); + ERROR1("unused parameter -- \"%s\"", argv[i]); + result = 0; break; } - return 1; + return result; } void opt::print() @@ -106,6 +114,7 @@ void opt::usage() << "print help and exit (use -hh or -hhh for extended help)\n"; if (opt::help_requested < 1) return; + std::clog << o("-V") << "print version and exit\n"; std::clog << o("-b") << "activate bookkeeping\n"; std::clog << oo("-c", "[fn,...]f0")