[GRASS-SVN] r43996 - grass/branches/develbranch_6/general/g.mapsets

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Oct 24 02:42:18 EDT 2010


Author: martinl
Date: 2010-10-23 23:42:18 -0700 (Sat, 23 Oct 2010)
New Revision: 43996

Modified:
   grass/branches/develbranch_6/general/g.mapsets/dsply_maps.c
   grass/branches/develbranch_6/general/g.mapsets/dsply_path.c
   grass/branches/develbranch_6/general/g.mapsets/main.c
Log:
g.mapsets: backport fs=space,comma,tab,newline from trunk


Modified: grass/branches/develbranch_6/general/g.mapsets/dsply_maps.c
===================================================================
--- grass/branches/develbranch_6/general/g.mapsets/dsply_maps.c	2010-10-24 06:30:47 UTC (rev 43995)
+++ grass/branches/develbranch_6/general/g.mapsets/dsply_maps.c	2010-10-24 06:42:18 UTC (rev 43996)
@@ -41,6 +41,20 @@
     int nleft, len, n;
     char *name;
 
+    if (strcmp(fs, "space") == 0)
+	fs = " ";
+    else if (strcmp(fs, "comma") == 0)
+	fs = ",";
+    else if (strcmp(fs, "tab") == 0)
+	fs = "\t";
+    else if (strcmp(fs, "newline") == 0) {
+	for (n = 0; n < nmapsets; n++) {
+	    fprintf(stdout, "%s\n", mapset_name[n]);
+	}
+	
+	return 0;
+    }
+    
     nleft = 78;
     for (n = 0; n < nmapsets; n++) {
 	len = strlen(name = mapset_name[n]);

Modified: grass/branches/develbranch_6/general/g.mapsets/dsply_path.c
===================================================================
--- grass/branches/develbranch_6/general/g.mapsets/dsply_path.c	2010-10-24 06:30:47 UTC (rev 43995)
+++ grass/branches/develbranch_6/general/g.mapsets/dsply_path.c	2010-10-24 06:42:18 UTC (rev 43996)
@@ -3,8 +3,21 @@
 #include <grass/glocale.h>
 #include "local_proto.h"
 
+static int display1(void);
+static int display2(const char *fs);
+
 int display_mapset_path(const char *fs)
 {
+    if (!fs)
+	display1();
+    else
+	display2(fs);
+
+    return 0;
+}
+
+int display1(void) 
+{
     int n;
     int map;			/* pointer into list of available mapsets */
     int offset = 6;		/* accounts for " <x>, " */
@@ -12,46 +25,74 @@
     int len;
     int nleft;
 
-    if (!fs) {
-	/* account for largest mapset number in offset value */
-	for (n = nmapsets; n /= 10; offset++) ;
+    /* account for largest mapset number in offset value */
+    for (n = nmapsets; n /= 10; offset++) ;
+    fprintf(stdout, _("Your mapset search list:\n"));
+    
+    nleft = 78;
+    for (n = 0; (name = G__mapset_name(n)); n++) {
+	/* match each mapset to its numeric equivalent */
+	for (map = 0; map < nmapsets && strcmp(mapset_name[map], name);
+	     map++) ;
+	if (map == nmapsets)
+	    G_fatal_error(_("<%s> not found in mapset list"),
+			  name);
+	
+	len = strlen(name);
+	if (len > nleft) {
+	    fprintf(stdout, "\n");
+	    nleft = 78;
+	}
 
-	fprintf(stdout, _("Your mapset search list:\n"));
+	if (n)
+	    fprintf(stdout, ", ");
+	fprintf(stdout, "%s <%d>", name, map + 1);
+	nleft -= (len + offset);
     }
+    fprintf(stdout, "\n");
+    
+    return 0;
+}
 
+int display2(const char *fs) 
+{
+    int n;
+    int map;			/* pointer into list of available mapsets */
+    int offset = 6;		/* accounts for " <x>, " */
+    const char *name;
+    int len;
+    int nleft;
+
+    if (strcmp(fs, "space") == 0)
+	fs = " ";
+    else if (strcmp(fs, "comma") == 0)
+	fs = ",";
+    else if (strcmp(fs, "tab") == 0)
+	fs = "\t";
+    else if (strcmp(fs, "newline") == 0) {
+	for (n = 0; (name = G__mapset_name(n)); n++) {
+	    fprintf(stdout, "%s\n", name);
+	}
+	
+	return 0;
+    }
+
     nleft = 78;
     for (n = 0; (name = G__mapset_name(n)); n++) {
 	/* match each mapset to its numeric equivalent */
-	if (!fs) {
-	    for (map = 0; map < nmapsets && strcmp(mapset_name[map], name);
-		 map++) ;
-	    if (map == nmapsets)
-		G_fatal_error(_("<%s> not found in mapset list"),
-			      name);
-	}
-
 	len = strlen(name);
 	if (len > nleft) {
 	    fprintf(stdout, "\n");
 	    nleft = 78;
 	}
 
-	if (!fs) {
-	    if (n)
-		fprintf(stdout, ", ");
-	    fprintf(stdout, "%s <%d>", name, map + 1);
-	    nleft -= (len + offset);
-	}
-	else {
-	    fprintf(stdout, "%s", name);
-	    if (G__mapset_name(n+1))
-		fprintf(stdout, "%s", fs);
-	    nleft -= (len + 1);
-	}
+	fprintf(stdout, "%s", name);
+	if (G__mapset_name(n+1))
+	    fprintf(stdout, "%s", fs);
+	nleft -= (len + 1);
     }
     fprintf(stdout, "\n");
-    if (!fs)
-	fprintf(stdout, "\n");
-
+    
     return 0;
 }
+

Modified: grass/branches/develbranch_6/general/g.mapsets/main.c
===================================================================
--- grass/branches/develbranch_6/general/g.mapsets/main.c	2010-10-24 06:30:47 UTC (rev 43995)
+++ grass/branches/develbranch_6/general/g.mapsets/main.c	2010-10-24 06:42:18 UTC (rev 43996)
@@ -86,7 +86,9 @@
 	_("Name(s) of existing mapset(s) to remove from search list");
     
     opt.fs = G_define_standard_option(G_OPT_F_SEP);
-    opt.fs->answer = " ";
+    opt.fs->label = _("Field separator");
+    opt.fs->description = _("Special characters: newline, space, comma, tab");
+    opt.fs->answer = "space";
     
     opt.list = G_define_flag();
     opt.list->key = 'l';


Property changes on: grass/branches/develbranch_6/general/g.mapsets/main.c
___________________________________________________________________
Deleted: svn:mergeinfo
   - 



More information about the grass-commit mailing list