From a3bb3fc0be841b35f089935afac64289da9b5978 Mon Sep 17 00:00:00 2001 From: epg <> Date: Mon, 30 Dec 2002 02:25:03 +0000 Subject: [PATCH] (logincoming): Move part of log_headers here. (log_headers): Pass the array of contents for each header to logincoming rather than indexing here. logincoming now checks for an empty array (i.e. message missing this header) before trying to index into it (it used to bomb). --- minc | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/minc b/minc index 070e22f..9f3f9ac 100755 --- a/minc +++ b/minc @@ -246,22 +246,34 @@ sub mylog { } } -sub logincoming { mylog('info', INCOMINGCHAR, @_); } sub logsave { mylog('notice', SAVECHAR, @_); } sub loginfo { mylog('info', INFOCHAR, @_); } sub logdebug { mylog('debug', DEBUGCHAR, @_); } sub logwarn { mylog('warning', WARNCHAR, @_); } sub logerr { mylog('error', ERRORCHAR, @_); } +sub logincoming { + my ($text, @contents) = @_; + my $last; + + if (@contents) { + $last = $contents[-1]; + } else { + $last = ''; + } + + mylog('info', INCOMINGCHAR, $text, $last); +} + sub log_headers { my %headers = @_; # For an explanation of the %headers structure, see the # get_headers function below. - logincoming('From: ', @{$headers{'return-path'}}[-1]); - logincoming('To: ', @{$headers{'to'}}[-1]); - logincoming('Subject: ', @{$headers{'subject'}}[-1]); - logincoming('Message-Id: ', @{$headers{'message-id'}}[-1]); + logincoming('From: ', @{$headers{'return-path'}}); + logincoming('To: ', @{$headers{'to'}}); + logincoming('Subject: ', @{$headers{'subject'}}); + logincoming('Message-Id: ', @{$headers{'message-id'}}); } -- 2.56.0