Subject: | Small portability fixes |
Here's a patch which fixes a few portability problems I found trying to compile this on Windows XP. With these changes I was able to compile it, although it fails many tests with crashes and nasty warnings.
The change from void to char for some pointers I'm not entirely sure about. The Microsoft compiler complains about them, and this seemed to make it happy, but I haven't thought much about what the right thing is.
Also adds a note to README.win32. I needed to tweak Makefile.PL to get this to compile, because it doesn't detect the version of libpq.dll you're compiling against. I just hacked it in manually.
qef
diff -ur DBD-Pg-1.32.orig/Pg.h DBD-Pg-1.32/Pg.h
--- DBD-Pg-1.32.orig/Pg.h Thu Jun 12 22:30:08 2003
+++ DBD-Pg-1.32/Pg.h Wed Aug 25 10:06:30 2004
@@ -14,6 +14,10 @@
static int errno;
#endif
+#ifdef _MSC_VER
+#define strncasecmp(a,b,c) _strnicmp((a),(b),(c))
+#endif
+
#include "libpq-fe.h"
#ifdef NEVER
diff -ur DBD-Pg-1.32.orig/Pg.xs DBD-Pg-1.32/Pg.xs
--- DBD-Pg-1.32.orig/Pg.xs Thu Feb 19 02:34:36 2004
+++ DBD-Pg-1.32/Pg.xs Wed Aug 25 10:06:30 2004
@@ -15,10 +15,6 @@
#include "types.h"
#include "pg_typeOID.h"
-#ifdef _MSC_VER
-#define strncasecmp(a,b,c) _strnicmp((a),(b),(c))
-#endif
-
DBISTATE_DECLARE;
diff -ur DBD-Pg-1.32.orig/README.win32 DBD-Pg-1.32/README.win32
--- DBD-Pg-1.32.orig/README.win32 Tue Oct 15 20:56:59 2002
+++ DBD-Pg-1.32/README.win32 Wed Aug 25 11:05:57 2004
@@ -53,6 +53,9 @@
---------------
cd DBD-Pg
+Alter Makefile.PL to manually set the three variables that set the version
+number. They aren't set automatically, because there is no version of the
+'pg_config' script for Windows.
perl Makefile.PL CAPI=TRUE
nmake
set the environment variable PGHOST to the name of the postgresql server: set PGHOST=myserver
diff -ur DBD-Pg-1.32.orig/dbdimp.c DBD-Pg-1.32/dbdimp.c
--- DBD-Pg-1.32.orig/dbdimp.c Tue Feb 3 19:50:22 2004
+++ DBD-Pg-1.32/dbdimp.c Wed Aug 25 10:13:57 2004
@@ -191,7 +191,7 @@
pgres_ret = PQexec(imp_dbh->conn, "SELECT version()");
if (pgres_ret && PQresultStatus(pgres_ret) == PGRES_TUPLES_OK) {
vstring = PQgetvalue(pgres_ret, 0,0); /* Tuple 0 ,filed 0 */
- vstart = index(vstring, ' ');
+ vstart = strchr(vstring, ' ');
imp_dbh->version.major = strtol(vstart, &vnext, 10);
imp_dbh->version.minor = strtol(vnext+1, NULL, 10);
diff -ur DBD-Pg-1.32.orig/quote.c DBD-Pg-1.32/quote.c
--- DBD-Pg-1.32.orig/quote.c Thu Feb 19 02:34:36 2004
+++ DBD-Pg-1.32/quote.c Wed Aug 25 10:01:20 2004
@@ -293,7 +293,7 @@
char *
null_quote(string, len, retlen)
- void *string;
+ char *string;
size_t len;
size_t *retlen;
{
@@ -330,7 +330,7 @@
char *
quote_char(string, len, retlen)
- void *string;
+ char *string;
size_t len;
size_t *retlen;
{
@@ -387,7 +387,7 @@
char *
quote_sql_binary( string, len, retlen)
- void *string;
+ char *string;
size_t len;
size_t *retlen;
{
@@ -571,7 +571,7 @@
void
null_dequote (string, retlen)
- void *string;
+ char *string;
size_t *retlen;
{
*retlen = strlen(string);