>
> Bruce Momjian wrote:
>
> > #define UNIXSOCK_PATH(sun,port) \
> > (sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
> > ! + 1 + sizeof ((sun).sun_family))
> > ! /*
> > ! * + 1 is for BSD-specific sizeof((sun).sun_len)
> > ! * We never actually set sun_len, and I can't think of a
> > ! * platform-safe way of doing it, but the code still works. bjm
> > ! */
OK, I am with you. Even better, let's use offset(). Takes care of
possible OS padding between fields too:
---------------------------------------------------------------------------
*** ./include/libpq/pqcomm.h.orig Tue Jan 27 14:28:27 1998
--- ./include/libpq/pqcomm.h Tue Jan 27 14:48:15 1998
***************
*** 35,44 ****
#define UNIXSOCK_PATH(sun,port) \
(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
! + 1 + sizeof ((sun).sun_family))
/*
! * + 1 is for BSD-specific sizeof((sun).sun_len)
! * We never actually set sun_len, and I can't think of a
* platform-safe way of doing it, but the code still works. bjm
*/
--- 35,44 ----
#define UNIXSOCK_PATH(sun,port) \
(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
! offsetof(struct sockaddr_un, sun_path))
/*
! * We do this because sun_len is in BSD's struct, while others don't.
! * We never actually set BSD's sun_len, and I can't think of a
* platform-safe way of doing it, but the code still works. bjm
*/
--
Bruce Momjian
maillist@candle.pha.pa.us