Skip to content

Commit

Permalink
clang-tidy changes from sync
Browse files Browse the repository at this point in the history
  • Loading branch information
theraysmith committed Jan 26, 2017
1 parent a1c22fb commit f566a45
Show file tree
Hide file tree
Showing 45 changed files with 114 additions and 131 deletions.
5 changes: 2 additions & 3 deletions api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,9 +995,8 @@ bool TessBaseAPI::ProcessPagesMultipageTiff(const l_uint8 *data,
od.pixReadTiffCl(filename, page);
} else {
#endif // USE_OPENCL
pix = (data) ?
pixReadMemFromMultipageTiff(data, size, &offset) :
pixReadFromMultipageTiff(filename, &offset);
pix = (data) ? pixReadMemFromMultipageTiff(data, size, &offset)
: pixReadFromMultipageTiff(filename, &offset);
#ifdef USE_OPENCL
}
#endif // USE_OPENCL
Expand Down
58 changes: 30 additions & 28 deletions api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
#include "allheaders.h"
#include "baseapi.h"
#include "basedir.h"
#include "openclwrapper.h"
#include "osdetect.h"
#include "renderer.h"
#include "simddetect.h"
#include "strngs.h"
#include "tprintf.h"
#include "openclwrapper.h"
#include "osdetect.h"

#if defined(HAVE_TIFFIO_H) && defined(_WIN32)

Expand Down Expand Up @@ -64,37 +64,39 @@ void PrintVersionInfo() {
lept_free(versionStrP);

#ifdef USE_OPENCL
cl_platform_id platform[4];
cl_uint num_platforms;

printf(" OpenCL info:\n");
if (clGetPlatformIDs(4, platform, &num_platforms) == CL_SUCCESS) {
printf(" Found %u platform(s).\n", num_platforms);
for (unsigned n = 0; n < num_platforms; n++) {
char info[256];
if (clGetPlatformInfo(platform[n], CL_PLATFORM_NAME, 256, info, 0) == CL_SUCCESS) {
printf(" Platform %u name: %s.\n", n + 1, info);
}
if (clGetPlatformInfo(platform[n], CL_PLATFORM_VERSION, 256, info, 0) == CL_SUCCESS) {
printf(" Version: %s.\n", info);
}
cl_device_id devices[2];
cl_uint num_devices;
if (clGetDeviceIDs(platform[n], CL_DEVICE_TYPE_ALL, 2, devices, &num_devices) == CL_SUCCESS) {
printf(" Found %u device(s).\n", num_devices);
for (unsigned i = 0; i < num_devices; ++i) {
if (clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 256, info, 0) == CL_SUCCESS) {
printf(" Device %u name: %s.\n", i + 1, info);
}
cl_platform_id platform[4];
cl_uint num_platforms;

printf(" OpenCL info:\n");
if (clGetPlatformIDs(4, platform, &num_platforms) == CL_SUCCESS) {
printf(" Found %u platform(s).\n", num_platforms);
for (unsigned n = 0; n < num_platforms; n++) {
char info[256];
if (clGetPlatformInfo(platform[n], CL_PLATFORM_NAME, 256, info, 0) ==
CL_SUCCESS) {
printf(" Platform %u name: %s.\n", n + 1, info);
}
if (clGetPlatformInfo(platform[n], CL_PLATFORM_VERSION, 256, info, 0) ==
CL_SUCCESS) {
printf(" Version: %s.\n", info);
}
cl_device_id devices[2];
cl_uint num_devices;
if (clGetDeviceIDs(platform[n], CL_DEVICE_TYPE_ALL, 2, devices,
&num_devices) == CL_SUCCESS) {
printf(" Found %u device(s).\n", num_devices);
for (unsigned i = 0; i < num_devices; ++i) {
if (clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 256, info, 0) ==
CL_SUCCESS) {
printf(" Device %u name: %s.\n", i + 1, info);
}
}
}
}
}
#endif
if (SIMDDetect::IsAVXAvailable())
printf(" Found AVX\n");
if (SIMDDetect::IsSSEAvailable())
printf(" Found SSE\n");
if (SIMDDetect::IsAVXAvailable()) printf(" Found AVX\n");
if (SIMDDetect::IsSSEAvailable()) printf(" Found SSE\n");
}

void PrintUsage(const char* program) {
Expand Down
4 changes: 2 additions & 2 deletions ccmain/paramsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ class ParamsEditor : public SVEventHandler {
ScrollView* sv_window_;
};

#endif // GRAPHICS_DISABLED
#endif // TESSERACT_CCMAIN_PARAMSD_H_
#endif // GRAPHICS_DISABLED
#endif // TESSERACT_CCMAIN_PARAMSD_H_
3 changes: 2 additions & 1 deletion ccmain/tesseractclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ Tesseract::Tesseract()
this->params()),
BOOL_MEMBER(tessedit_create_pdf, false, "Write .pdf output file",
this->params()),
BOOL_MEMBER(textonly_pdf, false, "Create PDF with only one invisible text layer",
BOOL_MEMBER(textonly_pdf, false,
"Create PDF with only one invisible text layer",
this->params()),
STRING_MEMBER(unrecognised_char, "|",
"Output char for unidentified blobs", this->params()),
Expand Down
4 changes: 2 additions & 2 deletions ccmain/tesseractclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,8 @@ class Tesseract : public Wordrec {
BOOL_VAR_H(tessedit_create_hocr, false, "Write .html hOCR output file");
BOOL_VAR_H(tessedit_create_tsv, false, "Write .tsv output file");
BOOL_VAR_H(tessedit_create_pdf, false, "Write .pdf output file");
BOOL_VAR_H(textonly_pdf, false, "Create PDF with only one invisible text layer");
BOOL_VAR_H(textonly_pdf, false,
"Create PDF with only one invisible text layer");
STRING_VAR_H(unrecognised_char, "|",
"Output char for unidentified blobs");
INT_VAR_H(suspect_level, 99, "Suspect marker level");
Expand Down Expand Up @@ -1229,5 +1230,4 @@ class Tesseract : public Wordrec {

} // namespace tesseract


#endif // TESSERACT_CCMAIN_TESSERACTCLASS_H_
1 change: 0 additions & 1 deletion ccstruct/boxword.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,4 @@ class BoxWord {

} // namespace tesseract.


#endif // TESSERACT_CSTRUCT_BOXWORD_H_
1 change: 0 additions & 1 deletion ccstruct/ccstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ class CCStruct : public CUtil {
class Tesseract;
} // namespace tesseract


#endif // TESSERACT_CCSTRUCT_CCSTRUCT_H_
1 change: 0 additions & 1 deletion ccstruct/dppoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,3 @@ class DPPoint {
} // namespace tesseract.

#endif // TESSERACT_CCSTRUCT_DPPOINT_H_

1 change: 0 additions & 1 deletion ccutil/bitvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
//
///////////////////////////////////////////////////////////////////////


#ifndef TESSERACT_CCUTIL_BITVECTOR_H_
#define TESSERACT_CCUTIL_BITVECTOR_H_

Expand Down
2 changes: 1 addition & 1 deletion ccutil/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ template<class T> bool NearlyEqual(T x, T y, T tolerance) {
return diff <= tolerance && -diff <= tolerance;
}

#endif // TESSERACT_CCUTIL_HOST_H_
#endif // TESSERACT_CCUTIL_HOST_H_
4 changes: 2 additions & 2 deletions ccutil/lsterr.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ const ERRCODE BAD_PARAMETER = "List parameter error";
const ERRCODE STILL_LINKED =
"Attempting to add an element with non NULL links, to a list";

#endif // !NDEBUG
#endif // TESSERACT_CCUTIL_LSTERR_H_
#endif // !NDEBUG
#endif // TESSERACT_CCUTIL_LSTERR_H_
2 changes: 1 addition & 1 deletion ccutil/tesscallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -9718,4 +9718,4 @@ NewPermanentTessCallback(R (*function)(P1,P2,P3,P4,P5,P6,A1,A2,A3,A4,A5), typena
return new _TessFunctionResultCallback_6_5<false,R,P1,P2,P3,P4,P5,P6,A1,A2,A3,A4,A5>(function, p1, p2, p3, p4, p5, p6);
}

#endif // TESS_CALLBACK_SPECIALIZATIONS_H_
#endif // TESS_CALLBACK_SPECIALIZATIONS_H_
7 changes: 3 additions & 4 deletions ccutil/unicharcompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,19 @@ class UnicharCompress {
// encoder_ is the only part that is serialized. The rest is computed on load.
GenericVector<RecodedCharID> encoder_;
// Decoder converts the output of encoder back to a unichar-id.
std::unordered_map<RecodedCharID, int,
RecodedCharID::RecodedCharIDHash>
std::unordered_map<RecodedCharID, int, RecodedCharID::RecodedCharIDHash>
decoder_;
// True if the index is a valid single or start code.
GenericVector<bool> is_valid_start_;
// Maps a prefix code to a list of valid next codes.
// The map owns the vectors.
std::unordered_map<RecodedCharID, GenericVectorEqEq<int>*,
RecodedCharID::RecodedCharIDHash>
RecodedCharID::RecodedCharIDHash>
next_codes_;
// Maps a prefix code to a list of valid final codes.
// The map owns the vectors.
std::unordered_map<RecodedCharID, GenericVectorEqEq<int>*,
RecodedCharID::RecodedCharIDHash>
RecodedCharID::RecodedCharIDHash>
final_codes_;
// Max of any value in encoder_ + 1.
int code_range_;
Expand Down
2 changes: 1 addition & 1 deletion ccutil/universalambigs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ extern const int ksizeofUniversalAmbigsFile;

} // namespace tesseract

#endif // TESSERACT_CCUTIL_UNIVERSALAMBIGS_H_
#endif // TESSERACT_CCUTIL_UNIVERSALAMBIGS_H_
2 changes: 1 addition & 1 deletion classify/clusttool.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ void WriteProtoList(FILE *File, uinT16 N, PARAM_DESC ParamDesc[],
#define ILLEGALDISTRIBUTION 5008
#define ILLEGALFLOAT 5009
#define ILLEGALESSENTIALSPEC 5013
#endif // TESSERACT_CLASSIFY_CLUSTTOOL_H_
#endif // TESSERACT_CLASSIFY_CLUSTTOOL_H_
1 change: 0 additions & 1 deletion classify/intfeaturespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,4 @@ class IntFeatureSpace {

} // namespace tesseract.


#endif // TESSERACT_CLASSIFY_INTFEATURESPACE_H_
2 changes: 1 addition & 1 deletion classify/mastertrainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void MasterTrainer::LoadPageImages(const char* filename) {
size_t offset = 0;
int page;
Pix* pix;
for (page = 0; ; page++) {
for (page = 0;; page++) {
pix = pixReadFromMultipageTiff(filename, &offset);
if (!pix) break;
page_images_.push_back(pix);
Expand Down
2 changes: 1 addition & 1 deletion classify/mastertrainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,4 @@ class MasterTrainer {

} // namespace tesseract.

#endif // TESSERACT_TRAINING_MASTERTRAINER_H_
#endif // TESSERACT_TRAINING_MASTERTRAINER_H_
6 changes: 3 additions & 3 deletions opencl/opencl_device_selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
}

if (numDevices > 0) {
devices = (cl_device_id*)malloc(numDevices*sizeof(cl_device_id));
devices = (cl_device_id*)malloc(numDevices * sizeof(cl_device_id));
if (devices == nullptr) {
status = DS_MEMORY_ERROR;
goto cleanup;
Expand Down Expand Up @@ -578,5 +578,5 @@ static ds_status readProfileFromFile(ds_profile* profile,
return status;
}

#endif // USE_OPENCL
#endif // DEVICE_SELECTION_H
#endif // USE_OPENCL
#endif // DEVICE_SELECTION_H
5 changes: 2 additions & 3 deletions opencl/openclwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,5 @@ class OpenclDevice

};


#endif // USE_OPENCL
#endif // TESSERACT_OPENCL_OPENCLWRAPPER_H_
#endif // USE_OPENCL
#endif // TESSERACT_OPENCL_OPENCLWRAPPER_H_
1 change: 0 additions & 1 deletion textord/alignedblob.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,3 @@ class AlignedBlob : public BlobGrid {
} // namespace tesseract.

#endif // TESSERACT_TEXTORD_ALIGNEDBLOB_H_

1 change: 0 additions & 1 deletion textord/imagefind.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,3 @@ class ImageFind {
} // namespace tesseract.

#endif // TESSERACT_TEXTORD_LINEFIND_H_

1 change: 0 additions & 1 deletion textord/linefind.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,3 @@ class LineFinder {
} // namespace tesseract.

#endif // TESSERACT_TEXTORD_LINEFIND_H_

1 change: 0 additions & 1 deletion textord/workingpartset.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,3 @@ ELISTIZEH(WorkingPartSet)
} // namespace tesseract.

#endif // TESSERACT_TEXTORD_WORKINGPARSET_H_

4 changes: 2 additions & 2 deletions training/ambiguous_words.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ int main(int argc, char** argv) {
GenericVector<STRING> vars_values;
vars_vec.push_back("output_ambig_words_file");
vars_values.push_back(output_file_str);
api.Init(tessdata_dir, lang.string(), tesseract::OEM_TESSERACT_ONLY,
nullptr, 0, &vars_vec, &vars_values, false);
api.Init(tessdata_dir, lang.string(), tesseract::OEM_TESSERACT_ONLY, nullptr,
0, &vars_vec, &vars_values, false);
tesseract::Dict &dict = api.tesseract()->getDict();
FILE *input_file = fopen(input_file_str, "rb");
if (input_file == nullptr) {
Expand Down
5 changes: 3 additions & 2 deletions training/boxchar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ void BoxChar::InsertNewlines(bool rtl_rules, bool vertical_rules,
delete (*boxes)[i];
boxes->erase(boxes->begin() + i);
--i;
} while (i >= 0 && i + 1 == boxes->size() && (*boxes)[i]->box_ == nullptr);
} while (i >= 0 && i + 1 == boxes->size() &&
(*boxes)[i]->box_ == nullptr);
}
continue;
}
Expand Down Expand Up @@ -178,7 +179,7 @@ void BoxChar::InsertSpaces(bool rtl_rules, bool vertical_rules,
// Left becomes the max right of all next boxes forward to the first
// space or newline.
for (int j = i + 2; j < boxes->size() && (*boxes)[j]->box_ != nullptr &&
(*boxes)[j]->ch_ != "\t";
(*boxes)[j]->ch_ != "\t";
++j) {
next = (*boxes)[j]->box_;
if (next->x + next->w > left) {
Expand Down
3 changes: 2 additions & 1 deletion training/boxchar.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class BoxChar {
// Inserts newline (tab) characters into the vector at newline positions.
static void InsertNewlines(bool rtl_rules, bool vertical_rules,
vector<BoxChar*>* boxes);
// Converts nullptr boxes to space characters, with appropriate bounding boxes.
// Converts nullptr boxes to space characters, with appropriate bounding
// boxes.
static void InsertSpaces(bool rtl_rules, bool vertical_rules,
vector<BoxChar*>* boxes);
// Reorders text in a right-to-left script in left-to-right order.
Expand Down
9 changes: 4 additions & 5 deletions training/classifier_tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ enum ClassifierName {
CN_COUNT
};

const char* names[] = {"pruner", "full",
nullptr};
const char* names[] = {"pruner", "full", nullptr};

static tesseract::ShapeClassifier* InitializeClassifier(
const char* classifer_name, const UNICHARSET& unicharset,
Expand Down Expand Up @@ -121,8 +120,8 @@ static tesseract::ShapeClassifier* InitializeClassifier(
int main(int argc, char **argv) {
ParseArguments(&argc, &argv);
STRING file_prefix;
tesseract::MasterTrainer* trainer = tesseract::LoadTrainingData(
argc, argv, false, nullptr, &file_prefix);
tesseract::MasterTrainer* trainer =
tesseract::LoadTrainingData(argc, argv, false, nullptr, &file_prefix);
tesseract::TessBaseAPI* api;
// Decode the classifier string.
tesseract::ShapeClassifier* shape_classifier = InitializeClassifier(
Expand All @@ -137,7 +136,7 @@ int main(int argc, char **argv) {
// We want to test with replicated samples too.
trainer->ReplicateAndRandomizeSamplesIfRequired();

trainer->TestClassifierOnSamples(tesseract:: CT_UNICHAR_TOP1_ERR,
trainer->TestClassifierOnSamples(tesseract::CT_UNICHAR_TOP1_ERR,
MAX(3, FLAGS_debug_level), false,
shape_classifier, nullptr);
delete shape_classifier;
Expand Down
9 changes: 4 additions & 5 deletions training/cntraining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) {
const char *PageName;
FILE *TrainingPage;
LIST CharList = NIL_LIST;
CLUSTERER *Clusterer = nullptr;
CLUSTERER *Clusterer = nullptr;
LIST ProtoList = NIL_LIST;
LIST NormProtoList = NIL_LIST;
LIST pCharList;
Expand All @@ -150,8 +150,8 @@ int main(int argc, char *argv[]) {
while ((PageName = GetNextFilename(argc, argv)) != nullptr) {
printf("Reading %s ...\n", PageName);
TrainingPage = Efopen(PageName, "rb");
ReadTrainingSamples(FeatureDefs, PROGRAM_FEATURE_TYPE,
100, nullptr, TrainingPage, &CharList);
ReadTrainingSamples(FeatureDefs, PROGRAM_FEATURE_TYPE, 100, nullptr,
TrainingPage, &CharList);
fclose(TrainingPage);
++num_fonts;
}
Expand Down Expand Up @@ -229,8 +229,7 @@ void WriteNormProtos(const char *Directory, LIST LabeledProtoList,
int N;

Filename = "";
if (Directory != nullptr && Directory[0] != '\0')
{
if (Directory != nullptr && Directory[0] != '\0') {
Filename += Directory;
Filename += "/";
}
Expand Down
4 changes: 2 additions & 2 deletions training/commandlineflags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ void SetStringFlagValue(const char* flag_name, const char* new_val) {
}

bool SafeAtoi(const char* str, int* val) {
char *endptr = nullptr;
char* endptr = nullptr;
*val = strtol(str, &endptr, 10);
return endptr != nullptr && *endptr == '\0';
}

bool SafeAtod(const char* str, double* val) {
char *endptr = nullptr;
char* endptr = nullptr;
*val = strtod(str, &endptr);
return endptr != nullptr && *endptr == '\0';
}
Expand Down
Loading

0 comments on commit f566a45

Please sign in to comment.