Thread: win32/MSVC fix for libpq

win32/MSVC fix for libpq

From
Andreas Pflug
Date:
The attached fix reenables libpq compilation with MSVC6.

Regards,
Andreas
Index: fe-connect.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.311
diff -u -r1.311 fe-connect.c
--- fe-connect.c    12 Jun 2005 00:07:07 -0000    1.311
+++ fe-connect.c    19 Jun 2005 09:47:18 -0000
@@ -3104,6 +3104,8 @@
     if (stat(pgpassfile, &stat_buf) == -1)
         return NULL;

+#ifndef WIN32
+
     if (!S_ISREG(stat_buf.st_mode))
     {
         fprintf(stderr,
@@ -3113,7 +3115,6 @@
         return NULL;
     }

-#ifndef WIN32
     /* If password file is insecure, alert the user and ignore it. */
     if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
     {

Index: win32.mak
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/win32.mak,v
retrieving revision 1.34
diff -u -r1.34 win32.mak
--- win32.mak    29 Apr 2005 13:42:21 -0000    1.34
+++ win32.mak    19 Jun 2005 10:19:06 -0000
@@ -115,7 +115,7 @@
     copy pthread.h.win32 pthread.h

 pg_config_paths.h: win32.mak
-    echo \#define SYSCONFDIR "" > pg_config_paths.h
+    echo #define SYSCONFDIR "" > pg_config_paths.h

 "$(OUTDIR)" :
     if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
@@ -215,5 +215,8 @@
     $(CPP_PROJ) /I"." ..\..\backend\utils\mb\encnames.c
 <<

+.c{$(CPP_OBJS)}.obj:
+    $(CPP) $(CPP_PROJ) $<
+
 .c.obj:
     $(CPP) $(CPP_PROJ) $<


Re: win32/MSVC fix for libpq

From
Bruce Momjian
Date:
OK, applied.  I had to use \# in:

    echo \#define SYSCONFDIR "" > pg_config_paths.h

so that bcc wouldn't consider the # to be a comment, but it seems MSVC
doesn't have that issue, and in fact has a problem with it.

I modified the psql/win32.mak too to remove the \# and use just #.

---------------------------------------------------------------------------

Andreas Pflug wrote:
> The attached fix reenables libpq compilation with MSVC6.
>
> Regards,
> Andreas

> Index: fe-connect.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v
> retrieving revision 1.311
> diff -u -r1.311 fe-connect.c
> --- fe-connect.c    12 Jun 2005 00:07:07 -0000    1.311
> +++ fe-connect.c    19 Jun 2005 09:47:18 -0000
> @@ -3104,6 +3104,8 @@
>      if (stat(pgpassfile, &stat_buf) == -1)
>          return NULL;
>
> +#ifndef WIN32
> +
>      if (!S_ISREG(stat_buf.st_mode))
>      {
>          fprintf(stderr,
> @@ -3113,7 +3115,6 @@
>          return NULL;
>      }
>
> -#ifndef WIN32
>      /* If password file is insecure, alert the user and ignore it. */
>      if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
>      {
>
> Index: win32.mak
> ===================================================================
> RCS file: /projects/cvsroot/pgsql/src/interfaces/libpq/win32.mak,v
> retrieving revision 1.34
> diff -u -r1.34 win32.mak
> --- win32.mak    29 Apr 2005 13:42:21 -0000    1.34
> +++ win32.mak    19 Jun 2005 10:19:06 -0000
> @@ -115,7 +115,7 @@
>      copy pthread.h.win32 pthread.h
>
>  pg_config_paths.h: win32.mak
> -    echo \#define SYSCONFDIR "" > pg_config_paths.h
> +    echo #define SYSCONFDIR "" > pg_config_paths.h
>
>  "$(OUTDIR)" :
>      if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
> @@ -215,5 +215,8 @@
>      $(CPP_PROJ) /I"." ..\..\backend\utils\mb\encnames.c
>  <<
>
> +.c{$(CPP_OBJS)}.obj:
> +    $(CPP) $(CPP_PROJ) $<
> +
>  .c.obj:
>      $(CPP) $(CPP_PROJ) $<
>

>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073