[GRASS-SVN] r55635 - grass/trunk/vector/v.db.select
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Apr 4 16:36:19 PDT 2013
Author: hamish
Date: 2013-04-04 16:36:18 -0700 (Thu, 04 Apr 2013)
New Revision: 55635
Modified:
grass/trunk/vector/v.db.select/main.c
Log:
support for fs alias words; needs possible malloc issue addressed before backporting
Modified: grass/trunk/vector/v.db.select/main.c
===================================================================
--- grass/trunk/vector/v.db.select/main.c 2013-04-04 23:32:46 UTC (rev 55634)
+++ grass/trunk/vector/v.db.select/main.c 2013-04-04 23:36:18 UTC (rev 55635)
@@ -44,7 +44,7 @@
struct Map_info Map;
char query[1024];
struct ilist *list_lines;
-
+ char *fs;
struct bound_box *min_box, *line_box;
int i, line, area, init_box, cat;
@@ -127,6 +127,18 @@
list_lines = NULL;
}
+ /* the field separator */
+ fs = fs_opt->answer;
+/* FIXME: malloc() or G_store() needed for *fs since the sep can be multiple chars? */
+ if (strcmp(fs, "\\t") == 0)
+ fs = "\t";
+ if (strcmp(fs, "tab") == 0)
+ fs = "\t";
+ if (strcmp(fs, "space") == 0)
+ fs = " ";
+ if (strcmp(fs, "comma") == 0)
+ fs = ",";
+
db_init_string(&sql);
db_init_string(&value_string);
@@ -180,7 +192,7 @@
for (col = 0; col < ncols; col++) {
column = db_get_table_column(table, col);
if (col)
- fprintf(stdout, "%s", fs_opt->answer);
+ fprintf(stdout, "%s", fs);
fprintf(stdout, "%s", db_get_column_name(column));
}
fprintf(stdout, "\n");
@@ -214,11 +226,10 @@
db_convert_column_value_to_string(column, &value_string);
if (!c_flag->answer && v_flag->answer)
- fprintf(stdout, "%s%s", db_get_column_name(column),
- fs_opt->answer);
+ fprintf(stdout, "%s%s", db_get_column_name(column), fs);
if (col && !v_flag->answer)
- fprintf(stdout, "%s", fs_opt->answer);
+ fprintf(stdout, "%s", fs);
if (nv_opt->answer && db_test_value_isnull(value))
fprintf(stdout, "%s", nv_opt->answer);
More information about the grass-commit
mailing list