X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=state.c;h=f21db7e62b30bd3b09181de3312a8272742a6e6f;hp=3dfdbfbbebff0b6f05ee17e2bb7d280b976e1f8f;hb=e4704214cabdd0b6e10b27cff5e2194959559809;hpb=618ceafdc9564dbb8f3bf45c3869297a1d5a3320 diff --git a/state.c b/state.c index 3dfdbfb..f21db7e 100644 --- a/state.c +++ b/state.c @@ -6,20 +6,15 @@ * It's licensed under the GNU General Public License, * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -#include "config.h" -#endif -#include -#include +#include + +#include #include "mutt.h" #include "state.h" -#include "rfc3676.h" - -#include "lib/debug.h" -static void state_prefix_put (const char *d, size_t dlen, STATE * s) +static void state_prefix_put (const char *d, ssize_t dlen, STATE * s) { if (s->prefix) while (dlen--) @@ -28,17 +23,17 @@ static void state_prefix_put (const char *d, size_t dlen, STATE * s) fwrite (d, dlen, 1, s->fpout); } -void mutt_convert_to_state (iconv_t cd, char *bufi, size_t * l, STATE * s) +void mutt_convert_to_state (iconv_t cd, char *bufi, ssize_t * l, STATE * s) { char bufo[BUFO_SIZE]; - ICONV_CONST char *ib; + const char *ib; char *ob; - size_t ibl, obl; + ssize_t ibl, obl; if (!bufi) { - if (cd != (iconv_t) (-1)) { + if (cd != MUTT_ICONV_ERROR) { ob = bufo, obl = sizeof (bufo); - iconv (cd, 0, 0, &ob, &obl); + my_iconv(cd, 0, 0, &ob, &obl); if (ob != bufo) state_prefix_put (bufo, ob - bufo, s); } @@ -47,7 +42,7 @@ void mutt_convert_to_state (iconv_t cd, char *bufi, size_t * l, STATE * s) return; } - if (cd == (iconv_t) (-1)) { + if (cd == MUTT_ICONV_ERROR) { state_prefix_put (bufi, *l, s); *l = 0; return; @@ -70,16 +65,13 @@ void state_prefix_putc (char c, STATE * s) if (s->flags & M_PENDINGPREFIX) { int i; - i = str_len (Quotebuf); + i = m_strlen(Quotebuf); Quotebuf[i++] = c; Quotebuf[i] = '\0'; if (i == sizeof (Quotebuf) - 1 || c == '\n') { - char buf[2 * SHORT_STRING]; + char buf[2 * STRING]; int j = 0, offset = 0; regmatch_t pmatch[1]; -#ifdef DEBUG - unsigned char save = '\0'; -#endif state_reset_prefix (s); while (regexec @@ -90,27 +82,17 @@ void state_prefix_putc (char c, STATE * s) if (!option (OPTQUOTEEMPTY) && Quotebuf[offset] == '\n') { buf[0] = '\n'; buf[1] = '\0'; - } else if (option (OPTTEXTFLOWED)) - rfc3676_quote_line (s, buf, sizeof (buf), Quotebuf); - else if (option (OPTQUOTEQUOTED) && offset) { + } + else if (!option (OPTTEXTFLOWED) && option (OPTQUOTEQUOTED) && offset) { for (i = 0; i < offset; i++) if (Quotebuf[i] != ' ') j = i; - strncpy (buf, Quotebuf, j + 1); - strcpy (buf + j + 1, Quotebuf + j); + m_strncpy(buf, sizeof(buf), Quotebuf, j + 1); + m_strcpy(buf + j + 1, sizeof(buf) - j - 1, Quotebuf + j); } else snprintf (buf, sizeof (buf), "%s%s", NONULL (s->prefix), Quotebuf); -#ifdef DEBUG - if (str_len (buf) >= 2) { - save = buf[str_len (buf) - 1]; - buf[str_len (buf) - 1] = '\0'; - debug_print (2, ("buf = '%s'\n", buf)); - buf[str_len (buf)] = save; - } -#endif - state_puts (buf, s); } } @@ -137,7 +119,7 @@ int state_printf (STATE * s, const char *fmt, ...) void state_mark_attach (STATE * s) { - if ((s->flags & M_DISPLAY) && !str_cmp (Pager, "builtin")) + if (s->flags & M_DISPLAY) state_puts (AttachmentMarker, s); }