glib/gnulib/vasnprintf.c wcslen() patch for Solaris 2.5.1



glib/gnulib/vasnprintf.c in glib-2.4.2 uses wcslen() which is defined
in -lw on Solaris 2.5.1. The patch below fixes this in the same way
that
http://savannah.gnu.org/cgi-bin/viewcvs/gnulib/gnulib/lib/vasnprintf.c?rev=1.13&content-type=text/vnd.viewcvs-markup
fixes it. However, the gnulib vasnprintf.c file is licensed under the
GPL whereas the version in glib is licensed under the LGPL. So, I
presume I cannot use this solution?

According to glib/gnulib/README,
  The files
 
   asnprintf.c 
   printf-args.c
   printf-args.h
   printf-parse.c
   printf-parse.h
   vasnprintf.c
   vasnprintf.h

  are taken from the vasnprintf module of the GNUlib package, which can
  be found at: 

   http://www.gnu.org/software/gnulib/

Were the files in http://www.gnu.org/software/gnulib/ ever licensed
under the LGPL?

-- 
albert chin (china thewrittenword com)

-- snip snip
--- glib/gnulib/vasnprintf.c.orig	2004-07-07 13:47:49.332468000 -0500
+++ glib/gnulib/vasnprintf.c	2004-07-07 13:54:40.647870000 -0500
@@ -50,6 +50,29 @@
 # 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.
+      Define this substitute only once, even if this file is included
+      twice in the same compilation unit.  */
+#  ifndef local_wcslen_defined
+#   define local_wcslen_defined 1
+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
+#endif
+
 #ifndef HAVE_LONG_LONG_FORMAT
 static int
 print_long_long (char *buf, 
@@ -539,7 +562,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
--- configure.in.orig	2004-07-01 10:02:29.774232000 -0500
+++ configure.in	2004-07-07 13:53:08.979174000 -0500
@@ -786,7 +744,7 @@
 AC_TYPE_SIZE_T
 AC_CHECK_TYPES(ptrdiff_t)
 jm_AC_TYPE_INTMAX_T
-AC_CHECK_FUNCS(snprintf)
+AC_CHECK_FUNCS(snprintf wcslen)
 AC_FUNC_SNPRINTF_C99
 
 # Check if bcopy can be used for overlapping copies, if memmove isn't found.



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