Skip to Content.
Sympa Menu

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

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: Marc Chantreux <address@concealed>
  • To: address@concealed
  • Subject: [sympa-developpers] any clue about that regexp ?
  • Date: Wed, 26 Sep 2018 17:30:10 +0200

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

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;



Archive powered by MHonArc 2.6.19+.

Top of Page