From: Mark Cave-Ayland Date: Sat, 13 Apr 2013 18:26:44 +0000 (+0000) Subject: Associated CLI fix for #2272: shp2pgsql-gui crashes when given filenames with dots. X-Git-Tag: 2.1.0beta2~101 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27cedd50159b8978675551b80a297fd3e31ae108;p=postgis Associated CLI fix for #2272: shp2pgsql-gui crashes when given filenames with dots. After some experimentation, the best solution seems to be to use a separate scan to remove the extension before finding the non-path section when deriving the table name. git-svn-id: http://svn.osgeo.org/postgis/trunk@11294 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/shp2pgsql-cli.c b/loader/shp2pgsql-cli.c index 0ffcaa9f0..2872ce05a 100644 --- a/loader/shp2pgsql-cli.c +++ b/loader/shp2pgsql-cli.c @@ -285,12 +285,20 @@ main (int argc, char **argv) { char *shp_file = strdup(config->shp_file); char *ptr; + + /* Remove the extension, if present */ for ( ptr = shp_file + strlen(shp_file); ptr > shp_file; ptr-- ) { if ( *ptr == '.' ) { *ptr = '\0'; + break; } + } + + /* The remaining non-path section is the table name */ + for ( ptr = shp_file + strlen(shp_file); ptr > shp_file; ptr-- ) + { if ( *ptr == '/' || *ptr == '\\' ) { ptr++;