Skip to content

Commit

Permalink
Merge pull request tesseract-ocr#2466 from stweil/warnings
Browse files Browse the repository at this point in the history
Fix more compiler warnings (mostly unused macros, unused methods)
  • Loading branch information
egorpugin authored May 26, 2019
2 parents 3971562 + 2c23e7e commit 4db6b9e
Show file tree
Hide file tree
Showing 26 changed files with 64 additions and 155 deletions.
3 changes: 0 additions & 3 deletions src/ccmain/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
#include "tessvars.h"
#include "werdit.h"

#define MIN_FONT_ROW_COUNT 8
#define MAX_XHEIGHT_DIFF 3

const char* const kBackUpConfigFile = "tempconfigdata.config";
// Min believable x-height for any text when refitting as a fraction of
// original x-height
Expand Down
1 change: 0 additions & 1 deletion src/ccmain/fixspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class BLOCK;
class ROW;

#define PERFECT_WERDS 999
#define MAXSPACING 128 /*max expected spacing in pix */

namespace tesseract {

Expand Down
9 changes: 1 addition & 8 deletions src/ccmain/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@
#include "reject.h"
#endif

#define EPAPER_EXT ".ep"
#define PAGE_YSIZE 3508
#define CTRL_INSET '\024' //dc4=text inset
#define CTRL_FONT '\016' //so=font change
#define CTRL_DEFAULT '\017' //si=default font
#define CTRL_SHIFT '\022' //dc2=x shift
#define CTRL_TAB '\011' //tab
#define CTRL_NEWLINE '\012' //newline
#define CTRL_NEWLINE '\012' //newline
#define CTRL_HARDLINE '\015' //cr

namespace tesseract {
Expand Down
1 change: 0 additions & 1 deletion src/ccmain/pgedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#define X_HEIGHT (kBlnBaselineOffset + kBlnXHeight)
#define BL_HEIGHT kBlnBaselineOffset
#define DESC_HEIGHT 0
#define MAXSPACING 128 /*max expected spacing in pix */

enum CMD_EVENTS
{
Expand Down
3 changes: 0 additions & 3 deletions src/ccmain/tessedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
# include "lstmrecognizer.h"
#endif

// config under api
#define API_CONFIG "configs/api_config"

namespace tesseract {

// Read a "config" file containing a set of variable, value pairs.
Expand Down
2 changes: 0 additions & 2 deletions src/ccstruct/ocrblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include "stepblob.h"
#include "tprintf.h"

#define BLOCK_LABEL_HEIGHT 150 //char height of block id

ELISTIZE (BLOCK)
/**
* BLOCK::BLOCK
Expand Down
1 change: 0 additions & 1 deletion src/ccstruct/polyaprx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "tprintf.h" // for tprintf
#include "vecfuncs.h" // for LENGTH, point_diff, CROSS

#define EXTERN
#define FASTEDGELENGTH 256

static BOOL_VAR(poly_debug, false, "Debug old poly");
Expand Down
1 change: 0 additions & 1 deletion src/ccutil/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#define PLUS '+' //flag states
#define MINUS '-'
#define EQUAL '='

tesseract::ParamsVectors *GlobalParams() {
static tesseract::ParamsVectors global_params = tesseract::ParamsVectors();
Expand Down
2 changes: 0 additions & 2 deletions src/classify/cutoffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include "serialis.h"
#include "unichar.h"

#define REALLY_QUOTE_IT(x) QUOTE_IT(x)

#define MAX_CUTOFF 1000

namespace tesseract {
Expand Down
8 changes: 0 additions & 8 deletions src/classify/mfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
Include Files and Type Defines
----------------------------------------------------------------------------*/

#define _USE_MATH_DEFINES // for M_PI
#include "mfx.h"
#include <cmath> // for M_PI
#include "mfdefs.h"
#include "mfoutline.h"
#include "clusttool.h" //NEEDED
Expand All @@ -38,12 +36,6 @@ double_VAR(classify_min_slope, 0.414213562,
double_VAR(classify_max_slope, 2.414213562,
"Slope above which lines are called vertical");

/*----------------------------------------------------------------------------
Macros
----------------------------------------------------------------------------*/
/* miscellaneous macros */
#define NormalizeAngle(A) ((((A) < 0) ? ((A) + 2 * M_PI) : (A)) / (2 * M_PI))

/*----------------------------------------------------------------------------
Private Function Prototypes
-----------------------------------------------------------------------------*/
Expand Down
17 changes: 0 additions & 17 deletions src/cutil/oldlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,6 @@
#include "errcode.h" // for ASSERT_HOST
#include "structures.h"

/*----------------------------------------------------------------------
M a c r o s
----------------------------------------------------------------------*/
#define add_on(l, x) l = push(l, first_node(x))
#define next_one(l) l = list_rest(l)

/**********************************************************************
* c o p y f i r s t
*
* Do the appropriate kind a push operation to copy the first node from
* one list to another.
*
**********************************************************************/

#define copy_first(l1,l2) \
(l2=push(l2, first_node(l1)))

/*----------------------------------------------------------------------
F u n c t i o n s
----------------------------------------------------------------------*/
Expand Down
6 changes: 2 additions & 4 deletions src/textord/drawtord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@
#define TO_WIN_NAME "Textord"
//title of window

#define EXTERN

EXTERN BOOL_VAR (textord_show_fixed_cuts, false,
BOOL_VAR (textord_show_fixed_cuts, false,
"Draw fixed pitch cell boundaries");

EXTERN ScrollView* to_win = nullptr;
ScrollView* to_win = nullptr;

/**********************************************************************
* create_to_win
Expand Down
2 changes: 0 additions & 2 deletions src/textord/edgblob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include "config_auto.h"
#endif

#define EXTERN

// Control parameters used in outline_complexity(), which rejects an outline
// if any one of the 3 conditions is satisfied:
// - number of children exceeds edges_max_children_per_outline
Expand Down
6 changes: 2 additions & 4 deletions src/textord/fpchop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
#include "config_auto.h"
#endif

#define EXTERN

EXTERN INT_VAR (textord_fp_chop_error, 2,
INT_VAR (textord_fp_chop_error, 2,
"Max allowed bending of chop cells");
EXTERN double_VAR (textord_fp_chop_snap, 0.5,
double_VAR (textord_fp_chop_snap, 0.5,
"Max distance of chop pt from vertex");

ELISTIZE(C_OUTLINE_FRAG)
Expand Down
9 changes: 2 additions & 7 deletions src/textord/oldbasel.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**********************************************************************
* File: oldbasel.cpp (Formerly oldbl.c)
* Description: A re-implementation of the old baseline algorithm.
* Author: Ray Smith
* Author: Ray Smith
*
* (C) Copyright 1993, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -34,11 +34,9 @@

#include <algorithm>

#define EXTERN

static BOOL_VAR (textord_really_old_xheight, false,
"Use original wiseowl xheight");
EXTERN BOOL_VAR (textord_oldbl_debug, false, "Debug old baseline generation");
BOOL_VAR (textord_oldbl_debug, false, "Debug old baseline generation");
static BOOL_VAR (textord_debug_baselines, false, "Debug baseline generation");
static BOOL_VAR (textord_oldbl_paradef, true, "Use para default mechanism");
static BOOL_VAR (textord_oldbl_split_splines, true, "Split stepped splines");
Expand All @@ -65,9 +63,6 @@ static double_VAR (textord_oldbl_jumplimit, 0.15,
#define MAXOVERLAP 0.1 /*max 10% missed overlap */
#define MAXBADRUN 2 /*max non best for failed */
#define HEIGHTBUCKETS 200 /* Num of buckets */
#define DELTAHEIGHT 5.0 /* Small amount of diff */
#define GOODHEIGHT 5
#define MAXLOOPS 10
#define MODENUM 10
#define MAXPARTS 6
#define SPLINESIZE 23
Expand Down
2 changes: 0 additions & 2 deletions src/textord/pithsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "pithsync.h"
#include "tprintf.h"

#define PROJECTION_MARGIN 10 //arbitrary

/**********************************************************************
* FPCUTPT::setup
*
Expand Down
5 changes: 2 additions & 3 deletions src/textord/scanedg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void block_edges(Pix *t_pix, // thresholded image

std::unique_ptr<uint8_t[]> bwline(new uint8_t[width]);

uint8_t margin = WHITE_PIX;
const uint8_t margin = WHITE_PIX;

for (int y = tright.y() - 1; y >= bleft.y() - 1; y--) {
if (y >= bleft.y() && y < tright.y()) {
Expand Down Expand Up @@ -149,7 +149,6 @@ void line_edges(int16_t x, // coord of line start
C_OUTLINE_IT* outline_it) {
CrackPos pos = {free_cracks, x, y };
int xmax; // max x coord
int colour; // of current pixel
int prevcolour; // of previous pixel
CRACKEDGE *current; // current h edge
CRACKEDGE *newcurrent; // new h edge
Expand All @@ -160,7 +159,7 @@ void line_edges(int16_t x, // coord of line start

// do each pixel
for (; pos.x < xmax; pos.x++, prevline++) {
colour = *bwpos++; // current pixel
const int colour = *bwpos++; // current pixel
if (*prevline != nullptr) {
// changed above
// change colour
Expand Down
21 changes: 9 additions & 12 deletions src/textord/topitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,25 @@

#include <memory>

#define EXTERN

static BOOL_VAR (textord_all_prop, false, "All doc is proportial text");
EXTERN BOOL_VAR (textord_debug_pitch_test, false,
BOOL_VAR (textord_debug_pitch_test, false,
"Debug on fixed pitch test");
static BOOL_VAR (textord_disable_pitch_test, false,
"Turn off dp fixed pitch algorithm");
EXTERN BOOL_VAR (textord_fast_pitch_test, false,
BOOL_VAR (textord_fast_pitch_test, false,
"Do even faster pitch algorithm");
EXTERN BOOL_VAR (textord_debug_pitch_metric, false,
BOOL_VAR (textord_debug_pitch_metric, false,
"Write full metric stuff");
EXTERN BOOL_VAR (textord_show_row_cuts, false, "Draw row-level cuts");
EXTERN BOOL_VAR (textord_show_page_cuts, false, "Draw page-level cuts");
EXTERN BOOL_VAR (textord_pitch_cheat, false,
BOOL_VAR (textord_show_row_cuts, false, "Draw row-level cuts");
BOOL_VAR (textord_show_page_cuts, false, "Draw page-level cuts");
BOOL_VAR (textord_pitch_cheat, false,
"Use correct answer for fixed/prop");
EXTERN BOOL_VAR (textord_blockndoc_fixed, false,
BOOL_VAR (textord_blockndoc_fixed, false,
"Attempt whole doc/block fixed pitch");
EXTERN double_VAR (textord_projection_scale, 0.200, "Ding rate for mid-cuts");
EXTERN double_VAR (textord_balance_factor, 1.0,
double_VAR (textord_projection_scale, 0.200, "Ding rate for mid-cuts");
double_VAR (textord_balance_factor, 1.0,
"Ding rate for unbalanced char cells");

#define FIXED_WIDTH_MULTIPLE 5
#define BLOCK_STATS_CLUSTERS 10
#define MAX_ALLOWED_PITCH 100 //max pixel pitch.

Expand Down
78 changes: 38 additions & 40 deletions src/textord/tovars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,62 @@
#include "tovars.h"
#include "params.h"

#define EXTERN

EXTERN BOOL_VAR (textord_show_initial_words, false, "Display separate words");
EXTERN BOOL_VAR (textord_show_new_words, false, "Display separate words");
EXTERN BOOL_VAR (textord_show_fixed_words, false,
BOOL_VAR (textord_show_initial_words, false, "Display separate words");
BOOL_VAR (textord_show_new_words, false, "Display separate words");
BOOL_VAR (textord_show_fixed_words, false,
"Display forced fixed pitch words");
EXTERN BOOL_VAR (textord_blocksall_fixed, false, "Moan about prop blocks");
EXTERN BOOL_VAR (textord_blocksall_prop, false,
BOOL_VAR (textord_blocksall_fixed, false, "Moan about prop blocks");
BOOL_VAR (textord_blocksall_prop, false,
"Moan about fixed pitch blocks");
EXTERN BOOL_VAR (textord_blocksall_testing, false, "Dump stats when moaning");
EXTERN BOOL_VAR (textord_test_mode, false, "Do current test");
EXTERN INT_VAR (textord_dotmatrix_gap, 3,
BOOL_VAR (textord_blocksall_testing, false, "Dump stats when moaning");
BOOL_VAR (textord_test_mode, false, "Do current test");
INT_VAR (textord_dotmatrix_gap, 3,
"Max pixel gap for broken pixed pitch");
EXTERN INT_VAR (textord_debug_block, 0, "Block to do debug on");
EXTERN INT_VAR (textord_pitch_range, 2, "Max range test on pitch");
EXTERN double_VAR (textord_wordstats_smooth_factor, 0.05,
INT_VAR (textord_debug_block, 0, "Block to do debug on");
INT_VAR (textord_pitch_range, 2, "Max range test on pitch");
double_VAR (textord_wordstats_smooth_factor, 0.05,
"Smoothing gap stats");
EXTERN double_VAR (textord_width_smooth_factor, 0.10,
double_VAR (textord_width_smooth_factor, 0.10,
"Smoothing width stats");
EXTERN double_VAR (textord_words_width_ile, 0.4,
double_VAR (textord_words_width_ile, 0.4,
"Ile of blob widths for space est");
EXTERN double_VAR (textord_words_maxspace, 4.0, "Multiple of xheight");
EXTERN double_VAR (textord_words_default_maxspace, 3.5,
double_VAR (textord_words_maxspace, 4.0, "Multiple of xheight");
double_VAR (textord_words_default_maxspace, 3.5,
"Max believable third space");
EXTERN double_VAR (textord_words_default_minspace, 0.6,
double_VAR (textord_words_default_minspace, 0.6,
"Fraction of xheight");
EXTERN double_VAR (textord_words_min_minspace, 0.3, "Fraction of xheight");
EXTERN double_VAR (textord_words_default_nonspace, 0.2,
double_VAR (textord_words_min_minspace, 0.3, "Fraction of xheight");
double_VAR (textord_words_default_nonspace, 0.2,
"Fraction of xheight");
EXTERN double_VAR(textord_words_initial_lower, 0.25,
double_VAR(textord_words_initial_lower, 0.25,
"Max initial cluster size");
EXTERN double_VAR (textord_words_initial_upper, 0.15,
double_VAR (textord_words_initial_upper, 0.15,
"Min initial cluster spacing");
EXTERN double_VAR (textord_words_minlarge, 0.75,
double_VAR (textord_words_minlarge, 0.75,
"Fraction of valid gaps needed");
EXTERN double_VAR (textord_words_pitchsd_threshold, 0.040,
double_VAR (textord_words_pitchsd_threshold, 0.040,
"Pitch sync threshold");
EXTERN double_VAR (textord_words_def_fixed, 0.016,
double_VAR (textord_words_def_fixed, 0.016,
"Threshold for definite fixed");
EXTERN double_VAR (textord_words_def_prop, 0.090,
double_VAR (textord_words_def_prop, 0.090,
"Threshold for definite prop");
EXTERN INT_VAR (textord_words_veto_power, 5,
INT_VAR (textord_words_veto_power, 5,
"Rows required to outvote a veto");
EXTERN double_VAR (textord_pitch_rowsimilarity, 0.08,
double_VAR (textord_pitch_rowsimilarity, 0.08,
"Fraction of xheight for sameness");
EXTERN BOOL_VAR (textord_pitch_scalebigwords, false,
BOOL_VAR (textord_pitch_scalebigwords, false,
"Scale scores on big words");
EXTERN double_VAR(words_initial_lower, 0.5, "Max initial cluster size");
EXTERN double_VAR (words_initial_upper, 0.15, "Min initial cluster spacing");
EXTERN double_VAR (words_default_prop_nonspace, 0.25, "Fraction of xheight");
EXTERN double_VAR (words_default_fixed_space, 0.75, "Fraction of xheight");
EXTERN double_VAR (words_default_fixed_limit, 0.6, "Allowed size variance");
EXTERN double_VAR (textord_words_definite_spread, 0.30,
double_VAR(words_initial_lower, 0.5, "Max initial cluster size");
double_VAR (words_initial_upper, 0.15, "Min initial cluster spacing");
double_VAR (words_default_prop_nonspace, 0.25, "Fraction of xheight");
double_VAR (words_default_fixed_space, 0.75, "Fraction of xheight");
double_VAR (words_default_fixed_limit, 0.6, "Allowed size variance");
double_VAR (textord_words_definite_spread, 0.30,
"Non-fuzzy spacing region");
EXTERN double_VAR (textord_spacesize_ratiofp, 2.8,
double_VAR (textord_spacesize_ratiofp, 2.8,
"Min ratio space/nonspace");
EXTERN double_VAR (textord_spacesize_ratioprop, 2.0,
double_VAR (textord_spacesize_ratioprop, 2.0,
"Min ratio space/nonspace");
EXTERN double_VAR (textord_fpiqr_ratio, 1.5, "Pitch IQR/Gap IQR threshold");
EXTERN double_VAR (textord_max_pitch_iqr, 0.20, "Xh fraction noise in pitch");
EXTERN double_VAR (textord_fp_min_width, 0.5, "Min width of decent blobs");
double_VAR (textord_fpiqr_ratio, 1.5, "Pitch IQR/Gap IQR threshold");
double_VAR (textord_max_pitch_iqr, 0.20, "Xh fraction noise in pitch");
double_VAR (textord_fp_min_width, 0.5, "Min width of decent blobs");
8 changes: 2 additions & 6 deletions src/textord/underlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@

#include "underlin.h"

#define PROJECTION_MARGIN 10 //arbitrary
#define EXTERN

EXTERN double_VAR (textord_underline_offset, 0.1, "Fraction of x to ignore");
EXTERN BOOL_VAR (textord_restore_underlines, true,
"Chop underlines & put back");
double_VAR (textord_underline_offset, 0.1, "Fraction of x to ignore");
BOOL_VAR (textord_restore_underlines, true, "Chop underlines & put back");

/**********************************************************************
* restore_underlined_blobs
Expand Down
Loading

0 comments on commit 4db6b9e

Please sign in to comment.