Skip to content

Commit

Permalink
tesseractmain: No command line options between image and outputbase
Browse files Browse the repository at this point in the history
The image name and the outputbase should not be separated by
command line options.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jun 2, 2018
1 parent e313ed1 commit 6dba34d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/api/tesseractmain.cpp
Expand Up @@ -301,9 +301,12 @@ static void ParseArgs(const int argc, char** argv, const char** lang,
}

bool noocr = false;
int i = 1;
while (i < argc && (*outputbase == nullptr || argv[i][0] == '-')) {
if (strcmp(argv[i], "-l") == 0 && i + 1 < argc) {
int i;
for (i = 1; i < argc && (*outputbase == nullptr || argv[i][0] == '-'); i++) {
if (*image != nullptr && *outputbase == nullptr) {
// outputbase follows image, don't allow options at that position.
*outputbase = argv[i];
} else if (strcmp(argv[i], "-l") == 0 && i + 1 < argc) {
*lang = argv[i + 1];
++i;
} else if (strcmp(argv[i], "--tessdata-dir") == 0 && i + 1 < argc) {
Expand Down Expand Up @@ -337,14 +340,11 @@ static void ParseArgs(const int argc, char** argv, const char** lang,
++i;
} else if (*image == nullptr) {
*image = argv[i];
} else if (*outputbase == nullptr) {
*outputbase = argv[i];
} else {
// Unexpected argument.
fprintf(stderr, "Error, unknown command line argument '%s'\n", argv[i]);
exit(1);
}
++i;
}

*arg_i = i;
Expand Down

0 comments on commit 6dba34d

Please sign in to comment.