Skip to content

Commit 6dba34d

Browse files
committed
tesseractmain: No command line options between image and outputbase
The image name and the outputbase should not be separated by command line options. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent e313ed1 commit 6dba34d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/api/tesseractmain.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,12 @@ static void ParseArgs(const int argc, char** argv, const char** lang,
301301
}
302302

303303
bool noocr = false;
304-
int i = 1;
305-
while (i < argc && (*outputbase == nullptr || argv[i][0] == '-')) {
306-
if (strcmp(argv[i], "-l") == 0 && i + 1 < argc) {
304+
int i;
305+
for (i = 1; i < argc && (*outputbase == nullptr || argv[i][0] == '-'); i++) {
306+
if (*image != nullptr && *outputbase == nullptr) {
307+
// outputbase follows image, don't allow options at that position.
308+
*outputbase = argv[i];
309+
} else if (strcmp(argv[i], "-l") == 0 && i + 1 < argc) {
307310
*lang = argv[i + 1];
308311
++i;
309312
} else if (strcmp(argv[i], "--tessdata-dir") == 0 && i + 1 < argc) {
@@ -337,14 +340,11 @@ static void ParseArgs(const int argc, char** argv, const char** lang,
337340
++i;
338341
} else if (*image == nullptr) {
339342
*image = argv[i];
340-
} else if (*outputbase == nullptr) {
341-
*outputbase = argv[i];
342343
} else {
343344
// Unexpected argument.
344345
fprintf(stderr, "Error, unknown command line argument '%s'\n", argv[i]);
345346
exit(1);
346347
}
347-
++i;
348348
}
349349

350350
*arg_i = i;

0 commit comments

Comments
 (0)