[GRASS-SVN] r48767 - in grass-addons/raster/r.pi: r.pi.corearea r.pi.corrwin r.pi.corrwindow r.pi.csr.mw r.pi.energy r.pi.energy.iter r.pi.enn r.pi.enn.iter r.pi.export r.pi.fnn r.pi.graph r.pi.graph.dec r.pi.graph.iter r.pi.graph.red r.pi.grow r.pi.import r.pi.index r.pi.library r.pi.lm r.pi.neigh r.pi.nlm r.pi.nlm.circ r.pi.nlm.stats r.pi.odc r.pi.prob.mw r.pi.prox r.pi.rectangle r.pi.searchtime r.pi.searchtime.iter r.pi.searchtime.mw

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 12 16:43:41 EDT 2011


Author: mmetz
Date: 2011-10-12 13:43:41 -0700 (Wed, 12 Oct 2011)
New Revision: 48767

Removed:
   grass-addons/raster/r.pi/r.pi.enn.iter/statmethods.c
   grass-addons/raster/r.pi/r.pi.neigh/stat_method.c
   grass-addons/raster/r.pi/r.pi.nlm.stats/stat_method.c
Modified:
   grass-addons/raster/r.pi/r.pi.corearea/local_proto.h
   grass-addons/raster/r.pi/r.pi.corearea/main.c
   grass-addons/raster/r.pi/r.pi.corrwin/main.c
   grass-addons/raster/r.pi/r.pi.corrwindow/main.c
   grass-addons/raster/r.pi/r.pi.csr.mw/local_proto.h
   grass-addons/raster/r.pi/r.pi.csr.mw/main.c
   grass-addons/raster/r.pi/r.pi.energy.iter/local_proto.h
   grass-addons/raster/r.pi/r.pi.energy.iter/main.c
   grass-addons/raster/r.pi/r.pi.energy/local_proto.h
   grass-addons/raster/r.pi/r.pi.enn.iter/Makefile
   grass-addons/raster/r.pi/r.pi.enn.iter/local_proto.h
   grass-addons/raster/r.pi/r.pi.enn.iter/main.c
   grass-addons/raster/r.pi/r.pi.enn/Makefile
   grass-addons/raster/r.pi/r.pi.enn/func.c
   grass-addons/raster/r.pi/r.pi.enn/local_proto.h
   grass-addons/raster/r.pi/r.pi.enn/main.c
   grass-addons/raster/r.pi/r.pi.export/local_proto.h
   grass-addons/raster/r.pi/r.pi.export/main.c
   grass-addons/raster/r.pi/r.pi.fnn/func.c
   grass-addons/raster/r.pi/r.pi.fnn/local_proto.h
   grass-addons/raster/r.pi/r.pi.fnn/main.c
   grass-addons/raster/r.pi/r.pi.graph.dec/func.c
   grass-addons/raster/r.pi/r.pi.graph.dec/local_proto.h
   grass-addons/raster/r.pi/r.pi.graph.dec/main.c
   grass-addons/raster/r.pi/r.pi.graph.iter/local_proto.h
   grass-addons/raster/r.pi/r.pi.graph.iter/main.c
   grass-addons/raster/r.pi/r.pi.graph.red/local_proto.h
   grass-addons/raster/r.pi/r.pi.graph.red/main.c
   grass-addons/raster/r.pi/r.pi.graph/hull.c
   grass-addons/raster/r.pi/r.pi.graph/local_proto.h
   grass-addons/raster/r.pi/r.pi.graph/main.c
   grass-addons/raster/r.pi/r.pi.grow/func.c
   grass-addons/raster/r.pi/r.pi.grow/local_proto.h
   grass-addons/raster/r.pi/r.pi.grow/main.c
   grass-addons/raster/r.pi/r.pi.import/local_proto.h
   grass-addons/raster/r.pi/r.pi.index/func.c
   grass-addons/raster/r.pi/r.pi.index/local_proto.h
   grass-addons/raster/r.pi/r.pi.index/main.c
   grass-addons/raster/r.pi/r.pi.library/r_pi.h
   grass-addons/raster/r.pi/r.pi.library/stat_method.c
   grass-addons/raster/r.pi/r.pi.lm/local_proto.h
   grass-addons/raster/r.pi/r.pi.neigh/Makefile
   grass-addons/raster/r.pi/r.pi.neigh/local_proto.h
   grass-addons/raster/r.pi/r.pi.neigh/main.c
   grass-addons/raster/r.pi/r.pi.nlm.circ/Makefile
   grass-addons/raster/r.pi/r.pi.nlm.circ/main.c
   grass-addons/raster/r.pi/r.pi.nlm.stats/local_proto.h
   grass-addons/raster/r.pi/r.pi.nlm.stats/main.c
   grass-addons/raster/r.pi/r.pi.nlm.stats/method.c
   grass-addons/raster/r.pi/r.pi.nlm/local_proto.h
   grass-addons/raster/r.pi/r.pi.nlm/main.c
   grass-addons/raster/r.pi/r.pi.odc/local_proto.h
   grass-addons/raster/r.pi/r.pi.odc/main.c
   grass-addons/raster/r.pi/r.pi.odc/voronoi.c
   grass-addons/raster/r.pi/r.pi.prob.mw/local_proto.h
   grass-addons/raster/r.pi/r.pi.prob.mw/main.c
   grass-addons/raster/r.pi/r.pi.prox/local_proto.h
   grass-addons/raster/r.pi/r.pi.prox/main.c
   grass-addons/raster/r.pi/r.pi.rectangle/main.c
   grass-addons/raster/r.pi/r.pi.searchtime.iter/local_proto.h
   grass-addons/raster/r.pi/r.pi.searchtime.iter/main.c
   grass-addons/raster/r.pi/r.pi.searchtime.iter/search.c
   grass-addons/raster/r.pi/r.pi.searchtime.mw/local_proto.h
   grass-addons/raster/r.pi/r.pi.searchtime.mw/main.c
   grass-addons/raster/r.pi/r.pi.searchtime.mw/search.c
   grass-addons/raster/r.pi/r.pi.searchtime/local_proto.h
   grass-addons/raster/r.pi/r.pi.searchtime/main.c
   grass-addons/raster/r.pi/r.pi.searchtime/search.c
Log:
next code cleanup, more to do

Modified: grass-addons/raster/r.pi/r.pi.corearea/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.corearea/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.corearea/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -33,8 +33,8 @@
     int count;
 } PatchBorderList;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
-typedef DCELL(*f_propmethod) (DCELL, DCELL);
+typedef DCELL(f_statmethod) (DCELL *, int);
+typedef DCELL(f_propmethod) (DCELL, DCELL);
 
 /* frag.c */
 void writeFragments(int *flagbuf, int nrows, int ncols, int nbr_cnt);

Modified: grass-addons/raster/r.pi/r.pi.corearea/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corearea/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.corearea/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -19,7 +19,7 @@
 
 struct statmethod
 {
-    f_statmethod method;	/* routine to compute new value */
+    f_statmethod *method;	/* routine to compute new value */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
     char *suffix;		/* output suffix */
@@ -33,7 +33,7 @@
 
 struct propmethod
 {
-    f_propmethod method;	/* routine to compute new value */
+    f_propmethod *method;	/* routine to compute new value */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
     char *suffix;		/* output suffix */
@@ -66,8 +66,8 @@
     int buffer;
     double distance;
     double angle;
-    f_statmethod method;
-    f_propmethod prop_method;
+    f_statmethod *method;
+    f_propmethod *prop_method;
     double dist_weight;
 
     /* map_type and categories */

Modified: grass-addons/raster/r.pi/r.pi.corrwin/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.corrwin/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -25,53 +25,37 @@
 #include "local_proto.h"
 
 
-typedef int (*ifunc) (void);
+typedef int (ifunc) (void);
 
 struct ncb ncb;
 
 int main(int argc, char *argv[])
 {
     char *p, *p1, *p2;
-
     int verbose;
-
-    // in and out file pointers
+    /* in and out file pointers */
     int in_fd1, in_fd2;
-
     int out_fd;
-
     DCELL *result;
-
     RASTER_MAP_TYPE map_type1, map_type2;
-
     int row, col, i, j;
-
     int readrow;
-
     int maxval;
-
     int nrows, ncols;
-
     int n;
-
     int copycolr;
-
     struct Colors colr;
-
     struct GModule *module;
-
     struct
     {
 	struct Option *input1, *input2, *output;
 	struct Option *size, *max;
 	struct Option *title;
     } parm;
-
     struct
     {
 	struct Flag *quiet;
     } flag;
-
     DCELL *values1, *values2;	/* list of neighborhood values */
 
     G_gisinit(argv[0]);
@@ -192,7 +176,7 @@
     if (out_fd < 0)
 	    G_fatal_error(_("Cannot create raster map <%s>"), ncb.newcell.name);
 
-    if (verbose = !flag.quiet->answer)
+    if ((verbose = !flag.quiet->answer))
 	fprintf(stderr, "Percent complete ... ");
 
     for (row = 0; row < nrows; row++) {

Modified: grass-addons/raster/r.pi/r.pi.corrwindow/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwindow/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.corrwindow/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -24,7 +24,7 @@
 #include "ncb.h"
 #include "local_proto.h"
 
-typedef int (*ifunc) (void);
+typedef int (ifunc) (void);
 
 struct ncb ncb;
 
@@ -32,17 +32,13 @@
 {
     char *p, *p1, *p2;
     int verbose;
-
     int in_fd1, in_fd2;
     int out_fd;
     DCELL *result;
-
     RASTER_MAP_TYPE map_type1, map_type2;
-
     int row, col, i, j;
     int readrow;
     int maxval;
-
     int nrows, ncols;
     int n;
     int copycolr;
@@ -58,7 +54,6 @@
     {
 	struct Flag *quiet;
     } flag;
-
     DCELL *values1, *values2;	/* list of neighborhood values */
 
     G_gisinit(argv[0]);
@@ -181,7 +176,7 @@
     if (out_fd < 0)
 	    G_fatal_error(_("Cannot create raster map <%s>"), ncb.newcell.name);
 
-    if (verbose = !flag.quiet->answer)
+    if ((verbose = !flag.quiet->answer))
 	fprintf(stderr, "Percent complete ... ");
 
     for (row = 0; row < nrows; row++) {

Modified: grass-addons/raster/r.pi/r.pi.csr.mw/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.csr.mw/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.csr.mw/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -17,28 +17,10 @@
 #define GLOBAL extern
 #endif
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
-typedef void (*f_method) (DCELL * values, int *map, int *mask, int n,
+typedef DCELL(f_statmethod) (DCELL *, int);
+typedef void (f_method) (DCELL * values, int *map, int *mask, int n,
 			  int size);
 
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
-void print_buffer(int *buffer, int sx, int sy);
-void print_d_buffer(DCELL * buffer, int sx, int sy);
-void print_map(double *map, int size);
-void print_array(DCELL * buffer, int size);
-void print_fragments();
-
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
-
 /* analysis.c */
 void clark_evans(DCELL * values, int *map, int *mask, int n, int size);
 void donnelly(DCELL * values, int *map, int *mask, int n, int size);

Modified: grass-addons/raster/r.pi/r.pi.csr.mw/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.csr.mw/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.csr.mw/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -68,7 +68,7 @@
     int n;
     int size;
     int method;
-    f_method method_func;
+    f_method *method_func;
 
     /* maps */
     int *map;
@@ -135,7 +135,7 @@
     parm.method->type = TYPE_STRING;
     parm.method->required = YES;
     parm.method->multiple = NO;
-    str = parm.method->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (n = 0; methods[n].name; n++) {
 	if (n)
 	    strcat(str, ",");
@@ -143,6 +143,7 @@
 	    *str = 0;
 	strcat(str, methods[n].name);
     }
+    parm.method->options = str;
     parm.method->description = _("Method to calculate resulting index");
 
     parm.size = G_define_option();
@@ -226,7 +227,7 @@
 
     /* allocate map buffers */
     map = (int *)G_malloc(sx * sy * sizeof(int));
-    mask = (DCELL *) G_malloc(sx * sy * sizeof(int));
+    mask = (int *) G_malloc(sx * sy * sizeof(int));
 
     result = G_allocate_c_raster_buf();
     d_res = G_allocate_d_raster_buf();

Modified: grass-addons/raster/r.pi/r.pi.energy/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.energy/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.energy/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -40,32 +40,14 @@
     int x, y;
 } Displacement;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
+typedef DCELL(f_statmethod) (DCELL *, int);
 
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
-void print_buffer(int *buffer, int sx, int sy);
-void print_d_buffer(DCELL * buffer, int sx, int sy);
-void print_map(double *map, int size);
-void print_array(DCELL * buffer, int size);
-void print_fragments();
-
 /* frag.c */
 void writeFragments(int *flagbuf, int nrows, int ncols, int nbr_cnt);
 
 /* search.c */
 void perform_search(int *map, DCELL * costmap, DCELL * suitmap);
 
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
-
 /* parameters */
 GLOBAL int sx, sy;
 GLOBAL int keyval;

Modified: grass-addons/raster/r.pi/r.pi.energy.iter/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.energy.iter/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.energy.iter/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -40,7 +40,7 @@
     int x, y;
 } Displacement;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
+typedef DCELL(f_statmethod) (DCELL *, int);
 
 /* frag.c */
 void writeFragments(int *flagbuf, int nrows, int ncols, int nbr_cnt);
@@ -49,13 +49,6 @@
 void perform_search(int *map, DCELL * costmap, DCELL * suitmap,
 		    int remove_indi);
 
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
 
 /* parameters */
 GLOBAL int sx, sy;

Modified: grass-addons/raster/r.pi/r.pi.energy.iter/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.energy.iter/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.energy.iter/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -195,7 +195,7 @@
     parm.stats->type = TYPE_STRING;
     parm.stats->required = YES;
     parm.stats->multiple = YES;
-    str = parm.stats->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (method = 0; statmethods[method].name; method++) {
 	if (method)
 	    strcat(str, ",");
@@ -203,6 +203,7 @@
 	    *str = 0;
 	strcat(str, statmethods[method].name);
     }
+    parm.stats->options = str;
     parm.stats->description =
 	_("Statistical method to perform on the pathlengths of the individuals");
     parm.stats->guisection = _("Required");
@@ -601,7 +602,7 @@
 	    }
 	}
 	for (method = 0; method < stat_count; method++) {
-	    f_statmethod func = statmethods[stats[method]].method;
+	    f_statmethod *func = statmethods[stats[method]].method;
 	    int index = method * fragcount + frag;
 
 	    out_immi[index] = func(dummy, fragcount - 1);

Modified: grass-addons/raster/r.pi/r.pi.enn/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn/Makefile	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.enn/Makefile	2011-10-12 20:43:41 UTC (rev 48767)
@@ -2,7 +2,10 @@
 
 PGM = r.pi.enn
 
-LIBES = $(STATSLIB) $(GISLIB)
+LIB_NAME = grass_rpi
+RPI_LIB  = -l$(LIB_NAME)
+
+LIBES = $(STATSLIB) $(GISLIB) $(RPI_LIB)
 DEPENDENCIES = $(STATSDEP) $(GISDEP)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make

Modified: grass-addons/raster/r.pi/r.pi.enn/func.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn/func.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.enn/func.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -1,48 +1,5 @@
 #include "local_proto.h"
 
-DCELL average(DCELL * vals, int count)
-{
-    if (count <= 0)
-	return 0;
-
-    int i;
-    DCELL res = 0;
-
-    for (i = 0; i < count; i++)
-	res += vals[i];
-
-    return res / count;
-}
-
-DCELL variance(DCELL * vals, int count)
-{
-    if (count <= 0)
-	return 0;
-
-    int i;
-    DCELL mean;
-    DCELL s = 0;
-    DCELL ss = 0;
-
-    for (i = 0; i < count; i++) {
-	DCELL val = vals[i];
-
-	s += val;
-	ss += val * val;
-    }
-
-    mean = s / (DCELL) count;
-    return ss / count - mean * mean;
-}
-
-DCELL std_deviat(DCELL * vals, int count)
-{
-    if (count <= 0)
-	return 0;
-
-    return sqrt(variance(vals, count));
-}
-
 DCELL value(DCELL * vals, int count)
 {
     if (count <= 0)
@@ -51,20 +8,6 @@
     return vals[count - 1];
 }
 
-DCELL sum(DCELL * vals, int count)
-{
-    if (count <= 0)
-	return 0;
-
-    int i;
-    DCELL res = 0;
-
-    for (i = 0; i < count; i++)
-	res += vals[i];
-
-    return res;
-}
-
 DCELL dist(Coords * p1, Coords * p2)
 {
     int x1 = p1->x;

Modified: grass-addons/raster/r.pi/r.pi.enn/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.enn/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -16,16 +16,12 @@
 #define GLOBAL extern
 #endif
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
-typedef int (*f_func) (DCELL *, int, int *, int, f_statmethod);
+typedef DCELL(f_statmethod) (DCELL *, int);
+typedef int (f_func) (DCELL *, int, int *, int, f_statmethod);
 
 void writeFrag(int row, int col, int nbr_cnt);
 
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
 DCELL value(DCELL * vals, int count);
-DCELL sum(DCELL * vals, int count);
 
 int get_dist_matrix(int count);
 

Modified: grass-addons/raster/r.pi/r.pi.enn/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.enn/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -74,8 +74,8 @@
     int statmethod;
     int method;
     int methods[GNAME_MAX];
-    f_func compute_values;
-    f_func compute_stat;
+    f_func *compute_values;
+    f_statmethod *compute_stat;
 
     char *p;
 
@@ -133,7 +133,7 @@
     parm.method->key = "method";
     parm.method->type = TYPE_STRING;
     parm.method->required = YES;
-    p = parm.method->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; menu[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -141,6 +141,7 @@
 	    *p = 0;
 	strcat(p, menu[n].name);
     }
+    parm.method->options = p;
     parm.method->multiple = YES;
     parm.method->description = _("Operation to perform on fragments");
 
@@ -156,7 +157,7 @@
     parm.statmethod->key = "statmethod";
     parm.statmethod->type = TYPE_STRING;
     parm.statmethod->required = YES;
-    p = parm.statmethod->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; statmethods[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -164,6 +165,7 @@
 	    *p = 0;
 	strcat(p, statmethods[n].name);
     }
+    parm.statmethod->options = p;
     parm.statmethod->description =
 	_("Statistical method to perform on the values");
 
@@ -290,7 +292,7 @@
     else
 	sprintf(title, "Fragmentation of file: %s", oldname);
 
-    if (verbose = !flag.quiet->answer)
+    if ((verbose = !flag.quiet->answer))
 	G_message("Loading patches...");
 
     /* find fragments */
@@ -335,7 +337,7 @@
 	compute_values = menu[methods[m]].method;
 
 	/* perform current function on the patches */
-	if (verbose = !flag.quiet->answer)
+	if ((verbose = !flag.quiet->answer))
 	    G_message("Performing operation %s ... ", menu[methods[m]].name);
 	values = (DCELL *) G_malloc(fragcount * number * sizeof(DCELL));
 	compute_values(values, fragcount, parseres, number, compute_stat);
@@ -344,7 +346,7 @@
 	    G_percent(fragcount, fragcount, 2);
 
 	/* write output files */
-	if (verbose = !flag.quiet->answer)
+	if ((verbose = !flag.quiet->answer))
 	    G_message("Writing output...");
 
 	/* for all requested patches */

Modified: grass-addons/raster/r.pi/r.pi.enn.iter/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn.iter/Makefile	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.enn.iter/Makefile	2011-10-12 20:43:41 UTC (rev 48767)
@@ -2,7 +2,10 @@
 
 PGM = r.fragment.iter
 
-LIBES = $(STATSLIB) $(GISLIB)
+LIB_NAME = grass_rpi
+RPI_LIB  = -l$(LIB_NAME)
+
+LIBES = $(STATSLIB) $(GISLIB) $(RPI_LIB)
 DEPENDENCIES = $(STATSDEP) $(GISDEP)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make

Modified: grass-addons/raster/r.pi/r.pi.enn.iter/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn.iter/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.enn.iter/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -22,8 +22,8 @@
     int x, y;
 } Point;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
-typedef int (*f_func) (DCELL *, Coords **, int, f_statmethod);
+typedef DCELL(f_statmethod) (DCELL *, int);
+typedef void (f_func) (DCELL *, Coords **, int, f_statmethod);
 
 /* frag.c */
 void writeFragments(int *flagbuf, int nrows, int ncols, int nbr_cnt);
@@ -34,10 +34,6 @@
 void f_area(DCELL * vals, Coords ** frags, int count,
 	    f_statmethod statmethod);
 
-/* statmethods.c */
-DCELL sum(DCELL * vals, int count);
-DCELL average(DCELL * vals, int count);
-
 /* global parameters */
 GLOBAL int verbose;
 GLOBAL Coords **fragments;

Modified: grass-addons/raster/r.pi/r.pi.enn.iter/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn.iter/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.enn.iter/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -26,7 +26,7 @@
 
 struct statmethod
 {
-    f_func *statmethod;		/* routine to compute new value */
+    f_statmethod *statmethod;		/* routine to compute new value */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
 };
@@ -57,12 +57,12 @@
     int keyval;
     int neighb_count;
     int method;
-    f_func perform_method;
+    f_func *perform_method;
     int statmethod;
-    f_func perform_statmethod;
+    f_statmethod *perform_statmethod;
 
     /* other parameters */
-    char *title[1024];
+    char title[1024];
 
     /* helper variables */
     RASTER_MAP_TYPE map_type;
@@ -110,7 +110,7 @@
     parm.method->key = "method";
     parm.method->type = TYPE_STRING;
     parm.method->required = YES;
-    p = parm.method->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (act_method = 0; methods[act_method].name; act_method++) {
 	if (act_method > 0)
 	    strcat(p, ",");
@@ -118,13 +118,14 @@
 	    *p = 0;
 	strcat(p, methods[act_method].name);
     }
+    parm.method->options = p;
     parm.method->description = _("Aspect of the nearest patch to use.");
 
     parm.statmethod = G_define_option();
     parm.statmethod->key = "statmethod";
     parm.statmethod->type = TYPE_STRING;
     parm.statmethod->required = YES;
-    p = parm.statmethod->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (act_method = 0; statmethods[act_method].name; act_method++) {
 	if (act_method > 0)
 	    strcat(p, ",");
@@ -132,6 +133,7 @@
 	    *p = 0;
 	strcat(p, statmethods[act_method].name);
     }
+    parm.statmethod->options = p;
     parm.statmethod->description =
 	_("Statistical method to perform on differences.");
 

Deleted: grass-addons/raster/r.pi/r.pi.enn.iter/statmethods.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn.iter/statmethods.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.enn.iter/statmethods.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -1,29 +0,0 @@
-#include "local_proto.h"
-
-DCELL sum(DCELL * vals, int count)
-{
-    if (count <= 0)
-	return 0;
-
-    int i;
-    DCELL res = 0;
-
-    for (i = 0; i < count; i++)
-	res += vals[i];
-
-    return res;
-}
-
-DCELL average(DCELL * vals, int count)
-{
-    if (count <= 0)
-	return 0;
-
-    int i;
-    DCELL res = 0;
-
-    for (i = 0; i < count; i++)
-	res += vals[i];
-
-    return res / count;
-}

Modified: grass-addons/raster/r.pi/r.pi.export/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.export/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.export/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -28,29 +28,11 @@
     int patch;
 } PatchPoint;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
+typedef DCELL(f_statmethod) (DCELL *, int);
 
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
-void print_buffer(int *buffer, int sx, int sy);
-void print_d_buffer(DCELL * buffer, int sx, int sy);
-void print_map(double *map, int size);
-void print_array(DCELL * buffer, int size);
-void print_fragments();
-
 /* frag.c */
 void writeFragments(DCELL * flagbuf, int nrows, int ncols, int nbr_cnt);
 
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
-
 /* global variables */
 GLOBAL int verbose;
 GLOBAL Coords **fragments;

Modified: grass-addons/raster/r.pi/r.pi.export/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.export/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.export/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -75,7 +75,7 @@
     char output_name[GNAME_MAX];
     char *str;
     int method;
-    f_statmethod perform_method;
+    f_statmethod *perform_method;
     DCELL val;
     DCELL *values;
     int count;
@@ -139,7 +139,7 @@
     parm.stats->type = TYPE_STRING;
     parm.stats->required = YES;
     parm.stats->multiple = YES;
-    str = parm.stats->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (n = 0; statmethods[n].name; n++) {
 	if (n)
 	    strcat(str, ",");
@@ -147,6 +147,7 @@
 	    *str = 0;
 	strcat(str, statmethods[n].name);
     }
+    parm.stats->options = str;
     parm.stats->description =
 	_("Statistical method to perform on the values");
 

Modified: grass-addons/raster/r.pi/r.pi.fnn/func.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.fnn/func.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.fnn/func.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -1,48 +1,5 @@
 #include "local_proto.h"
 
-DCELL average(DCELL * vals, int count)
-{
-    if (count <= 0)
-	return 0;
-
-    int i;
-    DCELL res = 0;
-
-    for (i = 0; i < count; i++)
-	res += vals[i];
-
-    return res / count;
-}
-
-DCELL variance(DCELL * vals, int count)
-{
-    if (count <= 0)
-	return 0;
-
-    int i;
-    DCELL mean;
-    DCELL s = 0;
-    DCELL ss = 0;
-
-    for (i = 0; i < count; i++) {
-	DCELL val = vals[i];
-
-	s += val;
-	ss += val * val;
-    }
-
-    mean = s / (DCELL) count;
-    return ss / count - mean * mean;
-}
-
-DCELL std_deviat(DCELL * vals, int count)
-{
-    if (count <= 0)
-	return 0;
-
-    return sqrt(variance(vals, count));
-}
-
 DCELL value(DCELL * vals, int count)
 {
     if (count <= 0)
@@ -51,20 +8,6 @@
     return vals[count - 1];
 }
 
-DCELL sum(DCELL * vals, int count)
-{
-    if (count <= 0)
-	return 0;
-
-    int i;
-    DCELL res = 0;
-
-    for (i = 0; i < count; i++)
-	res += vals[i];
-
-    return res;
-}
-
 DCELL euclid_dist(int x1, int y1, int x2, int y2)
 {
     int dx = x2 - x1;

Modified: grass-addons/raster/r.pi/r.pi.fnn/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.fnn/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.fnn/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -22,16 +22,12 @@
     DCELL f, g;
 } Path_Coords;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
-typedef int (*f_func) (DCELL *, int, int *, int, f_statmethod);
+typedef DCELL(f_statmethod) (DCELL *, int);
+typedef int (f_func) (DCELL *, int, int *, int, f_statmethod);
 
 void writeFrag(int row, int col, int nbr_cnt);
 
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
 DCELL value(DCELL * vals, int count);
-DCELL sum(DCELL * vals, int count);
 
 /* heap.c */
 void heap_alloc(int size);
@@ -39,7 +35,9 @@
 Path_Coords heap_delete(int pos);
 void heap_insert(int x, int y, DCELL f, DCELL g);
 void upheap(int pos);
+int heap_search(int x, int y);
 
+/* func.c */
 int get_dist_matrix(int count);
 
 int get_nearest_indices(int count, int *num_array, int num_count);

Modified: grass-addons/raster/r.pi/r.pi.fnn/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.fnn/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.fnn/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -75,8 +75,8 @@
     int statmethod;
     int method;
     int methods[GNAME_MAX];
-    f_func compute_values;
-    f_func compute_stat;
+    f_func *compute_values;
+    f_statmethod *compute_stat;
 
     char *p;
 
@@ -143,7 +143,7 @@
     parm.method->key = "method";
     parm.method->type = TYPE_STRING;
     parm.method->required = YES;
-    p = parm.method->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; menu[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -151,6 +151,7 @@
 	    *p = 0;
 	strcat(p, menu[n].name);
     }
+    parm.method->options = p;
     parm.method->multiple = YES;
     parm.method->description = _("Operation to perform on fragments");
 
@@ -166,7 +167,7 @@
     parm.statmethod->key = "statmethod";
     parm.statmethod->type = TYPE_STRING;
     parm.statmethod->required = YES;
-    p = parm.statmethod->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; statmethods[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -174,6 +175,7 @@
 	    *p = 0;
 	strcat(p, statmethods[n].name);
     }
+    parm.statmethod->options = p;
     parm.statmethod->description =
 	_("Statistical method to perform on the values");
 
@@ -316,7 +318,7 @@
     else
 	sprintf(title, "Fragmentation of file: %s", oldname);
 
-    if (verbose = !flag.quiet->answer)
+    if ((verbose = !flag.quiet->answer))
 	G_message("Loading patches...");
 
     /* read costmap */
@@ -370,7 +372,7 @@
 	compute_values = menu[methods[m]].method;
 
 	/* perform actual function on the patches */
-	if (verbose = !flag.quiet->answer)
+	if ((verbose = !flag.quiet->answer))
 	    G_message("Performing operation %s ... ", menu[methods[m]].name);
 	values = (DCELL *) G_malloc(fragcount * number * sizeof(DCELL));
 	compute_values(values, fragcount, parseres, number, compute_stat);
@@ -379,7 +381,7 @@
 	    G_percent(fragcount, fragcount, 2);
 
 	/* write output files */
-	if (verbose = !flag.quiet->answer)
+	if ((verbose = !flag.quiet->answer))
 	    G_message("Writing output...");
 
 	/* for all requested patches */

Modified: grass-addons/raster/r.pi/r.pi.graph/hull.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph/hull.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.graph/hull.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -9,8 +9,8 @@
 
     int cross = dx1 * dy2 - dx2 * dy1;
 
-    return cross > 0 || cross == 0 &&
-	(abs(dx1) + abs(dy1)) > (abs(dx2) + abs(dy2));
+    return cross > 0 || (cross == 0 &&
+	(abs(dx1) + abs(dy1)) > (abs(dx2) + abs(dy2)));
 }
 
 int concave(Position p1, Position p2, Position p3)

Modified: grass-addons/raster/r.pi/r.pi.graph/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.graph/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -21,8 +21,8 @@
     int x, y;
 } Position;
 
-typedef void (*f_neighborhood) (DCELL max_dist);
-typedef void (*f_index) ();
+typedef void (f_neighborhood) (DCELL max_dist);
+typedef void (f_index) ();
 
 /* frag.c */
 void writeFragments(int *flagbuf, int nrows, int ncols, int nbr_cnt);
@@ -56,6 +56,9 @@
 	       int sy, int width);
 void flood_fill(int *map, int val, int x, int y, int sx, int sy);
 
+/* hull.c */
+void convex_hull(int *map);
+
 /* global variables */
 GLOBAL int nrows, ncols;
 GLOBAL Coords *cells;

Modified: grass-addons/raster/r.pi/r.pi.graph/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.graph/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -90,8 +90,8 @@
     char *p;
     int row, col, i, j, m;
     int n;
-    f_neighborhood build_graph;
-    f_index calc_index;
+    f_neighborhood *build_graph;
+    f_index *calc_index;
     int *curpos;
     DCELL *values;
     CELL *result;
@@ -144,7 +144,7 @@
     parm.neighborhood->key = "neighborhood";
     parm.neighborhood->type = TYPE_STRING;
     parm.neighborhood->required = YES;
-    p = parm.neighborhood->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; neighborhoods[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -152,13 +152,14 @@
 	    *p = 0;
 	strcat(p, neighborhoods[n].name);
     }
+    parm.neighborhood->options = p;
     parm.neighborhood->description = _("Neighborhood definition");
 
     parm.index = G_define_option();
     parm.index->key = "index";
     parm.index->type = TYPE_STRING;
     parm.index->required = YES;
-    p = parm.index->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; indices[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -166,6 +167,7 @@
 	    *p = 0;
 	strcat(p, indices[n].name);
     }
+    parm.index->options = p;
     parm.index->description = _("Cluster index");
 
     flag.adjacent = G_define_flag();
@@ -433,7 +435,7 @@
     G_set_c_null_value(clustermap, nrows * ncols);
 
     /* calculate the convex hull */
-    convex_hull();
+    convex_hull(clustermap);
 
     /* write output */
     for (row = 0; row < nrows; row++) {

Modified: grass-addons/raster/r.pi/r.pi.graph.dec/func.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.dec/func.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.graph.dec/func.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -380,7 +380,7 @@
 
 	/* no patches are 0% connected */
 	if (n == 0) {
-	    values[i] == 0.0;
+	    values[i] = 0.0;
 	    continue;
 	}
 

Modified: grass-addons/raster/r.pi/r.pi.graph.dec/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.dec/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.graph.dec/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <math.h>
+#include <time.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
 #include <grass/stats.h>
@@ -28,13 +29,13 @@
     int count;
 } Cluster;
 
-typedef void (*f_neighborhood) (int *adjacency_matrix, DCELL * distmatrix,
+typedef void (f_neighborhood) (int *adjacency_matrix, DCELL * distmatrix,
 				int fragcount, DCELL max_dist);
-typedef void (*f_index) (DCELL * values, Cluster * cluster_list,
+typedef void (f_index) (DCELL * values, Cluster * cluster_list,
 			 int cluster_count, int *adjacency_matrix,
 			 Patch * fragments, int fragcount,
 			 DCELL * distmatrix);
-typedef int (*f_choice) (int cluster_index, Cluster * cluster_list,
+typedef int (f_choice) (int cluster_index, Cluster * cluster_list,
 			 int cluster_count, int *adjacency_matrix,
 			 Patch * fragments, int fragcount,
 			 DCELL * distmatrix);

Modified: grass-addons/raster/r.pi/r.pi.graph.dec/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.dec/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.graph.dec/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -20,21 +20,21 @@
 
 struct neighborhood
 {
-    f_neighborhood method;	/* routine to build adjacency matrix */
+    f_neighborhood *method;	/* routine to build adjacency matrix */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
 };
 
 struct index
 {
-    f_index method;		/* routine to calculate cluster index */
+    f_index *method;		/* routine to calculate cluster index */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
 };
 
 struct choice
 {
-    f_choice method;		/* routine to determine the next patch to delete */
+    f_choice *method;		/* routine to determine the next patch to delete */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
 };
@@ -111,9 +111,9 @@
     char *p;
     int row, col, i, j, m;
     int n;
-    f_neighborhood build_graph;
-    f_index calc_index;
-    f_choice choose_patch;
+    f_neighborhood *build_graph;
+    f_index *calc_index;
+    f_choice *choose_patch;
     int *curpos;
     CELL *result;
     DCELL *d_res;
@@ -174,7 +174,7 @@
     parm.neighborhood->key = "neighborhood";
     parm.neighborhood->type = TYPE_STRING;
     parm.neighborhood->required = YES;
-    p = parm.neighborhood->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; neighborhoods[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -182,13 +182,14 @@
 	    *p = 0;
 	strcat(p, neighborhoods[n].name);
     }
+    parm.neighborhood->options = p;
     parm.neighborhood->description = _("Neighborhood definition");
 
     parm.index = G_define_option();
     parm.index->key = "index";
     parm.index->type = TYPE_STRING;
     parm.index->required = YES;
-    p = parm.index->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; indices[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -196,13 +197,14 @@
 	    *p = 0;
 	strcat(p, indices[n].name);
     }
+    parm.index->options = p;
     parm.index->description = _("Cluster index");
 
     parm.choice = G_define_option();
     parm.choice->key = "choice";
     parm.choice->type = TYPE_STRING;
     parm.choice->required = YES;
-    p = parm.choice->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; choices[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -210,6 +212,7 @@
 	    *p = 0;
 	strcat(p, choices[n].name);
     }
+    parm.choice->options = p;
     parm.choice->description = _("Cluster index");
 
     parm.seed = G_define_option();

Modified: grass-addons/raster/r.pi/r.pi.graph.iter/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.iter/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.graph.iter/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -28,9 +28,9 @@
     int count;
 } Cluster;
 
-typedef void (*f_neighborhood) (int *adjacency_matrix, DCELL * distmatrix,
+typedef void (f_neighborhood) (int *adjacency_matrix, DCELL * distmatrix,
 				int fragcount, DCELL max_dist);
-typedef void (*f_index) (DCELL * values, Cluster * cluster_list,
+typedef void (f_index) (DCELL * values, Cluster * cluster_list,
 			 int clustercount, int *adjacency_matrix,
 			 Patch * fragments, int fragcount,
 			 DCELL * distmatrix);

Modified: grass-addons/raster/r.pi/r.pi.graph.iter/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.iter/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.graph.iter/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -22,14 +22,14 @@
 
 struct neighborhood
 {
-    f_neighborhood method;	/* routine to build adjacency matrix */
+    f_neighborhood *method;	/* routine to build adjacency matrix */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
 };
 
 struct index
 {
-    f_index method;		/* routine to calculate cluster index */
+    f_index *method;		/* routine to calculate cluster index */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
 };
@@ -93,8 +93,8 @@
     char *p;
     int row, col, i, j, m;
     int n;
-    f_neighborhood build_graph;
-    f_index calc_index;
+    f_neighborhood *build_graph;
+    f_index *calc_index;
     int *curpos;
     CELL *result;
     DCELL *d_res;
@@ -147,7 +147,7 @@
     parm.neighborhood->key = "neighborhood";
     parm.neighborhood->type = TYPE_STRING;
     parm.neighborhood->required = YES;
-    p = parm.neighborhood->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; neighborhoods[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -155,13 +155,14 @@
 	    *p = 0;
 	strcat(p, neighborhoods[n].name);
     }
+    parm.neighborhood->options = p;
     parm.neighborhood->description = _("Neighborhood definition");
 
     parm.index = G_define_option();
     parm.index->key = "index";
     parm.index->type = TYPE_STRING;
     parm.index->required = YES;
-    p = parm.index->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; indices[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -169,6 +170,7 @@
 	    *p = 0;
 	strcat(p, indices[n].name);
     }
+    parm.index->options = p;
     parm.index->description = _("Cluster index");
 
     flag.adjacent = G_define_flag();

Modified: grass-addons/raster/r.pi/r.pi.graph.red/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.red/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.graph.red/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -28,13 +28,13 @@
     int count;
 } Cluster;
 
-typedef void (*f_neighborhood) (int *adjacency_matrix, DCELL * distmatrix,
+typedef void (f_neighborhood) (int *adjacency_matrix, DCELL * distmatrix,
 				int fragcount, DCELL max_dist);
-typedef void (*f_index) (DCELL * values, Cluster * cluster_list,
+typedef void (f_index) (DCELL * values, Cluster * cluster_list,
 			 int clustercount, int *adjacency_matrix,
 			 Patch * fragments, int fragcount,
 			 DCELL * distmatrix);
-typedef DCELL(*f_statmethod) (DCELL * vals, int count);
+typedef DCELL (f_statmethod) (DCELL * vals, int count);
 
 
 /* frag.c */
@@ -96,17 +96,6 @@
 
 DCELL nearest_points(Patch * frags, int n1, int n2, Coords * np1,
 		     Coords * np2);
-
-/* stat_methods.c */
-
-DCELL average(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
-
 /* draw.c */
 void draw_line(int *map, int val, int x1, int y1, int x2, int y2, int sx,
 	       int sy, int width);

Modified: grass-addons/raster/r.pi/r.pi.graph.red/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.red/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.graph.red/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -20,21 +20,21 @@
 
 struct neighborhood
 {
-    f_neighborhood method;	/* routine to build adjacency matrix */
+    f_neighborhood *method;	/* routine to build adjacency matrix */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
 };
 
 struct index
 {
-    f_index method;		/* routine to calculate cluster index */
+    f_index *method;		/* routine to calculate cluster index */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
 };
 
 struct statmethod
 {
-    f_statmethod method;	/* routine to compute statistical value */
+    f_statmethod *method;	/* routine to compute statistical value */
     char *name;			/* method name */
     char *suffix;		/* abbreviation to be displayed in the output */
     char *text;			/* menu display - full description */
@@ -114,9 +114,9 @@
     char *p;
     int row, col, i, j, m;
     int n;
-    f_neighborhood build_graph;
-    f_index calc_index;
-    f_statmethod calc_stat;
+    f_neighborhood *build_graph;
+    f_index *calc_index;
+    f_statmethod *calc_stat;
     int *curpos;
     CELL *result;
     DCELL *d_res;
@@ -174,7 +174,7 @@
     parm.neighborhood->key = "neighborhood";
     parm.neighborhood->type = TYPE_STRING;
     parm.neighborhood->required = YES;
-    p = parm.neighborhood->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; neighborhoods[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -182,6 +182,7 @@
 	    *p = 0;
 	strcat(p, neighborhoods[n].name);
     }
+    parm.neighborhood->options = p;
     parm.neighborhood->description = _("Neighborhood definition");
 
     parm.index = G_define_option();
@@ -189,7 +190,7 @@
     parm.index->type = TYPE_STRING;
     parm.index->required = YES;
     parm.index->multiple = YES;
-    p = parm.index->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; indices[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -197,13 +198,14 @@
 	    *p = 0;
 	strcat(p, indices[n].name);
     }
+    parm.index->options = p;
     parm.index->description = _("Cluster index");
 
     parm.stats = G_define_option();
     parm.stats->key = "stats";
     parm.stats->type = TYPE_STRING;
     parm.stats->required = YES;
-    p = parm.stats->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; statmethods[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -211,6 +213,7 @@
 	    *p = 0;
 	strcat(p, statmethods[n].name);
     }
+    parm.stats->options = p;
     parm.stats->description =
 	_("Statistical method to perform on the values");
 
@@ -379,7 +382,7 @@
     /*      calc_index = indices[index].method;
        calc_index(ref_values, clusters, clustercount, adjmatrix, fragments, fragcount, distmatrix);
 
-       /*fprintf(stderr, "Reference values:");
+       fprintf(stderr, "Reference values:");
        for(i = 0; i < clustercount; i++) {
        fprintf(stderr, " %0.2f", ref_values[i]);
        }

Modified: grass-addons/raster/r.pi/r.pi.grow/func.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.grow/func.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.grow/func.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -15,11 +15,11 @@
 
 		switch (neighbors) {
 		case 4:
-		    if (col > 0 && flagbuf[row * ncols + col - 1] == 1 ||
-			col < ncols - 1 && flagbuf[row * ncols + col + 1] == 1
-			|| row > 0 && flagbuf[(row - 1) * ncols + col] == 1 ||
-			row < nrows - 1 &&
-			flagbuf[(row + 1) * ncols + col] == 1) {
+		    if ((col > 0 && flagbuf[row * ncols + col - 1] == 1) ||
+			(col < ncols - 1 && flagbuf[row * ncols + col + 1] == 1) ||
+			(row > 0 && flagbuf[(row - 1) * ncols + col] == 1) ||
+			(row < nrows - 1 &&
+			flagbuf[(row + 1) * ncols + col] == 1)) {
 			/* add position to the list */
 			Position pos = { col, row };
 			res[count] = pos;

Modified: grass-addons/raster/r.pi/r.pi.grow/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.grow/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.grow/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -22,12 +22,13 @@
     int x, y;
 } Position;
 
-typedef int (*f_method) (Position *, int, int);
+typedef int (f_method) (Position *, int, int);
 
 /* func.c */
 int f_circular(Position * list, int count, int neighbors);
 int f_random(Position * list, int count, int neighbors);
 int f_costbased(Position * list, int count, int neighbors);
+int gather_border(Position * res, int neighbors);
 
 /* global variables */
 GLOBAL int nrows, ncols;

Modified: grass-addons/raster/r.pi/r.pi.grow/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.grow/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.grow/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -19,7 +19,7 @@
 
 struct method
 {
-    f_method method;		/* routine to compute new value */
+    f_method *method;		/* routine to compute new value */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
     char *suffix;		/* output suffix */
@@ -45,7 +45,7 @@
     /* parameters */
     int keyval;
     int area;
-    f_method method;
+    f_method *method;
     int nbr_count;
 
     /* map_type and categories */
@@ -107,7 +107,7 @@
     parm.method->key = "method";
     parm.method->type = TYPE_STRING;
     parm.method->required = YES;
-    str = parm.method->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (n = 0; methods[n].name; n++) {
 	if (n)
 	    strcat(str, ",");
@@ -115,6 +115,7 @@
 	    *str = 0;
 	strcat(str, methods[n].name);
     }
+    parm.method->options = str;
     parm.method->description = _("Method of growth");
 
     parm.seed = G_define_option();

Modified: grass-addons/raster/r.pi/r.pi.import/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.import/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.import/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -22,18 +22,8 @@
 #define GLOBAL extern
 #endif
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
+typedef DCELL(f_statmethod) (DCELL *, int);
 
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
-void print_buffer(int *buffer, int sx, int sy);
-void print_d_buffer(DCELL * buffer, int sx, int sy);
-void print_map(double *map, int size);
-void print_array(DCELL * buffer, int size);
-void print_fragments();
-
 /* frag.c */
 void writeFragments(int *flagbuf, int nrows, int ncols, int nbr_cnt);
 

Modified: grass-addons/raster/r.pi/r.pi.index/func.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.index/func.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.index/func.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -13,9 +13,8 @@
 
     /* for all patches */
     for (i = 0; i < count; i++) {
-	// display progress
-	if (verbose)
-	    G_percent(i, count, 2);
+	/* display progress */
+	G_percent(i, count, 2);
 
 	vals[i] = (DCELL) (frags[i + 1] - frags[i]);
     }
@@ -30,12 +29,11 @@
 
     /* for all patches */
     for (i = 0; i < count; i++) {
-	// display progress
-	if (verbose)
-	    G_percent(i, count, 2);
-
 	int border = 0;
 
+	/* display progress */
+	G_percent(i, count, 2);
+
 	/* for all cells in a patch */
 	for (p = frags[i]; p < frags[i + 1]; p++) {
 	    border += 4 - p->neighbors;
@@ -53,13 +51,12 @@
 
     /* for all patches */
     for (i = 0; i < count; i++) {
-	// display progress
-	if (verbose)
-	    G_percent(i, count, 2);
-
 	int border = 0;
 	int area = (DCELL) (frags[i + 1] - frags[i]);
 
+	/* display progress */
+	G_percent(i, count, 2);
+
 	/* for all cells in a patch */
 	for (p = frags[i]; p < frags[i + 1]; p++) {
 	    border += 4 - p->neighbors;
@@ -77,15 +74,14 @@
 
     /* for all patches */
     for (i = 0; i < count; i++) {
-	// display progress
-	if (verbose)
-	    G_percent(i, count, 2);
-
 	int border = 0;
 	int maxx, maxy, minx, miny;
 	int l = 0;
 	int w = 0;
 
+	/* display progress */
+	G_percent(i, count, 2);
+
 	maxx = minx = frags[i]->x;
 	maxy = miny = frags[i]->y;
 	/* for all cells in a patch */
@@ -111,15 +107,14 @@
 
     /* for all patches */
     for (i = 0; i < count; i++) {
-	// display progress
-	if (verbose)
-	    G_percent(i, count, 2);
-
 	int area = 0;
 	int maxx, maxy, minx, miny;
 	int l = 0;
 	int w = 0;
 
+	/* display progress */
+	G_percent(i, count, 2);
+
 	maxx = minx = frags[i]->x;
 	maxy = miny = frags[i]->y;
 	/* for all cells in a patch */
@@ -145,10 +140,6 @@
 
     /* for all patches */
     for (i = 0; i < count; i++) {
-	// display progress
-	if (verbose)
-	    G_percent(i, count, 2);
-
 	/* compute variance for x,y and xy in the patch */
 	/* formula: a(x) = sum(x_i), b(x) = sum(x_i²), var(x) = (b(x) - a(x)² / n) / n */
 	/* covar(x*y) = (a(x * y) - a(x) * a(y) / n) /n */
@@ -157,10 +148,13 @@
 	DCELL vx, vy, vxy, vsum, invn;
 	int n = 0;
 
+	/* display progress */
+	G_percent(i, count, 2);
+
 	ax = ay = axy = 0;
 	bx = by = 0;
 	/* for all cells in a patch */
-	//              fprintf(stderr, "\npatch %d: ", i);
+	/*              fprintf(stderr, "\npatch %d: ", i); */
 	for (p = frags[i]; p < frags[i + 1]; p++, n++) {
 	    int x = p->x;
 	    int y = p->y;
@@ -171,16 +165,18 @@
 	    axy += xy;
 	    bx += x * x;
 	    by += y * y;
-	    //                      fprintf(stderr, "x_%d = %d, y_%d = %d; ", n, x, n, y);
+	    /*                      fprintf(stderr, "x_%d = %d, y_%d = %d; ", n, x, n, y); */
 	}
 	invn = 1.0 / (DCELL) n;
 	vx = ((DCELL) bx - (DCELL) ax * (DCELL) ax * invn) * invn;
 	vy = ((DCELL) by - (DCELL) ay * (DCELL) ay * invn) * invn;
 	vxy = ((DCELL) axy - (DCELL) ax * (DCELL) ay * invn) * invn;
-	//              fprintf(stderr, " axy = %d, ax = %d, ay = %d, n = %d", axy, ax, ay, n);
+	/*              fprintf(stderr, " axy = %d, ax = %d, ay = %d, n = %d", axy, ax, ay, n); */
 	vsum = vx + vy;
 	vals[i] = 2 * sqrt(0.25 * vsum * vsum + vxy * vxy - vx * vy) / vsum;
     }
+
+    return 1;
 }
 
 int f_area_perim_ratio(DCELL * vals, Coords ** frags, int count)
@@ -190,13 +186,12 @@
 
     /* for all patches */
     for (i = 0; i < count; i++) {
-	// display progress
-	if (verbose)
-	    G_percent(i, count, 2);
-
 	int border = 0;
 	int area = (DCELL) (frags[i + 1] - frags[i]);
 
+	/* display progress */
+	G_percent(i, count, 2);
+
 	/* for all cells in a patch */
 	for (p = frags[i]; p < frags[i + 1]; p++) {
 	    border += 4 - p->neighbors;
@@ -214,13 +209,12 @@
 
     /* for all patches */
     for (i = 0; i < count; i++) {
-	// display progress
-	if (verbose)
-	    G_percent(i, count, 2);
-
 	int border = 0;
 	int area = (DCELL) (frags[i + 1] - frags[i]);
 
+	/* display progress */
+	G_percent(i, count, 2);
+
 	/* for all cells in a patch */
 	for (p = frags[i]; p < frags[i + 1]; p++) {
 	    border += 4 - p->neighbors;
@@ -248,13 +242,13 @@
     Coords *p1, *p2;
     DCELL min = 1000000.0;
 
-    // for all cells in the first patch
+    /* for all cells in the first patch */
     for (p1 = frags[n1]; p1 < frags[n1 + 1]; p1++) {
-	// if cell at the border
+	/* if cell at the border */
 	if (p1->neighbors < 4) {
-	    // for all cells in the second patch
+	    /* for all cells in the second patch */
 	    for (p2 = frags[n2]; p2 < frags[n2 + 1]; p2++) {
-		// if cell at the border
+		/* if cell at the border */
 		if (p2->neighbors < 4) {
 		    DCELL d = dist(p1, p2);
 
@@ -274,12 +268,11 @@
 
     /* for all patches */
     for (i = 0; i < count; i++) {
-	// display progress
-	if (verbose)
-	    G_percent(i, count, 2);
-
 	DCELL min = 1000000.0;
 
+	/* display progress */
+	G_percent(i, count, 2);
+
 	for (j = 0; j < count; j++) {
 	    if (i != j) {
 		DCELL d = min_dist(frags, i, j);

Modified: grass-addons/raster/r.pi/r.pi.index/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.index/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.index/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -1,6 +1,8 @@
 #ifndef LOCAL_PROTO_H
 #define LOCAL_PROTO_H
 
+#include "../r.pi.library/r_pi.h"
+
 #ifdef MAIN
 #define GLOBAL
 #else
@@ -24,6 +26,5 @@
 GLOBAL Coords **fragments;
 GLOBAL int *flagbuf;
 GLOBAL Coords *actpos;
-GLOBAL int verbose;
 
 #endif /* LOCAL_PROTO_H */

Modified: grass-addons/raster/r.pi/r.pi.index/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.index/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.index/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -24,11 +24,11 @@
 #include <grass/stats.h>
 #include "local_proto.h"
 
-typedef int (*f_func) (DCELL *, Coords **, int);
+typedef int (f_func) (DCELL *, Coords **, int);
 
 struct menu
 {
-    f_func method;		/* routine to compute new value */
+    f_func *method;		/* routine to compute new value */
     char *name;			/* method name */
     char *text;			/* menu display - full description */
 };
@@ -63,7 +63,7 @@
     struct Categories cats;
 
     int method;
-    f_func compute_values;
+    f_func *compute_values;
 
     /* neighbors count */
     int neighb_count;
@@ -86,7 +86,7 @@
     } parm;
     struct
     {
-	struct Flag *adjacent, *quiet;
+	struct Flag *adjacent;
     } flag;
 
     DCELL *values;
@@ -117,7 +117,7 @@
     parm.method->key = "method";
     parm.method->type = TYPE_STRING;
     parm.method->required = YES;
-    p = parm.method->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; menu[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -125,6 +125,7 @@
 	    *p = 0;
 	strcat(p, menu[n].name);
     }
+    parm.method->options = p;
     parm.method->description = _("Operation to perform on fragments");
 
     parm.title = G_define_option();
@@ -139,10 +140,6 @@
     flag.adjacent->description =
 	_("Set for 8 cell-neighbors. 4 cell-neighbors are default");
 
-    flag.quiet = G_define_flag();
-    flag.quiet->key = 'q';
-    flag.quiet->description = _("Run quietly");
-
     if (G_parser(argc, argv))
 	    exit(EXIT_FAILURE);
 
@@ -211,8 +208,7 @@
     if (out_fd < 0)
 	    G_fatal_error(_("Cannot create raster map <%s>"), newname);
 
-    if (verbose = !flag.quiet->answer)
-	G_message("Loading patches...");
+    G_message("Loading patches...");
 
     /* find fragments */
     for (row = 0; row < nrows; row++) {
@@ -222,8 +218,7 @@
 		flagbuf[row * ncols + col] = 1;
 	}
 
-	if (verbose)
-	    G_percent(row, nrows, 2);
+	G_percent(row, nrows, 2);
     }
 
     for (row = 0; row < nrows; row++) {
@@ -235,20 +230,16 @@
 	    }
 	}
     }
-    if (verbose)
-	G_percent(nrows, nrows, 2);
+    G_percent(nrows, nrows, 2);
 
     /* perform actual function on the patches */
-    if (verbose = !flag.quiet->answer)
-	G_message("Performing operation...");
+    G_message("Performing operation...");
     values = (DCELL *) G_malloc(fragcount * sizeof(DCELL));
     compute_values(values, fragments, fragcount);
-    if (verbose)
-	G_percent(fragcount, fragcount, 2);
+    G_percent(fragcount, fragcount, 2);
 
     /* write the output file */
-    if (verbose = !flag.quiet->answer)
-	G_message("Writing output...");
+    G_message("Writing output...");
     for (row = 0; row < nrows; row++) {
 	G_set_d_null_value(result, ncols);
 
@@ -262,12 +253,10 @@
 
 	G_put_d_raster_row(out_fd, result);
 
-	if (verbose)
-	    G_percent(row, nrows, 2);
+	G_percent(row, nrows, 2);
     }
 
-    if (verbose)
-	G_percent(nrows, nrows, 2);
+    G_percent(nrows, nrows, 2);
 
     G_close_cell(out_fd);
     G_close_cell(in_fd);

Modified: grass-addons/raster/r.pi/r.pi.library/r_pi.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.library/r_pi.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.library/r_pi.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -46,8 +46,10 @@
 DCELL variance(DCELL * vals, int count);
 DCELL std_deviat(DCELL * vals, int count);
 DCELL median(DCELL * vals, int count);
+DCELL mode(DCELL * vals, int count);
 DCELL min(DCELL * vals, int count);
 DCELL max(DCELL * vals, int count);
+DCELL sum(DCELL * vals, int count);
 DCELL linear(DCELL value, DCELL propcost);
 DCELL exponential(DCELL value, DCELL propcost);
 

Modified: grass-addons/raster/r.pi/r.pi.library/stat_method.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.library/stat_method.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.library/stat_method.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -82,6 +82,78 @@
     return vals[k];
 }
 
+void quicksort(DCELL * vals, int begin, int end)
+{
+    int i, j;
+    DCELL pivot, tmp;
+
+    if (end <= begin)
+	return;
+
+    i = begin;
+    j = end - 1;
+    pivot = vals[end];
+
+    while (i <= j) {
+	while (i <= j && vals[i] < pivot)
+	    i++;
+	while (i <= j && vals[j] >= pivot)
+	    j--;
+
+	if (i < j) {
+	    tmp = vals[i];
+	    vals[i] = vals[j];
+	    vals[j] = tmp;
+	    i++;
+	    j--;
+	}
+    }
+
+    tmp = vals[i];
+    vals[i] = vals[end];
+    vals[end] = tmp;
+    i++;
+
+    quicksort(vals, begin, j);
+    quicksort(vals, i, end);
+}
+
+DCELL mode(DCELL * vals, int count)
+{
+    DCELL actval, maxval;
+    int actcnt, maxcnt;
+    int actpos;
+    int i;
+
+    if (count <= 0)
+	return 0;
+
+    quicksort(vals, 0, count - 1);
+
+    fprintf(stderr, "vals = (%0.2f", vals[0]);
+    for (i = 1; i < count; i++)
+	fprintf(stderr, ",%0.2f", vals[i]);
+    fprintf(stderr, ")\n\n");
+
+    maxval = 0;
+    maxcnt = 0;
+    actpos = 0;
+    while (actpos < count) {
+	actcnt = 0;
+	actval = vals[actpos];
+	while (actpos < count && actval == vals[actpos]) {
+	    actcnt++;
+	    actpos++;
+	}
+	if (actcnt > maxcnt) {
+	    maxcnt = actcnt;
+	    maxval = actval;
+	}
+    }
+
+    return maxval;
+}
+
 DCELL min(DCELL * vals, int count)
 {
     int i;
@@ -114,6 +186,20 @@
     return res;
 }
 
+DCELL sum(DCELL * vals, int count)
+{
+    if (count <= 0)
+	return 0;
+
+    int i;
+    DCELL res = 0;
+
+    for (i = 0; i < count; i++)
+	res += vals[i];
+
+    return res;
+}
+
 DCELL linear(DCELL value, DCELL propcost)
 {
     value -= propcost;

Modified: grass-addons/raster/r.pi/r.pi.lm/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.lm/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.lm/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -10,4 +10,11 @@
 #include "../r.pi.library/r_pi.h"
 #include <math.h>
 
+void clearPatch(DCELL * map, int *flagbuf, int flagval, int row, int col,
+		int nrows, int ncols, int nbr_cnt);
+
+void linear_regression(DCELL * x, DCELL * y, int count, DCELL * res_offset,
+		       DCELL * res_slope, DCELL * res_residuals,
+		       DCELL * res_correlation);
+
 #endif /* LOCAL_PROTO_H */

Modified: grass-addons/raster/r.pi/r.pi.neigh/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.neigh/Makefile	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.neigh/Makefile	2011-10-12 20:43:41 UTC (rev 48767)
@@ -2,7 +2,10 @@
 
 PGM = r.pi.neigh
 
-LIBES = $(STATSLIB) $(GISLIB)
+LIB_NAME = grass_rpi
+RPI_LIB  = -l$(LIB_NAME)
+
+LIBES = $(STATSLIB) $(GISLIB) $(RPI_LIB)
 DEPENDENCIES = $(STATSDEP) $(GISDEP)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make

Modified: grass-addons/raster/r.pi/r.pi.neigh/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.neigh/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.neigh/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -13,7 +13,7 @@
 #define GLOBAL extern
 #endif
 
-typedef DCELL(*f_func) (DCELL * values, int count);
+typedef DCELL(f_func) (DCELL * values, int count);
 
 /* frag.c */
 void writeFrag(int row, int col, int nbr_cnt);
@@ -21,14 +21,6 @@
 /* func.c */
 void compute_values(DCELL * vals, int min, int max, f_func stat_method);
 
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL mode(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
-
 /* global variables */
 GLOBAL int nrows, ncols;
 GLOBAL Coords **fragments;

Modified: grass-addons/raster/r.pi/r.pi.neigh/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.neigh/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.neigh/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -29,7 +29,7 @@
     {max, "max", "maximum of patch-values within certain range"},
     {average, "average", "average of patch-values within certain range"},
     {variance, "var", "variance of patch-values within certain range"},
-    {0, 0, 0, 0, 0}
+    {0, 0, 0}
 };
 
 int main(int argc, char *argv[])
@@ -38,7 +38,6 @@
     char *newname, *oldname, *newmapset, *oldmapset;
     char *vals_name, *vals_mapset;
     char title[1024];
-    int verbose;
 
     /* in and out file pointers */
     int in_fd;
@@ -50,7 +49,7 @@
     struct Categories cats;
 
     int method;
-    f_func stat_method;
+    f_func *stat_method;
 
     char *p;
 
@@ -75,7 +74,7 @@
     } parm;
     struct
     {
-	struct Flag *adjacent, *quiet;
+	struct Flag *adjacent;
     } flag;
 
     DCELL *values;
@@ -111,7 +110,7 @@
     parm.method->key = "method";
     parm.method->type = TYPE_STRING;
     parm.method->required = YES;
-    p = parm.method->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; menu[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -119,6 +118,7 @@
 	    *p = 0;
 	strcat(p, menu[n].name);
     }
+    parm.method->options = p;
     parm.method->description = _("Operation to perform on fragments");
 
     parm.min = G_define_option();
@@ -147,10 +147,6 @@
     parm.title->required = NO;
     parm.title->description = _("Title for resultant raster map");
 
-    flag.quiet = G_define_flag();
-    flag.quiet->key = 'q';
-    flag.quiet->description = _("Run quietly");
-
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
@@ -237,8 +233,7 @@
     if (out_fd < 0)
 	    G_fatal_error(_("Cannot create raster map <%s>"), newname);
 
-    if (verbose = !flag.quiet->answer)
-	fprintf(stderr, "Percent complete ... ");
+    fprintf(stderr, "Percent complete ... ");
 
     /* create flag buffer */
     for (row = 0; row < nrows; row++) {
@@ -256,8 +251,7 @@
     fragcount = 0;
     for (row = 0; row < nrows; row++) {
 	/* display progress */
-	if (verbose)
-	    G_percent(row, nrows, 2);
+	G_percent(row, nrows, 2);
 
 	for (col = 0; col < ncols; col++) {
 	    if (flagbuf[row * ncols + col] == 1) {
@@ -268,16 +262,14 @@
 	}
     }
 
-    if (verbose)
-	G_percent(1, 1, 2);
+    G_percent(1, 1, 2);
 
     /* open patch-values file */
     in_fd = G_open_cell_old(vals_name, vals_mapset);
     if (in_fd < 0)
         G_fatal_error(_("Unable to open raster map <%s>"), vals_name);
 
-    if (verbose = !flag.quiet->answer)
-	G_message("Read patch-values...");
+    G_message("Read patch-values...");
 
     /* read patch-values */
     valsbuf = (DCELL *) G_malloc(fragcount * sizeof(DCELL));
@@ -285,8 +277,7 @@
 	col = fragments[i]->x;
 	row = fragments[i]->y;
 
-	if (verbose)
-	    G_percent(i, fragcount, 2);
+	G_percent(i, fragcount, 2);
 
 	G_get_d_raster_row(in_fd, result, row);
 	valsbuf[i] = result[col];
@@ -311,8 +302,7 @@
 	G_put_d_raster_row(out_fd, result);
     }
 
-    if (verbose)
-	G_percent(row, nrows, 2);
+    G_percent(row, nrows, 2);
 
     G_close_cell(in_fd);
     G_close_cell(out_fd);

Deleted: grass-addons/raster/r.pi/r.pi.neigh/stat_method.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.neigh/stat_method.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.neigh/stat_method.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -1,177 +0,0 @@
-#include "local_proto.h"
-
-DCELL average(DCELL * vals, int count)
-{
-    int i;
-    DCELL res = 0;
-
-    if (count <= 0)
-	return 0;
-
-    for (i = 0; i < count; i++)
-	res += vals[i];
-
-    return res / count;
-}
-
-DCELL variance(DCELL * vals, int count)
-{
-    int i;
-    DCELL mean;
-    DCELL s = 0;
-    DCELL ss = 0;
-
-    if (count <= 0)
-	return 0;
-
-    for (i = 0; i < count; i++) {
-	DCELL val = vals[i];
-
-	s += val;
-	ss += val * val;
-    }
-
-    mean = s / (DCELL) count;
-    return ss / count - mean * mean;
-}
-
-void quicksort(DCELL * vals, int begin, int end)
-{
-    int i, j;
-    DCELL pivot, tmp;
-
-    if (end <= begin)
-	return;
-
-    i = begin;
-    j = end - 1;
-    pivot = vals[end];
-
-    while (i <= j) {
-	while (i <= j && vals[i] < pivot)
-	    i++;
-	while (i <= j && vals[j] >= pivot)
-	    j--;
-
-	if (i < j) {
-	    tmp = vals[i];
-	    vals[i] = vals[j];
-	    vals[j] = tmp;
-	    i++;
-	    j--;
-	}
-    }
-
-    tmp = vals[i];
-    vals[i] = vals[end];
-    vals[end] = tmp;
-    i++;
-
-    quicksort(vals, begin, j);
-    quicksort(vals, i, end);
-}
-
-DCELL mode(DCELL * vals, int count)
-{
-    DCELL actval, maxval;
-    int actcnt, maxcnt;
-    int actpos;
-    int i;
-
-    if (count <= 0)
-	return 0;
-
-    quicksort(vals, 0, count - 1);
-
-    fprintf(stderr, "vals = (%0.2f", vals[0]);
-    for (i = 1; i < count; i++)
-	fprintf(stderr, ",%0.2f", vals[i]);
-    fprintf(stderr, ")\n\n");
-
-    maxval = 0;
-    maxcnt = 0;
-    actpos = 0;
-    while (actpos < count) {
-	actcnt = 0;
-	actval = vals[actpos];
-	while (actpos < count && actval == vals[actpos]) {
-	    actcnt++;
-	    actpos++;
-	}
-	if (actcnt > maxcnt) {
-	    maxcnt = actcnt;
-	    maxval = actval;
-	}
-    }
-
-    return maxval;
-}
-
-DCELL median(DCELL * vals, int count)
-{
-    int k = (count - 1) / 2;
-    int l = 0;
-    int h = count - 1;
-    DCELL pivot, tmp;
-    int i, j, z;
-
-    if (count <= 0)
-	return 0;
-
-    while (l < h) {
-	pivot = vals[k];
-	i = l;
-	j = h;
-
-	do {
-	    while (vals[i] < pivot)
-		i++;
-	    while (vals[j] > pivot)
-		j--;
-	    if (i <= j) {
-		tmp = vals[i];
-		vals[i] = vals[j];
-		vals[j] = tmp;
-		i++;
-		j--;
-	    }
-	} while (i <= j);
-
-	if (j < k)
-	    l = i;
-	if (i > k)
-	    h = j;
-    }
-
-    return vals[k];
-}
-
-DCELL min(DCELL * vals, int count)
-{
-    int i;
-    DCELL minval = vals[0];
-
-    if (count <= 0)
-	return 0;
-
-    for (i = 1; i < count; i++)
-	if (vals[i] < minval)
-	    minval = vals[i];
-
-    return minval;
-}
-
-DCELL max(DCELL * vals, int count)
-{
-    int i;
-    DCELL maxval = vals[0];
-
-    if (count <= 0)
-	return 0;
-
-    for (i = 1; i < count; i++)
-	if (vals[i] > maxval)
-	    maxval = vals[i];
-
-    return maxval;
-}

Modified: grass-addons/raster/r.pi/r.pi.nlm/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.nlm/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -39,12 +39,6 @@
 int list_indexOf(int patch, int x, int y);
 void list_shuffle(int patch);
 
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
-void print_buffer(int *buffer, int sx, int sy);
-void print_map(double *map, int size);
 
 /* func.c */
 void FractalIter(double *map, double d, double dmod, int n, int size);

Modified: grass-addons/raster/r.pi/r.pi.nlm/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.nlm/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -35,7 +35,6 @@
     int rand_seed;
 
     /* other parameters */
-    int verbose;
     char *title;
 
     /* helper variables */
@@ -61,9 +60,10 @@
     } parm;
     struct
     {
-	struct Flag *quiet;
+	struct Flag *report;
     } flag;
 
+
     G_gisinit(argv[0]);
 
     module = G_define_module();
@@ -120,9 +120,10 @@
     parm.title->required = NO;
     parm.title->description = _("Title for resultant raster map");
 
-    flag.quiet = G_define_flag();
-    flag.quiet->key = 'q';
-    flag.quiet->description = _("Run quietly");
+    flag.report = G_define_flag();
+    flag.report->key = 'r';
+    flag.report->description =
+	_("Print report to stdout");
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
@@ -191,8 +192,6 @@
 	sharpness = Randomf();
     }
 
-    /* get verbose */
-    verbose = !flag.quiet->answer;
 
     /* allocate the cell buffer */
     buffer = (int *)G_malloc(sx * sy * sizeof(int));
@@ -295,24 +294,21 @@
     G_close_cell(out_fd);
 
     /* print report */
-    if (verbose) {
-	fprintf(stderr, "report:\n");
-	fprintf(stderr, "written file: <%s>\n", newname);
+    if (flag.report->answer) {
+	fprintf(stdout, "report:\n");
+	fprintf(stdout, "written file: <%s>\n", newname);
 
 	cnt = 0;
 	for (i = 0; i < sx * sy; i++)
 	    if (buffer[i] == 1)
 		cnt++;
 	landcover = (double)cnt / ((double)sx * (double)sy) * 100;
-	fprintf(stderr, "landcover: %0.2lf%%\n", landcover);
+	fprintf(stdout, "landcover: %0.2lf%%\n", landcover);
     }
 
     G_free(buffer);
     G_free(bigbuf);
     G_free(result);
 
-    if (verbose)
-	G_percent(100, 100, 2);
-
     exit(EXIT_SUCCESS);
 }

Modified: grass-addons/raster/r.pi/r.pi.nlm.circ/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.circ/Makefile	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.nlm.circ/Makefile	2011-10-12 20:43:41 UTC (rev 48767)
@@ -2,7 +2,10 @@
 
 PGM = r.pi.nlm.circ
 
-LIBES = $(STATSLIB) $(GISLIB)
+LIB_NAME = grass_rpi
+RPI_LIB  = -l$(LIB_NAME)
+
+LIBES = $(STATSLIB) $(GISLIB) $(RPI_LIB)
 DEPENDENCIES = $(STATSDEP) $(GISDEP)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make

Modified: grass-addons/raster/r.pi/r.pi.nlm.circ/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.circ/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.nlm.circ/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -24,10 +24,10 @@
 	for (x = 0; x < sx; x++) {
 	    switch (buffer[x + y * sx]) {
 	    case TYPE_NOTHING:
-		fprintf(stderr, "* ", TYPE_NOTHING);
+		fprintf(stderr, " * ");
 		break;
 	    case TYPE_NOGO:
-		fprintf(stderr, "X ", TYPE_NOGO);
+		fprintf(stderr, "X ");
 		break;
 	    default:
 		fprintf(stderr, "%d ", buffer[x + y * sx]);
@@ -106,18 +106,6 @@
     }				/* for y */
 }
 
-int Round(double d)
-{
-    return d < 0 ? d - 0.5 : d + 0.5;
-}
-
-int Random(int max)
-{
-    return max <=
-	RAND_MAX ? rand() % max : floor((double)rand() /
-					(double)(RAND_MAX + 1) * max);
-}
-
 void create_patches(int *buffer, int sx, int sy, int patch_count,
 		    int pixel_count)
 {

Modified: grass-addons/raster/r.pi/r.pi.nlm.stats/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.stats/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.nlm.stats/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -22,13 +22,9 @@
     int x, y;
 } Point;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
-typedef int (*f_func) (DCELL *, Coords **, int);
+typedef DCELL(f_statmethod) (DCELL *, int);
+typedef int (f_func) (DCELL *, Coords **, int);
 
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
 void print_buffer(int *buffer, int sx, int sy);
 void print_map(double *map, int size);
 
@@ -41,14 +37,6 @@
 		int newsize);
 void MinMax(double *map, double *min, double *max, int size);
 
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL mode(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
-
 /* method.c */
 int f_nearest_dist(DCELL * vals, Coords ** frags, int count);
 int f_area(DCELL * vals, Coords ** frags, int count);

Modified: grass-addons/raster/r.pi/r.pi.nlm.stats/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.stats/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.nlm.stats/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -167,7 +167,7 @@
     parm.method->key = "method";
     parm.method->type = TYPE_STRING;
     parm.method->required = YES;
-    actname = parm.method->options = G_malloc(1024);
+    actname = G_malloc(1024);
     for (n = 0; methodlist[n].name != NULL; n++) {
 	if (n)
 	    strcat(actname, ",");
@@ -175,6 +175,7 @@
 	    *actname = 0;
 	strcat(actname, methodlist[n].name);
     }
+    parm.method->options = actname;
     parm.method->multiple = YES;
     parm.method->description = _("Operation to perform on fragments");
 
@@ -182,7 +183,7 @@
     parm.statmethod->key = "statmethod";
     parm.statmethod->type = TYPE_STRING;
     parm.statmethod->required = YES;
-    actname = parm.statmethod->options = G_malloc(1024);
+    actname = G_malloc(1024);
     for (n = 0; statmethodlist[n].name != NULL; n++) {
 	if (n)
 	    strcat(actname, ",");
@@ -190,6 +191,7 @@
 	    *actname = 0;
 	strcat(actname, statmethodlist[n].name);
     }
+    parm.statmethod->options = actname;
     parm.statmethod->multiple = YES;
     parm.statmethod->description =
 	_("Statistical method to perform on the values");
@@ -406,7 +408,7 @@
 
 	/* calculate requested values */
 	for (m = 0; m < method_count; m++) {
-	    f_func calculate;
+	    f_func *calculate;
 
 	    method = methods[m];
 	    calculate = methodlist[method].method;
@@ -414,7 +416,7 @@
 	    calculate(res, fragments, fragcount);
 
 	    for (sm = 0; sm < statmethod_count; sm++) {
-		f_statmethod calcstat;
+		f_statmethod *calcstat;
 		DCELL val;
 
 		statmethod = statmethods[sm];
@@ -453,7 +455,7 @@
 	for (m = 0; m < method_count; m++) {
 	    int cnt;
 
-	    f_func calculate;
+	    f_func *calculate;
 
 	    method = methods[m];
 	    calculate = methodlist[method].method;
@@ -461,7 +463,7 @@
 	    calculate(res, fragments, fragcount);
 
 	    for (sm = 0; sm < statmethod_count; sm++) {
-		f_statmethod calcstat;
+		f_statmethod *calcstat;
 		DCELL val;
 
 		statmethod = statmethods[sm];

Modified: grass-addons/raster/r.pi/r.pi.nlm.stats/method.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.stats/method.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.nlm.stats/method.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -150,6 +150,7 @@
 	vsum = vx + vy;
 	vals[i] = 2 * sqrt(0.25 * vsum * vsum + vxy * vxy - vx * vy) / vsum;
     }
+    return 1;
 }
 
 int f_area_perim_ratio(DCELL * vals, Coords ** frags, int count)

Deleted: grass-addons/raster/r.pi/r.pi.nlm.stats/stat_method.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.stats/stat_method.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.nlm.stats/stat_method.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -1,177 +0,0 @@
-#include "local_proto.h"
-
-DCELL average(DCELL * vals, int count)
-{
-    int i;
-    DCELL res = 0;
-
-    if (count <= 0)
-	return 0;
-
-    for (i = 0; i < count; i++)
-	res += vals[i];
-
-    return res / count;
-}
-
-DCELL variance(DCELL * vals, int count)
-{
-    int i;
-    DCELL mean;
-    DCELL s = 0;
-    DCELL ss = 0;
-
-    if (count <= 0)
-	return 0;
-
-    for (i = 0; i < count; i++) {
-	DCELL val = vals[i];
-
-	s += val;
-	ss += val * val;
-    }
-
-    mean = s / (DCELL) count;
-    return ss / count - mean * mean;
-}
-
-void quicksort(DCELL * vals, int begin, int end)
-{
-    int i, j;
-    DCELL pivot, tmp;
-
-    if (end <= begin)
-	return;
-
-    i = begin;
-    j = end - 1;
-    pivot = vals[end];
-
-    while (i <= j) {
-	while (i <= j && vals[i] < pivot)
-	    i++;
-	while (i <= j && vals[j] >= pivot)
-	    j--;
-
-	if (i < j) {
-	    tmp = vals[i];
-	    vals[i] = vals[j];
-	    vals[j] = tmp;
-	    i++;
-	    j--;
-	}
-    }
-
-    tmp = vals[i];
-    vals[i] = vals[end];
-    vals[end] = tmp;
-    i++;
-
-    quicksort(vals, begin, j);
-    quicksort(vals, i, end);
-}
-
-DCELL mode(DCELL * vals, int count)
-{
-    DCELL actval, maxval;
-    int actcnt, maxcnt;
-    int actpos;
-    int i;
-
-    if (count <= 0)
-	return 0;
-
-    quicksort(vals, 0, count - 1);
-
-    fprintf(stderr, "vals = (%0.2f", vals[0]);
-    for (i = 1; i < count; i++)
-	fprintf(stderr, ",%0.2f", vals[i]);
-    fprintf(stderr, ")\n\n");
-
-    maxval = 0;
-    maxcnt = 0;
-    actpos = 0;
-    while (actpos < count) {
-	actcnt = 0;
-	actval = vals[actpos];
-	while (actpos < count && actval == vals[actpos]) {
-	    actcnt++;
-	    actpos++;
-	}
-	if (actcnt > maxcnt) {
-	    maxcnt = actcnt;
-	    maxval = actval;
-	}
-    }
-
-    return maxval;
-}
-
-DCELL median(DCELL * vals, int count)
-{
-    int k = (count - 1) / 2;
-    int l = 0;
-    int h = count - 1;
-    DCELL pivot, tmp;
-    int i, j, z;
-
-    if (count <= 0)
-	return 0;
-
-    while (l < h) {
-	pivot = vals[k];
-	i = l;
-	j = h;
-
-	do {
-	    while (vals[i] < pivot)
-		i++;
-	    while (vals[j] > pivot)
-		j--;
-	    if (i <= j) {
-		tmp = vals[i];
-		vals[i] = vals[j];
-		vals[j] = tmp;
-		i++;
-		j--;
-	    }
-	} while (i <= j);
-
-	if (j < k)
-	    l = i;
-	if (i > k)
-	    h = j;
-    }
-
-    return vals[k];
-}
-
-DCELL min(DCELL * vals, int count)
-{
-    int i;
-    DCELL minval = vals[0];
-
-    if (count <= 0)
-	return 0;
-
-    for (i = 1; i < count; i++)
-	if (vals[i] < minval)
-	    minval = vals[i];
-
-    return minval;
-}
-
-DCELL max(DCELL * vals, int count)
-{
-    int i;
-    DCELL maxval = vals[0];
-
-    if (count <= 0)
-	return 0;
-
-    for (i = 1; i < count; i++)
-	if (vals[i] > maxval)
-	    maxval = vals[i];
-
-    return maxval;
-}

Modified: grass-addons/raster/r.pi/r.pi.odc/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.odc/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.odc/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -28,13 +28,9 @@
     int patch;
 } PatchPoint;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
-typedef DCELL(*f_compensate) (DCELL, int);
+typedef DCELL(f_statmethod) (DCELL *, int);
+typedef DCELL(f_compensate) (DCELL, int);
 
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
 void print_buffer(int *buffer, int sx, int sy);
 void print_d_buffer(DCELL * buffer, int sx, int sy);
 void print_map(double *map, int size);
@@ -46,17 +42,11 @@
 
 /* voronoi.c */
 void voronoi(DCELL * values, int *map, int sx, int sy, int diag_move);
-void calc_neighbors(DCELL * res, DCELL * focals, f_statmethod * methods,
+void calc_neighbors(DCELL * res, DCELL * focals, f_statmethod **methods,
 		    int stat_count, f_compensate compensate,
 		    int neighbor_level);
 void getNeighborCount(DCELL * res);
 
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-
 /* compensation.c */
 DCELL none(DCELL value, int frag);
 DCELL odd_area(DCELL value, int frag);

Modified: grass-addons/raster/r.pi/r.pi.odc/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.odc/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.odc/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -54,17 +54,13 @@
 {
     /* input */
     char *oldname, *oldmapset;
-
     /* output */
     char *newname, *newmapset;
-
     /* mask */
     char *maskname, *maskmapset;
-
     /* in and out file pointers */
     int in_fd, out_fd;
     FILE *out_fp;		/* ASCII - output */
-
     /* parameters */
     int keyval;
     int stats[GNAME_MAX];
@@ -73,13 +69,10 @@
     int diag_grow;
     int compmethod;
     int neighbor_level;
-
     /* maps */
     int *map;
-
     /* other parameters */
     char *title;
-
     /* helper variables */
     int row, col;
     CELL *result;
@@ -93,9 +86,9 @@
     char output_name[GNAME_MAX];
     char *str;
     int method;
-    f_statmethod *method_array;
+    f_statmethod **method_array;
     DCELL area;
-    f_compensate compensate;
+    f_compensate *compensate;
 
     RASTER_MAP_TYPE map_type;
     struct Cell_head ch, window;
@@ -140,7 +133,7 @@
     parm.ratio->key = "ratio";
     parm.ratio->type = TYPE_STRING;
     parm.ratio->required = YES;
-    str = parm.ratio->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (n = 0; compmethods[n].name; n++) {
 	if (n)
 	    strcat(str, ",");
@@ -148,6 +141,7 @@
 	    *str = 0;
 	strcat(str, compmethods[n].name);
     }
+    parm.ratio->options = str;
     parm.ratio->description =
 	_("Compensation method to perform on the values");
 
@@ -156,7 +150,7 @@
     parm.stats->type = TYPE_STRING;
     parm.stats->required = YES;
     parm.stats->multiple = YES;
-    str = parm.stats->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (n = 0; statmethods[n].name; n++) {
 	if (n)
 	    strcat(str, ",");
@@ -164,6 +158,7 @@
 	    *str = 0;
 	strcat(str, statmethods[n].name);
     }
+    parm.stats->options = str;
     parm.stats->description =
 	_("Statistical method to perform on the values");
 
@@ -464,7 +459,7 @@
     neighb_values =
 	(DCELL *) G_malloc(3 * fragcount * stat_count * sizeof(DCELL));
     method_array =
-	(f_statmethod *) G_malloc(stat_count * sizeof(f_statmethod));
+	(f_statmethod **) G_malloc(stat_count * sizeof(f_statmethod *));
     for (i = 0; i < stat_count; i++) {
 	method_array[i] = statmethods[stats[i]].method;
     }

Modified: grass-addons/raster/r.pi/r.pi.odc/voronoi.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.odc/voronoi.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.odc/voronoi.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -347,7 +347,7 @@
 
    res = ( areas( stat1(patch1, patch2, ...), stat2(patch1, patch2, ...), ...  ), odds(), ... )
  */
-void calc_neighbors(DCELL * res, DCELL * focals, f_statmethod * methods,
+void calc_neighbors(DCELL * res, DCELL * focals, f_statmethod **methods,
 		    int stat_count, f_compensate compensate,
 		    int neighbor_level)
 {

Modified: grass-addons/raster/r.pi/r.pi.prob.mw/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.prob.mw/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.prob.mw/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -17,12 +17,8 @@
 #define GLOBAL extern
 #endif
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
+typedef DCELL(f_statmethod) (DCELL *, int);
 
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
 void print_buffer(int *buffer, int sx, int sy);
 void print_d_buffer(DCELL * buffer, int sx, int sy);
 void print_map(double *map, int size);
@@ -35,14 +31,6 @@
 /* frag.c */
 void writeFragments(int *flagbuf, int nrows, int ncols, double distance);
 
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
-
 /* global parameters */
 GLOBAL int sx, sy;
 

Modified: grass-addons/raster/r.pi/r.pi.prob.mw/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.prob.mw/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.prob.mw/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -40,16 +40,12 @@
 {
     /* input */
     char *oldname, *oldmapset;
-
     /* output */
     char *newname, *newmapset;
-
     /* mask */
     char *maskname, *maskmapset;
-
     /* in and out file pointers */
     int in_fd, out_fd;
-
     /* parameters */
     int stats[GNAME_MAX];
     f_statmethod *methods;
@@ -213,7 +209,7 @@
 
     /* allocate map buffers */
     map = (int *)G_malloc(sx * sy * sizeof(int));
-    mask = (DCELL *) G_malloc(sx * sy * sizeof(int));
+    mask = (int *) G_malloc(sx * sy * sizeof(int));
     cells = (Coords *) G_malloc(sx * sy * sizeof(Coords));
 
     result = G_allocate_c_raster_buf();

Modified: grass-addons/raster/r.pi/r.pi.prox/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.prox/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.prox/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -1,3 +1,5 @@
+#include "../r.pi.library/r_pi.h"
+
 #ifdef MAIN
 #define GLOBAL
 #else

Modified: grass-addons/raster/r.pi/r.pi.prox/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.prox/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.prox/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -26,7 +26,7 @@
 
 int recur_test(int, int, int);
 
-typedef int (*f_func) (DCELL *, Coords **, int, int, int);
+typedef int (f_func) (DCELL *, Coords **, int, int, int);
 
 struct menu
 {
@@ -42,7 +42,7 @@
      "modified proximity index for every patch within certain range"},
     {f_neighborhood, "neighborhood index",
      "number of patches within certain range"},
-    {0, 0, 0, 0, 0}
+    {0, 0, 0}
 };
 
 int main(int argc, char *argv[])
@@ -50,7 +50,6 @@
     /* input */
     char *newname, *oldname, *newmapset, *oldmapset;
     char title[1024];
-    int verbose;
 
     /* in and out file pointers */
     int in_fd;
@@ -62,7 +61,7 @@
     struct Categories cats;
 
     int method;
-    f_func compute_values;
+    f_func *compute_values;
 
     char *p;
 
@@ -87,7 +86,7 @@
     } parm;
     struct
     {
-	struct Flag *adjacent, *quiet;
+	struct Flag *adjacent;
     } flag;
 
     DCELL *values;
@@ -120,7 +119,7 @@
     parm.method->key = "method";
     parm.method->type = TYPE_STRING;
     parm.method->required = YES;
-    p = parm.method->options = G_malloc(1024);
+    p = G_malloc(1024);
     for (n = 0; menu[n].name; n++) {
 	if (n)
 	    strcat(p, ",");
@@ -128,6 +127,7 @@
 	    *p = 0;
 	strcat(p, menu[n].name);
     }
+    parm.method->options = p;
     parm.method->description = _("Operation to perform on fragments");
 
     parm.min = G_define_option();
@@ -156,10 +156,6 @@
     parm.title->required = NO;
     parm.title->description = _("Title for resultant raster map");
 
-    flag.quiet = G_define_flag();
-    flag.quiet->key = 'q';
-    flag.quiet->description = _("Run quietly");
-
     if (G_parser(argc, argv))
 	    exit(EXIT_FAILURE);
 
@@ -239,8 +235,7 @@
     if (out_fd < 0)
 	    G_fatal_error(_("Cannot create raster map <%s>"), newname);
 
-    if (verbose = !flag.quiet->answer)
-	fprintf(stderr, "Percent complete ... ");
+    G_message(_("Percent complete ... "));
 
     /* find fragments */
     for (row = 0; row < nrows; row++) {
@@ -253,8 +248,7 @@
 
     for (row = 0; row < nrows; row++) {
 	/* display progress */
-	if (verbose)
-	    G_percent(row, nrows, 2);
+	G_percent(row, nrows, 2);
 
 	for (col = 0; col < ncols; col++) {
 	    if (flagbuf[row * ncols + col] == 1) {
@@ -284,8 +278,7 @@
 	G_put_d_raster_row(out_fd, result);
     }
 
-    if (verbose)
-	G_percent(row, nrows, 2);
+    G_percent(row, nrows, 2);
 
     G_close_cell(out_fd);
     G_close_cell(in_fd);

Modified: grass-addons/raster/r.pi/r.pi.rectangle/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.rectangle/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.rectangle/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -111,7 +111,7 @@
     parm.alignment->key = "alignment";
     parm.alignment->type = TYPE_STRING;
     parm.alignment->required = YES;
-    str = parm.alignment->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (n = 0; alignments[n].name; n++) {
 	if (n)
 	    strcat(str, ",");
@@ -119,6 +119,7 @@
 	    *str = 0;
 	strcat(str, alignments[n].name);
     }
+    parm.alignment->options = str;
     parm.alignment->description =
 	_("Alignment of the rectangle relative to the input pixel. options: center, top-left, top-right, bottom");
 

Modified: grass-addons/raster/r.pi/r.pi.searchtime/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.searchtime/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -37,12 +37,8 @@
     int x, y;
 } Displacement;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
+typedef DCELL(f_statmethod) (DCELL *, int);
 
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
 void print_buffer(int *buffer, int sx, int sy);
 void print_d_buffer(DCELL * buffer, int sx, int sy);
 void print_map(double *map, int size);
@@ -54,16 +50,8 @@
 
 /* search.c */
 void perform_search(DCELL * values, int *map, DCELL * costmap,
-		    f_statmethod * stats, int stat_count);
+		    f_statmethod **stats, int stat_count);
 
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
-
 /* indices.c */
 DCELL shannon_index(int patch);
 DCELL simpson_index(int patch);

Modified: grass-addons/raster/r.pi/r.pi.searchtime/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.searchtime/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -49,7 +49,7 @@
 
     /* parameters */
     int stats[GNAME_MAX];
-    f_statmethod *methods;
+    f_statmethod **methods;
     int stat_count;
     DCELL threshold;
 
@@ -205,7 +205,7 @@
     parm.stats->type = TYPE_STRING;
     parm.stats->required = YES;
     parm.stats->multiple = YES;
-    str = parm.stats->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (n = 0; statmethods[n].name; n++) {
 	if (n)
 	    strcat(str, ",");
@@ -213,6 +213,7 @@
 	    *str = 0;
 	strcat(str, statmethods[n].name);
     }
+    parm.stats->options = str;
     parm.stats->description =
 	_("Statistical method to perform on the values");
     parm.stats->guisection = "Required";
@@ -490,7 +491,7 @@
     patch_imi = (int *)G_malloc(fragcount * sizeof(int));
 
     /* fill methods array */
-    methods = (f_statmethod *) G_malloc(stat_count * sizeof(f_statmethod));
+    methods = (f_statmethod **) G_malloc(stat_count * sizeof(f_statmethod *));
     for (method = 0; method < stat_count; method++) {
 	methods[method] = statmethods[stats[method]].method;
     }
@@ -508,7 +509,7 @@
 	}
 	fprintf(stderr, "\n");
     }
-    G_message("");
+    G_message(" ");
 
     G_message("Writing output...");
     for (method = 0; method < stat_count; method++) {

Modified: grass-addons/raster/r.pi/r.pi.searchtime/search.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime/search.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.searchtime/search.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -485,11 +485,11 @@
    performs a search run for each fragment
  */
 void perform_search(DCELL * values, int *map, DCELL * costmap,
-		    f_statmethod * stats, int stat_count)
+		    f_statmethod **stats, int stat_count)
 {
     int fragment, i;
     int steps;
-    f_statmethod func;
+    f_statmethod *func;
 
     /* allocate paths array */
     DCELL *indi_paths = (DCELL *) G_malloc(n * sizeof(DCELL));

Modified: grass-addons/raster/r.pi/r.pi.searchtime.iter/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime.iter/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.searchtime.iter/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -37,7 +37,7 @@
     int x, y;
 } Displacement;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
+typedef DCELL(f_statmethod) (DCELL *, int);
 
 /* helpers.c */
 int Round(double d);
@@ -54,7 +54,7 @@
 
 /* search.c */
 void perform_search(DCELL * values, int *map, DCELL * costmap,
-		    f_statmethod * stats, int stat_count);
+		    f_statmethod **stats, int stat_count);
 
 /* stat_method.c */
 DCELL average(DCELL * vals, int count);

Modified: grass-addons/raster/r.pi/r.pi.searchtime.iter/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime.iter/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.searchtime.iter/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -49,7 +49,7 @@
 
     /* parameters */
     int stats[GNAME_MAX];
-    f_statmethod *methods;
+    f_statmethod **methods;
     int stat_count;
 
     int dif_stats[GNAME_MAX];
@@ -172,7 +172,7 @@
     parm.stats->type = TYPE_STRING;
     parm.stats->required = YES;
     parm.stats->multiple = YES;
-    str = parm.stats->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (n = 0; statmethods[n].name; n++) {
 	if (n)
 	    strcat(str, ",");
@@ -180,6 +180,7 @@
 	    *str = 0;
 	strcat(str, statmethods[n].name);
     }
+    parm.stats->options = str;
     parm.stats->description =
 	_("Statistical method to perform on the pathlengths of the individuals");
     parm.stats->guisection = _("Required");
@@ -189,7 +190,7 @@
     parm.dif_stats->type = TYPE_STRING;
     parm.dif_stats->required = YES;
     parm.dif_stats->multiple = YES;
-    str = parm.dif_stats->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (n = 0; statmethods[n].name; n++) {
 	if (n)
 	    strcat(str, ",");
@@ -197,6 +198,7 @@
 	    *str = 0;
 	strcat(str, statmethods[n].name);
     }
+    parm.dif_stats->options = str;
     parm.dif_stats->description =
 	_("Statistical method to perform on the difference values");
     parm.dif_stats->guisection = _("Required");
@@ -479,7 +481,7 @@
     memset(deleted_arr, 0, fragcount * sizeof(char));
 
     /* fill methods array */
-    methods = (f_statmethod *) G_malloc(stat_count * sizeof(f_statmethod));
+    methods = (f_statmethod **) G_malloc(stat_count * sizeof(f_statmethod *));
     for (method = 0; method < stat_count; method++) {
 	methods[method] = statmethods[stats[method]].method;
     }
@@ -536,7 +538,7 @@
 		   (fragcount - frag - 1) * sizeof(DCELL));
 
 	    for (difmethod = 0; difmethod < dif_stat_count; difmethod++) {
-		f_statmethod func = statmethods[dif_stats[difmethod]].method;
+		f_statmethod *func = statmethods[dif_stats[difmethod]].method;
 		DCELL val = func(dummy, fragcount - 1);
 
 		output_values[(difmethod * stat_count + method) * fragcount +

Modified: grass-addons/raster/r.pi/r.pi.searchtime.iter/search.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime.iter/search.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.searchtime.iter/search.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -481,11 +481,11 @@
    output in "values": ( stat1(patch1, patch2, patch3, ...), stat2(patch1, patch2, ...) )
  */
 void perform_search(DCELL * values, int *map, DCELL * costmap,
-		    f_statmethod * stats, int stat_count)
+		    f_statmethod **stats, int stat_count)
 {
     int fragment, i;
     int steps;
-    f_statmethod func;
+    f_statmethod *func;
 
     /* allocate paths array */
     DCELL *indi_paths = (DCELL *) G_malloc(n * sizeof(DCELL));

Modified: grass-addons/raster/r.pi/r.pi.searchtime.mw/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime.mw/local_proto.h	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.searchtime.mw/local_proto.h	2011-10-12 20:43:41 UTC (rev 48767)
@@ -37,22 +37,14 @@
     int x, y;
 } Displacement;
 
-typedef DCELL(*f_statmethod) (DCELL *, int);
+typedef DCELL(f_statmethod) (DCELL *, int);
 
 /* frag.c */
 void writeFragments(int *flagbuf, int nrows, int ncols, int nbr_cnt);
 
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
-
 /* search.c */
 void perform_search(DCELL * values, int *map, DCELL * costmap, int size,
-		    f_statmethod * stats, int stat_count);
+		    f_statmethod **stats, int stat_count);
 
 /* global parameters */
 GLOBAL int sx, sy;

Modified: grass-addons/raster/r.pi/r.pi.searchtime.mw/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime.mw/main.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.searchtime.mw/main.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -54,7 +54,7 @@
     /* parameters */
     int size;
     int stats[GNAME_MAX];
-    f_statmethod *methods;
+    f_statmethod **methods;
     int stat_count;
     int keyval;
 
@@ -173,7 +173,7 @@
     parm.stats->type = TYPE_STRING;
     parm.stats->required = YES;
     parm.stats->multiple = YES;
-    str = parm.stats->options = G_malloc(1024);
+    str = G_malloc(1024);
     for (n = 0; statmethods[n].name; n++) {
 	if (n)
 	    strcat(str, ",");
@@ -181,6 +181,7 @@
 	    *str = 0;
 	strcat(str, statmethods[n].name);
     }
+    parm.stats->options = str;
     parm.stats->description =
 	_("Statistical method to perform on the pathlengths of the individuals");
     parm.stats->guisection = _("Required");
@@ -438,7 +439,7 @@
     patch_imi = (int *)G_malloc(fragcount * sizeof(int));
 
     /* fill methods array */
-    methods = (f_statmethod *) G_malloc(stat_count * sizeof(f_statmethod));
+    methods = (f_statmethod **) G_malloc(stat_count * sizeof(f_statmethod *));
     for (method = 0; method < stat_count; method++) {
 	methods[method] = statmethods[stats[method]].method;
     }

Modified: grass-addons/raster/r.pi/r.pi.searchtime.mw/search.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime.mw/search.c	2011-10-12 16:46:01 UTC (rev 48766)
+++ grass-addons/raster/r.pi/r.pi.searchtime.mw/search.c	2011-10-12 20:43:41 UTC (rev 48767)
@@ -299,8 +299,8 @@
 
     /* if new position is a patch, then set finished = true */
     /*act_cell = map[(int)newy * sx + (int)newx];
-       if (act_cell > TYPE_NOTHING) {
-       /* count patch immigrants for this patch */
+       if (act_cell > TYPE_NOTHING) { */
+	/* count patch immigrants for this patch */
     /*patch_imi[act_cell]++;
        individual->finished = 1;
        } */
@@ -351,11 +351,11 @@
    performs a search run for each fragment
  */
 void perform_search(DCELL * values, int *map, DCELL * costmap, int size,
-		    f_statmethod * stats, int stat_count)
+		    f_statmethod **stats, int stat_count)
 {
     int fragment, i;
     int steps;
-    f_statmethod func;
+    f_statmethod *func;
     int x, y;
 
     /* allocate paths array */



More information about the grass-commit mailing list