cosimo/perl5-text-hunspell — pull request #1 by hisdeedsaredust (2013-03-20 07:02:22+00:00)
Title: Fixes to support multiple speller objects, RT #84054

Text::Hunspell currently doesn't support multiple speller objects, and it fails in a rather surprising way. If you try to create a second object (to support loading another language's dictionary, for example), you can no longer look up words on the first handle.

A bit of digging shows that Hunspell.xs maintains a single static handle to the library. This seems to have been a workaround for THIS references not working. The underlying fault was a comment line in the typemap that was causing the compiler to miss out the line that initialised THIS, so it segfaulted all the time.

This patch looks rather big, so I'll explain:
1. The typemap has been corrected by removing the comments that caused compilation problems.

2. Hunspell.xs has been reworked to remove the static handle and restore THIS references.

3. Hunspell.xs now deprecates the delete() function, which didn't make sense, but it gains a DESTROY object so that the library object can be garbage collected (these two lines taken straight from perlxs documentation).

4. Test case added for multiple spellers. If you add this test case to 2.06, you'll see it failing.

5. Removed delete() from other test cases and Hunspell.pm documentation.