[GRASS-SVN] r53167 - grass/trunk/vector/v.out.ascii

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 11 09:10:36 PDT 2012


Author: martinl
Date: 2012-09-11 09:10:34 -0700 (Tue, 11 Sep 2012)
New Revision: 53167

Modified:
   grass/trunk/vector/v.out.ascii/args.c
   grass/trunk/vector/v.out.ascii/local_proto.h
   grass/trunk/vector/v.out.ascii/main.c
Log:
v.out.ascii: fix for layer names


Modified: grass/trunk/vector/v.out.ascii/args.c
===================================================================
--- grass/trunk/vector/v.out.ascii/args.c	2012-09-11 15:20:15 UTC (rev 53166)
+++ grass/trunk/vector/v.out.ascii/args.c	2012-09-11 16:10:34 UTC (rev 53167)
@@ -10,13 +10,13 @@
 void parse_args(int argc, char **argv,
 		char **input, char**output, int *format, int *dp, char **delim,
 		char **field, char ***columns, char **where, int *region,
-		int *old_format, int *header, struct cat_list **clist, int *type)
+		int *old_format, int *header, char **cats, int *type)
 {
     struct Option *input_opt, *output_opt, *format_opt, *dp_opt, *delim_opt,
 	*field_opt, *column_opt, *where_opt, *cats_opt, *type_opt;
     struct Flag *old_flag, *header_flag, *region_flag;
     
-    char * desc;
+    char *desc;
     
     input_opt = G_define_standard_option(G_OPT_V_INPUT);
 
@@ -130,23 +130,18 @@
 	    (*columns)[i] = G_store(column_opt->answers[i]);
 	(*columns)[nopt - 1] = NULL;
     }
+
     *where = NULL;
     if (where_opt->answer) {
 	*where = G_store(where_opt->answer);
     }
-    *clist = NULL;
+
+    *cats = NULL;
     if (cats_opt->answer) {
-	int ret;
-	
-	*clist = Vect_new_cat_list();
-	(*clist)->field = atoi(field_opt->answer);
-	if ((*clist)->field < 1)
-	    G_fatal_error(_("Option <%s> must be > 0"), field_opt->key);
-	ret = Vect_str_to_cat_list(cats_opt->answer, *clist);
-	if (ret > 0)
-	    G_fatal_error(_("%d errors in cat option"), ret);
+        *cats = G_store(cats_opt->answer);
     }
-    *region = region_flag->answer ? 1 : 0;
-    *old_format = old_flag->answer ? 1 : 0;
-    *header = header_flag->answer ? 1 : 0;
+
+    *region = region_flag->answer ? TRUE : FALSE;
+    *old_format = old_flag->answer ? TRUE : FALSE;
+    *header = header_flag->answer ? TRUE : FALSE;
 }

Modified: grass/trunk/vector/v.out.ascii/local_proto.h
===================================================================
--- grass/trunk/vector/v.out.ascii/local_proto.h	2012-09-11 15:20:15 UTC (rev 53166)
+++ grass/trunk/vector/v.out.ascii/local_proto.h	2012-09-11 16:10:34 UTC (rev 53167)
@@ -2,4 +2,4 @@
 void parse_args(int, char **,
 		char **, char**, int *, int *, char **,
 		char **, char ***, char **, int *, int *, int *,
-		struct cat_list **, int *);
+		char **, int *);

Modified: grass/trunk/vector/v.out.ascii/main.c
===================================================================
--- grass/trunk/vector/v.out.ascii/main.c	2012-09-11 15:20:15 UTC (rev 53166)
+++ grass/trunk/vector/v.out.ascii/main.c	2012-09-11 16:10:34 UTC (rev 53167)
@@ -33,12 +33,14 @@
     struct Map_info Map;
 
     FILE *ascii, *att;
-    char *input, *output, *delim, **columns, *where, *field_name;
+    char *input, *output, *delim, **columns, *where, *field_name, *cats;
     int format, dp, field, ret, region, old_format, header, type;
     int ver, pnt;
 
     struct cat_list *clist;
     
+    clist = NULL;
+    
     G_gisinit(argv[0]);
 
     module = G_define_module();
@@ -50,7 +52,7 @@
 
     parse_args(argc, argv, &input, &output, &format, &dp, &delim,
 	       &field_name, &columns, &where, &region, &old_format, &header,
-	       &clist, &type);
+	       &cats, &type);
     
     if (format == GV_ASCII_FORMAT_STD && columns) {
 	G_warning(_("Parameter 'column' ignored in standard mode"));
@@ -92,7 +94,17 @@
     }
 
     field = Vect_get_field_number(&Map, field_name);
-    
+    if (cats) {
+        clist = Vect_new_cat_list();
+        
+        clist->field = field;
+        if (clist->field < 1)
+            G_fatal_error(_("Layer <%s> not found"), field_name);
+        ret = Vect_str_to_cat_list(cats, clist);
+        if (ret > 0)
+            G_fatal_error(_("%d errors in <%s> option"), ret, "cats");
+    }
+
     if (strcmp(output, "-") != 0) {
 	if (ver == 4) {
 	    ascii = G_fopen_new("dig_ascii", output);
@@ -150,5 +162,8 @@
 
     Vect_close(&Map);
 
+    if (cats)
+        Vect_destroy_cat_list(clist);
+    
     exit(EXIT_SUCCESS);
 }



More information about the grass-commit mailing list