[GRASS-SVN] r42623 - in grass/trunk: general/g.mapsets lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jun 21 18:19:22 EDT 2010
Author: martinl
Date: 2010-06-21 22:19:22 +0000 (Mon, 21 Jun 2010)
New Revision: 42623
Added:
grass/trunk/general/g.mapsets/list.c
Removed:
grass/trunk/general/g.mapsets/dsply_maps.c
grass/trunk/general/g.mapsets/dsply_path.c
Modified:
grass/trunk/general/g.mapsets/local_proto.h
grass/trunk/general/g.mapsets/main.c
grass/trunk/lib/gis/parser_standard_options.c
Log:
g.mapsets: clean up list_mapsets fns
Deleted: grass/trunk/general/g.mapsets/dsply_maps.c
===================================================================
--- grass/trunk/general/g.mapsets/dsply_maps.c 2010-06-21 21:35:49 UTC (rev 42622)
+++ grass/trunk/general/g.mapsets/dsply_maps.c 2010-06-21 22:19:22 UTC (rev 42623)
@@ -1,59 +0,0 @@
-#include <string.h>
-#include <stdio.h>
-#include <grass/glocale.h>
-#include "local_proto.h"
-
-static int display1(void);
-static int display2(const char *fs);
-
-int display_available_mapsets(const char* fs)
-{
- if (!fs)
- display1();
- else
- display2(fs);
-
- return 0;
-}
-
-static int display1(void)
-{
- int n;
-
- fprintf(stdout, _("Available mapsets:"));
- for (n = 0; n < nmapsets; n++) {
- if (n % 4)
- fprintf(stdout, " ");
- else
- fprintf(stdout, "\n");
- fprintf(stdout, "%2d %-15s", n + 1, mapset_name[n]);
- }
- fprintf(stdout, "\n");
- if (nmapsets == 0)
- fprintf(stdout, _("** no mapsets **\n"));
- fprintf(stdout, "\n");
-
- return 0;
-}
-
-static int display2(const char *fs)
-{
- int nleft, len, n;
- char *name;
-
- nleft = 78;
- for (n = 0; n < nmapsets; n++) {
- len = strlen(name = mapset_name[n]);
- if (len > nleft) {
- fprintf(stdout, "\n");
- nleft = 78;
- }
- fprintf(stdout, "%s", name);
- if (n < nmapsets-1)
- fprintf(stdout, "%s", fs);
- nleft -= (len + 1);
- }
- fprintf(stdout, "\n");
-
- return 0;
-}
Deleted: grass/trunk/general/g.mapsets/dsply_path.c
===================================================================
--- grass/trunk/general/g.mapsets/dsply_path.c 2010-06-21 21:35:49 UTC (rev 42622)
+++ grass/trunk/general/g.mapsets/dsply_path.c 2010-06-21 22:19:22 UTC (rev 42623)
@@ -1,57 +0,0 @@
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include "local_proto.h"
-
-int display_mapset_path(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 (!fs) {
- /* 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 */
- 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, "\n");
- if (!fs)
- fprintf(stdout, "\n");
-
- return 0;
-}
Added: grass/trunk/general/g.mapsets/list.c
===================================================================
--- grass/trunk/general/g.mapsets/list.c (rev 0)
+++ grass/trunk/general/g.mapsets/list.c 2010-06-21 22:19:22 UTC (rev 42623)
@@ -0,0 +1,53 @@
+#include <string.h>
+#include <stdio.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
+#include "local_proto.h"
+
+void list_available_mapsets(const char* fs)
+{
+ int n;
+ G_message(_("Available mapsets:"));
+
+ for (n = 0; n < nmapsets; n++) {
+ fprintf(stdout, "%s", mapset_name[n]);
+ if (n < nmapsets-1) {
+ if (strcmp(fs, "newline") == 0)
+ fprintf(stdout, "\n");
+ else if (strcmp(fs, "space") == 0)
+ fprintf(stdout, " ");
+ else if (strcmp(fs, "comma") == 0)
+ fprintf(stdout, ",");
+ else if (strcmp(fs, "tab") == 0)
+ fprintf(stdout, "\t");
+ else
+ fprintf(stdout, "%s", fs);
+ }
+ }
+ fprintf(stdout, "\n");
+}
+
+void list_accessible_mapsets(const char* fs)
+{
+ int n;
+ const char *name;
+
+ G_message(_("Accessible mapsets:"));
+ for (n = 0; (name = G__mapset_name(n)); n++) {
+ /* match each mapset to its numeric equivalent */
+ fprintf(stdout, "%s", name);
+ if (G__mapset_name(n+1)) {
+ if (strcmp(fs, "newline") == 0)
+ fprintf(stdout, "\n");
+ else if (strcmp(fs, "space") == 0)
+ fprintf(stdout, " ");
+ else if (strcmp(fs, "comma") == 0)
+ fprintf(stdout, ",");
+ else if (strcmp(fs, "tab") == 0)
+ fprintf(stdout, "\t");
+ else
+ fprintf(stdout, "%s", fs);
+ }
+ }
+ fprintf(stdout, "\n");
+}
Modified: grass/trunk/general/g.mapsets/local_proto.h
===================================================================
--- grass/trunk/general/g.mapsets/local_proto.h 2010-06-21 21:35:49 UTC (rev 42622)
+++ grass/trunk/general/g.mapsets/local_proto.h 2010-06-21 22:19:22 UTC (rev 42623)
@@ -7,27 +7,9 @@
GLOBAL char **mapset_name;
GLOBAL int nmapsets;
-/* dsply_maps.c */
-int display_available_mapsets(const char *);
-
-/* dsply_path.c */
-int display_mapset_path(const char *);
-
/* get_maps.c */
int get_available_mapsets(void);
-/* get_path.c */
-int get_mapset_path(void);
-int delete_choices(void);
-
-/* main_cmd.c */
-int main(int, char *[]);
-
-/* main_inter.c */
-int main(int, char **);
-
-/* scan_int.c */
-int scan_int(char *, int *);
-
-/* set_path.c */
-int set_mapset_path(void);
+/* list.c */
+void list_available_mapsets(const char *);
+void list_accessible_mapsets(const char *);
Modified: grass/trunk/general/g.mapsets/main.c
===================================================================
--- grass/trunk/general/g.mapsets/main.c 2010-06-21 21:35:49 UTC (rev 42622)
+++ grass/trunk/general/g.mapsets/main.c 2010-06-21 22:19:22 UTC (rev 42623)
@@ -87,7 +87,7 @@
_("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->answer = "space";
opt.list = G_define_flag();
opt.list->key = 'l';
@@ -110,10 +110,11 @@
if (opt.list->answer) {
get_available_mapsets();
- display_available_mapsets(opt.fs->answer);
+ list_available_mapsets(opt.fs->answer);
}
if (opt.dialog->answer) {
+ putenv("GRASS_VERBOSE=0");
sprintf(path, "%s/etc/gui/scripts/g.mapsets_picker.py", G_gisbase());
G_spawn(getenv("GRASS_PYTHON"), "g.mapsets_picker.py", path, NULL);
}
@@ -195,7 +196,7 @@
if (nchoices == 0) {
if (opt.print->answer)
- display_mapset_path(opt.fs->answer);
+ list_accessible_mapsets(opt.fs->answer);
if (Path)
G_free(Path);
Modified: grass/trunk/lib/gis/parser_standard_options.c
===================================================================
--- grass/trunk/lib/gis/parser_standard_options.c 2010-06-21 21:35:49 UTC (rev 42622)
+++ grass/trunk/lib/gis/parser_standard_options.c 2010-06-21 22:19:22 UTC (rev 42623)
@@ -441,7 +441,8 @@
Opt->key_desc = "character";
Opt->required = NO;
Opt->answer = "|";
- Opt->description = _("Field separator");
+ Opt->label = _("Field separator");
+ Opt->description = _("Special characters: newline, space, comma, tab");
break;
/* colors */
More information about the grass-commit
mailing list