From 6a05b2159b84e1c5a462c9c466b0f586fbd47e83 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 16 May 2005 17:51:17 +0000 Subject: [PATCH] BUGFIX in attribute names unicity enforcement git-svn-id: http://svn.osgeo.org/postgis/branches/pgis_1_0@1711 b70326c6-7e19-0410-871a-916f4a2858ee --- loader/pgsql2shp.c | 64 ++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/loader/pgsql2shp.c b/loader/pgsql2shp.c index 38848a39a..1a05c03a6 100644 --- a/loader/pgsql2shp.c +++ b/loader/pgsql2shp.c @@ -2370,7 +2370,6 @@ get_postgis_major_version(void) exit(1); } - res = PQexec(conn, query); version = PQgetvalue(res, 0, 0); ver = atoi(version); PQclear(res); @@ -2395,6 +2394,8 @@ initialize(void) int mainscan_nflds=0; int size; int gidfound=0; + char *dbf_flds[256]; + int dbf_nfields=0; /* Detect postgis version */ pgis_major_version = get_postgis_major_version(); @@ -2504,7 +2505,7 @@ initialize(void) * This is exactly the geometry privided * by the user. */ - else if (!strcmp(geo_col_name,fname)) + else if (!strcmp(geo_col_name, fname)) { geom_fld = mainscan_nflds; type_ary[mainscan_nflds]=9; @@ -2538,47 +2539,38 @@ initialize(void) * becomes __xmin when escaped */ + /* Limit dbf field name to 10-digits */ + strncpy(field_name, ptr, 10); + field_name[10] = 0; - if(strlen(ptr) <32) strcpy(field_name, ptr); - else + /* + * make sure the fields all have unique names, + */ + tmpint=1; + for(j=0; j