[GRASS-SVN] r44620 - grass/trunk/general/g.mapsets

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 16 11:21:07 EST 2010


Author: martinl
Date: 2010-12-16 08:21:06 -0800 (Thu, 16 Dec 2010)
New Revision: 44620

Modified:
   grass/trunk/general/g.mapsets/get_maps.c
   grass/trunk/general/g.mapsets/main.c
Log:
#983 (sort g.mapsets -l output)


Modified: grass/trunk/general/g.mapsets/get_maps.c
===================================================================
--- grass/trunk/general/g.mapsets/get_maps.c	2010-12-16 15:53:47 UTC (rev 44619)
+++ grass/trunk/general/g.mapsets/get_maps.c	2010-12-16 16:21:06 UTC (rev 44620)
@@ -1,7 +1,11 @@
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <grass/gis.h>
 #include "local_proto.h"
 
+static int cmp(const void *, const void *);
+
 int get_available_mapsets(void)
 {
     char **ms;
@@ -14,5 +18,13 @@
     for(i = 0; i < nmapsets; i++)
 	mapset_name[i] = G_store(ms[i]);
 
+    /* sort mapsets */
+    qsort(mapset_name, nmapsets, sizeof(char *), cmp);
+
     return 0;
 }
+
+static int cmp(const void *a, const void *b) 
+{
+    return (strcmp(*(char **)a, *(char **)b));
+}

Modified: grass/trunk/general/g.mapsets/main.c
===================================================================
--- grass/trunk/general/g.mapsets/main.c	2010-12-16 15:53:47 UTC (rev 44619)
+++ grass/trunk/general/g.mapsets/main.c	2010-12-16 16:21:06 UTC (rev 44620)
@@ -94,12 +94,12 @@
     
     opt.list = G_define_flag();
     opt.list->key = 'l';
-    opt.list->description = _("List all available mapsets");
+    opt.list->description = _("List all available mapsets in alphabetical order");
     opt.list->guisection = _("Print");
 
     opt.print = G_define_flag();
     opt.print->key = 'p';
-    opt.print->description = _("Print current mapset search path");
+    opt.print->description = _("Print mapsets in current search path");
     opt.print->guisection = _("Print");
 
     opt.dialog = G_define_flag();



More information about the grass-commit mailing list