Work around the lack of wcslen() on Solaris 2.5.1.
authorBruno Haible <bruno@clisp.org>
Mon, 11 Aug 2003 13:02:26 +0000 (13:02 +0000)
committerBruno Haible <bruno@clisp.org>
Mon, 11 Aug 2003 13:02:26 +0000 (13:02 +0000)
lib/ChangeLog
lib/vasnprintf.c
m4/ChangeLog
m4/vasnprintf.m4

index e08573f..451a224 100644 (file)
@@ -1,5 +1,10 @@
 2003-08-11  Bruno Haible  <bruno@clisp.org>
 
+       * vasnprintf.c (local_wcslen): New function, for Solaris 2.5.1.
+       (vasnprintf): Use it instead of wcslen.
+
+2003-08-11  Bruno Haible  <bruno@clisp.org>
+
        * stdbool_.h (_Bool): Undo last change; instead use a negative enum
        value to ensure that _Bool promotes to int. Use #define for _Bool when
        using the Solaris C compiler. Adds comments suggested by Paul Eggert.
index 994f993..de1224a 100644 (file)
 # 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,7 +386,7 @@ vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
 # ifdef HAVE_WCHAR_T
                      if (type == TYPE_WIDE_STRING)
                        tmp_length =
-                         wcslen (a.arg[dp->arg_index].a.a_wide_string)
+                         local_wcslen (a.arg[dp->arg_index].a.a_wide_string)
                          * MB_CUR_MAX;
                      else
 # endif
index b4e396f..15ab932 100644 (file)
@@ -1,3 +1,7 @@
+2003-08-11  Bruno Haible  <bruno@clisp.org>
+
+       * vasnprintf.m4 (gl_PREREQ_VASNPRINTF): Also check for wcslen.
+
 2003-08-09  Paul Eggert  <eggert@twinsun.com>
 
        * regex.m4 (jm_INCLUDED_REGEX): Change "\201" to "\371";
index b520581..2cbee3a 100644 (file)
@@ -1,4 +1,4 @@
-# vasnprintf.m4 serial 1
+# vasnprintf.m4 serial 2
 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -50,7 +50,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF],
   AC_REQUIRE([gt_TYPE_LONGDOUBLE])
   AC_REQUIRE([gt_TYPE_WCHAR_T])
   AC_REQUIRE([gt_TYPE_WINT_T])
-  AC_CHECK_FUNCS(snprintf)
+  AC_CHECK_FUNCS(snprintf wcslen)
 ])
 
 # Prerequisites of lib/asnprintf.c.