]> granicus.if.org Git - mutt/commitdiff
Minor charset fixes. Users can now give any character set names in
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 14 Feb 2001 08:03:22 +0000 (08:03 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 14 Feb 2001 08:03:22 +0000 (08:03 +0000)
rfc2047.c
sendlib.c

index 69159bf5fcf2deeea5c45c0be751ad4c34b27159..f8565f6c2213d9c8e6f51dac193a2ace3b2ed4ed 100644 (file)
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -87,6 +87,7 @@ static size_t convert_string (const char *f, size_t flen,
 char *mutt_choose_charset (const char *fromcode, const char *charsets,
                      char *u, size_t ulen, char **d, size_t *dlen)
 {
+  char canonical_buff[LONG_STRING];
   char *e = 0, *tocode = 0;
   size_t elen = 0, bestn = 0;
   const char *p, *q;
@@ -142,6 +143,9 @@ char *mutt_choose_charset (const char *fromcode, const char *charsets,
       *d = e;
     if (dlen)
       *dlen = elen;
+    
+    mutt_canonical_charset (canonical_buff, sizeof (canonical_buff), tocode);
+    mutt_str_replace (&tocode, canonical_buff);
   }
   return tocode;
 }
index 257640172adeace00cbf1a40f47196263b0f4954..f7269919273040b27fb58b595dc70a90b503ddef 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -680,14 +680,11 @@ static size_t convert_file_to (FILE *file, const char *fromcode,
   if (cd1 == (iconv_t)(-1))
     return -1;
 
-  cd = safe_malloc (ncodes * sizeof (iconv_t));
-  score = safe_malloc (ncodes * sizeof (size_t));
-  states = safe_malloc (ncodes * sizeof (CONTENT_STATE));
-  infos = safe_malloc (ncodes * sizeof (CONTENT));
-
-  memset (score, 0, ncodes * sizeof (size_t));
-  memset (states, 0, ncodes * sizeof (CONTENT_STATE));
-  memset (infos, 0, ncodes * sizeof (CONTENT));
+  cd     = safe_malloc (ncodes * sizeof (iconv_t));
+  score  = safe_calloc (1, ncodes * sizeof (size_t));
+  states = safe_calloc (1, ncodes * sizeof (CONTENT_STATE));
+  infos  = safe_calloc (1, ncodes * sizeof (CONTENT));
+
   for (i = 0; i < ncodes; i++)
     if (strcasecmp (tocodes[i], "UTF-8"))
       cd[i] = mutt_iconv_open (tocodes[i], "UTF-8", 0);
@@ -912,7 +909,7 @@ CONTENT *mutt_get_content_info (const char *fname, BODY *b)
       if (!chs)
       {
        mutt_canonical_charset (chsbuf, sizeof (chsbuf), tocode);
-       mutt_set_parameter ("charset", tocode, &b->parameter);
+       mutt_set_parameter ("charset", chsbuf, &b->parameter);
       }
       safe_free ((void **) &tocode);
       safe_fclose (&fp);