[GRASS5] PATCH: r.grow2

Brad Douglas rez at touchofmadness.com
Tue Jun 14 16:03:38 EDT 2005


r.grow2 has not compiled for me for some time because abs() is
redefined.  Attached is a fix.  Any objections to me applying it?


-- 
Brad Douglas <rez at touchofmadness.com>
-------------- next part --------------
? OBJ.x86_64-unknown-linux-gnu
Index: main.c
===================================================================
RCS file: /grassrepository/grass6/raster/r.grow2/main.c,v
retrieving revision 2.1
diff -u -r2.1 main.c
--- main.c	15 Jan 2005 11:18:12 -0000	2.1
+++ main.c	14 Jun 2005 19:58:19 -0000
@@ -4,20 +4,13 @@
 #include "gis.h"
 #include "glocale.h"
 
+#define ABS(x)		((x) < 0 ? -(x) : (x))
+#define MAX(a, b)	((a) > (b) ? (a) : (b))
+
 static int size;
 static int count;
 static int (*neighbors)[2];
 
-static int abs(int x)
-{
-	return (x < 0) ? -x : x;
-}
-
-static int max(int a, int b)
-{
-	return (a > b) ? a : b;
-}
-
 typedef int metric_fn(int, int);
 
 static int distance_euclidian_squared(int dx, int dy)
@@ -27,12 +20,12 @@
 
 static int distance_maximum(int dx, int dy)
 {
-	return max(abs(dx), abs(dy));
+	return MAX(ABS(dx), ABS(dy));
 }
 
 static int distance_manhattan(int dx, int dy)
 {
-	return abs(dx) + abs(dy);
+	return ABS(dx) + ABS(dy);
 }
 
 static void setup_neighbors(double radius, int limit, metric_fn *dist)


More information about the grass-dev mailing list