[GRASS-SVN] r43998 - grass/branches/releasebranch_6_4/general/g.mapsets

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Oct 24 02:46:14 EDT 2010


Author: martinl
Date: 2010-10-23 23:46:14 -0700 (Sat, 23 Oct 2010)
New Revision: 43998

Modified:
   grass/branches/releasebranch_6_4/general/g.mapsets/dsply_maps.c
   grass/branches/releasebranch_6_4/general/g.mapsets/dsply_path.c
   grass/branches/releasebranch_6_4/general/g.mapsets/main.c
Log:
g.mapsets: backport fs=space,comma,tab,newline from trunk
(merge r43996 from devbr6)


Modified: grass/branches/releasebranch_6_4/general/g.mapsets/dsply_maps.c
===================================================================
--- grass/branches/releasebranch_6_4/general/g.mapsets/dsply_maps.c	2010-10-24 06:43:45 UTC (rev 43997)
+++ grass/branches/releasebranch_6_4/general/g.mapsets/dsply_maps.c	2010-10-24 06:46:14 UTC (rev 43998)
@@ -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/releasebranch_6_4/general/g.mapsets/dsply_path.c
===================================================================
--- grass/branches/releasebranch_6_4/general/g.mapsets/dsply_path.c	2010-10-24 06:43:45 UTC (rev 43997)
+++ grass/branches/releasebranch_6_4/general/g.mapsets/dsply_path.c	2010-10-24 06:46:14 UTC (rev 43998)
@@ -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/releasebranch_6_4/general/g.mapsets/main.c
===================================================================
--- grass/branches/releasebranch_6_4/general/g.mapsets/main.c	2010-10-24 06:43:45 UTC (rev 43997)
+++ grass/branches/releasebranch_6_4/general/g.mapsets/main.c	2010-10-24 06:46:14 UTC (rev 43998)
@@ -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/releasebranch_6_4/general/g.mapsets/main.c
___________________________________________________________________
Deleted: svn:mergeinfo
   - 



More information about the grass-commit mailing list