From 34cb977ba2ad2335fa9ac4142c53f1a29f89ed80 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 19 May 2021 18:29:12 +0200 Subject: [PATCH] Fix warnings from LGTM Signed-off-by: Stefan Weil --- src/textord/blkocc.cpp | 17 ++++++----------- src/textord/underlin.cpp | 6 +++--- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/textord/blkocc.cpp b/src/textord/blkocc.cpp index 9ad8d8342c..077a6b0424 100644 --- a/src/textord/blkocc.cpp +++ b/src/textord/blkocc.cpp @@ -50,16 +50,11 @@ bool test_underline( // look for underlines int16_t baseline, ///< coords of baseline int16_t xheight ///< height of line ) { - int16_t occ; - int16_t blob_width; // width of blob - TBOX blob_box; // bounding box - int32_t desc_occ; - int32_t x_occ; - int32_t asc_occ; + int32_t occ; STATS projection; - blob_box = blob->bounding_box(); - blob_width = blob->bounding_box().width(); + auto blob_box = blob->bounding_box(); + auto blob_width = blob->bounding_box().width(); projection.set_range(blob_box.bottom(), blob_box.top() + 1); if (testing_on) { // blob->plot(to_win,GOLDENROD,GOLDENROD); @@ -73,21 +68,21 @@ bool test_underline( // look for underlines blob->bounding_box().right(), blob->bounding_box().top(), baseline); } horizontal_cblob_projection(blob, &projection); - desc_occ = 0; + int32_t desc_occ = 0; for (occ = blob_box.bottom(); occ < baseline; occ++) { if (occ <= blob_box.top() && projection.pile_count(occ) > desc_occ) { // max in region desc_occ = projection.pile_count(occ); } } - x_occ = 0; + int32_t x_occ = 0; for (occ = baseline; occ <= baseline + xheight; occ++) { if (occ >= blob_box.bottom() && occ <= blob_box.top() && projection.pile_count(occ) > x_occ) { // max in region x_occ = projection.pile_count(occ); } } - asc_occ = 0; + int32_t asc_occ = 0; for (occ = baseline + xheight + 1; occ <= blob_box.top(); occ++) { if (occ >= blob_box.bottom() && projection.pile_count(occ) > asc_occ) { asc_occ = projection.pile_count(occ); diff --git a/src/textord/underlin.cpp b/src/textord/underlin.cpp index 8af534cf77..8d5abe2495 100644 --- a/src/textord/underlin.cpp +++ b/src/textord/underlin.cpp @@ -162,7 +162,6 @@ void find_underlined_blobs( // get chop points float baseline_offset, // amount to shrinke it ICOORDELT_LIST *chop_cells // places to chop ) { - int16_t x, y; // sides of blob ICOORD blob_chop; // sides of blob TBOX blob_box = u_line->bounding_box(); // cell iterator @@ -180,9 +179,10 @@ void find_underlined_blobs( // get chop points &middle_proj, &upper_proj); } - for (x = blob_box.left(); x < blob_box.right(); x++) { + for (auto x = blob_box.left(); x < blob_box.right(); x++) { if (middle_proj.pile_count(x) > 0) { - for (y = x + 1; y < blob_box.right() && middle_proj.pile_count(y) > 0; y++) { + auto y = x + 1; + for (; y < blob_box.right() && middle_proj.pile_count(y) > 0; y++) { ; } blob_chop = ICOORD(x, y);