Skip to content

Net::SMTP support: fix $+ alternation bug and IO::File::new_tmpfile recursion#448

Merged
fglock merged 1 commit into
masterfrom
feature/net-smtp-support
Apr 6, 2026
Merged

Net::SMTP support: fix $+ alternation bug and IO::File::new_tmpfile recursion#448
fglock merged 1 commit into
masterfrom
feature/net-smtp-support

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 6, 2026

Summary

Net::SMTP (libnet 3.15) CPAN tests now pass: 19/19 test programs, 110/110 subtests.

Two bugs were fixed:

  • Fix $+ (LAST_PAREN_MATCH) for regex alternations: lastCaptureString() was returning the highest-numbered capture group regardless of whether it participated in the match. Now iterates backwards to find the first non-null group, matching Perl 5 semantics. This fixes Net::Netrc's token parser which uses $+ to extract quoted/unquoted tokens.

  • Fix IO::File::new_tmpfile infinite recursion: The pure-Perl new_tmpfile() called $class->new which causes StackOverflowError when subclasses override new() to call new_tmpfile(). Replaced with bless gensym(), $class to match the XS behavior (no polymorphic dispatch through subclass new).

Files Changed

  • src/main/java/org/perlonjava/runtime/regex/RuntimeRegex.javalastCaptureString() method
  • src/main/perl/lib/IO/File.pmnew_tmpfile() method
  • dev/modules/net_smtp.md — Support plan document

Test plan

  • ./jcpan -t Net::SMTP — All 19 test programs pass (110/110 subtests)
  • make — All unit tests pass (no regressions)
  • $+ returns correct group in alternations: "test" =~ /(a)|(test)|(c)/ gives $+ = "test"
  • IO::File::new_tmpfile works with subclasses that override new()

Generated with Devin

…ecursion

Two fixes that make all 19 libnet (Net::SMTP) test programs pass (110/110 subtests):

1. Fix $+ (LAST_PAREN_MATCH) for regex alternations: lastCaptureString()
   was returning the highest-numbered capture group regardless of whether
   it participated in the match. Now iterates backwards to find the first
   non-null group, matching Perl 5 semantics. This fixes Net::Netrc token
   parser which uses $+ to extract quoted/unquoted tokens.

2. Fix IO::File::new_tmpfile infinite recursion: The pure-Perl new_tmpfile()
   called $class->new which causes StackOverflowError when subclasses
   override new() to call new_tmpfile(). Replaced with bless+gensym to
   match the XS behavior (no polymorphic dispatch through subclass new).

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit 044eeb3 into master Apr 6, 2026
2 checks passed
@fglock fglock deleted the feature/net-smtp-support branch April 6, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant