[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-libunistring] Re: gnulib integration
From: |
Bruno Haible |
Subject: |
[bug-libunistring] Re: gnulib integration |
Date: |
Wed, 15 Sep 2010 03:30:50 +0200 |
User-agent: |
KMail/1.9.9 |
Hi Pádraig,
> I'm not using the 'libunistring-optional' module for the moment.
Thanks for clarifying. So, just the 'libunistring' and 'unistr/u8-mbtouc-unsafe'
modules.
> When building using the 'libunistring' module with libunistring installed,
> I get a compile warning saying u8_mbtouc_unsafe() is undeclared,
> which is because it's ifdefed out in gnulib/lib/unistr.h
This sounds like a bug. It took me a while to guess the instructions how to
reproduce it:
$ ./gnulib-tool --create-testdir --dir=/tmp/testdir1 --with-tests \
--avoid=unistr/u8-mbtouc-unsafe \
libunistring unistr/u16-mbtouc unistr/u8-mbtouc-unsafe-tests
then build that directory against an older libunistring installation:
$ ./configure --prefix=/arch/x86-linux/gnu-inst-libunistring/0.9.1.1
This results in:
unistr/test-u8-mbtouc-unsafe.c: In function 'main':
unistr/test-u8-mbtouc-unsafe.c:30: error: 'u8_mbtouc_unsafe' undeclared
(first use in this function)
unistr/test-u8-mbtouc-unsafe.c:30: error: (Each undeclared identifier is
reported only once
unistr/test-u8-mbtouc-unsafe.c:30: error: for each function it appears in.)
make[4]: *** [unistr/test-u8-mbtouc-unsafe.o] Error 1
The attached patch fixes it. Committed.
> > So, you need to link every coreutils program that uses the <unistr.h> or
> > similar include files with $(LIBUNISTRING).
>
> That's fair enough. However there is a 16% startup overhead
> when linking `printf` against libunistring as tested with:
> time seq 1000 | xargs -n1 ./printf
> It's a pity that this overhead is introduced just for u8_uctomb_aux().
> I was just wondering if there was an easy way to use the gnulib version
> of this function, even if libunistring is installed and
> I include the libunistring module.
OK, now you have explained it well, now I understand :-)
The east way to achieve this is:
1. Request module 'unistr/u8-uctomb-aux' from gnulib.
2. Add to configure.ac:
AM_CONDITIONAL([LIBUNISTRING_COMPILE_UNISTR_U8_MBTOUC_UNSAFE], [true])
3. Don't add $(LIBUNISTRING) to the link options of the 'printf' program.
Bruno
2010-09-14 Bruno Haible <address@hidden>
unistr/base: Avoid link errors when module 'libunistring' is also used.
* lib/unistr.in.h (u8_mbtouc_unsafe, u16_mbtouc_unsafe,
u32_mbtouc_unsafe, u8_mbtouc, u16_mbtouc, u32_mbtouc, u8_mbtoucr,
u16_mbtoucr, u32_mbtoucr, u8_uctomb_aux, u16_uctomb_aux, u32_uctomb):
Declare also when HAVE_LIBUNISTRING is set.
Reported by Pádraig Brady <address@hidden>.
--- lib/unistr.in.h.orig Wed Sep 15 02:40:52 2010
+++ lib/unistr.in.h Wed Sep 15 02:38:03 2010
@@ -134,7 +134,7 @@
/* The variants with _safe suffix are safe, even if the library is compiled
without --enable-safety. */
-#ifdef GNULIB_UNISTR_U8_MBTOUC_UNSAFE
+#if GNULIB_UNISTR_U8_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n);
@@ -157,7 +157,7 @@
# endif
#endif
-#ifdef GNULIB_UNISTR_U16_MBTOUC_UNSAFE
+#if GNULIB_UNISTR_U16_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n);
@@ -180,7 +180,7 @@
# endif
#endif
-#ifdef GNULIB_UNISTR_U32_MBTOUC_UNSAFE
+#if GNULIB_UNISTR_U32_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n);
@@ -205,7 +205,7 @@
# endif
#endif
-#ifdef GNULIB_UNISTR_U8_MBTOUC
+#if GNULIB_UNISTR_U8_MBTOUC || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n);
@@ -228,7 +228,7 @@
# endif
#endif
-#ifdef GNULIB_UNISTR_U16_MBTOUC
+#if GNULIB_UNISTR_U16_MBTOUC || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n);
@@ -251,7 +251,7 @@
# endif
#endif
-#ifdef GNULIB_UNISTR_U32_MBTOUC
+#if GNULIB_UNISTR_U32_MBTOUC || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n);
@@ -279,17 +279,17 @@
/* Similar to u*_mbtouc(), except that the return value gives more details
about the failure, similar to mbrtowc(). */
-#ifdef GNULIB_UNISTR_U8_MBTOUCR
+#if GNULIB_UNISTR_U8_MBTOUCR || HAVE_LIBUNISTRING
extern int
u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n);
#endif
-#ifdef GNULIB_UNISTR_U16_MBTOUCR
+#if GNULIB_UNISTR_U16_MBTOUCR || HAVE_LIBUNISTRING
extern int
u16_mbtoucr (ucs4_t *puc, const uint16_t *s, size_t n);
#endif
-#ifdef GNULIB_UNISTR_U32_MBTOUCR
+#if GNULIB_UNISTR_U32_MBTOUCR || HAVE_LIBUNISTRING
extern int
u32_mbtoucr (ucs4_t *puc, const uint32_t *s, size_t n);
#endif
@@ -300,7 +300,7 @@
/* Similar to wctomb(), except that s must not be NULL, and the argument n
must be specified. */
-#ifdef GNULIB_UNISTR_U8_UCTOMB
+#if GNULIB_UNISTR_U8_UCTOMB || HAVE_LIBUNISTRING
/* Auxiliary function, also used by u8_chr, u8_strchr, u8_strrchr. */
extern int
u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n);
@@ -322,7 +322,7 @@
# endif
#endif
-#ifdef GNULIB_UNISTR_U16_UCTOMB
+#if GNULIB_UNISTR_U16_UCTOMB || HAVE_LIBUNISTRING
/* Auxiliary function, also used by u16_chr, u16_strchr, u16_strrchr. */
extern int
u16_uctomb_aux (uint16_t *s, ucs4_t uc, int n);
@@ -344,7 +344,7 @@
# endif
#endif
-#ifdef GNULIB_UNISTR_U32_UCTOMB
+#if GNULIB_UNISTR_U32_UCTOMB || HAVE_LIBUNISTRING
# if !HAVE_INLINE
extern int
u32_uctomb (uint32_t *s, ucs4_t uc, int n);