diff options
| author | fukachan <fukachan> | 2001-01-23 09:03:30 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2001-01-23 09:03:30 +0000 |
| commit | ce97df62ab14ba9d0ee8975ce2a798a52caf7401 (patch) | |
| tree | aabf19232249834a7336a7fdbb1f1bc22655b271 | |
| parent | 7fdba85e30d4221c80968114ee5e214a903c2f79 (diff) | |
| download | fml8-ce97df62ab14ba9d0ee8975ce2a798a52caf7401.tar.gz fml8-ce97df62ab14ba9d0ee8975ce2a798a52caf7401.tar.bz2 fml8-ce97df62ab14ba9d0ee8975ce2a798a52caf7401.zip | |
implement basic subject_tag manipuration
| -rw-r--r-- | fml/lib/FML/Header/Subject.pm | 16 | ||||
| -rwxr-xr-x | regress/header/subject_tag.pl | 54 | ||||
| -rw-r--r-- | regress/libtagdef.pl | 117 |
3 files changed, 58 insertions, 129 deletions
diff --git a/fml/lib/FML/Header/Subject.pm b/fml/lib/FML/Header/Subject.pm index 27154f92..ed104e2c 100644 --- a/fml/lib/FML/Header/Subject.pm +++ b/fml/lib/FML/Header/Subject.pm @@ -36,9 +36,7 @@ sub rewrite_subject_tag my $subject = $header->get('subject'); # de-tag - my $retag = _regexp_compile($tag); - $subject =~ s/$retag//g; - $subject =~ s/^\s*//; + $subject = _delete_subject_tag( $subject, $tag ); # add the updated tag $tag = sprintf($tag, $ml_name, $args->{ id }); @@ -47,6 +45,18 @@ sub rewrite_subject_tag } +sub _delete_subject_tag +{ + my ($subject, $tag) = @_; + my $retag = _regexp_compile($tag); + + $subject =~ s/$retag//g; + $subject =~ s/^\s*//; + + return $subject; +} + + # Descriptions: create regexp for a subject tag, for example # "[%s %05d]" => "\[\S+ \d+\]" # Arguments: a subject tag string diff --git a/regress/header/subject_tag.pl b/regress/header/subject_tag.pl index cacc53f4..fe28a195 100755 --- a/regress/header/subject_tag.pl +++ b/regress/header/subject_tag.pl @@ -7,17 +7,53 @@ use lib qw(../../fml/lib); use FML::Header::Subject; my $format = "%8s %s\n"; -my $subject_tag = '[%s %05d]'; -my $x = sprintf($subject_tag, 'elena', 100). " uja"; -{ - printf $format, "tag:", $subject_tag; - $re = FML::Header::Subject::_regexp_compile( $subject_tag ); - printf $format, "regexp:", $re; +$tags = { + '[ ]' => [ '[', ' ', ']' ], + '[:]' => [ '[', ':', ']' ], + '[,]' => [ '[', ',', ']' ], + '[]' => [ '[', '' , ']' ], + '[I]' => [ '[', 'I', ']' ], - printf $format, "in:", $x; - $x = FML::Header::Subject::_delete_subject_tag( $x , $subject_tag ); - printf $format, "out:", $x; + '( )' => [ '(', ' ', ')' ], + '(:)' => [ '(', ':', ')' ], + '(,)' => [ '(', ',', ')' ], + '()' => [ '(', '', ')' ], + '(I)' => [ '(', 'I', ')' ], +}; + +my $i = 0; +while ( ($k, $v) = each %$tags) { + $i++; + print "${i}. ${k}\n"; + my ($left, $sep, $right) = @$v; + + if ($sep) { + if ($sep eq 'I') { + $subject_tag = $left. '%05d'. $right; + $x = sprintf($subject_tag, 100). " uja"; + } + else { + $subject_tag = $left. '%s'. $sep .'%05d'. $right; + $x = sprintf($subject_tag, 'elena', 100). " uja"; + } + } + else { + $subject_tag = $left. '%s'. $right; + $x = sprintf($subject_tag, 'elena', 100). " uja"; + } + + + { + printf $format, "tag:", $subject_tag; + $re = FML::Header::Subject::_regexp_compile( $subject_tag ); + printf $format, "regexp:", $re; + + printf $format, "in:", $x; + $x = FML::Header::Subject::_delete_subject_tag( $x , $subject_tag ); + printf $format, "out:", $x; + } + print "\n"; } exit 0; diff --git a/regress/libtagdef.pl b/regress/libtagdef.pl deleted file mode 100644 index 40dd6591..00000000 --- a/regress/libtagdef.pl +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright (C) 1993-1998 Ken'ichi Fukamachi -# All rights reserved. -# 1993-1996 fukachan@phys.titech.ac.jp -# 1996-1998 fukachan@sapporo.iij.ad.jp -# -# FML is free software; you can redistribute it and/or modify -# it under the terms of GNU General Public License. -# See the file COPYING for more details. -# -# $Id$; - -# if $SUBJECT_HML_FORM = 1; -# [Elena:100] -# -# other candidates as follows: -sub SubjectTagDef -{ - local($mode) = @_; - - $mode =~ s/\"//g; - $mode =~ s/\'//g; - - # (Elena 100) - if ($mode eq '( )') { - $SUBJECT_FREE_FORM = 1; - $BEGIN_BRACKET = '('; - $BRACKET = $BRACKET || 'Elena'; - $BRACKET_SEPARATOR = ' '; - $END_BRACKET = ')'; - $SUBJECT_FREE_FORM_REGEXP = "\\($BRACKET\\s+\\d+\\)"; - } - # [Elena 100]; - elsif ($mode eq '[ ]') { - $SUBJECT_FREE_FORM = 1; - $BEGIN_BRACKET = '['; - $BRACKET = $BRACKET || 'Elena'; - $BRACKET_SEPARATOR = ' '; - $END_BRACKET = ']'; - $SUBJECT_FREE_FORM_REGEXP = "\\[$BRACKET\\s+\\d+\\]"; - } - # (Elena:100) - elsif ($mode eq '(:)') { - $SUBJECT_FREE_FORM = 1; - $BEGIN_BRACKET = '('; - $BRACKET = $BRACKET || 'Elena'; - $BRACKET_SEPARATOR = ':'; - $END_BRACKET = ')'; - $SUBJECT_FREE_FORM_REGEXP = "\\($BRACKET:\\d+\\)"; - } - # [Elena:100]; - elsif ($mode eq '[:]') { - $SUBJECT_FREE_FORM = 1; - $BEGIN_BRACKET = '['; - $BRACKET = $BRACKET || 'Elena'; - $BRACKET_SEPARATOR = ':'; - $END_BRACKET = ']'; - $SUBJECT_FREE_FORM_REGEXP = "\\[$BRACKET:\\d+\\]"; - } - elsif ($mode eq '[,]') { - $SUBJECT_FREE_FORM = 1; - $BEGIN_BRACKET = '['; - $BRACKET = $BRACKET || 'Elena'; - $BRACKET_SEPARATOR = ','; - $END_BRACKET = ']'; - $SUBJECT_FREE_FORM_REGEXP = "\\[$BRACKET,\\d+\\]"; - } - elsif ($mode eq '(,)') { - $SUBJECT_FREE_FORM = 1; - $BEGIN_BRACKET = '('; - $BRACKET = $BRACKET || 'Elena'; - $BRACKET_SEPARATOR = ','; - $END_BRACKET = ')'; - $SUBJECT_FREE_FORM_REGEXP = "\\($BRACKET,\\d+\\)"; - } - ### - ### without numbers - ### - elsif ($mode eq '()') { - $SUBJECT_FREE_FORM = 1; - $BEGIN_BRACKET = '('; - $BRACKET = $BRACKET || 'Elena'; - $BRACKET_SEPARATOR = ''; - $END_BRACKET = ')'; - $SUBJECT_FREE_FORM_REGEXP = "\\($BRACKET\\)"; - } - # [Elena 100]; - elsif ($mode eq '[]') { - $SUBJECT_FREE_FORM = 1; - $BEGIN_BRACKET = '['; - $BRACKET = $BRACKET || 'Elena'; - $BRACKET_SEPARATOR = ''; - $END_BRACKET = ']'; - $SUBJECT_FREE_FORM_REGEXP = "\\[$BRACKET\\]"; - } - ### - ### NUMBER AND BRACKET - ### - elsif ($mode eq '(ID)') { - $SUBJECT_FREE_FORM = 1; - $BEGIN_BRACKET = '('; - $BRACKET = ''; - $BRACKET_SEPARATOR = ''; - $END_BRACKET = ')'; - $SUBJECT_FREE_FORM_REGEXP = "\\(\\d+\\)"; - } - elsif ($mode eq '[ID]') { - $SUBJECT_FREE_FORM = 1; - $BEGIN_BRACKET = '['; - $BRACKET = ''; - $BRACKET_SEPARATOR = ''; - $END_BRACKET = ']'; - $SUBJECT_FREE_FORM_REGEXP = "\\[\\d+\\]"; - } - -} - -1; |
