diff options
author | zzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-20 13:41:02 +0000 |
---|---|---|
committer | zzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-20 13:41:02 +0000 |
commit | b4489ae953601cceb30e5dbdac5fe213ecad1b75 (patch) | |
tree | 0e8bea2d6e4a0cdfc900c835653a83a2637ff740 /sample/from.rb | |
parent | 368cecc1517ba2a09b0413eeaf5c3ba9981de4db (diff) |
* sample/*: whitespace patch by Sergio Campama [Fixes GH-364]
https://github.com/ruby/ruby/pull/364
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/from.rb')
-rw-r--r-- | sample/from.rb | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/sample/from.rb b/sample/from.rb index 918745e55f..db1299c869 100644 --- a/sample/from.rb +++ b/sample/from.rb @@ -43,8 +43,8 @@ def get_mailfile(user) [ENV['SPOOLDIR'], '/usr/spool', '/var/spool', '/usr', '/var'].each do |m| path = "#{m}/mail/#{user}" if File.exist?(path) - file = path - break + file = path + break end end end @@ -64,23 +64,23 @@ def from_main mtime = File.mtime(file) open(file, "r") do |f| until f.eof? - header = {} - f.each_line do |line| - next if /^From / =~ line # skip From-line - break if /^$/ =~ line # end of header - - if /^(?<attr>\S+?):\s*(?<value>.*)/ =~ line - attr.capitalize! - header[attr] = value - elsif attr - header[attr] += "\n" + line.lstrip - end - end - - f.each_line do |line| - break if /^From / =~ line - end - outcount += fromout(header['Date'], header['From'], header['Subject']) + header = {} + f.each_line do |line| + next if /^From / =~ line # skip From-line + break if /^$/ =~ line # end of header + + if /^(?<attr>\S+?):\s*(?<value>.*)/ =~ line + attr.capitalize! + header[attr] = value + elsif attr + header[attr] += "\n" + line.lstrip + end + end + + f.each_line do |line| + break if /^From / =~ line + end + outcount += fromout(header['Date'], header['From'], header['Subject']) end end File.utime(atime, mtime, file) |