1 |
From 96aa5ba171be75dbd25c44de813e74eb4e3d08b5 Mon Sep 17 00:00:00 2001 |
2 |
From: Jared Johnson <jaredj@jdjlaptop.(none)> |
3 |
Date: Fri, 20 Feb 2009 21:22:28 +0800 |
4 |
Subject: Shorten/clarify Connection and Transaction notes() |
5 |
|
6 |
Update Qpsmtpd::Connection::notes() and Qpsmtpd::Transaction::notes() |
7 |
with clearer, more brief syntax. A previous patch used seemingly better |
8 |
syntax, but did not evaluate the size of @_ in order to distinguish |
9 |
between a call to notes('arg1',undef) and notes('arg1'). This corrects |
10 |
this issue, and adds a comment to that effect. |
11 |
--- |
12 |
lib/Qpsmtpd/Connection.pm | 8 ++++---- |
13 |
lib/Qpsmtpd/Transaction.pm | 9 ++++----- |
14 |
2 files changed, 8 insertions(+), 9 deletions(-) |
15 |
|
16 |
diff --git a/lib/Qpsmtpd/Connection.pm b/lib/Qpsmtpd/Connection.pm |
17 |
index 22ed704..99b7b38 100644 |
18 |
--- a/lib/Qpsmtpd/Connection.pm |
19 |
+++ b/lib/Qpsmtpd/Connection.pm |
20 |
@@ -108,10 +108,10 @@ sub hello_host { |
21 |
} |
22 |
|
23 |
sub notes { |
24 |
- my $self = shift; |
25 |
- my $key = shift; |
26 |
- @_ and $self->{_notes}->{$key} = shift; |
27 |
- $self->{_notes}->{$key}; |
28 |
+ my ($self,$key) = (shift,shift); |
29 |
+ # Check for any additional arguments passed by the caller -- including undef |
30 |
+ return $self->{_notes}->{$key} unless @_; |
31 |
+ return $self->{_notes}->{$key} = shift; |
32 |
} |
33 |
|
34 |
sub reset { |
35 |
diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm |
36 |
index 18635ad..1dec547 100644 |
37 |
--- a/lib/Qpsmtpd/Transaction.pm |
38 |
+++ b/lib/Qpsmtpd/Transaction.pm |
39 |
@@ -61,11 +61,10 @@ sub header { |
40 |
#} |
41 |
|
42 |
sub notes { |
43 |
- my $self = shift; |
44 |
- my $key = shift; |
45 |
- @_ and $self->{_notes}->{$key} = shift; |
46 |
- #warn Data::Dumper->Dump([\$self->{_notes}], [qw(notes)]); |
47 |
- $self->{_notes}->{$key}; |
48 |
+ my ($self,$key) = (shift,shift); |
49 |
+ # Check for any additional arguments passed by the caller -- including undef |
50 |
+ return $self->{_notes}->{$key} unless @_; |
51 |
+ return $self->{_notes}->{$key} = shift; |
52 |
} |
53 |
|
54 |
sub set_body_start { |
55 |
-- |
56 |
1.7.2.2 |
57 |
|