Skip to content

Commit

Permalink
Remove functions open_file, exists_file
Browse files Browse the repository at this point in the history
cutil.cpp is now no longer needed and removed, too.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 3, 2018
1 parent a0291c7 commit 2cd2d32
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 75 deletions.
13 changes: 10 additions & 3 deletions src/ccmain/recogtraining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "boxread.h"
#include "control.h"
#include "cutil.h"
#include "host.h"
#include "ratngs.h"
#include "reject.h"
Expand All @@ -45,7 +44,11 @@ FILE *Tesseract::init_recog_training(const STRING &fname) {
const char *lastdot = strrchr(output_fname.string(), '.');
if (lastdot != nullptr) output_fname[lastdot - output_fname.string()] = '\0';
output_fname += ".txt";
FILE *output_file = open_file(output_fname.string(), "a+");
FILE *output_file = fopen(output_fname.string(), "a+");
if (output_file == nullptr) {
tprintf("Error: Could not open file %s\n", output_fname.string());
ASSERT_HOST(output_file);
}
return output_file;
}

Expand Down Expand Up @@ -85,7 +88,11 @@ void Tesseract::recog_training_segmented(const STRING &fname,
if (lastdot != nullptr) box_fname[lastdot - box_fname.string()] = '\0';
box_fname += ".box";
// ReadNextBox() will close box_file
FILE *box_file = open_file(box_fname.string(), "r");
FILE *box_file = fopen(box_fname.string(), "r");
if (box_file == nullptr) {
tprintf("Error: Could not open file %s\n", box_fname.string());
ASSERT_HOST(box_file);
}

PAGE_RES_IT page_res_it;
page_res_it.page_res = page_res;
Expand Down
2 changes: 1 addition & 1 deletion src/cutil/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ noinst_HEADERS = \
noinst_LTLIBRARIES = libtesseract_cutil.la

libtesseract_cutil_la_SOURCES = \
bitvec.cpp callcpp.cpp cutil.cpp cutil_class.cpp danerror.cpp \
bitvec.cpp callcpp.cpp cutil_class.cpp danerror.cpp \
emalloc.cpp \
oldlist.cpp structures.cpp
60 changes: 0 additions & 60 deletions src/cutil/cutil.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions src/cutil/cutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,5 @@ typedef void (*void_dest) (void *);
#define print_string(str) \
printf ("%s\n", str)

/*----------------------------------------------------------------------
F u n c t i o n s
----------------------------------------------------------------------*/

FILE *open_file(const char *filename, const char *mode);

bool exists_file(const char *filename);

#include "cutil_class.h"
#endif
7 changes: 5 additions & 2 deletions src/dict/dawg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include "dawg.h"

#include "cutil.h"
#include "dict.h"
#include "emalloc.h"
#include "helpers.h"
Expand Down Expand Up @@ -78,7 +77,11 @@ int Dawg::check_for_words(const char *filename,
int misses = 0;
UNICHAR_ID wildcard = unicharset.unichar_to_id(kWildcard);

word_file = open_file (filename, "r");
word_file = fopen(filename, "r");
if (word_file == nullptr) {
tprintf("Error: Could not open file %s\n", filename);
ASSERT_HOST(word_file);
}

while (fgets (string, CHARS_PER_LINE, word_file) != nullptr) {
chomp_string(string); // remove newline
Expand Down
6 changes: 5 additions & 1 deletion src/dict/dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,11 @@ void Dict::add_document_word(const WERD_CHOICE &best_choice) {
if (save_doc_words) {
STRING filename(getCCUtil()->imagefile);
filename += ".doc";
FILE *doc_word_file = open_file (filename.string(), "a");
FILE *doc_word_file = fopen(filename.string(), "a");
if (doc_word_file == nullptr) {
tprintf("Error: Could not open file %s\n", filename.string());
ASSERT_HOST(doc_word_file);
}
fprintf(doc_word_file, "%s\n",
best_choice.debug_string().string());
fclose(doc_word_file);
Expand Down

0 comments on commit 2cd2d32

Please sign in to comment.