mb support fix

Started by Tatsuo Ishiialmost 27 years ago2 messages
#1Tatsuo Ishii
t-ishii@sra.co.jp
Included patches fix a portability problem of unsetenv() used in
6.4.2 multi-byte support. unsetenv() is only avaliable on FreeBSD and
Linux so I decided to replace with putenv().
--
Tatsuo Ishii
t-ishii@sra.co.jp
----------------------------- cut here ----------------------------
*** postgresql-6.4.2/src/bin/psql/psql.c.orig	Wed Jan  6 13:25:45 1999
--- postgresql-6.4.2/src/bin/psql/psql.c	Wed Jan  6 13:26:27 1999
***************
*** 1498,1504 ****
  		   PGCLIENTENCODING value. -- 1998/12/12 Tatsuo Ishii */

if (!has_client_encoding) {
! unsetenv("PGCLIENTENCODING");
}
#endif

--- 1498,1505 ----
  		   PGCLIENTENCODING value. -- 1998/12/12 Tatsuo Ishii */

if (!has_client_encoding) {
! static const char ev[] = "PGCLIENTENCODING=";
! putenv(ev);
}
#endif

*** postgresql-6.4.2/src/interfaces/libpq/fe-print.c.orig	Wed Jan  6 13:27:21 1999
--- postgresql-6.4.2/src/interfaces/libpq/fe-print.c	Wed Jan  6 13:29:19 1999
***************
*** 506,512 ****
  	int			encoding = -1;
  	str = getenv("PGCLIENTENCODING");
! 	if (str)
  		encoding = pg_char_to_encoding(str);
  	if (encoding < 0)
  		encoding = MULTIBYTE;
--- 506,512 ----
  	int			encoding = -1;
  	str = getenv("PGCLIENTENCODING");
! 	if (str && *str != NULL)
  		encoding = pg_char_to_encoding(str);
  	if (encoding < 0)
  		encoding = MULTIBYTE;
*** postgresql-6.4.2/src/interfaces/libpq/fe-connect.c.orig	Wed Jan  6 13:29:47 1999
--- postgresql-6.4.2/src/interfaces/libpq/fe-connect.c	Wed Jan  6 13:30:55 1999
***************
*** 813,819 ****
  #ifdef MULTIBYTE
  	/* query server encoding */
  	env = getenv(envname);
! 	if (!env)
  	{
  		rtn = PQexec(conn, "select getdatabaseencoding()");
  		if (rtn && PQresultStatus(rtn) == PGRES_TUPLES_OK)
--- 813,819 ----
  #ifdef MULTIBYTE
  	/* query server encoding */
  	env = getenv(envname);
! 	if (!env || *env == NULL)
  	{
  		rtn = PQexec(conn, "select getdatabaseencoding()");
  		if (rtn && PQresultStatus(rtn) == PGRES_TUPLES_OK)
#2The Hermit Hacker
scrappy@hub.org
In reply to: Tatsuo Ishii (#1)
Re: [PATCHES] mb support fix

Applied...

On Wed, 27 Jan 1999, Tatsuo Ishii wrote:

Included patches fix a portability problem of unsetenv() used in
6.4.2 multi-byte support. unsetenv() is only avaliable on FreeBSD and
Linux so I decided to replace with putenv().
--
Tatsuo Ishii
t-ishii@sra.co.jp
----------------------------- cut here ----------------------------
*** postgresql-6.4.2/src/bin/psql/psql.c.orig	Wed Jan  6 13:25:45 1999
--- postgresql-6.4.2/src/bin/psql/psql.c	Wed Jan  6 13:26:27 1999
***************
*** 1498,1504 ****
PGCLIENTENCODING value. -- 1998/12/12 Tatsuo Ishii */

if (!has_client_encoding) {
! unsetenv("PGCLIENTENCODING");
}
#endif

--- 1498,1505 ----
PGCLIENTENCODING value. -- 1998/12/12 Tatsuo Ishii */

if (!has_client_encoding) {
! static const char ev[] = "PGCLIENTENCODING=";
! putenv(ev);
}
#endif

*** postgresql-6.4.2/src/interfaces/libpq/fe-print.c.orig	Wed Jan  6 13:27:21 1999
--- postgresql-6.4.2/src/interfaces/libpq/fe-print.c	Wed Jan  6 13:29:19 1999
***************
*** 506,512 ****
int			encoding = -1;
str = getenv("PGCLIENTENCODING");
! 	if (str)
encoding = pg_char_to_encoding(str);
if (encoding < 0)
encoding = MULTIBYTE;
--- 506,512 ----
int			encoding = -1;
str = getenv("PGCLIENTENCODING");
! 	if (str && *str != NULL)
encoding = pg_char_to_encoding(str);
if (encoding < 0)
encoding = MULTIBYTE;
*** postgresql-6.4.2/src/interfaces/libpq/fe-connect.c.orig	Wed Jan  6 13:29:47 1999
--- postgresql-6.4.2/src/interfaces/libpq/fe-connect.c	Wed Jan  6 13:30:55 1999
***************
*** 813,819 ****
#ifdef MULTIBYTE
/* query server encoding */
env = getenv(envname);
! 	if (!env)
{
rtn = PQexec(conn, "select getdatabaseencoding()");
if (rtn && PQresultStatus(rtn) == PGRES_TUPLES_OK)
--- 813,819 ----
#ifdef MULTIBYTE
/* query server encoding */
env = getenv(envname);
! 	if (!env || *env == NULL)
{
rtn = PQexec(conn, "select getdatabaseencoding()");
if (rtn && PQresultStatus(rtn) == PGRES_TUPLES_OK)

Marc G. Fournier
Systems Administrator @ hub.org
primary: scrappy@hub.org secondary: scrappy@{freebsd|postgresql}.org