BSD gettext

Started by Peter Eisentrautover 24 years ago9 messages
#1Peter Eisentraut
peter_e@gmx.net

http://www.postgresql.org/~petere/gettext.html

This is a compilation of the BSD-licensed gettext tools from NetBSD plus
some of my own code, put into a (hopefully) portable package, intended to
be evaluated for possible use in PostgreSQL. Give it a try if you're
interested. I've already tried it on FreeBSD, Linux, and Unixware, so
don't bother with those.

I feel that this is ready to go. NetBSD is using it in production as a
GNU gettext replacement, even for large packages. The .mo file format is
pretty simple actually, so if issues came up we could tackle them
ourselves.

As for portability, the fanciest feature it uses is mmap(), but only to
map a real file into memory to read it there. The missing functions
(strlcat, strlcpy, strsep) I've worked around with autoconf, the rest
looks all like basic POSIX stuff.

So I suppose if this looks okay I will start trying to work out how we can
use this for PostgreSQL.

--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter

#2Rick Robino
rrobino@wavedivision.com
In reply to: Peter Eisentraut (#1)
Re: BSD gettext

Peter Eisentraut wrote:

http://www.postgresql.org/~petere/gettext.html

This is a compilation of the BSD-licensed gettext tools from NetBSD plus
some of my own code, put into a (hopefully) portable package, intended to
be evaluated for possible use in PostgreSQL. Give it a try if you're
interested. I've already tried it on FreeBSD, Linux, and Unixware, so
don't bother with those.

# uname -a
SunOS mage 5.8 Generic_108528-06 sun4u sparc SUNW,Ultra-5_10
# pwd
/usr/local/src/3/bsd-gettext-0.0
# gmake install >/dev/null 2>&1
# echo $?
0
# LANGUAGE=sv /usr/local/bin/gettext
/usr/local/bin/gettext: argument saknas
#

--

Rick Robino v. (503) 891-9283
Wave Division Consulting @. wavedivision.com

#3Alessio Bragadini
alessio@albourne.com
In reply to: Peter Eisentraut (#1)
Re: BSD gettext

Peter Eisentraut wrote:

This is a compilation of the BSD-licensed gettext tools from NetBSD plus
some of my own code, put into a (hopefully) portable package, intended to
be evaluated for possible use in PostgreSQL. Give it a try if you're
interested. I've already tried it on FreeBSD, Linux, and Unixware, so
don't bother with those.

I tried on Digital Unix 4.0f, using Digital cc:

Making all in gettext
make[2]: Entering directory `/tmp/bsd-gettext-0.0/gettext'
cc -DHAVE_CONFIG_H -I. -I. -I..
-DLOCALEDIR=\"/tmp/gettext/share/locale\" -I ../libintl -g -c
gettext-main.c
cc: Severe: ../config.h, line 36: Cannot find file <unistd.h> specified
in #include directive. (noinclfilef)
#include <unistd.h>
-^
make[2]: *** [gettext-main.o] Error 1

Using gcc it breaks when linking against snprintf (this can be worked
around)

Hope it helps.

--
Alessio F. Bragadini alessio@albourne.com
APL Financial Services http://village.albourne.com
Nicosia, Cyprus phone: +357-2-755750

"It is more complicated than you think"
-- The Eighth Networking Truth from RFC 1925

#4Noname
pgsql-hackers@thewrittenword.com
In reply to: Alessio Bragadini (#3)
Re: Re: BSD gettext

On Wed, May 23, 2001 at 10:55:35AM +0300, Alessio Bragadini wrote:

Peter Eisentraut wrote:

This is a compilation of the BSD-licensed gettext tools from NetBSD plus
some of my own code, put into a (hopefully) portable package, intended to
be evaluated for possible use in PostgreSQL. Give it a try if you're
interested. I've already tried it on FreeBSD, Linux, and Unixware, so
don't bother with those.

I tried on Digital Unix 4.0f, using Digital cc:

Making all in gettext
make[2]: Entering directory `/tmp/bsd-gettext-0.0/gettext'
cc -DHAVE_CONFIG_H -I. -I. -I..
-DLOCALEDIR=\"/tmp/gettext/share/locale\" -I ../libintl -g -c
gettext-main.c
cc: Severe: ../config.h, line 36: Cannot find file <unistd.h> specified
in #include directive. (noinclfilef)
#include <unistd.h>
-^
make[2]: *** [gettext-main.o] Error 1

Make sure you have no spaces after -I on Tru64 UNIX.

--
albert chin (china@thewrittenword.com)

#5Alessio Bragadini
alessio@albourne.com
In reply to: Noname (#4)
Re: BSD gettext

pgsql-hackers@thewrittenword.com wrote:

Make sure you have no spaces after -I on Tru64 UNIX.

That was it, thanks. Sent a micro-patch to Peter.

--
Alessio F. Bragadini alessio@albourne.com
APL Financial Services http://village.albourne.com
Nicosia, Cyprus phone: +357-2-755750

"It is more complicated than you think"
-- The Eighth Networking Truth from RFC 1925

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#1)
Re: BSD gettext

Peter Eisentraut <peter_e@gmx.net> writes:

This is a compilation of the BSD-licensed gettext tools from NetBSD plus
some of my own code, put into a (hopefully) portable package, intended to
be evaluated for possible use in PostgreSQL. Give it a try if you're
interested.

On HPUX 10.20:

make[2]: Entering directory `/home/tgl/pgsql/bsd-gettext-0.0/libintl'
/bin/sh ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -g -O2 -c gettext.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -g -O2 -c gettext.c -o gettext.o
gettext.c: In function `mapit':
gettext.c:313: `MAP_FAILED' undeclared (first use in this function)
gettext.c:313: (Each undeclared identifier is reported only once
gettext.c:313: for each function it appears in.)
gettext.c: In function `unmapit':
gettext.c:442: `MAP_FAILED' undeclared (first use in this function)
make[2]: *** [gettext.lo] Error 1

The HPUX man page for mmap documents its failure return value as "-1",
so I hacked around this with

#ifndef MAP_FAILED
#define MAP_FAILED ((void *) (-1))
#endif

whereupon it built and passed the simple self-test you suggested.
However, I think it's pretty foolish to depend on mmap for such
little reason as this code does. I suggest ripping out the mmap
usage and just reading the file with good old read(2).

regards, tom lane

#7Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#6)
Re: BSD gettext

The HPUX man page for mmap documents its failure return value as "-1",
so I hacked around this with

#ifndef MAP_FAILED
#define MAP_FAILED ((void *) (-1))
#endif

whereupon it built and passed the simple self-test you suggested.
However, I think it's pretty foolish to depend on mmap for such
little reason as this code does. I suggest ripping out the mmap
usage and just reading the file with good old read(2).

Agreed. Let read() use mmap() internally if it wants to.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#8Noname
ncm@zembu.com
In reply to: Bruce Momjian (#7)
Re: BSD gettext

On Thu, May 24, 2001 at 10:30:01AM -0400, Bruce Momjian wrote:

The HPUX man page for mmap documents its failure return value as "-1",
so I hacked around this with

#ifndef MAP_FAILED
#define MAP_FAILED ((void *) (-1))
#endif

whereupon it built and passed the simple self-test you suggested.
However, I think it's pretty foolish to depend on mmap for such
little reason as this code does. I suggest ripping out the mmap
usage and just reading the file with good old read(2).

Agreed. Let read() use mmap() internally if it wants to.

The reason mmap() is faster than read() is that it can avoid copying
data to the place you specify. read() can "use mmap() internally" only
in cases rare enough to hardly be worth checking for.

Stdio is often able to use mmap() internally for parsing, and in
glibc-2.x (and, I think, on recent Solarix and BSDs) it does. Usually,
therefore, it would be better to use stdio functions (except fread()!)
in place of read(), where possible, to allow this optimization.

Using mmap() in place of disk read() almost always results in enough
performance improvement to make doing so worth a lot of disruption.
Today mmap() is used heavily enough, in important programs, that
worries about unreliability are no better founded than worries about
read().

Nathan Myers
ncm@zembu.com

#9Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#6)
Re: BSD gettext

Tom Lane writes:

However, I think it's pretty foolish to depend on mmap for such
little reason as this code does. I suggest ripping out the mmap
usage and just reading the file with good old read(2).

I'm prepared to do that if mmap doesn't work for someone, but I'm not
eager to fork the code without proven breakage.

--
Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter