[GRASS-SVN] r50562 - in grass/trunk: general/g.list lib/manage
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 30 11:09:15 EST 2012
Author: martinl
Date: 2012-01-30 08:09:15 -0800 (Mon, 30 Jan 2012)
New Revision: 50562
Modified:
grass/trunk/general/g.list/main.c
grass/trunk/lib/manage/do_list.c
Log:
bugfix #1557 (g.list segmentation fault)
Modified: grass/trunk/general/g.list/main.c
===================================================================
--- grass/trunk/general/g.list/main.c 2012-01-30 14:12:28 UTC (rev 50561)
+++ grass/trunk/general/g.list/main.c 2012-01-30 16:09:15 UTC (rev 50562)
@@ -65,7 +65,7 @@
if (!mapset)
mapset = "";
- if (G_strcasecmp(mapset, ".") == 0)
+ if (strcmp(mapset, ".") == 0)
mapset = G_mapset();
i = 0;
@@ -74,11 +74,13 @@
if (full->answer) {
char lister[GPATH_MAX];
-
- sprintf(lister, "%s/etc/lister/%s", G_gisbase(),
- M_get_list(n)->element[0]);
- G_debug(3, "lister CMD: %s", lister);
- if (access(lister, 1) == 0) /* execute permission? */
+
+ if (n > -1) {
+ sprintf(lister, "%s/etc/lister/%s", G_gisbase(),
+ M_get_list(n)->element[0]);
+ G_debug(3, "lister CMD: %s", lister);
+ }
+ if (n > -1 && access(lister, 1) == 0) /* execute permission? */
G_spawn(lister, lister, mapset, NULL);
else
M_do_list(n, mapset);
Modified: grass/trunk/lib/manage/do_list.c
===================================================================
--- grass/trunk/lib/manage/do_list.c 2012-01-30 14:12:28 UTC (rev 50561)
+++ grass/trunk/lib/manage/do_list.c 2012-01-30 16:09:15 UTC (rev 50562)
@@ -3,7 +3,7 @@
\brief Manage Library - List elements
- (C) 2001-2011 by the GRASS Development Team
+ (C) 2001-2012 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@@ -12,16 +12,32 @@
*/
#include <grass/gis.h>
+#include <grass/glocale.h>
#include "manage_local_proto.h"
/*!
\brief List elements
- \param n element id
- \param mapset name of mapset
+ \param n element index in the array (negative value for all elements)
+ \param mapset name of mapset ("" for search path)
*/
void M_do_list(int n, const char *mapset)
{
- G_list_element(list[n].element[0], list[n].desc[0], mapset, (int (*)())0);
+ int i;
+
+ if (n >= nlist) {
+ G_fatal_error(_("%s: invalid index %d"), "M_do_list()", n);
+ }
+
+ if (n < 0) {
+ for (i = 0; i < nlist; i++) {
+ G_list_element(list[i].element[0], list[i].desc[0],
+ mapset, (int (*)())0);
+ }
+ }
+ else {
+ G_list_element(list[n].element[0], list[n].desc[0],
+ mapset, (int (*)())0);
+ }
}
More information about the grass-commit
mailing list