I ran into a problem. I made another improvement to Win32::API, in ::Struct, to fix this div by zero, http://perlmonks.org/?node_id=978667 . No changes to recognize(), since recognize already has a way to signal failure, its just typedef() didn't check for failure before. recognize() indicated failure by returning a list with 1 undef, rather than the non-error list with 3 elements. The undefs/missing array elements later become 0s which after that become div by 0s. _____________________________________________ sub typedef { my $class = shift; my $struct = shift; my ($type, $name, @recog_arr); my $self = { align => undef, typedef => [], }; while (defined($type = shift)) { $name = shift; $name =~ s/;$//; @recog_arr = recognize($type, $name); #http://perlmonks.org/?node_id=978468, not catching the type not found here, #will lead to a div 0 later if(@recog_arr != 3){ warn "Win32::API::Struct::typedef: unknown member type=\"$type\", name=\"$name\""; return undef; } push(@{$self->{typedef}}, [@recog_arr]); }
$Known{$struct} = $self; return 1; } _____________________________________________ the problem is 05_more_struct.t now fails its tests, specifically, _____________________________________________ C:\Documents and Settings\Owner\Desktop\cpan libs\Win32API\wrkinprog>perl ./t/05 _more_struct.t 1..28 ok 1 - "all_longs" struct defined ok 2 - Size of struct "all_longs" is calculated correctly (20) ok 3 - "array_of_chars" struct defined ok 4 - Size of struct "array_of_chars" is calculated correctly (100) ok 5 - "compound_1" struct defined ok 6 - Size of struct "compound_1" is calculated correctly (212) ok 7 - "compound_2" struct defined not ok 8 - Size of struct "compound_2" is calculated correctly (14) # TODO Break s atm # Failed (TODO) test 'Size of struct "compound_2" is calculated correctly (14) ' # at ./t/05_more_struct.t line 131. # got: '14' # expected: '11' ok 9 - "empty" struct defined ok 10 - Size of struct "empty" is calculated correctly (0) Win32::API::Struct::typedef: unknown member type="\n", name="\n" at C:/perl512/s ite/lib/Win32/API/Struct.pm line 46. Unknown Win32::API::Struct 'empty_with_spaces' at ./t/05_more_struct.t line 125 not ok 11 - "empty_with_spaces" struct defined # Failed test '"empty_with_spaces" struct defined' # at ./t/05_more_struct.t line 126. Can't call method "sizeof" on an undefined value at ./t/05_more_struct.t line 13 5. # Looks like you planned 28 tests but ran 11. # Looks like you failed 1 test of 11 run. # Looks like your test exited with 2 just after 11. C:\Documents and Settings\Owner\Desktop\cpan libs\Win32API\wrkinprog> ________________________________________________ if I comment out _________________________________________________ empty_with_spaces => { typedef => [qw( \n \n )], sizeof => 0, }, _________________________________________________ in 05_more_struct.t, 05_more_struct.t passes all its tests. Since you (Cosimo) originally wrote 05_more_struct.t (I assume, per https://github.com/cosimo/perl5-win32-api/commit/99a1506e8a941f9625ead648c207f4639f9cbf07#t/05_more_struct.t ), I ask, what should I do? Some ideas, -make empty_with_spaces pass its tests (a 0 length struct is created successfully) at any cost (no idea how to implement, some kind of whitespace stripper/normalizer regex before passing off the string to defined/while?) -remove empty_with_spaces test, note "empty" works fine with the new ::Struct -or you (Cosimo) have your own idea how to fix this? This email is going to Cosimo and libwin32 mailing list, anyone can give their opinion.