"Fixing my FORTRAN". Ensure we always have some valid char converter for the
authorJeremy Allison <jra@samba.org>
Thu, 1 Apr 2004 19:42:36 +0000 (19:42 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 1 Apr 2004 19:42:36 +0000 (19:42 +0000)
neccessary types before we will run at all. If we can't get one, use ASCII
but complain mightily.
Jeremy.

source/lib/charcnv.c

index 11b1448f1eb228dc314e130df8d87561fe3bba48..b9791931a35d45b28cb508848f663248ec4d25eb 100644 (file)
@@ -130,9 +130,21 @@ void init_iconv(void)
 
                        conv_handles[c1][c2] = smb_iconv_open(n2,n1);
                        if (conv_handles[c1][c2] == (smb_iconv_t)-1) {
-                               DEBUG(0,("Conversion from %s to %s not supported\n",
+                               DEBUG(0,("init_iconv: Conversion from %s to %s not supported\n",
                                         charset_name((charset_t)c1), charset_name((charset_t)c2)));
-                               conv_handles[c1][c2] = NULL;
+                               if (c1 != CH_UCS2) {
+                                       n1 = "ASCII";
+                               }
+                               if (c2 != CH_UCS2) {
+                                       n2 = "ASCII";
+                               }
+                               DEBUG(0,("init_iconv: Attempting to replace with conversion from %s to %s\n",
+                                       n1, n2 ));
+                               conv_handles[c1][c2] = smb_iconv_open(n2,n1);
+                               if (!conv_handles[c1][c2]) {
+                                       DEBUG(0,("init_iconv: Conversion from %s to %s failed", n1, n2));
+                                       smb_panic("init_iconv: conv_handle initialization failed.");
+                               }
                        }
                }
        }
@@ -477,8 +489,6 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
        if (descriptor == (smb_iconv_t)-1 || descriptor == (smb_iconv_t)0) {
                if (!conv_silent)
                        DEBUG(0,("convert_string_allocate: Conversion not supported.\n"));
-               if (allow_bad_conv)
-                       goto use_as_is;
                return (size_t)-1;
        }