make cppcheck happy

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@388 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
joregan 2010-05-30 03:16:54 +00:00
parent c94e5fe528
commit cfcd9a1b5a
3 changed files with 23 additions and 11 deletions

View File

@ -222,6 +222,7 @@ int main(int argc, char **argv) {
FILE* fp = fopen(argv[1], "rb");
if (fp == NULL) {
tprintf("Image file %s cannot be opened!\n", argv[1]);
fclose(fp);
exit(1);
}
#ifdef HAVE_LIBLEPT
@ -260,17 +261,19 @@ int main(int argc, char **argv) {
// If the image fails to read, try it as a list of filenames.
PIX* pix = pixRead(argv[1]);
if (pix == NULL) {
FILE* fp = fopen(argv[1], "r");
if (fp == NULL) {
FILE* fimg = fopen(argv[1], "r");
if (fimg == NULL) {
tprintf("File %s cannot be opened!\n", argv[1]);
fclose(fimg);
exit(1);
}
char filename[MAX_PATH];
while (fgets(filename, sizeof(filename), fp) != NULL) {
while (fgets(filename, sizeof(filename), fimg) != NULL) {
chomp_string(filename);
pix = pixRead(filename);
if (pix == NULL) {
tprintf("Image file %s cannot be read!\n", filename);
fclose(fimg);
exit(1);
}
tprintf("Page %d : %s\n", page, filename);
@ -278,7 +281,7 @@ int main(int argc, char **argv) {
pixDestroy(&pix);
++page;
}
fclose(fp);
fclose(fimg);
} else {
TesseractImage(argv[1], NULL, pix, 0, &api, &text_out);
pixDestroy(&pix);
@ -341,12 +344,17 @@ int main(int argc, char **argv) {
#endif
#endif // HAVE_LIBLEPT
//no longer using ext or fp
delete[] ext;
fclose(fp);
bool output_hocr = tessedit_create_hocr;
outfile = argv[2];
outfile += output_hocr ? ".html" : tessedit_create_boxfile ? ".box" : ".txt";
fp = fopen(outfile.string(), "w");
if (fp == NULL) {
FILE* fout = fopen(outfile.string(), "w");
if (fout == NULL) {
tprintf("Cannot create output file %s\n", outfile.string());
fclose(fout);
exit(1);
}
if (output_hocr) {
@ -357,12 +365,12 @@ int main(int argc, char **argv) {
"<meta http-equiv=\"Content-Type\" content=\"text/html;"
"charset=utf-8\" >\n<meta name='ocr-system' content='tesseract'>\n"
"</head>\n<body>\n";
fprintf(fp, "%s", html_header);
fprintf(fout, "%s", html_header);
}
fwrite(text_out.string(), 1, text_out.length(), fp);
fwrite(text_out.string(), 1, text_out.length(), fout);
if (output_hocr)
fprintf(fp, "</body>\n</html>\n");
fclose(fp);
fprintf(fout, "</body>\n</html>\n");
fclose(fout);
return 0; //Normal exit
}

View File

@ -145,7 +145,7 @@ char* msg = new char[1024];
if (((STRING) * (sIt)).string() != NULL) {
sprintf(msg, "%s", ((STRING) * (sIt)).string());
} else {
return "Null";
sprintf(msg, "Null");
}
}
return msg;

View File

@ -137,6 +137,10 @@ class DLLSYM ELIST
last = NULL;
}
virtual ~ELIST() {
// Empty
}
void internal_clear ( //destroy all links
//ptr to zapper functn
void (*zapper) (ELIST_LINK *));