[GRASS-SVN] r30341 - grass/trunk/general/manage/cmd

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Feb 25 01:20:39 EST 2008


Author: glynn
Date: 2008-02-25 01:20:38 -0500 (Mon, 25 Feb 2008)
New Revision: 30341

Modified:
   grass/trunk/general/manage/cmd/remove.c
Log:
Only perform reclass check for rasters.



Modified: grass/trunk/general/manage/cmd/remove.c
===================================================================
--- grass/trunk/general/manage/cmd/remove.c	2008-02-24 23:31:57 UTC (rev 30340)
+++ grass/trunk/general/manage/cmd/remove.c	2008-02-25 06:20:38 UTC (rev 30341)
@@ -24,6 +24,74 @@
 #include "list.h"
 #include "local_proto.h"
 
+static int
+check_reclass(const char *name, const char *mapset, int force)
+{
+    char rname[GNAME_MAX], rmapset[GMAPSET_MAX];
+    char **rmaps;
+    int nrmaps;
+
+    if (G_is_reclassed_to(name, mapset, &nrmaps, &rmaps) > 0)
+    {
+	for ( ; *rmaps; rmaps++)
+	{
+	    /* force remove */
+	    if (force)
+		G_warning(
+		    _("[%s@%s] is a base map for [%s]. Remove forced."),
+		    name, mapset,  *rmaps);
+	    else
+		G_warning(
+		    _("[%s@%s] is a base map. Remove reclassed map first: %s"),
+		    name, mapset,  *rmaps);
+	}
+
+	if (!force)
+	    return 1;
+    }
+
+    if (G_is_reclass(name, mapset, rname, rmapset) > 0 &&
+	G_is_reclassed_to(rname, rmapset, &nrmaps, &rmaps) > 0)
+    {
+	char path[GPATH_MAX];
+	char *p = strchr(rname, '@');
+	char *qname = G_fully_qualified_name(name, mapset);
+
+	if (p)
+	    *p = '\0';
+
+	G__file_name_misc(path, "cell_misc", "reclassed_to", rname, rmapset);
+
+	if(nrmaps == 1 && !G_strcasecmp(rmaps[0], qname))
+	{
+			
+	    if (remove(path) < 0)
+		G_warning(
+		    _("Removing information about reclassed map from [%s@%s] failed"),
+		    rname, rmapset);
+	}
+	else
+	{
+	    FILE *fp = fopen(path, "w");
+
+	    if (fp)
+	    {
+		for ( ; *rmaps; rmaps++)
+		    if (G_strcasecmp(*rmaps, qname))
+			fprintf(fp, "%s\n", *rmaps);
+		fclose(fp);
+	    }
+	    else
+		G_warning(
+		    _("Removing information about reclassed map from [%s@%s] failed"),
+		    rname, rmapset);
+
+	}
+    }
+
+    return 0;
+}
+
 int 
 main (int argc, char *argv[])
 {
@@ -32,10 +100,7 @@
     struct Option **parm, *p;
     struct Flag *force_flag;
     char *name, *mapset;
-    char rname[256], rmapset[256];
-    int nrmaps;
-    char **rmaps, *location_path;
-    FILE *fp;
+    char *location_path;
     int result = EXIT_SUCCESS;
     int force = 0;
 
@@ -80,62 +145,10 @@
 	if (parm[n]->answers)
 	    for (i = 0; (name = parm[n]->answers[i]); i++)
 	    {
-		if(G_is_reclassed_to(name, mapset, &nrmaps, &rmaps) > 0)
-		{
-		    for(; *rmaps; rmaps++) {
-                        /* force remove */
-                        if ( force ) {
-                            G_warning(
-                            _("[%s@%s] is a base map for [%s]. Remove forced."),
-                                                name, mapset,  *rmaps);
-                        }
-                        else {
-                            G_warning(
-                            _("[%s@%s] is a base map. Remove reclassed map first: %s"),
-                                                name, mapset,  *rmaps);
-                        }
-                    }
-                    if ( !force ) 
-                        continue;
-		}
-		if(G_is_reclass(name, mapset, rname, rmapset) > 0 &&
-		   G_is_reclassed_to(rname, rmapset, &nrmaps, &rmaps) > 0)
-		{
-		    char path[GPATH_MAX];
-		    char *p = strchr(rname, '@');
-		    char *qname = G_fully_qualified_name(name, mapset);
-		    if (p)
-			*p = '\0';
-		    G__file_name_misc(path, "cell_misc", "reclassed_to", rname, rmapset);
+		if (G_strcasecmp(list[n].alias, "rast") == 0 &&
+		    check_reclass(name, mapset, force))
+		    continue;
 
-		    if(nrmaps == 1 && !G_strcasecmp(rmaps[0], qname))
-		    {
-			
-		        if (  remove(path) < 0 ) {
-                            G_warning(
-                            _("Removing information about reclassed map from [%s@%s] failed"),
-                                                rname, rmapset);
-                        }
-
-		    }
-		    else
-		    {
-		        if ( (fp = fopen(path, "w")) ) {
-                            for(; *rmaps; rmaps++)
-                            {
-                                if(G_strcasecmp(*rmaps, qname))
-                                    fprintf(fp, "%s\n", *rmaps);
-                            }
-                            fclose(fp);
-                        }
-                        else {
-                            G_warning(
-                            _("Removing information about reclassed map from [%s@%s] failed"),
-                                                rname, rmapset);
-
-                        }
-		    }
-		}
 		if ( do_remove (n, name) == 1 )
                 {
 		    result = EXIT_FAILURE;



More information about the grass-commit mailing list