Subject: | Math::Complex make error |
Date: | Wed, 19 Jun 2013 10:33:12 +0100 |
To: | bug-Math-Complex [...] rt.cpan.org |
From: | Zefram <zefram [...] fysh.org> |
Adam Morton <am@adammorton.com> wrote:
Show quoted text
>Hi Zefram, are you still maintaining Math::Complex? I believe i have found
>and fixed an error in the single argument form of ::make (actually in
>::_make).
>
>The regex will not detect 'i' or '-i' as a valid value, and misiterprets
>things like '30i'
>
>I have some test cases and a fix if you would like to see them... the fix
>is basically an alternate middle section of the first if block in _make:
>
> if ($arg =~ /^$gre$/) {
> ($p, $q) = ($1, 0);
> } elsif ($arg =~ /^(?:$gre)??(?:$gre|([+-]))?\s*i\s*$/) {
> $p = $1 || 0;
> $q = $2 || 1;
> $3 and $q = $3 . $q;
> } elsif ($arg =~ /^\s*\(\s*$gre\s*(?:,\s*$gre\s*)?\)\s*$/) {
> ($p, $q) = ($1, $2 || 0);
> }
>
>--Adam
Notionally I'm still maintaining it, but I've got some major catching
up to do on CPAN work.
The handling of "30i" is a clear bug.
"i" or "-i" doesn't match the stated format for string arguments, so not
handling it isn't actually a bug. Still, it would be nice to handle it,
as an extra feature.
-zefram