From: Regina Obe Date: Sat, 20 Jul 2013 03:44:03 +0000 (+0000) Subject: #2230 can't dump on windows 64 if schema qualified. Fix by replacing with more modern... X-Git-Tag: 2.2.0rc1~1434 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ea20de660c12753552c9e56238fb93659439403;p=postgis #2230 can't dump on windows 64 if schema qualified. Fix by replacing with more modern code (follow same pattern and standardiz naming of variable as shp2pgsql) (should probably apply astyle but will do later) git-svn-id: http://svn.osgeo.org/postgis/trunk@11710 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/pgsql2shp-cli.c b/loader/pgsql2shp-cli.c index 89a5becb6..61caf7b0a 100644 --- a/loader/pgsql2shp-cli.c +++ b/loader/pgsql2shp-cli.c @@ -130,8 +130,6 @@ main(int argc, char **argv) it's a user-defined query then set that instead */ if (pgis_optind < argc) { - char *ptr; - /* User-defined queries begin with SELECT */ if (!strncmp(argv[pgis_optind], "SELECT ", 7) || !strncmp(argv[pgis_optind], "select ", 7)) @@ -141,21 +139,28 @@ main(int argc, char **argv) else { /* Schema qualified table name */ - ptr = strchr(argv[pgis_optind], '.'); - - if (ptr) - { - config->schema = malloc(strlen(argv[pgis_optind]) + 1); - snprintf(config->schema, ptr - argv[pgis_optind] + 1, "%s", argv[pgis_optind]); - - config->table = malloc(strlen(argv[pgis_optind])); - snprintf(config->table, strlen(argv[pgis_optind]) - strlen(config->schema), "%s", ptr + 1); - } - else - { - config->table = malloc(strlen(argv[pgis_optind]) + 1); - strcpy(config->table, argv[pgis_optind]); - } + char *strptr = argv[pgis_optind]; + char *chrptr = strchr(strptr, '.'); + + /* OK, this is a schema-qualified table name... */ + if (chrptr) + { + if ( chrptr == strptr ) + { + /* table is ".something" display help */ + usage(0); + exit(0); + } + /* Null terminate at the '.' */ + *chrptr = '\0'; + /* Copy in the parts */ + config->schema = strdup(strptr); + config->table = strdup(chrptr+1); + } + else + { + config->table = strdup(strptr); + } } }