From: Joël Riou Date: Mon, 12 Apr 2004 19:42:10 +0000 (+0000) Subject: Introduce config_charset. X-Git-Tag: mutt-1-5-15-rel~197 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=50cf25b02315c95ab5e4505a35ea0f52c268a06a;p=mutt Introduce config_charset. --- diff --git a/globals.h b/globals.h index 3774797f..8841c854 100644 --- 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 f6568e9f..3d1c13a0 100644 --- 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(¤tline, 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(¤tline); break; + } } else + { if (rc < 0) rc = -1; + } + if (conv) + FREE(¤tline); } FREE (&token.data); FREE (&linebuf); diff --git a/init.h b/init.h index 7d2c772f..97fc23ef 100644 --- 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