Compile failure on nl_langinfo

Lists: pgsql-hackers
From: Euler Taveira de Oliveira <euler(at)ufgnet(dot)ufg(dot)br>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Compile failure on nl_langinfo
Date: 2004-07-31 14:10:28
Message-ID: 20040731111028.2f497019.euler@ufgnet.ufg.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I am seeing the following compile failure in currrent CVS.

gmake[4]: Leaving directory `/dados/pgsql/cvs/pgsql/src/port'
gcc -O2 -fno-strict-aliasing -g -Wall -Wmissing-prototypes -Wmissing-declarations -DFRONTEND -I../../../src/interfaces/libpq -I../../../src/include -I/usr/local/include -I/usr/local/include/tcl8.4 -c -o initdb.o initdb.c -MMD
initdb.c: In function `get_encoding_from_locale':
initdb.c:758: `CODESET' undeclared (first use in this function)
initdb.c:758: (Each undeclared identifier is reported only once
initdb.c:758: for each function it appears in.)
gmake[3]: *** [initdb.o] Error 1
gmake[3]: Leaving directory `/dados/pgsql/cvs/pgsql/src/bin/initdb'
gmake[2]: *** [all] Error 2
gmake[2]: Leaving directory `/dados/pgsql/cvs/pgsql/src/bin'
gmake[1]: *** [all] Error 2
gmake[1]: Leaving directory `/dados/pgsql/cvs/pgsql/src'
gmake: *** [all] Error 2
$

I am using an OpenBSD 3.5. OpenBSD doesn't have 'CODESET' symbol.
How can we fix it?

1) just define it on configure.in when we don't have it. Like this:
dnl Check for nl_langinfo and CODESET
AC_MSG_CHECKING([for nl_langinfo (CODESET)])
AC_TRY_LINK([#include <langinfo.h>],
[char *codeset = nl_langinfo (CODESET);],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_DEFINE(CODESET, 0, [Define to 0 if you don't have CODESET.])
])

2) define a 'HAVE_CODESET' symbol and just ifdef in initdb.c

3) another?

Personally I prefer the first one. The completed patch is attached. It requires to run 'autoheader' and 'autoconf'. CODESET 0 is ASCII.
So in those plataforms that do not have 'CODESET' we'll always go with locale C.

Comments?

--
Euler Taveira de Oliveira
euler (at) ufgnet.ufg.br
Desenvolvedor Web e Administrador de Sistemas
UFGNet - Universidade Federal de Goiás

Attachment Content-Type Size
foo.diff application/octet-stream 623 bytes

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Euler Taveira de Oliveira <euler(at)ufgnet(dot)ufg(dot)br>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compile failure on nl_langinfo
Date: 2004-07-31 14:59:09
Message-ID: 200407311659.09291.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Euler Taveira de Oliveira wrote:
> I am using an OpenBSD 3.5. OpenBSD doesn't have 'CODESET' symbol.
> How can we fix it?

Put #ifdef CODESET around the offending code.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Euler Taveira de Oliveira <euler(at)ufgnet(dot)ufg(dot)br>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compile failure on nl_langinfo
Date: 2004-07-31 15:24:18
Message-ID: 20407.1091287458@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Euler Taveira de Oliveira <euler(at)ufgnet(dot)ufg(dot)br> writes:
> I am using an OpenBSD 3.5. OpenBSD doesn't have 'CODESET' symbol.
> How can we fix it?

> 1) just define it on configure.in when we don't have it. Like this:

You've got to be kidding. That will cause get_encoding_from_locale to
return some random bit of information (whatever is mapped to zero),
with who-knows-what result.

A configure-time probe seems unnecessary anyway, since we can just do
"#ifdef CODESET" in initdb.c. The real question is what we should do
if it isn't defined. We can certainly make get_encoding_from_locale
return NULL, but it looks like initdb will behave moderately
unpleasantly if we do that (ie, force you to specify -E in most cases).
Is there any reasonable fallback behavior?

regards, tom lane


From: Euler Taveira de Oliveira <euler(at)ufgnet(dot)ufg(dot)br>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compile failure on nl_langinfo
Date: 2004-07-31 15:39:31
Message-ID: 20040731123931.6347843a.euler@ufgnet.ufg.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Peter,

> > I am using an OpenBSD 3.5. OpenBSD doesn't have 'CODESET' symbol.
> > How can we fix it?
>
> Put #ifdef CODESET around the offending code.
>
OK. Another try.

--
Euler Taveira de Oliveira
euler (at) ufgnet.ufg.br
Desenvolvedor Web e Administrador de Sistemas
UFGNet - Universidade Federal de Goiás

Attachment Content-Type Size
initdb.diff application/octet-stream 373 bytes

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Euler Taveira de Oliveira <euler(at)ufgnet(dot)ufg(dot)br>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compile failure on nl_langinfo
Date: 2004-07-31 15:57:51
Message-ID: 410BC17F.4060109@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:

>Euler Taveira de Oliveira <euler(at)ufgnet(dot)ufg(dot)br> writes:
>
>
>>I am using an OpenBSD 3.5. OpenBSD doesn't have 'CODESET' symbol.
>>How can we fix it?
>>
>>
>
>
>
>>1) just define it on configure.in when we don't have it. Like this:
>>
>>
>
>You've got to be kidding. That will cause get_encoding_from_locale to
>return some random bit of information (whatever is mapped to zero),
>with who-knows-what result.
>
>A configure-time probe seems unnecessary anyway, since we can just do
>"#ifdef CODESET" in initdb.c. The real question is what we should do
>if it isn't defined. We can certainly make get_encoding_from_locale
>return NULL, but it looks like initdb will behave moderately
>unpleasantly if we do that (ie, force you to specify -E in most cases).
>Is there any reasonable fallback behavior?
>
>

A quick Google shows Mozilla falling back to ISO-8859-1

cheers

andrew


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Euler Taveira de Oliveira <euler(at)ufgnet(dot)ufg(dot)br>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compile failure on nl_langinfo
Date: 2004-07-31 16:33:00
Message-ID: 200407311833.00422.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Euler Taveira de Oliveira wrote:
> > > I am using an OpenBSD 3.5. OpenBSD doesn't have 'CODESET' symbol.
> > > How can we fix it?
> >
> > Put #ifdef CODESET around the offending code.
>
> OK. Another try.

What does

nl_langinfo(NULL)

return? Probably not a valid codepage.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Euler Taveira de Oliveira <euler(at)ufgnet(dot)ufg(dot)br>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Compile failure on nl_langinfo
Date: 2004-07-31 17:23:46
Message-ID: 20040731142346.3bcd7dd0.euler@ufgnet.ufg.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Peter,

> > > > I am using an OpenBSD 3.5. OpenBSD doesn't have 'CODESET' symbol.
> > > > How can we fix it?
> > >
> > > Put #ifdef CODESET around the offending code.
> >
> > OK. Another try.
>
> What does
>
> nl_langinfo(NULL)
>
> return? Probably not a valid codepage.
>
No. Just "". See
http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/locale/nl_langinfo.c?rev=1.3&content-type=text/x-cvsweb-markup

Isn't it acceptable? I just got locale C at initdb. But I saw this we I try to set an specific locale:

$ initdb --locale=pt_BR
initdb: invalid locale name "pt_BR"
initdb: invalid locale name "pt_BR"
initdb: invalid locale name "pt_BR"
initdb: invalid locale name "pt_BR"
initdb: invalid locale name "pt_BR"
initdb: invalid locale name "pt_BR"
The files belonging to this database system will be owned by user "euler".
This user must also own the server process.

The database cluster will be initialized with locale C.
....

The chklocale() seems to fail. I don't set neither LC_* nor LANG.

--
Euler Taveira de Oliveira
euler (at) ufgnet.ufg.br
Desenvolvedor Web e Administrador de Sistemas
UFGNet - Universidade Federal de Goiás