]> granicus.if.org Git - mutt/commitdiff
Introduce config_charset.
authorJoël Riou <joel.riou@normalesup.org>
Mon, 12 Apr 2004 19:42:10 +0000 (19:42 +0000)
committerJoël Riou <joel.riou@normalesup.org>
Mon, 12 Apr 2004 19:42:10 +0000 (19:42 +0000)
globals.h
init.c
init.h

index 3774797f6745ed4a1faf719a82d26b19ad1cbf58..8841c854f74c60622d062fed1f0d4839404bcacb 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -37,6 +37,7 @@ WHERE char *Attribution;
 WHERE char *AttachFormat;
 WHERE char *Charset;
 WHERE char *ComposeFormat;
+WHERE char *ConfigCharset;
 WHERE char *ContentType;
 WHERE char *DefaultHook;
 WHERE char *DateFmt;
diff --git a/init.c b/init.c
index f6568e9f2d1e0e6639888b9a26712dccd67ea312..3d1c13a0496ba6a4e4b2b5e7f5a862314790aa2b 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1363,9 +1363,10 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
 static int source_rc (const char *rcfile, BUFFER *err)
 {
   FILE *f;
-  int line = 0, rc = 0;
+  int line = 0, rc = 0, conv = 0;
   BUFFER token;
   char *linebuf = NULL;
+  char *currentline = NULL;
   size_t buflen;
   pid_t pid;
 
@@ -1378,15 +1379,32 @@ static int source_rc (const char *rcfile, BUFFER *err)
   memset (&token, 0, sizeof (token));
   while ((linebuf = mutt_read_line (linebuf, &buflen, f, &line)) != NULL)
   {
-    if (mutt_parse_rc_line (linebuf, &token, err) == -1)
+    conv=ConfigCharset && (*ConfigCharset) && Charset;
+    if (conv) 
+    {
+      currentline=safe_strdup(linebuf);
+      if (!currentline) continue;
+      mutt_convert_string(&currentline, ConfigCharset, Charset, 0);
+    } 
+    else 
+      currentline=linebuf;
+
+    if (mutt_parse_rc_line (currentline, &token, err) == -1)
     {
       mutt_error (_("Error in %s, line %d: %s"), rcfile, line, err->data);
-      if (--rc < -MAXERRS)
+      if (--rc < -MAXERRS) 
+      {
+        if (conv) FREE(&currentline);
         break;
+      }
     }
     else
+    {
       if (rc < 0)
         rc = -1;
+    }
+    if (conv) 
+      FREE(&currentline);
   }
   FREE (&token.data);
   FREE (&linebuf);
diff --git a/init.h b/init.h
index 7d2c772ffbbba1a3ce18ab725122731b91d88070..97fc23ef397ee68af65d733eea73747255c5f0cf 100644 (file)
--- a/init.h
+++ b/init.h
@@ -322,6 +322,12 @@ struct option_t MuttVars[] = {
   ** See the text describing the ``$$status_format'' option for more 
   ** information on how to set ``$$compose_format''.
   */
+  { "config_charset",  DT_STR,  R_NONE, UL &ConfigCharset, UL 0 },
+  /*
+  ** .pp
+  ** When defined, Mutt will recode commands in rc files from this
+  ** encoding.
+  */
   { "confirmappend",   DT_BOOL, R_NONE, OPTCONFIRMAPPEND, 1 },
   /*
   ** .pp