From: Paul Ramsey Date: Mon, 13 Jul 2009 17:27:41 +0000 (+0000) Subject: MinGW fix for loader (#222), Mark Cave-Ayland X-Git-Tag: 1.5.0b1~576 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=491022206db2e7c9e4a2936bc5ec20e3a121aa68;p=postgis MinGW fix for loader (#222), Mark Cave-Ayland git-svn-id: http://svn.osgeo.org/postgis/trunk@4293 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/liblwgeom.h b/liblwgeom/liblwgeom.h index e54d41162..132cc8254 100644 --- a/liblwgeom/liblwgeom.h +++ b/liblwgeom/liblwgeom.h @@ -121,8 +121,16 @@ void default_freeor(void *ptr); void default_errorreporter(const char *fmt, va_list ap); void default_noticereporter(const char *fmt, va_list ap); - extern int lw_vasprintf (char **result, const char *format, va_list args); +extern int lw_asprintf +#if __STDC__ +(char **result, const char *format, ...); +#else +(result, va_alist); +char **result; +va_dcl +#endif + /* Debug macros */ #if POSTGIS_DEBUG_LEVEL > 0 diff --git a/loader/Makefile.in b/loader/Makefile.in index 6f600a8ce..4a149839e 100644 --- a/loader/Makefile.in +++ b/loader/Makefile.in @@ -72,7 +72,7 @@ shp2pgsql-gui.o: shp2pgsql-gui.c $(SHP2PGSQL-GUI): stringbuffer.o shpopen.o dbfopen.o shp2pgsql-core-gui.o shp2pgsql-gui.o $(LIBLWGEOM) $(CC) $(CFLAGS) $(GTK_LIBS) $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm $^ -o $@ -$(SHP2PGSQL-CLI): stringbuffer.o shpopen.o dbfopen.o shp2pgsql-core.o shp2pgsql-cli.o $(LIBLWGEOM) +$(SHP2PGSQL-CLI): stringbuffer.o shpopen.o dbfopen.o getopt.o shp2pgsql-core.o shp2pgsql-cli.o $(LIBLWGEOM) $(CC) $(CFLAGS) $(ICONV_LDFLAGS) -lm $^ -o $@ install: all diff --git a/loader/shp2pgsql-cli.c b/loader/shp2pgsql-cli.c index 7eefbc922..7d985777a 100644 --- a/loader/shp2pgsql-cli.c +++ b/loader/shp2pgsql-cli.c @@ -61,7 +61,7 @@ pcli_cmdline(int ARGC, char **ARGV) pcli_usage(ARGV[0], 0, stdout); } - while ((c = getopt(ARGC, ARGV, "kcdapDs:Sg:iW:wIN:n")) != EOF){ + while ((c = pgis_getopt(ARGC, ARGV, "kcdapDs:Sg:iW:wIN:n")) != EOF){ switch (c) { case 'c': if (opt == ' ') diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c index d79641302..1c936a764 100644 --- a/loader/shp2pgsql-core.c +++ b/loader/shp2pgsql-core.c @@ -174,7 +174,7 @@ pgis_logf(const char *fmt, ... ) #ifdef PGUI pgui_log_va(fmt, ap); #else - if (!vasprintf (&msg, fmt, ap)) + if (!lw_vasprintf (&msg, fmt, ap)) { va_end (ap); return; @@ -755,12 +755,12 @@ LoadData(void) char *copysql; if ( schema ) { - asprintf(©sql, "COPY \"%s\".\"%s\" %s FROM stdin", + lw_asprintf(©sql, "COPY \"%s\".\"%s\" %s FROM stdin", schema, table, col_names); } else { - asprintf(©sql, "COPY \"%s\" %s FROM stdin", + lw_asprintf(©sql, "COPY \"%s\" %s FROM stdin", table, col_names); } pgis_copy_start(copysql); @@ -1526,7 +1526,7 @@ DropTable(char *schema, char *table, char *geom) { if (readshape == 1) { - asprintf(&sql, "SELECT DropGeometryColumn('%s','%s','%s')", schema, table, geom); + lw_asprintf(&sql, "SELECT DropGeometryColumn('%s','%s','%s')", schema, table, geom); if ( ! pgis_exec(sql) ) { free(sql); @@ -1534,7 +1534,7 @@ DropTable(char *schema, char *table, char *geom) } free(sql); } - asprintf(&sql, "DROP TABLE \"%s\".\"%s\"", schema, table); + lw_asprintf(&sql, "DROP TABLE \"%s\".\"%s\"", schema, table); if ( ! pgis_exec(sql) ) { free(sql); @@ -1546,7 +1546,7 @@ DropTable(char *schema, char *table, char *geom) { if (readshape == 1) { - asprintf(&sql, "SELECT DropGeometryColumn('','%s','%s')", table, geom); + lw_asprintf(&sql, "SELECT DropGeometryColumn('','%s','%s')", table, geom); if ( ! pgis_exec(sql) ) { free(sql); @@ -1554,7 +1554,7 @@ DropTable(char *schema, char *table, char *geom) } free(sql); } - asprintf(&sql, "DROP TABLE \"%s\"", table); + lw_asprintf(&sql, "DROP TABLE \"%s\"", table); if ( ! pgis_exec(sql) ) { free(sql); diff --git a/loader/shp2pgsql-core.h b/loader/shp2pgsql-core.h index 120769e68..b16f2198c 100644 --- a/loader/shp2pgsql-core.h +++ b/loader/shp2pgsql-core.h @@ -1,4 +1,3 @@ -#define _GNU_SOURCE #include #include diff --git a/loader/shp2pgsql-gui.c b/loader/shp2pgsql-gui.c index c05822365..db7bbc567 100644 --- a/loader/shp2pgsql-gui.c +++ b/loader/shp2pgsql-gui.c @@ -12,8 +12,6 @@ * **********************************************************************/ -#define _GNU_SOURCE - #include #include #include @@ -79,7 +77,7 @@ pgui_log_va(const char *fmt, va_list ap) { char *msg; - if (!vasprintf (&msg, fmt, ap)) return; + if (!lw_vasprintf (&msg, fmt, ap)) return; gtk_text_buffer_insert_at_cursor(textbuffer_log, msg, -1); gtk_text_buffer_insert_at_cursor(textbuffer_log, "\n", -1); @@ -304,7 +302,7 @@ pgui_read_connection(void) pgui_seterr("Server port must be a number."); return NULL; } - if ( ! asprintf(&connection_string, "user=%s password=%s port=%s host=%s dbname=%s", pg_user, pg_pass, pg_port, pg_host, pg_db) ) + if ( ! lw_asprintf(&connection_string, "user=%s password=%s port=%s host=%s dbname=%s", pg_user, pg_pass, pg_port, pg_host, pg_db) ) { return NULL; }