Use p_new instead of xmalloc()
[apps/madmutt.git] / handler.c
index 2ecf577..27bfb08 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -270,16 +270,14 @@ void mutt_decode_base64 (STATE * s, long len, int istext, iconv_t cd)
   state_reset_prefix (s);
 }
 
-static unsigned char decode_byte (char ch)
+static unsigned char decode_byte(int ch)
 {
-  if (ch == 96)
-    return 0;
-  return ch - 32;
+    return ch == 96 ? 0 : ch - 32;
 }
 
 static void mutt_decode_uuencoded (STATE * s, long len, int istext, iconv_t cd)
 {
-  char tmps[SHORT_STRING];
+  char tmps[STRING];
   char linelen, c, l, out;
   char *pt;
   char bufi[BUFI_SIZE];
@@ -302,13 +300,13 @@ static void mutt_decode_uuencoded (STATE * s, long len, int istext, iconv_t cd)
     if (!m_strncmp(tmps, "end", 3))
       break;
     pt = tmps;
-    linelen = decode_byte (*pt);
+    linelen = decode_byte(*pt);
     pt++;
     for (c = 0; c < linelen;) {
       for (l = 2; l <= 6; l += 2) {
-        out = decode_byte (*pt) << l;
+        out = decode_byte(*pt) << l;
         pt++;
-        out |= (decode_byte (*pt) >> (6 - l));
+        out |= (decode_byte(*pt) >> (6 - l));
         bufi[k++] = out;
         c++;
         if (c == linelen)
@@ -340,22 +338,21 @@ static struct {
   const char *tag_name;
   int index;
 } EnrichedTags[] = {
-  {
-  "param", RICH_PARAM}, {
-  "bold", RICH_BOLD}, {
-  "italic", RICH_ITALIC}, {
-  "underline", RICH_UNDERLINE}, {
-  "nofill", RICH_NOFILL}, {
-  "excerpt", RICH_EXCERPT}, {
-  "indent", RICH_INDENT}, {
-  "indentright", RICH_INDENT_RIGHT}, {
-  "center", RICH_CENTER}, {
-  "flushleft", RICH_FLUSHLEFT}, {
-  "flushright", RICH_FLUSHRIGHT}, {
-  "flushboth", RICH_FLUSHLEFT}, {
-  "color", RICH_COLOR}, {
-  "x-color", RICH_COLOR}, {
-  NULL, -1}
+  {"param", RICH_PARAM},
+  {"bold", RICH_BOLD},
+  {"italic", RICH_ITALIC},
+  {"underline", RICH_UNDERLINE},
+  {"nofill", RICH_NOFILL},
+  {"excerpt", RICH_EXCERPT},
+  {"indent", RICH_INDENT},
+  {"indentright", RICH_INDENT_RIGHT},
+  {"center", RICH_CENTER},
+  {"flushleft", RICH_FLUSHLEFT},
+  {"flushright", RICH_FLUSHRIGHT},
+  {"flushboth", RICH_FLUSHLEFT},
+  {"color", RICH_COLOR},
+  {"x-color", RICH_COLOR},
+  {NULL, -1}
 };
 
 struct enriched_state {
@@ -541,8 +538,7 @@ static void enriched_putc (int c, struct enriched_state *stte)
       else {
         stte->buffer[stte->buff_used++] = c;
       }
-    }
-    else {
+    } else {
       stte->buffer[stte->buff_used++] = c;
     }
     stte->word_len++;
@@ -1085,8 +1081,7 @@ static int autoview_handler (BODY * a, STATE * s)
     if (!piped) {
       m_fclose(&fpin);
       thepid = mutt_create_filter (command, NULL, &fpout, &fperr);
-    }
-    else {
+    } else {
       unlink (tempfile);
       fflush (fpin);
       rewind (fpin);
@@ -1124,8 +1119,7 @@ static int autoview_handler (BODY * a, STATE * s)
           state_puts (buffer, s);
         }
       }
-    }
-    else {
+    } else {
       mutt_copy_stream (fpout, s->fpout);
       /* Check for stderr messages */
       if (fgets (buffer, sizeof (buffer), fperr)) {
@@ -1219,8 +1213,7 @@ static int external_body_handler (BODY * b, STATE * s)
                      (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
                      CH_DECODE, NULL);
     }
-  }
-  else {
+  } else {
     if (s->flags & M_DISPLAY) {
       state_mark_attach (s);
       state_printf (s,
@@ -1376,11 +1369,10 @@ int mutt_body_handler (BODY * b, STATE * s)
     fseeko (s->fpin, b->offset, 0);
 
     /* see if we need to decode this part before processing it */
-    if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE || b->encoding == ENCUUENCODED || plaintext || mutt_is_text_part (b)) {   /* text subtypes may
-                                                                                                                                                 * require character
-                                                                                                                                                 * set conversion even
-                                                                                                                                                 * with 8bit encoding.
-                                                                                                                                                 */
+    if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE
+    ||  b->encoding == ENCUUENCODED || plaintext || mutt_is_text_part (b)) {
+        /* text subtypes may require character set conversion even with 8bit
+           encoding.  */
       int origType = b->type;
       char *savePrefix = NULL;