Merge pull request #1488 from stweil/cmdline

training: Fix dubious parsing of command line
This commit is contained in:
zdenop 2018-04-18 08:26:59 +02:00 committed by GitHub
commit 36d6cb3a46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -170,14 +170,14 @@ void ParseCommandLineFlags(const char* usage,
break;
}
// Position current_arg after startings hyphens. We treat a sequence of
// consecutive hyphens of any length identically.
while (*current_arg == '-') {
// one or two consecutive hyphens identically.
++current_arg;
if (current_arg[0] == '-') {
++current_arg;
}
// If this is asking for usage, print the help message and abort.
if (!strcmp(current_arg, "help") ||
!strcmp(current_arg, "helpshort")) {
printf("USAGE: %s\n", usage);
if (!strcmp(current_arg, "help")) {
printf("Usage:\n %s [OPTION ...]\n\n", usage);
PrintCommandLineFlags();
exit(0);
}

View File

@ -67,7 +67,7 @@
namespace tesseract {
// Parse commandline flags and values. Prints the usage string and exits on
// input of --help or --helpshort.
// input of --help or --version.
//
// If remove_flags is true, the argv pointer is advanced so that (*argv)[1]
// points to the first non-flag argument, (*argv)[0] points to the same string