]> Dogcows Code - chaz/tar/blobdiff - lib/unicodeio.c
(EILSEQ): Include <time.h> and <wchar.h> if <errno.h> does not define
[chaz/tar] / lib / unicodeio.c
index 3a5448f059791a625a812189282f20832219eaf1..35bb68075ccdf69c8896157f2138bea7977305e9 100644 (file)
 #ifndef errno
 extern int errno;
 #endif
+
+/* Define EILSEQ and ENOTSUP as portably as possible.  Some
+   nonstandard systems, like SunOS 4, don't have EILSEQ.  Others, like
+   BSD/OS 4.1, define it in <wchar.h>.  Callers that use EILSEQ and/or
+   ENOTSUP and that want to be portable to these nonstandard systems
+   should mimic the following includes and defines.  */
+
+/* BSD/OS 4.1 wchar.h defines EILSEQ, but it requires FILE (defined in
+   <stdio.h>, included above) and struct tm (defined in <time.h>) to
+   be declared.  */
+#if HAVE_WCHAR_H && ! defined EILSEQ
+# include <time.h>
+# include <wchar.h>
+#endif
+
+/* Do not define EILSEQ to be EINVAL, since callers may want to
+   distinguish EINVAL and EILSEQ.  */
 #ifndef EILSEQ
-# define EILSEQ EINVAL
+# define EILSEQ ENOENT
 #endif
 #ifndef ENOTSUP
 # define ENOTSUP EINVAL
@@ -48,11 +65,8 @@ extern int errno;
 # include <iconv.h>
 #endif
 
-#if ENABLE_NLS
-# include <libintl.h>
-# define _(Text) gettext (Text)
-#else
-# define _(Text) Text
+#if HAVE_LANGINFO_CODESET && ! USE_INCLUDED_LIBINTL
+# include <langinfo.h>
 #endif
 
 #include "unicodeio.h"
@@ -133,8 +147,18 @@ unicode_to_mb (unsigned int code,
 
   if (!initialized)
     {
+      const char *charset;
+
+#if USE_INCLUDED_LIBINTL
       extern const char *locale_charset PARAMS ((void));
-      const char *charset = locale_charset ();
+      charset = locale_charset ();
+#else
+# if HAVE_LANGINFO_CODESET
+      charset = nl_langinfo (CODESET);
+# else
+      charset = "";
+# endif
+#endif
 
       is_utf8 = !strcmp (charset, UTF8_NAME);
 #if HAVE_ICONV
This page took 0.023652 seconds and 4 git commands to generate.