Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 09 Sep 2012 00:14:24 -0700
From:      Jan Beich <jbeich@tormail.org>
To:        Zhihao Yuan <lichray@gmail.com>
Cc:        Gabor Kovesdan <gabor@kovesdan.org>, Mike Manilone <crtmike@gmx.us>, freebsd-stable@freebsd.org
Subject:   Re: A BSD-licensed internationalization solution?
Message-ID:  <1TAbjH-00087E-6x@internal.tormail.org>
In-Reply-To: <CAGsORuD9SraSzq8nfhrJTU5eGwh80XGOg%2BtPnvNLrDong9KFtg@mail.gmail.com> (Zhihao Yuan's message of "Sat, 8 Sep 2012 07:27:59 -0500")
References:  <504B206E.7000409@gmx.us> <CAGsORuD9SraSzq8nfhrJTU5eGwh80XGOg%2BtPnvNLrDong9KFtg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
Content-Type: text/plain

Zhihao Yuan <lichray@gmail.com> writes:

>>
>> Here are many applications using GNU gettext to provide an
>> internationalized user interface. But I found that there isn't a
>> BSD-licensed gettext. (so BSD apps do not have internationalization?)
>>
>> Is there one? Then I can just switch from gettext to that.
>
> libintl is LGPL, we don't have license issues against it.

There is BSD licensed libintl, though. It seems to work fine with GPL
gettext/msgfmt tools and no recompilation (libmap.conf trick).

# grep for "citrus"
http://www.netbsd.org/docs/software/3rdparty/


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=libintl_freebsd.diff
Content-Description: integrate libintl into base

Index: lib/Makefile
===================================================================
--- lib/Makefile	(revision 240180)
+++ lib/Makefile	(working copy)
@@ -37,6 +37,7 @@ SUBDIR_ORDERED=	${_csu} \
 	libcrypt \
 	libelf \
 	${_libiconv_modules} \
+	${_libintl} \
 	libkvm \
 	msun \
 	libmd \
@@ -166,6 +167,7 @@ _librpcsec_gss=	librpcsec_gss
 
 .if ${MK_ICONV} != "no"
 _libiconv_modules=	libiconv_modules
+_libintl=	libintl
 .endif
 
 .if ${MK_IPX} != "no"
Index: lib/libc/iconv/Symbol.map
===================================================================
--- lib/libc/iconv/Symbol.map	(revision 240180)
+++ lib/libc/iconv/Symbol.map	(working copy)
@@ -39,6 +39,7 @@ FBSDprivate_1.0 {
 	_citrus_bcs_strtoul;
 	_citrus_bcs_tolower;
 	_citrus_bcs_toupper;
+	_citrus_bcs_trunc_rws_len;
 	_citrus_bcs_trunc_ws_len;
 	_citrus_csmapper_open;
 	_citrus_csmapper_close;
Index: lib/libintl/Makefile
===================================================================
RCS file: /cvsroot/src/lib/libintl/Makefile,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile
--- lib/libintl/Makefile	14 May 2005 17:58:56 -0000	1.6
+++ lib/libintl/Makefile	9 Sep 2012 03:46:47 -0000
@@ -1,15 +1,13 @@
 #	$NetBSD: Makefile,v 1.6 2005/05/14 17:58:56 tshiozak Exp $
 
-.include <bsd.own.mk>
-
 LIB=	intl
+SHLIB_MAJOR=	1
 SRCS=	gettext.c textdomain.c gettext_iconv.c gettext_dummy.c strhash.c \
 	sysdep.c plural_parser.c
 INCS=	libintl.h
-INCSDIR=/usr/include
+CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../libc
 
-#CFLAGS+=-g
-CPPFLAGS+=-I${.CURDIR} -I${.CURDIR}/../libc
+NO_WCAST_ALIGN.clang=
 
 MAN=	gettext.3
 MLINKS=	gettext.3 dgettext.3 gettext.3 dcgettext.3 \
Index: lib/libintl/gettext.c
===================================================================
RCS file: /cvsroot/src/lib/libintl/gettext.c,v
retrieving revision 1.28
diff -u -p -r1.28 gettext.c
--- lib/libintl/gettext.c	30 Jul 2012 23:04:42 -0000	1.28
+++ lib/libintl/gettext.c	9 Sep 2012 03:46:47 -0000
@@ -290,7 +290,9 @@ validate(void *arg, struct mohandle *moh
 static __inline uint32_t
 calc_collision_step(uint32_t hashval, uint32_t hashsize)
 {
-	_DIAGASSERT(hashsize>2);
+#ifdef DIAGNOSTIC
+	assert(hashsize > 2);
+#endif
 	return (hashval % (hashsize - 2)) + 1;
 }
 
@@ -856,7 +856,7 @@ get_indexed_string(const char *str, size
 }
 
 #define	_NGETTEXT_DEFAULT(msgid1, msgid2, n)	\
-	((char *)__UNCONST((n) == 1 ? (msgid1) : (msgid2)))
+	__DECONST(char *, (n) == 1 ? (msgid1) : (msgid2))
 
 char *
 dcngettext(const char *domainname, const char *msgid1, const char *msgid2,
@@ -970,7 +970,7 @@ found:
 		msgid = v;
 	}
 
-	return (char *)__UNCONST(msgid);
+	return __DECONST(char *, msgid);
 
 fail:
 	return _NGETTEXT_DEFAULT(msgid1, msgid2, n);
Index: lib/libintl/gettext_iconv.c
===================================================================
RCS file: /cvsroot/src/lib/libintl/gettext_iconv.c,v
retrieving revision 1.8
diff -u -p -r1.8 gettext_iconv.c
--- lib/libintl/gettext_iconv.c	18 Feb 2009 13:08:22 -0000	1.8
+++ lib/libintl/gettext_iconv.c	9 Sep 2012 05:57:56 -0000
@@ -55,7 +55,7 @@ static void *cacheroot;
 
 /* ARGSUSED1 */
 static const struct cache *
-cache_find(const char *msg, struct domainbinding *db)
+cache_find(const char *msg, struct domainbinding *db __unused)
 {
 	struct cache key;
 	struct cache **c;
Index: lib/libintl/libintl.h
===================================================================
RCS file: /cvsroot/src/lib/libintl/libintl.h,v
retrieving revision 1.4
diff -u -p -r1.4 libintl.h
--- lib/libintl/libintl.h	14 Oct 2011 22:42:01 -0000	1.4
+++ lib/libintl/libintl.h	9 Sep 2012 03:46:47 -0000
@@ -31,6 +31,16 @@
 
 #include <sys/cdefs.h>
 
+#define gettext libintl_gettext
+#define dgettext libintl_dgettext
+#define dcgettext libintl_dcgettext
+#define ngettext libintl_ngettext
+#define dngettext libintl_dngettext
+#define dcngettext libintl_dcngettext
+#define textdomain libintl_textdomain
+#define bindtextdomain libintl_bindtextdomain
+#define bind_textdomain_codeset libintl_bind_textdomain_codeset
+
 __BEGIN_DECLS
 char *gettext(const char *) __format_arg(1);
 char *dgettext(const char *, const char *) __format_arg(2);
Index: lib/libintl/plural_parser.c
===================================================================
RCS file: /cvsroot/src/lib/libintl/plural_parser.c,v
retrieving revision 1.2
diff -u -p -r1.2 plural_parser.c
--- lib/libintl/plural_parser.c	17 Jan 2007 23:24:22 -0000	1.2
+++ lib/libintl/plural_parser.c	9 Sep 2012 03:46:48 -0000
@@ -34,10 +34,10 @@ __RCSID("$NetBSD: plural_parser.c,v 1.2 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <citrus/citrus_namespace.h>
-#include <citrus/citrus_region.h>
-#include <citrus/citrus_memstream.h>
-#include <citrus/citrus_bcs.h>
+#include <iconv/citrus_namespace.h>
+#include <iconv/citrus_region.h>
+#include <iconv/citrus_memstream.h>
+#include <iconv/citrus_bcs.h>
 #include "plural_parser.h"
 
 #if defined(TEST_TOKENIZER) || defined(TEST_PARSER)
@@ -893,7 +893,7 @@ region_skip_ws(struct _region *r)
 	size_t len = _region_size(r);
 
 	str = _bcs_skip_ws_len(str, &len);
-	_region_init(r, __UNCONST(str), len);
+	_region_init(r, __DECONST(void *, str), len);
 }
 
 static void
@@ -903,7 +903,7 @@ region_trunc_rws(struct _region *r)
 	size_t len = _region_size(r);
 
 	_bcs_trunc_rws_len(str, &len);
-	_region_init(r, __UNCONST(str), len);
+	_region_init(r, __DECONST(void *, str), len);
 }
 
 static int
@@ -1028,7 +1028,7 @@ parse_plural(struct parser_element **rpe
 {
 	struct _region r;
 
-	_region_init(&r, __UNCONST(str), len);
+	_region_init(&r, __DECONST(void *, str), len);
 
 	if (find_plural_forms(&r))
 		return T_NOTFOUND;
@@ -1090,7 +1090,7 @@ _gettext_parse_plural(struct gettext_plu
 unsigned long
 _gettext_calculate_plural(const struct gettext_plural *pe, unsigned long n)
 {
-	return calculate_plural((void *)__UNCONST(pe), n);
+	return calculate_plural(__DECONST(void *, pe), n);
 }
 
 void
Index: lib/libintl/strhash.c
===================================================================
RCS file: /cvsroot/src/lib/libintl/strhash.c,v
retrieving revision 1.3
diff -u -p -r1.3 strhash.c
--- lib/libintl/strhash.c	25 Sep 2007 08:19:09 -0000	1.3
+++ lib/libintl/strhash.c	9 Sep 2012 03:46:48 -0000
@@ -38,7 +38,7 @@ __RCSID("$NetBSD: strhash.c,v 1.3 2007/0
 
 /*
  * string hash function by P.J.Weinberger.
- * this implementation is derived from src/lib/libc/citrus/citrus_db_hash.c.
+ * this implementation is derived from src/lib/libc/iconv/citrus_db_hash.c.
  */
 uint32_t
 /*ARGSUSED*/
Index: lib/libintl/textdomain.c
===================================================================
RCS file: /cvsroot/src/lib/libintl/textdomain.c,v
retrieving revision 1.13
diff -u -p -r1.13 textdomain.c
--- lib/libintl/textdomain.c	21 Mar 2012 10:10:36 -0000	1.13
+++ lib/libintl/textdomain.c	9 Sep 2012 03:46:48 -0000
@@ -96,7 +96,7 @@ bindtextdomain(const char *domainname, c
 		if (p)
 			return (p->path);
 		else
-			return (char *)__UNCONST(_PATH_TEXTDOMAIN);
+			return __DECONST(char *, _PATH_TEXTDOMAIN);
 	}
 
 	strlcpy(p->path, dirname, sizeof(p->path));

--=-=-=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1TAbjH-00087E-6x>