Skip to content

Commit dd73f76

Browse files
committed
Recognizing subroutine definitions.
Better recognition also in case of unicode. `\w` is all alphanumeric character plus `_`, but as the first character of a name cannot be a number we have to perform a small trick(`\D`, not numeric but it is unknown what is actually included so it is to be used together with the `\w` in the previous part giving the first character just the "alpha" characters puls the `_`)
1 parent 59073ff commit dd73f76

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/Doxygen/Filter/Perl.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ sub ProcessFile
213213
if ($self->{'_sState'} eq 'NORMAL')
214214
{
215215
$logger->debug("We are in state: NORMAL");
216-
if ($line =~ /^\s*sub\s+([a-zA-Z_].*)/) { $self->_ChangeState('METHOD'); }
216+
if ($line =~ /^\s*sub\s+([\w]+)/ and $line =~ /^\s*sub\s+([\D][\w]*)/) { $self->_ChangeState('METHOD'); }
217217
elsif ($line =~ /^\s*#\*\*\s*\@/) { $self->_ChangeState('DOXYGEN'); }
218218
elsif ($line =~ /^=.*/) { $self->_ChangeState('POD'); }
219219
}
@@ -240,7 +240,7 @@ sub ProcessFile
240240
{
241241
# If this comment block is right next to a subroutine, lets make sure we
242242
# handle that condition
243-
if ($line =~ /^\s*sub\s+([a-zA-Z_].*)/) { $self->_ChangeState('METHOD'); }
243+
if ($line =~ /^\s*sub\s+([\w]+)/ and $line =~ /^\s*sub\s+([\D][\w]*)/) { $self->_ChangeState('METHOD'); }
244244
}
245245
}
246246
}
@@ -672,7 +672,7 @@ sub _ProcessPerlMethod
672672

673673
my $sClassName = $self->{'_sCurrentClass'};
674674

675-
if ($line =~ /^\s*sub\s+([a-zA-Z_].*)/)
675+
if ($line =~ /^\s*sub\s+([\w]+)/ and $line =~ /^\s*sub\s+([\D][\w]*)/)
676676
{
677677
# We should keep track of the order in which the methods were written in the code so we can print
678678
# them out in the same order

0 commit comments

Comments
 (0)