changeset 4523:6cc4874a100b

Work around the lack of wcslen() on Solaris 2.5.1.
author Bruno Haible <bruno@clisp.org>
date Mon, 11 Aug 2003 13:02:26 +0000
parents b2da55c5313c
children 5546f601135b
files lib/ChangeLog lib/vasnprintf.c m4/ChangeLog m4/vasnprintf.m4
diffstat 4 files changed, 30 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -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
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -47,6 +47,24 @@
 # 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 @@
 # 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
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -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";
--- a/m4/vasnprintf.m4
+++ b/m4/vasnprintf.m4
@@ -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_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.