]> granicus.if.org Git - mutt/commitdiff
Add a character set comparison function.
authorThomas Roessler <roessler@does-not-exist.org>
Fri, 8 Sep 2000 08:05:17 +0000 (08:05 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Fri, 8 Sep 2000 08:05:17 +0000 (08:05 +0000)
charset.c
protos.h
rfc2231.c
sendlib.c

index 325f023b3c0b4507005fa2af17054865595db37e..af4ecded779e60d615e683aa798d9697f346c617 100644 (file)
--- a/charset.c
+++ b/charset.c
@@ -232,15 +232,14 @@ void mutt_canonical_charset (char *dest, size_t dlen, const char *name)
       *p += 'a' - 'A';
 }
 
-int mutt_is_utf8 (const char *s)
+int mutt_chscmp (const char *s, const char *chs)
 {
-  char buffer[8];
+  char buffer[STRING];
 
-  if (!s) 
-    return 0;
+  if (!s) return 0;
 
   mutt_canonical_charset (buffer, sizeof (buffer), s);
-  return !mutt_strcmp (buffer, "utf-8");
+  return !mutt_strcasecmp (buffer, chs);
 }
 
 
index 40cbdfeef5d54c799dfe1e94b1812d5f7bea3035..e582aa4c6f4241036050ac2a5b9c1ac49635774c 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -246,7 +246,9 @@ int mutt_display_message (HEADER *h);
 int mutt_edit_attachment(BODY *);
 int mutt_edit_message (CONTEXT *, HEADER *);
 int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags);
-int mutt_is_utf8 (const char *);
+int mutt_chscmp (const char *s, const char *chs);
+#define mutt_is_utf8(a) mutt_chscmp (a, "utf-8")
+#define mutt_is_us_ascii(a) mutt_chscmp (a, "us-ascii")
 int mutt_parent_message (CONTEXT *, HEADER *);
 int mutt_prepare_template(FILE*, CONTEXT *, HEADER *, HEADER *, short);
 int mutt_resend_message (FILE *, CONTEXT *, HEADER *);
index f2d01bd570568f4b80dbf70a9567326f67434345..92e94202f7f7cec9dc52d46cebd7e17d3c37962e 100644 (file)
--- a/rfc2231.c
+++ b/rfc2231.c
@@ -330,7 +330,7 @@ int rfc2231_encode_string (char **pd)
     d = *pd, dlen = strlen (d);
   }
 
-  if (strcasecmp (charset, "us-ascii"))
+  if (!mutt_is_us_ascii (charset))
     encode = 1;
 
   for (s = d, slen = dlen; slen; s++, slen--)
index 6f991ff49773972cae6ac752c5c26eb24ee3ec45..c3aca6ae2193c8251521cb7776a8b9607f789911 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1225,7 +1225,7 @@ void mutt_update_encoding (BODY *a)
   char chsbuff[STRING];
 
   /* override noconv when it's us-ascii */
-  if (!mutt_strcasecmp (mutt_get_body_charset (chsbuff, sizeof (chsbuff), a), "us-ascii"))
+  if (mutt_is_us_ascii (mutt_get_body_charset (chsbuff, sizeof (chsbuff), a)))
     a->noconv = 0;
 
   if (!a->force_charset && !a->noconv)