[GRASS-SVN] r57826 - grass/branches/releasebranch_6_4/vector/v.db.select
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 24 16:50:47 PDT 2013
Author: hamish
Date: 2013-09-24 16:50:47 -0700 (Tue, 24 Sep 2013)
New Revision: 57826
Modified:
grass/branches/releasebranch_6_4/vector/v.db.select/main.c
Log:
add support for fs=tab,space,\t,comma translation (merge from devbr6)
Modified: grass/branches/releasebranch_6_4/vector/v.db.select/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.db.select/main.c 2013-09-24 23:49:03 UTC (rev 57825)
+++ grass/branches/releasebranch_6_4/vector/v.db.select/main.c 2013-09-24 23:50:47 UTC (rev 57826)
@@ -7,7 +7,7 @@
*
* PURPOSE: Print vector attributes
*
- * COPYRIGHT: (C) 2005-2009 by the GRASS Development Team
+ * COPYRIGHT: (C) 2005-2013 by the GRASS Development Team
*
* This program is free software under the
* GNU General Public License (>=v2).
@@ -42,7 +42,7 @@
struct field_info *Fi;
int field, ncols, col, more;
struct Map_info Map;
- char *mapset;
+ char *mapset, *fs;
char query[1024];
struct ilist *list_lines;
@@ -124,6 +124,17 @@
list_lines = NULL;
}
+ /* the field separator */
+ fs = fs_opt->answer;
+ 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);
@@ -183,7 +194,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");
@@ -217,11 +228,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