regex $pattern does not match name part of geos-3-7-0.dll on windows
shawnlaffan opened this issue · 4 comments
The GEOS library on windows generates a DLL called geos-3-7-0.dll. This does not work with the regex used in FFI::CheckLib::_matches, as the name part appears invalid. FFI::CheckLib::find_lib returns undef, while the assert method dies with library not found.
my $pat = qr{^(?:lib)?(.*?)(?:-([0-9])+)?\.dll$}i; # current regexp
my $pat2 = qr{^(?:lib)?(.*?)(?:-([0-9]+))?(?:-[0-9]+)*\.dll$}i; # revised regexp
my $string = 'geos-3-7-0.dll';
say 'gives: ' . join ', ', ($string =~ $pat);
# gives: geos-3-7, 0
say 'gives: ' . join ', ', ($string =~ $pat2);
# gives: geos, 3I'm not sure what you want to do with the remaining version components. They could be used in the _sort sub, but hopefully they are not needed as that would make it more complex. If you have a preference then I can work up a PR and test.
There are other complications in that some of the other DLLs I have under strawberry perl look like s1sgdk-win32-2.0-0.dll and libgd-3__.dll. I have nothing that uses them, but they are valid DLL names.
The naming convention isn't as strict as on linux, darwin, etc. So we have to make some educated guesses. I think though that the first capture group should capture 3-7-0 and the split here (similar to how libgeos.so.3.7.0 would capture 3.7.0 on linux):
https://github.com/Perl5-FFI/FFI-CheckLib/blob/master/lib/FFI/CheckLib.pm#L106
should split on - instead of . on MSWin32.
cygwin should maybe work the same way, though I think I prefer to wait to "fix" that for when/if we find an example in cygwin that uses this form.
As for the more exotic ones with -win32-2.0 or __ ... unless these are pretty common, I think that is an example where you'd have to handle that outside of FFI::CheckLib.
OK, I'll update the regexp to grab everything after the first dash and adjust the splitter.
The -win32- pattern is used for Gtk2. It's essentially the same pattern as the msys libs use. It's not common, though, so I'll leave that out. The trailing underscores are provided with strawberry perl, so have a bit more justification. They're also pretty easy to strip out.
fair enough. I will review and let you know next week.
No worries.
For those reading later, the PR is #11