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 e08573f9fef6f536f8d7e40272aef3e649df5d67..451a2249f1a03e0d5424a9efe4b42e156620963c 100644 (file)
@@ -1,3 +1,8 @@
+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
index 994f99348382a9fb56335fb539352d5dd75f6b05..de1224a77e8749df755c2f1497b4240e4b746d1c 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 b4e396f33d944bbdd869d8ade231c2b1d56cbcfc..15ab932bb93ee12f3ac3e6156c55db07496eca0b 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 b520581e0314431054a1dd81c07f0a9967936a56..2cbee3af97be3b99d9a08a9a98c758f79828cac4 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.