[PATCH] Msg file always needs '\n' before EOF (Re: What should go into 1.5.7?)
[bug] Mutt sometimes fails to convert a message file
from $charset to $send_charset.
[detail] If a Japanese message file doesn't end with '\n',
mutt finishes converting it from $charset to $iso-2022-jp
without turning back to US-ASCII.
Mutt should terminate ISO-2022-JP state.
[stability] Many Japanese users have used this patch
(included in JA patch) for yeas.
No side effects have been found so far.
[credit] TAKIZAWA Takashi wrote it.
--
tamo
EOF must be '\n' in any cases. Otherwise, mutt cannot detect some charset.
This patch makes sure that all messages end with '\n'.
--- mutt-1.5.6.orig/PATCHES Mon Feb 2 02:42:47 2004
+++ mutt-1.5.6/PATCHES Sat Feb 14 10:02:10 2004
@@ -0,0 +1 @@
+patch-1.5.6.tt.fix_eof.1
--- mutt-1.5.6.orig/curs_lib.c Wed Nov 5 18:41:31 2003
+++ mutt-1.5.6/curs_lib.c Sat Feb 14 10:01:29 2004
@@ -139,6 +139,19 @@
CLEARLINE (LINES-1);
}
+static void fix_end_of_file (const char *data)
+{
+ FILE *fp;
+ int c;
+
+ if ((fp = safe_fopen (data, "a+")) == NULL)
+ return;
+ fseek (fp,-1,SEEK_END);
+ if ((c = fgetc(fp)) != '\n')
+ fputc ('\n', fp);
+ safe_fclose (&fp);
+}
+
void mutt_edit_file (const char *editor, const char *data)
{
char cmd[LONG_STRING];
@@ -147,6 +160,7 @@
mutt_expand_file_fmt (cmd, sizeof (cmd), editor, data);
if (mutt_system (cmd) == -1)
mutt_error (_("Error running \"%s\"!"), cmd);
+ fix_end_of_file (data);
keypad (stdscr, TRUE);
clearok (stdscr, TRUE);
}