Skip to Content.
Sympa Menu

devel - Re: [sympa-developpers] any clue about that regexp ?

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: IKEDA Soji <address@concealed>
  • To: Marc Chantreux <address@concealed>
  • Cc: address@concealed
  • Subject: Re: [sympa-developpers] any clue about that regexp ?
  • Date: Thu, 27 Sep 2018 10:21:49 +0900

Marc,

At first, before you begin modifying code, you would be better to
read the code carefully.

I suggest you should put your immediate target to write test cases.
To accomplish it, you have to read and unserstand the code.

# Several people have argued necessity of tests. However, only a
# little test cases were written. I think understanding what the
# code does is important.

BTW Sympa::Bulk is a bit more complex than the other Spool
subsclasses. That's why it have not been a subclass of Spool yet.
You would be better to read and understand Spool and its subclasses
at first.

(Maybe you chose Sympa::Bulk because it comes the beginning in
alphabetical order.)


On Wed, 26 Sep 2018 17:30:10 +0200
Marc Chantreux <address@concealed> wrote:

> Hello,
>
> we arbitrary started to refactor some code from
> Bulk and Spool so i got to figure out what the old one
> do ... while there is no test, no doc, no comment, no
> explaination whatsoever in some parts of the code.
>
> I'm on my way to make Sympa::Spool::build_glob_pattern
> more maintainable (adding some test, some type checking and
> rearange the code a little bit).
>
> Soji: it would be great if you add a test suite to this
> function so we can figure out what to expect from it
>
> Also. i found this (line 302)
>
> s/(%%|%[-#+.\d ]*[l]*\w)/$1 eq '%%' ? '%%' : '%s'/reg
>
> and my brain converted the first alternative by:
>
> replace '%%' by '%%'
>
> so i want to rewrite this way
>
> s{ % [-#+.\d ]* [l]* \w }{%s}rgx

That s/// operator converts all of sprintf format directives
("%d", "%x" etc.) in the string to "%s" directive.

"%%" is also a sprintf directive to be formatted to single "%".

Thus, "%%day" in the string should not be converted to "%%say".
Otherwise, formatted string might be "%say" instead of "%day".


Regards,
-- Soji

> but ... that couldn't be so easy? is it? I write the test suite
> below but Soji: can you explain what you write the sub this way?
>
> regards,
> marc
>
>
> use Sympatic;
> use Test::More;
>
> map {
> my ( $soji, $marc ) = map {
> s/(%%|%[-#+.\d ]*[l]*\w)/$1 eq '%%' ? '%%' : '%s'/reg
> , s{ % [-#+.\d ]* [l]* \w }{%s}rgx
> } $_;
> is $soji, $marc, "soji and marc agreed for $_";
> }
> '%s.%s.%d.%f.%s@%s_%s,%ld,%d/%s'
> , '%%%s'
> , '%s%%s'
> , '%-[]ld%%s'
> ;
>
> done_testing;


--
株式会社 コンバージョン
ITソリューション部 システムソリューション1グループ 池田荘児
〒140-0014 東京都品川区大井1-49-15 アクセス大井町ビル4F
e-mail address@concealed TEL 03-6429-2880
https://www.conversion.co.jp/



Archive powered by MHonArc 2.6.19+.

Top of Page