X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-mime%2Frfc3676.c;h=3caa76f42d1296e82e710684992d99bd953a9729;hp=e9ae0a7054fec78d3f057f77c2b2af3bb3a2a04a;hb=819c071fa7efc8dffb4dd92f36f0111227ff692f;hpb=16536d59024177409f49134c3f03f69855c144b9 diff --git a/lib-mime/rfc3676.c b/lib-mime/rfc3676.c index e9ae0a7..3caa76f 100644 --- a/lib-mime/rfc3676.c +++ b/lib-mime/rfc3676.c @@ -11,7 +11,9 @@ #include -#include +#include + +#include #include "state.h" #include "rfc3676.h" @@ -40,15 +42,12 @@ static void print_flowed_line (char *line, STATE * s, int ql) { width = MaxLineLength; } else { - if (option (OPTMBOXPANE)) - width = COLS - SidebarWidth - WrapMargin - ql - 1; - else - width = COLS - WrapMargin - ql - 1; + width = getmaxx(main_w) - WrapMargin - ql - 1; if (!(s->flags & M_REPLYING) && option (OPTSTUFFQUOTED)) --width; if (width < 0) - width = COLS; + width = getmaxx(main_w); } if (m_strlen(line) == 0) { @@ -163,7 +162,7 @@ int rfc3676_handler (BODY * a, STATE * s) { * which may make the line look like fixed although it wasn't * so keep this in mind for later processing */ fixed = buf_len == 0 || buf[buf_len - 1] != ' ' || - (strcmp(buf + buf_off, "-- ") == 0); + (m_strcmp(buf + buf_off, "-- ") == 0); if (delsp && buf_len >= 1 && buf[buf_len-1] == ' ') buf[--buf_len] = '\0'; @@ -178,14 +177,14 @@ int rfc3676_handler (BODY * a, STATE * s) { } /* signature separator also flushes the previous paragraph */ - if (strcmp(buf + buf_off, "-- ") == 0 && curline && *curline) { + if (m_strcmp(buf + buf_off, "-- ") == 0 && curline && *curline) { print_flowed_line (curline, s, quotelevel); *curline = '\0'; curline_len = 1; } p_realloc(&curline, curline_len + buf_len - buf_off); - strcpy (curline + curline_len - 1, buf + buf_off); + m_strcpy(curline + curline_len - 1, buf_len - buf_off + 1, buf + buf_off); curline_len += buf_len - buf_off; /* if this was a fixed line the paragraph is finished */ @@ -200,6 +199,18 @@ int rfc3676_handler (BODY * a, STATE * s) { return (0); } +/* sets mtime of 'to' to mtime of 'from' */ +static void mutt_set_mtime (const char* from, const char* to) { + struct utimbuf utim; + struct stat st; + + if (stat (from, &st) != -1) { + utim.actime = st.st_mtime; + utim.modtime = st.st_mtime; + utime (to, &utim); + } +} + void rfc3676_space_stuff (HEADER* hdr) { FILE* in = NULL, *out = NULL; char buf[LONG_STRING]; @@ -210,20 +221,21 @@ void rfc3676_space_stuff (HEADER* hdr) { if ((in = safe_fopen (hdr->content->filename, "r")) == NULL) return; - mutt_mktemp (tmpf); - if ((out = safe_fopen (tmpf, "w+")) == NULL) { - fclose (in); + + out = m_tempfile(tmpf, sizeof(tmpf), NONULL(mod_core.tmpdir), NULL); + if (!out) { + m_fclose(&in); return; } - while (fgets (buf, sizeof (buf), in)) { + while (fgets(buf, sizeof (buf), in)) { if (m_strncmp("From ", buf, 4) == 0 || buf[0] == ' ') { fputc (' ', out); } fputs (buf, out); } - fclose (in); - fclose (out); + m_fclose(&in); + m_fclose(&out); mutt_set_mtime (hdr->content->filename, tmpf); unlink (hdr->content->filename); m_strreplace(&hdr->content->filename, tmpf);