mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-08-06 13:56:47 +08:00
Removed some compiler warnings on operator precedence
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@129 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
dd18aea052
commit
166c867d84
@ -221,9 +221,9 @@ void fix2( //polygonal approx
|
||||
register EDGEPT *edgefix0, *edgefix1, *edgefix2, *edgefix3;
|
||||
|
||||
edgept = start; /*start of loop */
|
||||
while ((edgept->flags[DIR] - edgept->prev->flags[DIR] + 1 & 7) < 3
|
||||
while (((edgept->flags[DIR] - edgept->prev->flags[DIR] + 1) & 7) < 3
|
||||
&& (dir1 =
|
||||
edgept->prev->flags[DIR] - edgept->next->flags[DIR] & 7) != 2
|
||||
(edgept->prev->flags[DIR] - edgept->next->flags[DIR]) & 7) != 2
|
||||
&& dir1 != 6)
|
||||
edgept = edgept->next; /*find suitable start */
|
||||
loopstart = edgept; /*remember start */
|
||||
@ -239,7 +239,7 @@ void fix2( //polygonal approx
|
||||
dir2 = edgept->flags[DIR]; /*2nd direction */
|
||||
/*length in dir2 */
|
||||
sum2 = edgept->flags[RUNLENGTH];
|
||||
if ((dir1 - dir2 + 1 & 7) < 3) {
|
||||
if (((dir1 - dir2 + 1) & 7) < 3) {
|
||||
while (edgept->prev->flags[DIR] == edgept->next->flags[DIR]) {
|
||||
edgept = edgept->next; /*look at next */
|
||||
if (edgept->flags[DIR] == dir1)
|
||||
@ -260,11 +260,11 @@ void fix2( //polygonal approx
|
||||
linestart->flags[FLAGS] |= FIXED;
|
||||
}
|
||||
|
||||
if ((edgept->next->flags[DIR] - edgept->flags[DIR] + 1 & 7) >= 3
|
||||
|| edgept->flags[DIR] == dir1 && sum1 >= sum2
|
||||
|| (edgept->prev->flags[RUNLENGTH] < edgept->flags[RUNLENGTH]
|
||||
|| edgept->flags[DIR] == dir2 && sum2 >= sum1)
|
||||
&& linestart->next != edgept)
|
||||
if (((edgept->next->flags[DIR] - edgept->flags[DIR] + 1) & 7) >= 3
|
||||
|| (edgept->flags[DIR] == dir1 && sum1 >= sum2)
|
||||
|| ((edgept->prev->flags[RUNLENGTH] < edgept->flags[RUNLENGTH]
|
||||
|| (edgept->flags[DIR] == dir2 && sum2 >= sum1))
|
||||
&& linestart->next != edgept))
|
||||
edgept = edgept->next;
|
||||
}
|
||||
/*sharp bend */
|
||||
@ -295,7 +295,7 @@ void fix2( //polygonal approx
|
||||
&& edgept->next->flags[FLAGS] & FIXED && (edgept->prev->flags[FLAGS] & FIXED) == 0
|
||||
/*same pair of dirs */
|
||||
&& (edgept->next->next->flags[FLAGS] & FIXED) == 0 && edgept->prev->flags[DIR] == edgept->next->flags[DIR] && edgept->prev->prev->flags[DIR] == edgept->next->next->flags[DIR]
|
||||
&& (edgept->prev->flags[DIR] - edgept->flags[DIR] + 1 & 7) < 3) {
|
||||
&& ((edgept->prev->flags[DIR] - edgept->flags[DIR] + 1) & 7) < 3) {
|
||||
/*unfix it */
|
||||
edgept->flags[FLAGS] &= ~FIXED;
|
||||
edgept->next->flags[FLAGS] &= ~FIXED;
|
||||
|
@ -291,13 +291,14 @@ LIST ConvertOutlines(TESSLINE *Outline,
|
||||
MFOUTLINE MFOutline;
|
||||
|
||||
while (Outline != NULL) {
|
||||
if (Outline->child != NULL)
|
||||
if (Outline->child != NULL) {
|
||||
if (OutlineType == outer)
|
||||
ConvertedOutlines = ConvertOutlines (Outline->child,
|
||||
ConvertedOutlines, hole);
|
||||
else
|
||||
ConvertedOutlines = ConvertOutlines (Outline->child,
|
||||
ConvertedOutlines, outer);
|
||||
}
|
||||
|
||||
MFOutline = ConvertOutline (Outline);
|
||||
ConvertedOutlines = push (ConvertedOutlines, MFOutline);
|
||||
|
@ -134,7 +134,7 @@ extern char_proc allocate;
|
||||
**********************************************************************/
|
||||
|
||||
#define strsave(s) \
|
||||
((s) ? \
|
||||
((s) != NULL ? \
|
||||
((char*) strcpy ((*allocate) (strlen(s)+1), s)) : \
|
||||
(NULL))
|
||||
|
||||
|
@ -29,8 +29,8 @@ different popular data structures. A new "das" can be created by declaring
|
||||
a variable of type 'DAS'
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ARRAY_H
|
||||
#define ARRAY_H
|
||||
#ifndef TESSARRAY_H
|
||||
#define TESSARRAY_H
|
||||
|
||||
/*
|
||||
----------------------------------------------------------------------
|
||||
@ -135,11 +135,11 @@ for (x=0; x < array_count (a); x++)
|
||||
/*----------------------------------------------------------------------
|
||||
F u n c t i o n s
|
||||
----------------------------------------------------------------------*/
|
||||
ARRAY array_insert(ARRAY array, int index, void *value);
|
||||
ARRAY array_insert(ARRAY array, int index, void *value);
|
||||
|
||||
ARRAY array_new(int num);
|
||||
ARRAY array_new(int num);
|
||||
|
||||
ARRAY array_push(ARRAY array, void *value);
|
||||
ARRAY array_push(ARRAY array, void *value);
|
||||
|
||||
/*
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
|
@ -290,7 +290,7 @@ int compare_states(STATE *true_state, STATE *this_state, int *blob_index) {
|
||||
return 2;
|
||||
if (*blob_index == 0) {
|
||||
if (bits_in_states > 32) {
|
||||
for (mask = 1 << bits_in_states - 33; mask != 0; mask >>= 1) {
|
||||
for (mask = 1 << (bits_in_states - 33); mask != 0; mask >>= 1) {
|
||||
if (this_state->part1 & mask) {
|
||||
if (true_state->part1 & mask)
|
||||
return 2;
|
||||
@ -320,7 +320,7 @@ int compare_states(STATE *true_state, STATE *this_state, int *blob_index) {
|
||||
blob_count = 0;
|
||||
true_index = 0;
|
||||
if (bits_in_states > 32) {
|
||||
for (mask = 1 << bits_in_states - 33; mask != 0; mask >>= 1) {
|
||||
for (mask = 1 << (bits_in_states - 33); mask != 0; mask >>= 1) {
|
||||
if (true_state->part1 & mask)
|
||||
true_index++;
|
||||
if (this_state->part1 & mask) {
|
||||
|
@ -203,7 +203,7 @@ INT8 open_tif_image( //read header
|
||||
*res = -1;
|
||||
resoffset = -1;
|
||||
if (read (fd, (char *) &filetype, sizeof filetype) != sizeof filetype
|
||||
|| filetype != INTEL && filetype != MOTO) {
|
||||
|| (filetype != INTEL && filetype != MOTO)) {
|
||||
BADIMAGEFORMAT.error ("read_tif_image", TESSLOG, "Filetype");
|
||||
return -1;
|
||||
}
|
||||
@ -577,7 +577,7 @@ INT8 write_tif_image( //write whole image
|
||||
resolution.top = res;
|
||||
resolution.bottom = 1;
|
||||
if (write (fd, (char *) &type, sizeof type) != sizeof type
|
||||
|| type != INTEL && type != MOTO) {
|
||||
|| (type != INTEL && type != MOTO)) {
|
||||
WRITEFAILED.error ("write_tif_image", TESSLOG, "Filetype");
|
||||
return -1;
|
||||
}
|
||||
|
@ -428,8 +428,8 @@ double check_pitch_sync2( //find segmentation
|
||||
if (cutpts[x - array_origin].index () +
|
||||
cutpts[x - array_origin].fake_count <= best_count + best_fake) {
|
||||
if (cutpts[x - array_origin].fake_count < best_fake
|
||||
|| cutpts[x - array_origin].fake_count == best_fake
|
||||
&& cutpts[x - array_origin].cost_function () < best_cost) {
|
||||
|| (cutpts[x - array_origin].fake_count == best_fake
|
||||
&& cutpts[x - array_origin].cost_function () < best_cost)) {
|
||||
best_fake = cutpts[x - array_origin].fake_count;
|
||||
best_cost = cutpts[x - array_origin].cost_function ();
|
||||
best_left_x = x;
|
||||
@ -610,7 +610,7 @@ double check_pitch_sync3( //find segmentation
|
||||
mid_cut = TRUE;
|
||||
}
|
||||
}
|
||||
if (start == 0 && end == 0
|
||||
if ((start == 0 && end == 0)
|
||||
|| !textord_fast_pitch_test
|
||||
|| (x - projection_left - start) % pitch <= end)
|
||||
cutpts[x - array_origin].assign (cutpts, array_origin, x,
|
||||
@ -643,8 +643,8 @@ double check_pitch_sync3( //find segmentation
|
||||
if (cutpts[x - array_origin].index () +
|
||||
cutpts[x - array_origin].fake_count <= best_count + best_fake) {
|
||||
if (cutpts[x - array_origin].fake_count < best_fake
|
||||
|| cutpts[x - array_origin].fake_count == best_fake
|
||||
&& cutpts[x - array_origin].cost_function () < best_cost) {
|
||||
|| (cutpts[x - array_origin].fake_count == best_fake
|
||||
&& cutpts[x - array_origin].cost_function () < best_cost)) {
|
||||
best_fake = cutpts[x - array_origin].fake_count;
|
||||
best_cost = cutpts[x - array_origin].cost_function ();
|
||||
best_left_x = x;
|
||||
|
@ -253,9 +253,9 @@ double check_pitch_sync( //find segmentation
|
||||
}
|
||||
if (x <= max_box.left () + pitch_error
|
||||
|| x >= max_box.right () - pitch_error || x >= right_edge
|
||||
|| max_index < blob_count - 1 && x >= next_box.left ()
|
||||
|| x - max_box.left () > pitch * pitsync_joined_edge
|
||||
&& max_box.right () - x > pitch * pitsync_joined_edge) {
|
||||
|| (max_index < blob_count - 1 && x >= next_box.left ())
|
||||
|| (x - max_box.left () > pitch * pitsync_joined_edge
|
||||
&& max_box.right () - x > pitch * pitsync_joined_edge)) {
|
||||
// || projection->local_min(x))
|
||||
if (x - max_box.left () > 0
|
||||
&& x - max_box.left () <= pitch_error)
|
||||
|
@ -281,9 +281,8 @@ EDGEPT *pick_close_point(EDGEPT *critical_point,
|
||||
if (this_distance <= *best_dist) {
|
||||
|
||||
if (!(same_point (critical_point->pos, vertical_point->pos) ||
|
||||
same_point (critical_point->pos, vertical_point->next->pos)
|
||||
|| best_point != NULL
|
||||
&& same_point (best_point->pos, vertical_point->pos) ||
|
||||
same_point (critical_point->pos, vertical_point->next->pos) ||
|
||||
(best_point && same_point (best_point->pos, vertical_point->pos)) ||
|
||||
is_exterior_point (critical_point, vertical_point))) {
|
||||
*best_dist = this_distance;
|
||||
best_point = vertical_point;
|
||||
|
@ -451,8 +451,8 @@ CHOICES_LIST chop_word_main(register TWERD *word,
|
||||
}
|
||||
|
||||
if (!AcceptableChoice (char_choices, best_choice, raw_choice, &fixpt)
|
||||
|| (tester || trainer)
|
||||
&& strcmp (word->correct, class_string (best_choice))) {
|
||||
|| ((tester || trainer)
|
||||
&& strcmp (word->correct, class_string (best_choice)))) {
|
||||
did_chopping = 1;
|
||||
if (first_pass)
|
||||
words_chopped1++;
|
||||
@ -477,10 +477,10 @@ CHOICES_LIST chop_word_main(register TWERD *word,
|
||||
|
||||
if (chop_debug)
|
||||
print_seams ("Final seam list:", seam_list);
|
||||
if (enable_assoc &&
|
||||
!AcceptableChoice (char_choices, best_choice, raw_choice, NULL)
|
||||
|| (tester || trainer)
|
||||
&& strcmp (word->correct, class_string (best_choice))) {
|
||||
if ((enable_assoc &&
|
||||
!AcceptableChoice (char_choices, best_choice, raw_choice, NULL))
|
||||
|| ((tester || trainer)
|
||||
&& strcmp (word->correct, class_string (best_choice)))) {
|
||||
ratings = word_associator (word->blobs, seam_list, &state, fx,
|
||||
best_choice, raw_choice, word->correct,
|
||||
/*0, */ &fixpt,
|
||||
@ -606,11 +606,12 @@ INT16 select_blob_to_split(CHOICES_LIST char_choices, float rating_ceiling) {
|
||||
float worst = -MAX_FLOAT32;
|
||||
int worst_index = -1;
|
||||
|
||||
if (chop_debug)
|
||||
if (chop_debug) {
|
||||
if (rating_ceiling < MAX_FLOAT32)
|
||||
cprintf ("rating_ceiling = %8.4f\n", rating_ceiling);
|
||||
else
|
||||
cprintf ("rating_ceiling = No Limit\n");
|
||||
else
|
||||
cprintf ("rating_ceiling = No Limit\n");
|
||||
}
|
||||
|
||||
for_each_choice(char_choices, x) {
|
||||
this_choice = (CHOICES) array_value (char_choices, x);
|
||||
|
@ -284,26 +284,38 @@ void combine_seam(SEAM_QUEUE seam_queue, SEAM_PILE seam_pile, SEAM *seam) {
|
||||
if (-SPLIT_CLOSENESS < dist &&
|
||||
dist < SPLIT_CLOSENESS &&
|
||||
seam->priority + this_one->priority < ok_split) {
|
||||
INT16 split1_point1_y = this_one->split1->point1->pos.y;
|
||||
INT16 split1_point2_y = this_one->split1->point2->pos.y;
|
||||
INT16 split2_point1_y = 0;
|
||||
INT16 split2_point2_y = 0;
|
||||
if (this_one->split2) {
|
||||
split2_point1_y = this_one->split2->point1->pos.y;
|
||||
split2_point2_y = this_one->split2->point2->pos.y;
|
||||
}
|
||||
if (
|
||||
/*!tessedit_fix_sideways_chops
|
||||
|| */
|
||||
(this_one->split1->point1->pos.y >= top1
|
||||
&& this_one->split1->point2->pos.y >= top1
|
||||
|| this_one->split1->point1->pos.y <= bottom1
|
||||
&& this_one->split1->point2->pos.y <= bottom1)
|
||||
&& (this_one->split1->point1->pos.y >= top2
|
||||
&& this_one->split1->point2->pos.y >= top2
|
||||
|| this_one->split1->point1->pos.y <= bottom2
|
||||
&& this_one->split1->point2->pos.y <= bottom2)
|
||||
&& (this_one->split2 == NULL
|
||||
|| (this_one->split2->point1->pos.y >= top1
|
||||
&& this_one->split2->point2->pos.y >= top1
|
||||
|| this_one->split2->point1->pos.y <= bottom1
|
||||
&& this_one->split2->point2->pos.y <= bottom1)
|
||||
&& (this_one->split2->point1->pos.y >= top2
|
||||
&& this_one->split2->point2->pos.y >= top2
|
||||
|| this_one->split2->point1->pos.y <= bottom2
|
||||
&& this_one->split2->point2->pos.y <= bottom2))) {
|
||||
/*!tessedit_fix_sideways_chops || */
|
||||
(
|
||||
/* this_one->split1 always exists */
|
||||
(
|
||||
((split1_point1_y >= top1 && split1_point2_y >= top1) ||
|
||||
(split1_point1_y <= bottom1 && split1_point2_y <= bottom1))
|
||||
&&
|
||||
((split1_point1_y >= top2 && split1_point2_y >= top2) ||
|
||||
(split1_point1_y <= bottom2 && split1_point2_y <= bottom2))
|
||||
)
|
||||
)
|
||||
&&
|
||||
(
|
||||
this_one->split2 == NULL ||
|
||||
(
|
||||
((split2_point1_y >= top1 && split2_point2_y >= top1) ||
|
||||
(split2_point1_y <= bottom1 && split2_point2_y <= bottom1))
|
||||
&&
|
||||
((split2_point1_y >= top2 && split2_point2_y >= top2) ||
|
||||
(split2_point1_y <= bottom2 && split2_point2_y <= bottom2))
|
||||
)
|
||||
)
|
||||
) {
|
||||
new_one = join_two_seams (seam, this_one);
|
||||
if (chop_debug > 1)
|
||||
print_seam ("Combo priority ", new_one);
|
||||
|
@ -88,9 +88,9 @@ int is_crossed(TPOINT a0, TPOINT a1, TPOINT b0, TPOINT b1) {
|
||||
/*a1a0xa1b0=CROSS(a1a0,a1b0); */
|
||||
a1a0xa1b0 = -CROSS (a1a0, b0a1);
|
||||
|
||||
return (b0a1xb0b1 > 0 && b0b1xb0a0 > 0
|
||||
|| b0a1xb0b1 < 0 && b0b1xb0a0 < 0)
|
||||
&& (a1b1xa1a0 > 0 && a1a0xa1b0 > 0 || a1b1xa1a0 < 0 && a1a0xa1b0 < 0);
|
||||
return ((b0a1xb0b1 > 0 && b0b1xb0a0 > 0)
|
||||
|| (b0a1xb0b1 < 0 && b0b1xb0a0 < 0))
|
||||
&& ((a1b1xa1a0 > 0 && a1a0xa1b0 > 0) || (a1b1xa1a0 < 0 && a1a0xa1b0 < 0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -353,8 +353,8 @@ SEAM *join_two_seams(SEAM *seam1, SEAM *seam2) {
|
||||
|
||||
assert(seam1 &&seam2);
|
||||
|
||||
if ((seam1->split3 == NULL && seam2->split2 == NULL ||
|
||||
seam1->split2 == NULL && seam2->split3 == NULL ||
|
||||
if (((seam1->split3 == NULL && seam2->split2 == NULL) ||
|
||||
(seam1->split2 == NULL && seam2->split3 == NULL) ||
|
||||
seam1->split1 == NULL ||
|
||||
seam2->split1 == NULL) && (!shared_split_points (seam1, seam2))) {
|
||||
clone_seam(result, seam1);
|
||||
|
Loading…
Reference in New Issue
Block a user