Skip to content

Commit

Permalink
Replace Efopen by fopen and remove efio.cpp, efio.h
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 2, 2018
1 parent 909af5d commit b57afc7
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 114 deletions.
1 change: 0 additions & 1 deletion src/ccmain/tessedit.cpp
Expand Up @@ -36,7 +36,6 @@
#include "stopper.h"
#include "intmatcher.h"
#include "chop.h"
#include "efio.h"
#include "danerror.h"
#include "globals.h"
#ifndef ANDROID_BUILD
Expand Down
14 changes: 8 additions & 6 deletions src/classify/blobclass.cpp
Expand Up @@ -24,7 +24,6 @@
#include <cstdio>

#include "classify.h"
#include "efio.h"
#include "featdefs.h"
#include "mf.h"
#include "normfeat.h"
Expand Down Expand Up @@ -95,12 +94,15 @@ void Classify::LearnBlob(const STRING& fontname, TBLOB* blob,
// Writes stored training data to a .tr file based on the given filename.
// Returns false on error.
bool Classify::WriteTRFile(const STRING& filename) {
bool result = false;
STRING tr_filename = filename + ".tr";
FILE* fp = Efopen(tr_filename.string(), "wb");
const size_t len = tr_file_data_.length();
const bool result =
fwrite(&tr_file_data_[0], sizeof(tr_file_data_[0]), len, fp) == len;
fclose(fp);
FILE* fp = fopen(tr_filename.string(), "wb");
if (fp) {
const size_t len = tr_file_data_.length();
result =
fwrite(&tr_file_data_[0], sizeof(tr_file_data_[0]), len, fp) == len;
fclose(fp);
}
tr_file_data_.truncate_at(0);
return result;
}
Expand Down
1 change: 0 additions & 1 deletion src/classify/cutoffs.cpp
Expand Up @@ -23,7 +23,6 @@
#include <cstdio>

#include "classify.h"
#include "efio.h"
#include "globals.h"
#include "helpers.h"
#include "serialis.h"
Expand Down
3 changes: 1 addition & 2 deletions src/classify/mastertrainer.cpp
Expand Up @@ -30,7 +30,6 @@
#include "allheaders.h"
#include "boxread.h"
#include "classify.h"
#include "efio.h"
#include "errorcounter.h"
#include "featdefs.h"
#include "sampleiterator.h"
Expand Down Expand Up @@ -121,7 +120,7 @@ void MasterTrainer::ReadTrainingSamples(const char* page_name,
const int cn_feature_type = ShortNameToFeatureType(feature_defs, kCNFeatureType);
const int geo_feature_type = ShortNameToFeatureType(feature_defs, kGeoFeatureType);

FILE* fp = Efopen(page_name, "rb");
FILE* fp = fopen(page_name, "rb");
if (fp == nullptr) {
tprintf("Failed to open tr file: %s\n", page_name);
return;
Expand Down
1 change: 0 additions & 1 deletion src/classify/normmatch.cpp
Expand Up @@ -26,7 +26,6 @@
#include "classify.h"
#include "clusttool.h"
#include "const.h"
#include "efio.h"
#include "emalloc.h"
#include "globals.h"
#include "helpers.h"
Expand Down
1 change: 0 additions & 1 deletion src/classify/outfeat.cpp
Expand Up @@ -21,7 +21,6 @@
#include "outfeat.h"

#include "classify.h"
#include "efio.h"
#include "featdefs.h"
#include "mfoutline.h"
#include "ocrfeatures.h"
Expand Down
1 change: 0 additions & 1 deletion src/classify/picofeat.cpp
Expand Up @@ -21,7 +21,6 @@
#include "picofeat.h"

#include "classify.h"
#include "efio.h"
#include "featdefs.h"
#include "fpoint.h"
#include "mfoutline.h"
Expand Down
4 changes: 2 additions & 2 deletions src/cutil/Makefile.am
Expand Up @@ -8,13 +8,13 @@ AM_CPPFLAGS += -DTESS_EXPORTS \
endif

noinst_HEADERS = \
bitvec.h callcpp.h const.h cutil.h cutil_class.h danerror.h efio.h \
bitvec.h callcpp.h const.h cutil.h cutil_class.h danerror.h \
emalloc.h globals.h \
oldlist.h structures.h

noinst_LTLIBRARIES = libtesseract_cutil.la

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

This file was deleted.

32 changes: 0 additions & 32 deletions src/cutil/efio.h

This file was deleted.

1 change: 0 additions & 1 deletion src/dict/stopper.cpp
Expand Up @@ -27,7 +27,6 @@
#include "const.h"
#include "danerror.h"
#include "dict.h"
#include "efio.h"
#include "helpers.h"
#include "matchdefs.h"
#include "pageres.h"
Expand Down
18 changes: 10 additions & 8 deletions src/training/cntraining.cpp
Expand Up @@ -24,7 +24,6 @@
Include Files and Type Defines
----------------------------------------------------------------------------*/
#include "oldlist.h"
#include "efio.h"
#include "emalloc.h"
#include "featdefs.h"
#include "tessopt.h"
Expand Down Expand Up @@ -120,7 +119,6 @@ int main(int argc, char *argv[]) {
Config = CNConfig;

const char *PageName;
FILE *TrainingPage;
LIST CharList = NIL_LIST;
CLUSTERER *Clusterer = nullptr;
LIST ProtoList = NIL_LIST;
Expand All @@ -134,11 +132,14 @@ int main(int argc, char *argv[]) {
int num_fonts = 0;
while ((PageName = GetNextFilename(argc, argv)) != nullptr) {
printf("Reading %s ...\n", PageName);
TrainingPage = Efopen(PageName, "rb");
ReadTrainingSamples(FeatureDefs, PROGRAM_FEATURE_TYPE, 100, nullptr,
TrainingPage, &CharList);
fclose(TrainingPage);
++num_fonts;
FILE *TrainingPage = fopen(PageName, "rb");
ASSERT_HOST(TrainingPage);
if (TrainingPage) {
ReadTrainingSamples(FeatureDefs, PROGRAM_FEATURE_TYPE, 100, nullptr,
TrainingPage, &CharList);
fclose(TrainingPage);
++num_fonts;
}
}
printf("Clustering ...\n");
// To allow an individual font to form a separate cluster,
Expand Down Expand Up @@ -220,7 +221,8 @@ static void WriteNormProtos(const char *Directory, LIST LabeledProtoList,
}
Filename += "normproto";
printf ("\nWriting %s ...", Filename.string());
File = Efopen (Filename.string(), "wb");
File = fopen(Filename.string(), "wb");
ASSERT_HOST(File);
fprintf(File, "%0d\n", feature_desc->NumParams);
WriteParamDesc(File, feature_desc->NumParams, feature_desc->ParamDesc);
iterate(LabeledProtoList)
Expand Down
1 change: 0 additions & 1 deletion src/training/commontraining.cpp
Expand Up @@ -21,7 +21,6 @@
#include "classify.h"
#include "cluster.h"
#include "clusttool.h"
#include "efio.h"
#include "emalloc.h"
#include "featdefs.h"
#include "fontinfo.h"
Expand Down
1 change: 0 additions & 1 deletion src/training/mergenf.cpp
Expand Up @@ -17,7 +17,6 @@
******************************************************************************/
#include "mergenf.h"
#include "host.h"
#include "efio.h"
#include "clusttool.h"
#include "cluster.h"
#include "oldlist.h"
Expand Down
1 change: 0 additions & 1 deletion src/training/mftraining.cpp
Expand Up @@ -39,7 +39,6 @@
#include "clusttool.h"
#include "commontraining.h"
#include "danerror.h"
#include "efio.h"
#include "emalloc.h"
#include "featdefs.h"
#include "fontinfo.h"
Expand Down

0 comments on commit b57afc7

Please sign in to comment.