From 2a61f6dfcd335f9710c883a18893dd837999dbf1 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 3 Sep 2018 10:59:11 +0200 Subject: [PATCH] Fix compiler warnings in c_blob_comparator and make it a local function Compiler warnings from clang: src/ccstruct/genblob.cpp:34:20: warning: use of old-style cast [-Wold-style-cast] src/ccstruct/genblob.cpp:34:32: warning: cast from 'const void *' to 'C_BLOB **' drops const qualifier [-Wcast-qual] src/ccstruct/genblob.cpp:35:20: warning: use of old-style cast [-Wold-style-cast] src/ccstruct/genblob.cpp:35:32: warning: cast from 'const void *' to 'C_BLOB **' drops const qualifier [-Wcast-qual] The function c_blob_comparator is only used in fixspace.cpp, so move it to that file, make it a local function, and remove genblob.cpp and genblob.h which are no longer needed. Signed-off-by: Stefan Weil --- src/ccmain/fixspace.cpp | 18 +++++++++++++++++- src/ccstruct/Makefile.am | 4 ++-- src/ccstruct/genblob.cpp | 38 -------------------------------------- src/ccstruct/genblob.h | 27 --------------------------- 4 files changed, 19 insertions(+), 68 deletions(-) delete mode 100644 src/ccstruct/genblob.cpp delete mode 100644 src/ccstruct/genblob.h diff --git a/src/ccmain/fixspace.cpp b/src/ccmain/fixspace.cpp index f821e7422..171efab2a 100644 --- a/src/ccmain/fixspace.cpp +++ b/src/ccmain/fixspace.cpp @@ -24,7 +24,6 @@ #include "blobs.h" // for TWERD, TBLOB, TESSLINE #include "boxword.h" // for BoxWord #include "errcode.h" // for ASSERT_HOST -#include "genblob.h" // for c_blob_comparator #include "host.h" // for FALSE, TRUE #include "normalis.h" // for kBlnXHeight, kBlnBaselineOffset #include "ocrclass.h" // for ETEXT_DESC @@ -49,6 +48,23 @@ class ROW; namespace tesseract { +/********************************************************************** + * c_blob_comparator() + * + * Blob comparator used to sort a blob list so that blobs are in increasing + * order of left edge. + **********************************************************************/ + +static int c_blob_comparator( // sort blobs + const void *blob1p, // ptr to ptr to blob1 + const void *blob2p // ptr to ptr to blob2 + ) { + const C_BLOB *blob1 = *reinterpret_cast(blob1p); + const C_BLOB *blob2 = *reinterpret_cast(blob2p); + + return blob1->bounding_box ().left () - blob2->bounding_box ().left (); +} + /** * @name fix_fuzzy_spaces() * Walk over the page finding sequences of words joined by fuzzy spaces. Extract diff --git a/src/ccstruct/Makefile.am b/src/ccstruct/Makefile.am index 63605df9e..ed4e6fd75 100644 --- a/src/ccstruct/Makefile.am +++ b/src/ccstruct/Makefile.am @@ -14,7 +14,7 @@ pkginclude_HEADERS = publictypes.h noinst_HEADERS = \ blamer.h blobbox.h blobs.h blread.h boxread.h boxword.h \ ccstruct.h coutln.h crakedge.h \ - debugpixa.h detlinefit.h dppoint.h fontinfo.h genblob.h \ + debugpixa.h detlinefit.h dppoint.h fontinfo.h \ imagedata.h \ ipoints.h \ linlsq.h matrix.h mod128.h normalis.h \ @@ -28,7 +28,7 @@ noinst_LTLIBRARIES = libtesseract_ccstruct.la libtesseract_ccstruct_la_SOURCES = \ blamer.cpp blobbox.cpp blobs.cpp blread.cpp boxread.cpp boxword.cpp ccstruct.cpp coutln.cpp \ - detlinefit.cpp dppoint.cpp fontinfo.cpp genblob.cpp \ + detlinefit.cpp dppoint.cpp fontinfo.cpp \ imagedata.cpp \ linlsq.cpp matrix.cpp mod128.cpp normalis.cpp \ ocrblock.cpp ocrpara.cpp ocrrow.cpp otsuthr.cpp \ diff --git a/src/ccstruct/genblob.cpp b/src/ccstruct/genblob.cpp deleted file mode 100644 index 03ae60b9a..000000000 --- a/src/ccstruct/genblob.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/********************************************************************** - * File: genblob.cpp (Formerly gblob.c) - * Description: Generic Blob processing routines - * Author: Phil Cheatle - * Created: Mon Nov 25 10:53:26 GMT 1991 - * - * (C) Copyright 1991, Hewlett-Packard Ltd. - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** http://www.apache.org/licenses/LICENSE-2.0 - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ** See the License for the specific language governing permissions and - ** limitations under the License. - * - **********************************************************************/ - -#include "genblob.h" -#include "stepblob.h" - -/********************************************************************** - * c_blob_comparator() - * - * Blob comparator used to sort a blob list so that blobs are in increasing - * order of left edge. - **********************************************************************/ - -int c_blob_comparator( // sort blobs - const void *blob1p, // ptr to ptr to blob1 - const void *blob2p // ptr to ptr to blob2 - ) { - C_BLOB *blob1 = *(C_BLOB **) blob1p; - C_BLOB *blob2 = *(C_BLOB **) blob2p; - - return blob1->bounding_box ().left () - blob2->bounding_box ().left (); -} diff --git a/src/ccstruct/genblob.h b/src/ccstruct/genblob.h deleted file mode 100644 index 2fb55a1a4..000000000 --- a/src/ccstruct/genblob.h +++ /dev/null @@ -1,27 +0,0 @@ -/********************************************************************** - * File: genblob.h (Formerly gblob.h) - * Description: Generic Blob processing routines - * Author: Phil Cheatle - * Created: Mon Nov 25 10:53:26 GMT 1991 - * - * (C) Copyright 1991, Hewlett-Packard Ltd. - ** Licensed under the Apache License, Version 2.0 (the "License"); - ** you may not use this file except in compliance with the License. - ** You may obtain a copy of the License at - ** http://www.apache.org/licenses/LICENSE-2.0 - ** Unless required by applicable law or agreed to in writing, software - ** distributed under the License is distributed on an "AS IS" BASIS, - ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ** See the License for the specific language governing permissions and - ** limitations under the License. - * - **********************************************************************/ - -#ifndef GENBLOB_H -#define GENBLOB_H - -// Sort function to sort blobs by ascending left edge. -int c_blob_comparator(const void *blob1p, // ptr to ptr to blob1 - const void *blob2p); - -#endif