/[suikacvs]/messaging/manakai/lib/Message/Field/Subject.pm
Suika

Diff of /messaging/manakai/lib/Message/Field/Subject.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by wakaba, Sat Mar 23 10:41:33 2002 UTC revision 1.3 by wakaba, Mon Mar 25 10:15:26 2002 UTC
# Line 14  require 5.6.0; Line 14  require 5.6.0;
14  use strict;  use strict;
15  use re 'eval';  use re 'eval';
16  use vars qw(%DEFAULT %REG $VERSION);  use vars qw(%DEFAULT %REG $VERSION);
17  $VERSION = '1.00';  $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
18    require Message::Util;
19    
20  use overload '""' => sub {shift->stringify};  use overload '""' => sub {shift->stringify};
21  $REG{FWS} = qr/[\x09\x20]*/;  $REG{FWS} = qr/[\x09\x20]*/;
# Line 27  $REG{M_control} = qr/^cmsg$REG{FWS}([\x0 Line 28  $REG{M_control} = qr/^cmsg$REG{FWS}([\x0
28  $REG{M_was} = qr/\([Ww][Aa][Ss]:? ([\x00-\xFF]+)\)$REG{FWS}$/;  $REG{M_was} = qr/\([Ww][Aa][Ss]:? ([\x00-\xFF]+)\)$REG{FWS}$/;
29    
30  %DEFAULT = (  %DEFAULT = (
31      encoding_after_encode => '*default',
32      encoding_before_decode        => '*default',
33      hook_encode_string    => #sub {shift; (value => shift, @_)},
34            \&Message::Util::encode_header_string,
35      hook_decode_string    => #sub {shift; (value => shift, @_)},
36            \&Message::Util::decode_header_string,
37    string_re     => 'Re: ',    string_re     => 'Re: ',
38    string_was    => ' (was: %s)',    string_was    => ' (was: %s)',
39  );  );
# Line 61  sub parse ($$;%) { Line 68  sub parse ($$;%) {
68      $self->{control} = $1;      $self->{control} = $1;
69      return $self;      return $self;
70    }    }
71      my %s = &{$self->{option}->{hook_decode_string}} ($self, $field_body,
72                type => 'text');
73      $field_body = $s{value};
74    $field_body =~ s{^$REG{FWS}($REG{prefix})$REG{FWS}}{    $field_body =~ s{^$REG{FWS}($REG{prefix})$REG{FWS}}{
75      my $prefix = $1;      my $prefix = $1;
76      $self->{is_reply} = 1 if $prefix =~ /$REG{re}/;      $self->{is_reply} = 1 if $prefix =~ /$REG{re}/;
# Line 83  sub stringify ($;%) { Line 93  sub stringify ($;%) {
93    my %option = @_;    my %option = @_;
94    $option{string_re} ||= $self->{option}->{string_re};    $option{string_re} ||= $self->{option}->{string_re};
95    $option{string_was} ||= $self->{option}->{string_was};    $option{string_was} ||= $self->{option}->{string_was};
96    ($self->{is_reply}>0? $option{string_re}: '').    my (%e) = &{$self->{option}->{hook_encode_string}} ($self,
97    $self->{field_body}.            $self->{field_body}, type => 'text');
98    (length $self->{was}? sprintf ($option{string_was}, $self->{was}): '');    ($self->{is_reply}>0? $option{string_re}: '').$e{value}
99      .(length $self->{was}? sprintf ($option{string_was}, $self->{was}): '');
100  }  }
101    sub as_string ($;%) {shift->stringify (@_)}
102    
103  sub as_plain_string ($) {  sub as_plain_string ($;%) {
104    my $self = shift;    my $self = shift;
105    $self->stringify (@_);    my %option = @_;
106      $option{string_re} ||= $self->{option}->{string_re};
107      $option{string_was} ||= $self->{option}->{string_was};
108      ($self->{is_reply}>0? $option{string_re}: '').$self->{field_body}
109      .(length $self->{was}?
110        sprintf ($option{string_was}, $self->{was}->as_plain_string): '');
111  }  }
112    
113  sub is ($$;$) {  sub is ($$;$) {

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24