Subject: [sup-talk] [PATCH] Fix for some warnings

From: [email-masked] (Marcus Williams)
Date: Fri, 11 Jan 2008 11:09:12 +0000

This patch fixes a couple of warnings in message and message-chunks.
The first is because a log message uses the from address before it is
assigned, the second is because @lines is uninitialised in some cases
(a sourceforge message in my case that didnt have any text content)

This stops the console getting filled with warnings on spam.

Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: warnings-patch
Type: application/octet-stream
Size: 1668 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20080111/07581dd7/attachment.obj

---

From: [email-masked] (William Morgan)
Date: Sat, 12 Jan 2008 18:32:20 -0800

Hi Marcus,

>          returning("sup-faked-" + Digest::MD5.hexdigest(raw_header)) do |id|
> -          Redwood::log "faking message-id for message from #@from: #{id}"
> +          fakeid = id
>          end

In this case, we can just assign the result directly to fakeid rather
than using the k-combinator (aka "returning"). Also there was a bit of
extraneous whitespace introduced at the end of one line in that patch,
which became obvious when I did a git diff --color.

Can you try using git-format-patch to send the patch? It will create a
nice email out of a commit for you, which I can then apply without too
much effort. (Or if you're feeling courageous, use git-send-email, which
will also do the emailing for you.)

I'm going to add a page to the wiki with an overview of git, branching,
and submitting patches.

-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (William Morgan)
Date: Sat, 12 Jan 2008 19:32:04 -0800

Excerpts from William Morgan's message of Sat Jan 12 18:32:20 -0800 2008:
> I'm going to add a page to the wiki with an overview of git,
> branching, and submitting patches.

http://sup.rubyforge.org/wiki/wiki.pl?Contributing

---

From: [email-masked] (Marcus Williams)
Date: Sun, 13 Jan 2008 18:19:46 +0000

> which became obvious when I did a git diff --color.

Yep, sorry sent the patch in half cocked and realised this afterwards.
Will resubmit tonight sometime.

MArcus

---

From: [email-masked] (William Morgan)
Date: Sun, 13 Jan 2008 18:17:26 -0800

> http://sup.rubyforge.org/wiki/wiki.pl?Contributing

I've updated this with a bit more information on how to create a
beautiful patch. Comments welcome.

---

From: [email-masked] (Marcus Williams)
Date: Tue, 15 Jan 2008 14:02:27 +0000

Fixes a few unitialised variable warnings when logging faked message
addresses or faked message ids. Also initialises the @lines var when the
message is not text.
---
 lib/sup/message-chunks.rb |    1 +
 lib/sup/message.rb        |   17 ++++++++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/sup/message-chunks.rb b/lib/sup/message-chunks.rb
index 2fcf8f9..08dcf27 100644
--- a/lib/sup/message-chunks.rb
+++ b/lib/sup/message-chunks.rb
@@ -82,6 +82,7 @@ EOS
                           :sibling_types => sibling_types
         end
 
+      @lines = nil
       if text
         @lines = text.gsub("\r\n", "\n").gsub(/\t/, "        ").gsub(/\r/, "").split("\n")
         @quotable = true
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index 65aebd5..bd37162 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -60,25 +60,28 @@ class Message
 
   def parse_header header
     header.each { |k, v| header[k.downcase] = v }
-    
+
+    fakeid = nil
+    fakename = nil
+
     @id =
       if header["message-id"]
         sanitize_message_id header["message-id"]
       else
-        returning("sup-faked-" + Digest::MD5.hexdigest(raw_header)) do |id|
-          Redwood::log "faking message-id for message from #@from: #{id}"
-        end
+        fakeid = "sup-faked-" + Digest::MD5.hexdigest(raw_header)
       end
     
     @from =
       if header["from"]
         PersonManager.person_for header["from"]
       else
-        name = "Sup Auto-generated Fake Sender <sup at fake.sender.example.com>"
-        Redwood::log "faking from for message #@id: #{name}"
-        PersonManager.person_for name
+        fakename = "Sup Auto-generated Fake Sender <sup at fake.sender.example.com>"
+        PersonManager.person_for fakename
       end
 
+    Redwood::log "faking message-id for message from #@from: #{id}" if fakeid
+    Redwood::log "faking from for message #@id: #{fakename}" if fakename
+
     date = header["date"]
     @date =
       case date
-- 
1.5.3.7

---

From: [email-masked] (William Morgan)
Date: Tue, 15 Jan 2008 17:32:31 -0800

Reformatted excerpts from Marcus Williams's message of 2008-01-15:
> addresses or faked message ids. Also initialises the @lines var when
> the message is not text.

Applied to next. I think it's probably safe enough for master but I
wanted to give those of you who get such poorly-behaved email a chance
to test it out.