mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-11 23:19:04 +08:00
Issue #529: inside main() use return rather than exit
This commit is contained in:
parent
90db5a17f0
commit
e465542a99
@ -437,14 +437,14 @@ int main(int argc, char** argv) {
|
|||||||
argc - arg_i, &vars_vec, &vars_values, false);
|
argc - arg_i, &vars_vec, &vars_values, false);
|
||||||
if (init_failed) {
|
if (init_failed) {
|
||||||
fprintf(stderr, "Could not initialize tesseract.\n");
|
fprintf(stderr, "Could not initialize tesseract.\n");
|
||||||
exit(1);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetVariablesFromCLArgs(&api, argc, argv);
|
SetVariablesFromCLArgs(&api, argc, argv);
|
||||||
|
|
||||||
if (list_langs) {
|
if (list_langs) {
|
||||||
PrintLangsList(&api);
|
PrintLangsList(&api);
|
||||||
exit(0);
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_parameters) {
|
if (print_parameters) {
|
||||||
@ -452,18 +452,18 @@ int main(int argc, char** argv) {
|
|||||||
fprintf(stdout, "Tesseract parameters:\n");
|
fprintf(stdout, "Tesseract parameters:\n");
|
||||||
api.PrintVariables(fout);
|
api.PrintVariables(fout);
|
||||||
api.End();
|
api.End();
|
||||||
exit(0);
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
FixPageSegMode(&api, pagesegmode);
|
FixPageSegMode(&api, pagesegmode);
|
||||||
|
|
||||||
if (pagesegmode == tesseract::PSM_AUTO_ONLY) {
|
if (pagesegmode == tesseract::PSM_AUTO_ONLY) {
|
||||||
int ret_val = 0;
|
int ret_val = EXIT_SUCCESS;
|
||||||
|
|
||||||
Pix* pixs = pixRead(image);
|
Pix* pixs = pixRead(image);
|
||||||
if (!pixs) {
|
if (!pixs) {
|
||||||
fprintf(stderr, "Cannot open input file: %s\n", image);
|
fprintf(stderr, "Cannot open input file: %s\n", image);
|
||||||
exit(2);
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
api.SetImage(pixs);
|
api.SetImage(pixs);
|
||||||
@ -481,13 +481,13 @@ int main(int argc, char** argv) {
|
|||||||
"Deskew angle: %.4f\n",
|
"Deskew angle: %.4f\n",
|
||||||
orientation, direction, order, deskew_angle);
|
orientation, direction, order, deskew_angle);
|
||||||
} else {
|
} else {
|
||||||
ret_val = 1;
|
ret_val = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete it;
|
delete it;
|
||||||
|
|
||||||
pixDestroy(&pixs);
|
pixDestroy(&pixs);
|
||||||
exit(ret_val);
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set in_training_mode to true when using one of these configs:
|
// set in_training_mode to true when using one of these configs:
|
||||||
@ -512,10 +512,11 @@ int main(int argc, char** argv) {
|
|||||||
bool succeed = api.ProcessPages(image, NULL, 0, renderers[0]);
|
bool succeed = api.ProcessPages(image, NULL, 0, renderers[0]);
|
||||||
if (!succeed) {
|
if (!succeed) {
|
||||||
fprintf(stderr, "Error during processing.\n");
|
fprintf(stderr, "Error during processing.\n");
|
||||||
exit(1);
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PERF_COUNT_END
|
PERF_COUNT_END
|
||||||
return 0; // Normal exit
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user