[GRASS-SVN] r61995 - in grass/branches/releasebranch_7_0: . lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 16 07:51:17 PDT 2014
Author: neteler
Date: 2014-09-16 07:51:17 -0700 (Tue, 16 Sep 2014)
New Revision: 61995
Modified:
grass/branches/releasebranch_7_0/
grass/branches/releasebranch_7_0/lib/gis/find_file.c
Log:
libgis: When searching the mapset search path, find the first map, not the first map with the requested element (trunk, r61840 + r61853)
Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
- /grass/trunk:60289,60696,61269,61380,61420,61422,61480,61500,61764,61808,61829,61831,61851-61852,61854,61858,61888,61891,61905,61907,61913-61914,61916,61918,61921,61938,61967-61968,61975,61980
+ /grass/trunk:60289,60696,61269,61380,61420,61422,61480,61500,61764,61808,61829,61831,61840,61851-61854,61858,61888,61891,61905,61907,61913-61914,61916,61918,61921,61938,61967-61968,61975,61980
Modified: grass/branches/releasebranch_7_0/lib/gis/find_file.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/gis/find_file.c 2014-09-16 12:05:44 UTC (rev 61994)
+++ grass/branches/releasebranch_7_0/lib/gis/find_file.c 2014-09-16 14:51:17 UTC (rev 61995)
@@ -18,6 +18,40 @@
#include <grass/gis.h>
#include <grass/glocale.h>
+static const char *find_element(int misc, const char *dir, const char *element)
+{
+ static const char *cell_elements[] = {
+ "cellhd",
+ "cell",
+ "cats",
+ "colr",
+ "hist",
+ "cell_misc",
+ "fcell",
+ "g3dcell",
+ NULL
+ };
+ static const char *dig_elements[] = {
+ "dig",
+ "dig_att",
+ "dig_plus",
+ "dig_cats",
+ "dig_misc",
+ "reg",
+ NULL
+ };
+ const char *search = misc ? dir : element;
+ int i;
+
+ for (i = 1; cell_elements[i]; i++)
+ if (strcmp(search, cell_elements[i]) == 0)
+ return cell_elements[0];
+ for (i = 1; dig_elements[i]; i++)
+ if (strcmp(search, dig_elements[i]) == 0)
+ return dig_elements[0];
+ return element;
+}
+
static const char *find_file(int misc, const char *dir,
const char *element, const char *name,
const char *mapset)
@@ -66,28 +100,35 @@
if (pmapset == NULL || *pmapset == 0) {
int cnt = 0;
const char *pselmapset = NULL;
+ const char *pelement = find_element(misc, dir, element);
for (n = 0; (pmapset = G_get_mapset_name(n)); n++) {
- if (misc)
- G_file_name_misc(path, dir, element, pname, pmapset);
+ if (misc && element == pelement)
+ G_file_name_misc(path, dir, pelement, pname, pmapset);
else
- G_file_name(path, element, pname, pmapset);
+ G_file_name(path, pelement, pname, pmapset);
if (access(path, 0) == 0) {
if (!pselmapset)
pselmapset = pmapset;
- else
+ else if (element == pelement)
G_warning(_("'%s/%s' was found in more mapsets (also found in <%s>)"),
element, pname, pmapset);
cnt++;
}
}
if (cnt > 0) {
- /* If the same name exists in more mapsets and print a warning */
- if (cnt > 1)
- G_warning(_("Using <%s@%s>"),
- pname, pselmapset);
+ if (misc)
+ G_file_name_misc(path, dir, element, pname, pselmapset);
+ else
+ G_file_name(path, element, name, pselmapset);
+ if (access(path, 0) == 0) {
+ /* If the same name exists in more mapsets and print a warning */
+ if (cnt > 1 && element == pelement)
+ G_warning(_("Using <%s@%s>"),
+ pname, pselmapset);
- return G_store(pselmapset);
+ return G_store(pselmapset);
+ }
}
}
/*
More information about the grass-commit
mailing list