[GRASS-SVN] r46719 - grass/trunk/db/drivers/dbf
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jun 15 11:58:28 EDT 2011
Author: mmetz
Date: 2011-06-15 08:58:28 -0700 (Wed, 15 Jun 2011)
New Revision: 46719
Modified:
grass/trunk/db/drivers/dbf/column.c
grass/trunk/db/drivers/dbf/globals.h
Log:
fix dbf column name length handling
Modified: grass/trunk/db/drivers/dbf/column.c
===================================================================
--- grass/trunk/db/drivers/dbf/column.c 2011-06-15 14:59:10 UTC (rev 46718)
+++ grass/trunk/db/drivers/dbf/column.c 2011-06-15 15:58:28 UTC (rev 46719)
@@ -32,6 +32,16 @@
"add_column(): tab = %d, type = %d, name = %s, width = %d, decimals = %d",
tab, type, name, width, decimals);
+ /* truncate column name */
+ if (strlen(name) > DBF_COL_NAME - 1) {
+ char buf[2000];
+
+ sprintf(buf, "DBMI-DBF driver: column name '%s'", name);
+ name[DBF_COL_NAME - 1] = '\0';
+ sprintf(buf + strlen(buf), " truncated to '%s'", name);
+ G_warning(buf);
+ }
+
/* Check if the column exists */
for (c = 0; c < db.tables[tab].ncols; c++) {
if (G_strcasecmp(db.tables[tab].cols[c].name, name) == 0) {
Modified: grass/trunk/db/drivers/dbf/globals.h
===================================================================
--- grass/trunk/db/drivers/dbf/globals.h 2011-06-15 14:59:10 UTC (rev 46718)
+++ grass/trunk/db/drivers/dbf/globals.h 2011-06-15 15:58:28 UTC (rev 46719)
@@ -1,6 +1,6 @@
#include <grass/sqlp.h>
-#define DBF_COL_NAME 20 /* maximum column name (in fact shouldn't be > 10) */
+#define DBF_COL_NAME 11 /* maximum column name (10 characters plus \0) */
/*
* DBF API: http://shapelib.maptools.org/dbf_api.html
More information about the grass-commit
mailing list