From 98b98e1dccb5659956d2d32540490372978a4051 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 27 Jul 2005 02:34:29 +0000 Subject: [PATCH] Minor cleanups in loader git-svn-id: http://svn.osgeo.org/postgis/branches/pgis_1_0@1835 b70326c6-7e19-0410-871a-916f4a2858ee --- CHANGES | 1 + loader/shp2pgsql.c | 41 +++++++++++++++++------------------------ 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/CHANGES b/CHANGES index b2a18ffab..b0f5766f5 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,7 @@ PostGIS 1.0.3 - Bugfix in dumper handling of user-defined queries - Bugfix in create_undef.pl script - Small performance improvement in canonical input function + - Minor cleanups in loader - Severe bugfix in lwgeom's 2d bounding box computation PostGIS 1.0.2 diff --git a/loader/shp2pgsql.c b/loader/shp2pgsql.c index 94aef1456..b583e1d18 100644 --- a/loader/shp2pgsql.c +++ b/loader/shp2pgsql.c @@ -1511,10 +1511,15 @@ DropTable(char *schema, char *table, char *geom) void GetFieldsSpec(void) { +/* + * Shapefile (dbf) field name are at most 10chars + 1 NULL. + * Postgresql field names are at most 63 bytes + 1 NULL. + */ +#define MAXFIELDNAMELEN 64 int field_precision, field_width; int j, z; - char name[64]; - char name2[64]; + char name[MAXFIELDNAMELEN]; + char name2[MAXFIELDNAMELEN]; DBFFieldType type = -1; num_fields = DBFGetFieldCount( hDBFHandle ); @@ -1523,7 +1528,7 @@ GetFieldsSpec(void) types = (DBFFieldType *)malloc(num_fields*sizeof(int)); widths = malloc(num_fields*sizeof(int)); precisions = malloc(num_fields*sizeof(int)); - col_names = malloc((num_fields+2) * sizeof(char) * 32); + col_names = malloc((num_fields+2) * sizeof(char) * MAXFIELDNAMELEN); strcpy(col_names, "(" ); //fprintf(stderr, "Number of fields from DBF: %d\n", num_fields); @@ -1540,28 +1545,14 @@ GetFieldsSpec(void) * Make field names lowercase unless asked to * keep identifiers case. */ - if ( ! quoteidentifiers ) { - for(z=0; z