[GRASS-SVN] r71771 - grass/branches/releasebranch_7_2/lib/vector/diglib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 19 09:22:27 PST 2017
Author: mmetz
Date: 2017-11-19 09:22:27 -0800 (Sun, 19 Nov 2017)
New Revision: 71771
Modified:
grass/branches/releasebranch_7_2/lib/vector/diglib/plus_area.c
Log:
diglib: fix bug caused by compiler optimizations (backport from relbr74 r71770)
Modified: grass/branches/releasebranch_7_2/lib/vector/diglib/plus_area.c
===================================================================
--- grass/branches/releasebranch_7_2/lib/vector/diglib/plus_area.c 2017-11-19 17:21:23 UTC (rev 71770)
+++ grass/branches/releasebranch_7_2/lib/vector/diglib/plus_area.c 2017-11-19 17:22:27 UTC (rev 71771)
@@ -464,8 +464,7 @@
dig_angle_next_line(struct Plus_head *plus, plus_t current_line, int side,
int type, float *angle)
{
- int i, next;
- int current;
+ int next;
int line;
plus_t node;
struct P_node *Node;
@@ -519,6 +518,8 @@
G_debug(3, " n_lines = %d", Node->n_lines);
/* avoid loop when not debugging */
if (debug_level > 2) {
+ int i;
+
for (i = 0; i < Node->n_lines; i++) {
G_debug(3, " i = %d line = %d angle = %f", i, Node->lines[i],
Node->angles[i]);
@@ -526,12 +527,15 @@
}
/* first find index for that line */
- next = -1;
- for (current = 0; current < Node->n_lines; current++) {
- if (Node->lines[current] == current_line)
- next = current;
+ next = Node->n_lines - 1;
+ while (next >= 0 && Node->lines[next] != current_line) {
+ next--;
}
+
if (next == -1) {
+ /* internal error, should not happen */
+ G_fatal_error("dig_angle_next_line(): line %d not found at its own node %d",
+ current_line, node);
if (angle)
*angle = -9.;
return 0; /* not found */
@@ -562,21 +566,22 @@
continue;
}
- line = abs(Node->lines[next]);
- Line = plus->Line[line];
+ line = Node->lines[next];
+ Line = plus->Line[abs(line)];
if (Line->type & type) { /* line found */
G_debug(3, " this one");
if (angle)
*angle = Node->angles[next];
- return (Node->lines[next]);
+ return line;
}
/* input line reached, this must be last, because current_line may be correct return value (dangle) */
- if (Node->lines[next] == current_line)
+ if (line == current_line)
break;
}
- G_debug(3, " Line NOT found at node %d", (int)node);
+ G_debug(3, " No next line for line %d at node %d",
+ current_line, (int)node);
if (angle)
*angle = -9.;
More information about the grass-commit
mailing list