Patch for iconv-impaired systems



Hi,

recently I tried to compile GLib on aome platform (I forgot which) without
iconv. I will commit the following patch, if noone objects:

Now g_convert_* just throws an error, if called on a platfrom without iconv.
That makes GLib at least compile. It might however be a good idea to at least
implement some basic and often wanted conversions explicity on such platforms
later. 

The guard for including iconv.h is HAVE_ICONV and not HAVE_ICONV_H, because I
hope, that UNIX has learned its leassons and now standardize the header names
as well, i.e. "iconv exists iff iconv.h exists and has the prototype".

The patch is attached.

Bye,
Sebastian
-- 
Sebastian Wilhelmi
mailto:wilhelmi ira uka de
http://goethe.ira.uka.de/~wilhelmi
Index: configure.in
===================================================================
RCS file: /cvs/gnome/glib/configure.in,v
retrieving revision 1.156
diff -u -b -B -r1.156 configure.in
--- configure.in	2000/10/30 21:55:21	1.156
+++ configure.in	2000/11/07 09:38:56
@@ -351,7 +351,7 @@
 GLIB_SIZEOF([$size_includes], intmax_t, intmax_t)
 
 # Check for some functions
-AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf strcasecmp strncasecmp poll getcwd)
+AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf strcasecmp strncasecmp poll getcwd iconv)
 
 # Check if bcopy can be used for overlapping copies, if memmove isn't found.
 # The check is borrowed from the PERL Configure script.
Index: gconvert.c
===================================================================
RCS file: /cvs/gnome/glib/gconvert.c,v
retrieving revision 1.4
diff -u -b -B -r1.4 gconvert.c
--- gconvert.c	2000/10/19 15:21:03	1.4
+++ gconvert.c	2000/11/07 09:38:56
@@ -20,7 +20,14 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_ICONV
 #include <iconv.h>
+#endif /* HAVE_ICONV */
+
 #include <errno.h>
 #include <string.h>
 
@@ -37,6 +44,7 @@
   return quark;
 }
 
+#ifdef HAVE_ICONV
 static iconv_t
 open_converter (const gchar *to_codeset,
 		const gchar *from_codeset,
@@ -60,6 +68,7 @@
   return cd;
 
 }
+#endif /* HAVE_ICONV */
 
 /**
  * g_convert:
@@ -95,6 +104,7 @@
 	   gint        *bytes_written,
 	   GError     **error)
 {
+#ifdef HAVE_ICONV
   gchar *dest;
   gchar *outp;
   const gchar *p;
@@ -184,6 +194,12 @@
     }
   else
     return dest;
+#else /* !HAVE_ICONV */
+  g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_NO_CONVERSION,
+	       _("Conversion from character set `%s' to `%s' is not supported"),
+	       from_codeset, to_codeset);
+  return NULL;
+#endif /* !HAVE_ICONV */
 }
 
 /**
@@ -232,6 +248,7 @@
 			 gint        *bytes_written,
 			 GError     **error)
 {
+#ifdef HAVE_ICONV
   gchar *utf8;
   gchar *dest;
   gchar *outp;
@@ -401,4 +418,10 @@
     }
   else
     return dest;
+#else /* !HAVE_ICONV */
+  g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_NO_CONVERSION,
+	       _("Conversion from character set `%s' to `%s' is not supported"),
+	       from_codeset, to_codeset);
+  return NULL;
+#endif /* !HAVE_ICONV */
 }


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