소스 검색

Define MIN() and MAX() correctly and exactly once (#1795)

Instead of many .c and .h files defining, undefing and redefining MIN()
and MAX() have <grass/gis.h> (re)define each macro. Besides the obvious
code deduplication, this addresses a number of compiler warnings:

main.c:51: warning: "MIN" redefined
main.c:52: warning: "MAX" redefined
main.c:30: warning: "MIN" redefined
main.c:31: warning: "MAX" redefined
contour.h:10: warning: "MIN" redefined
contour.h:10: warning: "MIN" redefined
contour.h:10: warning: "MIN" redefined
contour.h:10: warning: "MIN" redefined
contour.h:10: warning: "MIN" redefined
frac.h:19: warning: "MAX" redefined
frac.h:19: warning: "MAX" redefined
frac.h:19: warning: "MAX" redefined
frac.h:19: warning: "MAX" redefined

This also addresses another, less apparent problem: macro definitions
that lack sufficient parenthesis around their arguments are a classic
error. For example, this definition evaluates incorrectly when b is a
ternary conditional itself:

 #define MAX(a,b) (a > b ? a : b)

Resolve the name clash in raster/r.stats.zonal/main.c with a prefix and
fixup indentation while at it.
Denis Ovsienko 3 년 전
부모
커밋
3089db70b0

+ 0 - 7
display/d.linegraph/main.c

@@ -41,13 +41,6 @@
 #include <grass/glocale.h>
 #include "linegraph.h"
 
-#ifndef MAX
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-#endif
-#ifndef MIN
-#define MIN(x,y) ((x) < (y) ? (x) : (y))
-#endif
-
 /* the default order of precedence of colors to use for Y lines */
 int default_y_colors[] = {
     0,

+ 0 - 9
imagery/i.segment/region_growing.c

@@ -16,15 +16,6 @@
 
 #define EPSILON 1.0e-8
 
-#ifdef MAX
-#undef MAX
-#endif
-#define MAX(a,b) ( ((a) > (b)) ? (a) : (b) )
-#ifdef MIN
-#undef MIN
-#endif
-#define MIN(a,b) ( ((a) < (b)) ? (a) : (b) )
-
 struct idlist
 {
     int *ids;

+ 10 - 0
include/grass/gis.h

@@ -129,6 +129,16 @@ static const char *GRASS_copyright __attribute__ ((unused))
 #define CONFIG_DIR ".grass8"
 #endif
 
+#ifdef MAX
+#undef MAX
+#endif
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
+#ifdef MIN
+#undef MIN
+#endif
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
 /* define PI and friends */
 #undef M_PI
 #define M_PI    3.14159265358979323846	/* pi */

+ 0 - 5
lib/btree2/kdtree.c

@@ -20,11 +20,6 @@
 #include <grass/glocale.h>
 #include "kdtree.h"
 
-#ifdef MAX
-#undef MAX
-#endif
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-
 #define KD_BTOL 7
 
 #ifdef KD_DEBUG

+ 1 - 4
lib/cairodriver/line_width.c

@@ -12,14 +12,11 @@
   \author Glynn Clements  
 */
 
+#include <grass/gis.h>
 #include "cairodriver.h"
 
 #define MIN_WIDTH 1
 
-#ifndef MAX
-#define MAX(a,b) ((a)>(b)?(a):(b))
-#endif
-
 static double previous_width = -1;
 
 /*!

+ 1 - 6
lib/cairodriver/raster.c

@@ -15,15 +15,10 @@
 #include <math.h>
 
 #include "cairodriver.h"
+#include <grass/gis.h>
 #include <grass/glocale.h>
 
 #define MAX_IMAGE_SIZE 32767
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
-#ifndef MAX
-#define MAX(a,b) ((a)>(b)?(a):(b))
-#endif
 
 static int src_t, src_b, src_l, src_r, src_w, src_h;
 static int dst_t, dst_b, dst_l, dst_r, dst_w, dst_h;

+ 0 - 7
lib/imagery/georef_tps.c

@@ -42,13 +42,6 @@ struct MATRIX
 
 #define MAXORDER 3    /* HIGHEST SUPPORTED ORDER OF TRANSFORMATION */
 
-#ifndef MAX
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-#endif
-#ifndef MIN
-#define MIN(x,y) ((x) < (y) ? (x) : (y))
-#endif
-
 /***********************************************************************
 
   FUNCTION PROTOTYPES FOR STATIC (INTERNAL) FUNCTIONS

+ 0 - 5
lib/raster/fpreclass.c

@@ -246,11 +246,6 @@
 
 /*--------------------------------------------------------------------------*/
 
-#undef MIN
-#undef MAX
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-
 #define NO_DEFAULT_RULE (! r->defaultDRuleSet)
 #define NO_LEFT_INFINITE_RULE (! r->infiniteLeftSet)
 #define NO_RIGHT_INFINITE_RULE (! r->infiniteRightSet)

+ 0 - 5
lib/raster/quant.c

@@ -27,11 +27,6 @@ static int double_comp(const void *, const void *);
 #define MAX_LOOKUP_TABLE_SIZE 2048
 #define NO_DATA (Rast_set_c_null_value (&tmp, 1), (CELL) tmp)
 
-#undef MIN
-#undef MAX
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-
 #define NO_LEFT_INFINITE_RULE (! q->infiniteLeftSet)
 #define NO_RIGHT_INFINITE_RULE (! q->infiniteRightSet)
 #define NO_FINITE_RULE (q->nofRules <= 0)

+ 1 - 6
lib/raster3d/tilewrite.c

@@ -3,6 +3,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include <grass/gis.h>
 #include <grass/raster.h>
 #include "raster3d_intern.h"
 
@@ -276,12 +277,6 @@ int Rast3d_flush_tile(RASTER3D_Map * map, int tileIndex)
 
 /*---------------------------------------------------------------------------*/
 
-#ifndef MIN
-#define MIN(a,b) (a < b ? a : b)
-#define MAX(a,b) (a > b ? a : b)
-#endif
-
-
 /*!
  * \brief 
  *

+ 1 - 6
lib/vector/Vlib/buffer2.c

@@ -18,18 +18,13 @@
 
 #include <stdlib.h>
 #include <math.h>
+#include <grass/gis.h>
 #include <grass/vector.h>
 #include <grass/glocale.h>
 
 #include "dgraph.h"
 
 #define LENGTH(DX, DY) (sqrt((DX*DX)+(DY*DY)))
-#ifndef MIN
-#define MIN(X,Y) ((X<Y)?X:Y)
-#endif
-#ifndef MAX
-#define MAX(X,Y) ((X>Y)?X:Y)
-#endif
 #define PI M_PI
 #define RIGHT_SIDE 1
 #define LEFT_SIDE -1

+ 1 - 6
lib/vector/Vlib/dgraph.c

@@ -16,18 +16,13 @@
 #include <stdlib.h>
 #include <string.h>
 #include <math.h>
+#include <grass/gis.h>
 #include <grass/vector.h>
 #include <grass/glocale.h>
 #include "dgraph.h"
 #include "e_intersect.h"
 
 #define LENGTH(DX, DY) (sqrt((DX*DX)+(DY*DY)))
-#ifndef MIN
-#define MIN(X,Y) ((X<Y)?X:Y)
-#endif
-#ifndef MAX
-#define MAX(X,Y) ((X>Y)?X:Y)
-#endif
 #define PI M_PI
 
 struct intersection_point

+ 0 - 6
lib/vector/Vlib/e_intersect.c

@@ -21,12 +21,6 @@
 #include "e_intersect.h"
 
 #define SWAP(a,b) {double t = a; a = b; b = t;}
-#ifndef MIN
-#define MIN(X,Y) ((X<Y)?X:Y)
-#endif
-#ifndef MAX
-#define MAX(X,Y) ((X>Y)?X:Y)
-#endif
 #define D ((ax2-ax1)*(by1-by2) - (ay2-ay1)*(bx1-bx2))
 #define DA ((bx1-ax1)*(by1-by2) - (by1-ay1)*(bx1-bx2))
 #define DB ((ax2-ax1)*(by1-ay1) - (ay2-ay1)*(bx1-ax1))

+ 1 - 4
lib/vector/dglib/graph.c

@@ -30,6 +30,7 @@
 
 #define DGL_V2 1
 
+#include <grass/gis.h>
 #include "type.h"
 #include "tree.h"
 #include "graph.h"
@@ -1687,10 +1688,6 @@ int dglWriteChunk(dglIOContext_s * pIO, dglWriteChunk_fn pfn, void *pv)
     return 0;
 }
 
-#ifndef MIN
-#define MIN(x,y)	(((x)<(y))?x:y)
-#endif
-
 int dglReadChunk(dglIOContext_s * pIO, dglByte_t * pbChunk, int cbChunk)
 {
     int i, c;

+ 1 - 2
lib/vector/rtree/rect.c

@@ -23,13 +23,12 @@
 
 #include <float.h>
 #include <math.h>
+#include <grass/gis.h>
 
 #define BIG_NUM (FLT_MAX/4.0)
 
 
 #define Undefined(x, t) ((x)->boundary[0] > (x)->boundary[t->ndims_alloc])
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
 
 /*!
  \brief Create a new rectangle for a given tree

+ 1 - 5
raster/r.buildvrt/proto.h

@@ -1,10 +1,6 @@
+#include <grass/gis.h>
 #include <grass/raster.h>
 
-#undef MIN
-#undef MAX
-#define MIN(a,b)      ((a) < (b) ? (a) : (b))
-#define MAX(a,b)      ((a) > (b) ? (a) : (b))
-
 struct input
 {
     const char *name;

+ 1 - 5
raster/r.external/proto.h

@@ -1,10 +1,6 @@
+#include <grass/gis.h>
 #include <grass/raster.h>
 
-#undef MIN
-#undef MAX
-#define MIN(a,b)      ((a) < (b) ? (a) : (b))
-#define MAX(a,b)      ((a) > (b) ? (a) : (b))
-
 struct band_info
 {
     RASTER_MAP_TYPE data_type;

+ 0 - 8
raster/r.geomorphon/local_proto.h

@@ -27,14 +27,6 @@
 #define DEGREE2RAD(a) ((a)/(180/PI))
 #define RAD2DEGREE(a) ((a)*(180/PI))
 
-#ifndef MAX
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
-#ifndef MIN
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
 /* Number of cardinal directions. */
 #define NUM_DIRS 8
 

+ 0 - 3
raster/r.grow.distance/main.c

@@ -37,9 +37,6 @@ static DCELL *old_val_row, *new_val_row;
 static double (*distance) (double dx, double dy);
 static double xres, yres;
 
-#undef MAX
-#define MAX(a, b)	((a) > (b) ? (a) : (b))
-
 static double distance_euclidean_squared(double dx, double dy)
 {
     return dx * dx + dy * dy;

+ 0 - 5
raster/r.in.gdal/main.c

@@ -32,11 +32,6 @@
 #include <gdal.h>
 #include <cpl_conv.h>
 
-#undef MIN
-#undef MAX
-#define MIN(a,b)      ((a) < (b) ? (a) : (b))
-#define MAX(a,b)      ((a) > (b) ? (a) : (b))
-
 void check_projection(struct Cell_head *cellhd, GDALDatasetH hDS,
                       char *outloc, int create_only, int override,
 		      int check_only);

+ 0 - 3
raster/r.out.pov/main.c

@@ -48,9 +48,6 @@ void processProfiles(int inputFile, FILE * outputF);
 #define     YMAX     65536	/*  max length scan line */
 #define     XMAX     65536	/*  max # of scan lines */
 
-#define MIN(x,y)     (((x) < (y)) ? (x) : (y))
-#define MAX(x,y)     (((x) > (y)) ? (x) : (y))
-
 #define SW     0
 #define NW     1
 #define NE     2

+ 0 - 10
raster/r.proj/bordwalk.c

@@ -33,16 +33,6 @@
 #include <grass/glocale.h>
 #include "r.proj.h"
 
-#ifdef MIN
-#undef MIN
-#endif
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-
-#ifdef MAX
-#undef MAX
-#endif
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-
 static void debug(const char *name, const struct Cell_head *hd)
 {
     G_debug(3, "%s: xmin: %f; xmax: %f; ymin: %f; ymax: %f",

+ 70 - 70
raster/r.stats.zonal/main.c

@@ -25,21 +25,21 @@
 #include <grass/spawn.h>
 #include <grass/glocale.h>
 
-#define COUNT	   1		/* Count                 */
-#define SUM	   2		/* Sum                   */
-#define MIN	   3		/* Minimum               */
-#define MAX	   4		/* Maximum               */
-#define RANGE	   5		/* Range                 */
-#define AVERAGE    6		/* Average (mean)        */
-#define ADEV       7		/* Average deviation     */
-#define VARIANCE1  8		/* Variance              */
-#define STDDEV1    9		/* Standard deviation    */
-#define SKEWNESS1 10		/* Skewness              */
-#define KURTOSIS1 11		/* Kurtosis              */
-#define VARIANCE2 12		/* Variance              */
-#define STDDEV2   13		/* Standard deviation    */
-#define SKEWNESS2 14		/* Skewness              */
-#define KURTOSIS2 15		/* Kurtosis              */
+#define FUNC_COUNT      1		/* Count                 */
+#define FUNC_SUM        2		/* Sum                   */
+#define FUNC_MIN        3		/* Minimum               */
+#define FUNC_MAX        4		/* Maximum               */
+#define FUNC_RANGE      5		/* Range                 */
+#define FUNC_AVERAGE    6		/* Average (mean)        */
+#define FUNC_ADEV       7		/* Average deviation     */
+#define FUNC_VARIANCE1  8		/* Variance              */
+#define FUNC_STDDEV1    9		/* Standard deviation    */
+#define FUNC_SKEWNESS1 10		/* Skewness              */
+#define FUNC_KURTOSIS1 11		/* Kurtosis              */
+#define FUNC_VARIANCE2 12		/* Variance              */
+#define FUNC_STDDEV2   13		/* Standard deviation    */
+#define FUNC_SKEWNESS2 14		/* Skewness              */
+#define FUNC_KURTOSIS2 15		/* Kurtosis              */
 
 struct menu
 {
@@ -52,21 +52,21 @@ extern struct menu menu[];
 
 /* modify this table to add new methods */
 struct menu menu[] = {
-    {"count",     COUNT,     "Count of values in specified objects"},
-    {"sum",       SUM,       "Sum of values in specified objects"},
-    {"min",       MIN,       "Minimum of values in specified objects"},
-    {"max",       MAX,       "Maximum of values in specified objects"},
-    {"range",     RANGE,     "Range of values (max - min) in specified objects"},
-    {"average",   AVERAGE,   "Average of values in specified objects"},
-    {"avedev",    ADEV,      "Average deviation of values in specified objects"},
-    {"variance",  VARIANCE1, "Variance of values in specified objects"},
-    {"stddev",    STDDEV1,   "Standard deviation of values in specified objects"},
-    {"skewness",  SKEWNESS1, "Skewness of values in specified objects"},
-    {"kurtosis",  KURTOSIS1, "Kurtosis of values in specified objects"},
-    {"variance2", VARIANCE2, "(2-pass) Variance of values in specified objects"},
-    {"stddev2",   STDDEV2,   "(2-pass) Standard deviation of values in specified objects"},
-    {"skewness2", SKEWNESS2, "(2-pass) Skewness of values in specified objects"},
-    {"kurtosis2", KURTOSIS2, "(2-pass) Kurtosis of values in specified objects"},
+    {"count",     FUNC_COUNT,     "Count of values in specified objects"},
+    {"sum",       FUNC_SUM,       "Sum of values in specified objects"},
+    {"min",       FUNC_MIN,       "Minimum of values in specified objects"},
+    {"max",       FUNC_MAX,       "Maximum of values in specified objects"},
+    {"range",     FUNC_RANGE,     "Range of values (max - min) in specified objects"},
+    {"average",   FUNC_AVERAGE,   "Average of values in specified objects"},
+    {"avedev",    FUNC_ADEV,      "Average deviation of values in specified objects"},
+    {"variance",  FUNC_VARIANCE1, "Variance of values in specified objects"},
+    {"stddev",    FUNC_STDDEV1,   "Standard deviation of values in specified objects"},
+    {"skewness",  FUNC_SKEWNESS1, "Skewness of values in specified objects"},
+    {"kurtosis",  FUNC_KURTOSIS1, "Kurtosis of values in specified objects"},
+    {"variance2", FUNC_VARIANCE2, "(2-pass) Variance of values in specified objects"},
+    {"stddev2",   FUNC_STDDEV2,   "(2-pass) Standard deviation of values in specified objects"},
+    {"skewness2", FUNC_SKEWNESS2, "(2-pass) Skewness of values in specified objects"},
+    {"kurtosis2", FUNC_KURTOSIS2, "(2-pass) Kurtosis of values in specified objects"},
     {0, 0, 0}
 };
 
@@ -191,44 +191,44 @@ int main(int argc, char **argv)
     cols = Rast_window_cols();
 
     switch (method) {
-    case COUNT:
+    case FUNC_COUNT:
 	count = G_calloc(ncats, sizeof(DCELL));
 	break;
-    case SUM:
+    case FUNC_SUM:
 	sum = G_calloc(ncats, sizeof(DCELL));
 	break;
-    case MIN:
+    case FUNC_MIN:
 	min = G_malloc(ncats * sizeof(DCELL));
 	break;
-    case MAX:
+    case FUNC_MAX:
 	max = G_malloc(ncats * sizeof(DCELL));
 	break;
-    case RANGE:
+    case FUNC_RANGE:
 	min = G_malloc(ncats * sizeof(DCELL));
 	max = G_malloc(ncats * sizeof(DCELL));
 	break;
-    case AVERAGE:
-    case ADEV:
-    case VARIANCE2:
-    case STDDEV2:
-    case SKEWNESS2:
-    case KURTOSIS2:
+    case FUNC_AVERAGE:
+    case FUNC_ADEV:
+    case FUNC_VARIANCE2:
+    case FUNC_STDDEV2:
+    case FUNC_SKEWNESS2:
+    case FUNC_KURTOSIS2:
 	count = G_calloc(ncats, sizeof(DCELL));
 	sum = G_calloc(ncats, sizeof(DCELL));
 	break;
-    case VARIANCE1:
-    case STDDEV1:
+    case FUNC_VARIANCE1:
+    case FUNC_STDDEV1:
 	count = G_calloc(ncats, sizeof(DCELL));
 	sum = G_calloc(ncats, sizeof(DCELL));
 	sum2 = G_calloc(ncats, sizeof(DCELL));
 	break;
-    case SKEWNESS1:
+    case FUNC_SKEWNESS1:
 	count = G_calloc(ncats, sizeof(DCELL));
 	sum = G_calloc(ncats, sizeof(DCELL));
 	sum2 = G_calloc(ncats, sizeof(DCELL));
 	sum3 = G_calloc(ncats, sizeof(DCELL));
 	break;
-    case KURTOSIS1:
+    case FUNC_KURTOSIS1:
 	count = G_calloc(ncats, sizeof(DCELL));
 	sum = G_calloc(ncats, sizeof(DCELL));
 	sum2 = G_calloc(ncats, sizeof(DCELL));
@@ -294,11 +294,11 @@ int main(int argc, char **argv)
     result = G_calloc(ncats, sizeof(DCELL));
 
     switch (method) {
-    case ADEV:
-    case VARIANCE2:
-    case STDDEV2:
-    case SKEWNESS2:
-    case KURTOSIS2:
+    case FUNC_ADEV:
+    case FUNC_VARIANCE2:
+    case FUNC_STDDEV2:
+    case FUNC_SKEWNESS2:
+    case FUNC_KURTOSIS2:
 	mean = G_calloc(ncats, sizeof(DCELL));
 	for (i = 0; i < ncats; i++)
 	    mean[i] = sum[i] / count[i];
@@ -307,18 +307,18 @@ int main(int argc, char **argv)
     }
 
     switch (method) {
-    case ADEV:
+    case FUNC_ADEV:
 	sumu = G_calloc(ncats, sizeof(DCELL));
 	break;
-    case VARIANCE2:
-    case STDDEV2:
+    case FUNC_VARIANCE2:
+    case FUNC_STDDEV2:
 	sum2 = G_calloc(ncats, sizeof(DCELL));
 	break;
-    case SKEWNESS2:
+    case FUNC_SKEWNESS2:
 	sum2 = G_calloc(ncats, sizeof(DCELL));
 	sum3 = G_calloc(ncats, sizeof(DCELL));
 	break;
-    case KURTOSIS2:
+    case FUNC_KURTOSIS2:
 	sum2 = G_calloc(ncats, sizeof(DCELL));
 	sum4 = G_calloc(ncats, sizeof(DCELL));
 	break;
@@ -369,45 +369,45 @@ int main(int argc, char **argv)
     }
 
     switch (method) {
-    case COUNT:
+    case FUNC_COUNT:
 	for (i = 0; i < ncats; i++)
 	    result[i] = count[i];
 	break;
-    case SUM:
+    case FUNC_SUM:
 	for (i = 0; i < ncats; i++)
 	    result[i] = sum[i];
 	break;
-    case AVERAGE:
+    case FUNC_AVERAGE:
 	for (i = 0; i < ncats; i++)
 	    result[i] = sum[i] / count[i];
 	break;
-    case MIN:
+    case FUNC_MIN:
 	for (i = 0; i < ncats; i++)
 	    result[i] = min[i];
 	break;
-    case MAX:
+    case FUNC_MAX:
 	for (i = 0; i < ncats; i++)
 	    result[i] = max[i];
 	break;
-    case RANGE:
+    case FUNC_RANGE:
 	for (i = 0; i < ncats; i++)
 	    result[i] = max[i] - min[i];
 	break;
-    case VARIANCE1:
+    case FUNC_VARIANCE1:
 	for (i = 0; i < ncats; i++) {
 	    double n = count[i];
 	    double var = (sum2[i] - sum[i] * sum[i] / n) / (n - 1);
 	    result[i] = var;
 	}
 	break;
-    case STDDEV1:
+    case FUNC_STDDEV1:
 	for (i = 0; i < ncats; i++) {
 	    double n = count[i];
 	    double var = (sum2[i] - sum[i] * sum[i] / n) / (n - 1);
 	    result[i] = sqrt(var);
 	}
 	break;
-    case SKEWNESS1:
+    case FUNC_SKEWNESS1:
 	for (i = 0; i < ncats; i++) {
 	    double n = count[i];
 	    double var = (sum2[i] - sum[i] * sum[i] / n) / (n - 1);
@@ -418,7 +418,7 @@ int main(int argc, char **argv)
 	    result[i] = skew;
 	}
 	break;
-    case KURTOSIS1:
+    case FUNC_KURTOSIS1:
 	for (i = 0; i < ncats; i++) {
 	    double n = count[i];
 	    double var = (sum2[i] - sum[i] * sum[i] / n) / (n - 1);
@@ -430,19 +430,19 @@ int main(int argc, char **argv)
 	    result[i] = kurt;
 	}
 	break;
-    case ADEV:
+    case FUNC_ADEV:
 	for (i = 0; i < ncats; i++)
 	    result[i] = sumu[i] / count[i];
 	break;
-    case VARIANCE2:
+    case FUNC_VARIANCE2:
 	for (i = 0; i < ncats; i++)
 	    result[i] = sum2[i] / (count[i] - 1);
 	break;
-    case STDDEV2:
+    case FUNC_STDDEV2:
 	for (i = 0; i < ncats; i++)
 	    result[i] = sqrt(sum2[i] / (count[i] - 1));
 	break;
-    case SKEWNESS2:
+    case FUNC_SKEWNESS2:
 	for (i = 0; i < ncats; i++) {
 	    double n = count[i];
 	    double var = sum2[i] / (n - 1);
@@ -453,7 +453,7 @@ int main(int argc, char **argv)
 	G_free(sum2);
 	G_free(sum3);
 	break;
-    case KURTOSIS2:
+    case FUNC_KURTOSIS2:
 	for (i = 0; i < ncats; i++) {
 	    double n = count[i];
 	    double var = sum2[i] / (n - 1);

+ 1 - 1
raster/r.surf.contour/contour.h

@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <math.h>
+#include <grass/gis.h>
 #include <grass/raster.h>
 #include "flag.h"
 
@@ -7,7 +8,6 @@
 #define INIT_AR		64
 #define AR_INCR		64
 #define ABS(x)		(((x) < 0) ? -(x) : (x))
-#define MIN(x,y)	(((x) < (y)) ? (x) : (y))
 #define TST(x)			/* fprintf(stderr,"(x):%d\n",(x)) */
 #define TSTSTR(x)		/* fprintf(stderr,"%s\n",(x)) */
 

+ 0 - 1
raster/r.surf.fractal/frac.h

@@ -16,7 +16,6 @@
 				/* programs. It sets up the necessary   */
 				/* prototypes for GRASS library calls.  */
 
-#define MAX(a,b) ((a)>(b) ? (a):(b))
 #define SWAP(a,b) tempr=(a); (a)=(b); (b) = tempr
 
 #define TWOPI 6.283185307179590	/* Constant value of 2 pi */

+ 0 - 3
raster3d/r3.in.ascii/main.c

@@ -245,9 +245,6 @@ FILE *openAscii(char *asciiFile, RASTER3D_Region * region)
 
 /*---------------------------------------------------------------------------*/
 
-#undef MAX
-#define MAX(a,b) (a > b ? a : b)
-
 void
 asciiToG3d(FILE * fp, RASTER3D_Region * region, int convertNull, char *nullValue)
 {

+ 0 - 3
raster3d/r3.in.v5d/main.c

@@ -34,9 +34,6 @@
 #include <grass/raster3d.h>
 #include <grass/glocale.h>
 
-#undef MAX
-#define MAX(a,b) (a > b ? a : b)
-
 /*---------------------------------------------------------------------------*/
 
 void *map = NULL;

+ 0 - 3
raster3d/r3.mask/main.c

@@ -41,9 +41,6 @@ void getParams(char **name, d_Mask ** maskRules)
 
 /*-------------------------------------------------------------------------*/
 
-#undef MAX
-#define MAX(a,b) (a > b ? a : b)
-
 static void makeMask(char *name, d_Mask * maskRules)
 {
     void *map, *mask;

+ 0 - 4
raster3d/r3.null/main.c

@@ -24,10 +24,6 @@
 #include <grass/glocale.h>
 
 
-#undef MAX
-#define MAX(a,b) (a > b ? a : b)
-
-
 typedef struct
 {
     struct Option *map, *setNull, *null;

+ 0 - 3
raster3d/r3.out.ascii/main.c

@@ -23,9 +23,6 @@
 #include <grass/raster3d.h>
 #include <grass/glocale.h>
 
-#undef MAX
-#define MAX(a,b) (a > b ? a : b)
-
 /* structs */
 typedef struct {
     struct Option *input, *output, *decimals, *null_val;

+ 0 - 3
raster3d/r3.out.v5d/main.c

@@ -23,9 +23,6 @@
 #include <grass/raster3d.h>
 #include <grass/glocale.h>
 
-#undef MAX
-#define MAX(a,b) (a > b ? a : b)
-
 /* structs */
 typedef struct
 {

+ 0 - 6
vector/v.buffer/main.c

@@ -28,12 +28,6 @@
 #include "local_proto.h"
 
 #define PI M_PI
-#ifndef MIN
-#define MIN(X,Y) ((X<Y)?X:Y)
-#endif
-#ifndef MAX
-#define MAX(X,Y) ((X>Y)?X:Y)
-#endif
 
 /* returns 1 if unit_tolerance is adjusted, 0 otherwise */
 int adjust_tolerance(double *tolerance)

+ 0 - 5
vector/v.cluster/main.c

@@ -25,11 +25,6 @@
 #include <grass/glocale.h>
 #include <grass/kdtree.h>
 
-#ifdef MAX
-#undef MAX
-#endif
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-
 #define CL_DBSCAN	1
 #define CL_DBSCAN2	2
 #define CL_DENSE	3