bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] vasnprintf.m4 patch for Solaris 2.5.1 wcslen problem


From: Bruno Haible
Subject: Re: [Bug-gnulib] vasnprintf.m4 patch for Solaris 2.5.1 wcslen problem
Date: Mon, 11 Aug 2003 15:02:16 +0200
User-agent: KMail/1.5

Paul Eggert wrote:

> > wcslen                              ../lib/libfetish.a(vasnprintf.o) 
> > (symbol belongs to implicit dependency /usr/lib/libw.so.1)
>
> This problem arises because Solaris 2.5.1 puts the following functions
> into /usr/lib/libw.so.1, so you need to link with -lw if you use any
> of these functions:
>
>    fgetwc fputwc getwc isenglish isideogram isnumber isphonogram isspecial
>    iswalnum iswalpha iswcntrl iswctype iswdigit iswgraph iswlower iswprint
>    iswpunct iswspace iswupper iswxdigit mbftowc putwc scrwidth towlower
>    towupper ungetwc watoll wcscat wcschr wcscmp wcscoll wcscpy wcscspn
>    wcslen wcsncat wcsncmp wcsncpy wcspbrk wcsrchr wcstod wcstok wcstol
>    wcstoul wcswcs wcswidth wcsxfrm wctype wcwidth wscasecmp wscat wschr
>    wscmp wscoll wscpy wscspn wslen wsncasecmp wsncat wsncmp wsncpy wspbrk
>    wsrchr wstod wstok wstol wstoll wsxfrm

Thanks for the analysis.

>       * m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF):
>       Solaris 2.5.1 needs -lw to get the wcslen function.

Since vasnprintf.c is also used by libintl (starting from gettext-0.12.2),
this would imply making a dependency from libintl.so to libw.so, thus
slowing down all internationalized applications... I prefer the appended
patch, which I'm committing into gnulib.

> I notice that other gnulib modules use the above functions.

- In fnmatch.c it is no problem because HANDLE_MULTIBYTE is only defined
  if mbsrtowcs() is found, which is not the case on Solaris 2.5.1.
- In regex.c it is no problem because gnulib doesn't compile regex with
  MBS_SUPPORT.
- In strftime.c it is no problem gnulib doesn't compile strftime with
  COMPILE_WIDE.

Bruno



2003-08-11  Bruno Haible  <address@hidden>

        * vasnprintf.c (local_wcslen): New function, for Solaris 2.5.1.
        (vasnprintf): Use it instead of wcslen.

diff -c -3 -r1.4 vasnprintf.c
*** vasnprintf.c        15 Jul 2003 12:42:06 -0000      1.4
--- vasnprintf.c        11 Aug 2003 12:57:29 -0000
***************
*** 47,52 ****
--- 47,70 ----
  # define freea(p) free (p) 
  #endif
  
+ #ifdef HAVE_WCHAR_T
+ # ifdef HAVE_WCSLEN
+ #  define local_wcslen wcslen
+ # else
+    /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
+       a dependency towards this library, here is a local substitute.  */
+ static size_t
+ local_wcslen (const wchar_t *s)
+ {
+   const wchar_t *ptr;
+ 
+   for (ptr = s; *ptr != (wchar_t) 0; ptr++)
+     ;
+   return ptr - s;
+ }
+ # endif
+ #endif
+ 
  char *
  vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list 
args)
  {
***************
*** 368,374 ****
  # ifdef HAVE_WCHAR_T
                      if (type == TYPE_WIDE_STRING)
                        tmp_length =
!                         wcslen (a.arg[dp->arg_index].a.a_wide_string)
                          * MB_CUR_MAX;
                      else
  # endif
--- 386,392 ----
  # ifdef HAVE_WCHAR_T
                      if (type == TYPE_WIDE_STRING)
                        tmp_length =
!                         local_wcslen (a.arg[dp->arg_index].a.a_wide_string)
                          * MB_CUR_MAX;
                      else
  # endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]