Rocco Rutte:
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Mon, 22 Aug 2005 21:26:53 +0000 (21:26 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Mon, 22 Aug 2005 21:26:53 +0000 (21:26 +0000)
- for vvv.nntp, don't duplicate code from mutt_read_rfc822_header()

git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@428 e385b8ad-14ed-0310-8656-cc95a2468c6d

nntp/nntp.c
parse.c
rfc2047.c
rfc2047.h

index aebf3c4..64a6434 100644 (file)
@@ -570,23 +570,10 @@ static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr)
       break;
     case 1:
       hdr->env->subject = str_dup (b);
-      /* Now we need to do the things which would normally be done in 
-       * mutt_read_rfc822_header() */
-      if (hdr->env->subject) {
-        regmatch_t pmatch[1];
-
-        rfc2047_decode (&hdr->env->subject);
-
-        if (regexec (ReplyRegexp.rx, hdr->env->subject, 1, pmatch, 0) == 0)
-          hdr->env->real_subj = hdr->env->subject + pmatch[0].rm_eo;
-        else
-          hdr->env->real_subj = hdr->env->subject;
-      }
       break;
     case 2:
       rfc822_free_address (&hdr->env->from);
       hdr->env->from = rfc822_parse_adrlist (hdr->env->from, b);
-      rfc2047_decode_adrlist (hdr->env->from);
       /* same as for mutt_parse_rfc822_line():
        * don't leave from info NULL if there's an invalid address (or
        * whatever) in From: field; mutt would just display it as empty
@@ -622,6 +609,7 @@ static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr)
       hdr->env->xref = str_dup (b);
       nntp_parse_xref (ctx, nntp_data->group, b, hdr);
     }
+    rfc2047_decode_envelope (hdr->env);
     if (!*p)
       return -1;
     b = p;
diff --git a/parse.c b/parse.c
index 34ba5ce..c5b6aac 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -1393,31 +1393,11 @@ ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs,
   if (hdr) {
     hdr->content->hdr_offset = hdr->offset;
     hdr->content->offset = ftell (f);
-
-    /* do RFC2047 decoding */
-    rfc2047_decode_adrlist (e->from);
-    rfc2047_decode_adrlist (e->to);
-    rfc2047_decode_adrlist (e->cc);
-    rfc2047_decode_adrlist (e->bcc);
-    rfc2047_decode_adrlist (e->reply_to);
-    rfc2047_decode_adrlist (e->mail_followup_to);
-    rfc2047_decode_adrlist (e->return_path);
-    rfc2047_decode_adrlist (e->sender);
-
-    if (e->subject) {
-      regmatch_t pmatch[1];
-
-      rfc2047_decode (&e->subject);
-
-      if (regexec (ReplyRegexp.rx, e->subject, 1, pmatch, 0) == 0)
-        e->real_subj = e->subject + pmatch[0].rm_eo;
-      else
-        e->real_subj = e->subject;
-    }
-
+    rfc2047_decode_envelope (e);
     /* check for missing or invalid date */
     if (hdr->date_sent <= 0) {
-      debug_print (1, ("no date found, using received time from msg separator\n"));
+      debug_print (1, ("no date found, using received "
+                       "time from msg separator\n"));
       hdr->date_sent = hdr->received;
     }
   }
index 7fc21d0..50304c6 100644 (file)
--- a/rfc2047.c
+++ b/rfc2047.c
@@ -801,3 +801,30 @@ void rfc2047_decode_adrlist (ADDRESS * a)
     a = a->next;
   }
 }
+
+void rfc2047_decode_envelope (ENVELOPE* e) {
+
+  if (!e)
+    return;
+
+  /* do RFC2047 decoding */
+  rfc2047_decode_adrlist (e->from);
+  rfc2047_decode_adrlist (e->to);
+  rfc2047_decode_adrlist (e->cc);
+  rfc2047_decode_adrlist (e->bcc);
+  rfc2047_decode_adrlist (e->reply_to);
+  rfc2047_decode_adrlist (e->mail_followup_to);
+  rfc2047_decode_adrlist (e->return_path);
+  rfc2047_decode_adrlist (e->sender);
+
+  if (e->subject) {
+    regmatch_t pmatch[1];
+
+    rfc2047_decode (&e->subject);
+
+    if (regexec (ReplyRegexp.rx, e->subject, 1, pmatch, 0) == 0)
+      e->real_subj = e->subject + pmatch[0].rm_eo;
+    else
+      e->real_subj = e->subject;
+  }
+}
index 5c09280..e05e558 100644 (file)
--- a/rfc2047.h
+++ b/rfc2047.h
@@ -17,3 +17,5 @@ void rfc2047_encode_adrlist (ADDRESS *, const char *);
 
 void rfc2047_decode (char **);
 void rfc2047_decode_adrlist (ADDRESS *);
+
+void rfc2047_decode_envelope (ENVELOPE* e);