]> granicus.if.org Git - postgis/commitdiff
Associated CLI fix for #2272: shp2pgsql-gui crashes when given filenames with dots.
authorMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Sat, 13 Apr 2013 18:26:44 +0000 (18:26 +0000)
committerMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Sat, 13 Apr 2013 18:26:44 +0000 (18:26 +0000)
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

loader/shp2pgsql-cli.c

index 0ffcaa9f0e5acd041c5dfee9a8d79734616f3300..2872ce05a80f58390685e741f4411275a04e398e 100644 (file)
@@ -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++;