Skip to content

Commit

Permalink
Item13897: Regexp adjustments
Browse files Browse the repository at this point in the history
- Replaced \n with \R

- Added /n to matches to gain some speed

- Added /u
  • Loading branch information
vrurg committed Jun 30, 2017
1 parent df1fdae commit 9af3ece
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/lib/Foswiki/IncludeHandlers/doc.pm
Expand Up @@ -84,16 +84,16 @@ sub INCLUDE {
$perl,
{
_Package =>
'(?:(?<=\n)\bpackage|\Apackage)\s+(?<packageName>[\w:]+);',
'(?:(?<=\R)\bpackage|\Apackage)\s+(?<packageName>[\w:]+);',
_Doc =>
'\n=(?:begin(?:\h+(?:twiki|TML|html))?|pod)\h*\n(?<docText>.+?\n)=cut\h*?(?=\n)',
'\R=(?:begin(?:\h+(?:twiki|TML|html))?|pod)\h*\R(?<docText>.+?\R)=cut\h*?(?=\R)',
_Extends => $extendsRx . $paramsRx,
_With => $withRx . $paramsRx,
_FoswikiClass => $fwClassRx . $paramsRx,
(
$showSmells # Don't even parse FIXME comments to non-admin users.
? ( _FixmeComment =>
'\n\h*?(?<commentLine>#\h*?(?<commentType>SMELL|TODO|FIXME)\b\h*(?<commentText>.+?))(?=\n)'
'\R\h*?(?<commentLine>#\h*?(?<commentType>SMELL|TODO|FIXME)\b\h*(?<commentText>.+?))(?=\R)'
)
: ()
),
Expand Down Expand Up @@ -146,7 +146,7 @@ sub INCLUDE {
$docRaw,
{
_Section =>
'(?<secPrefix>\n|\A)(?<secLine>(?<secDef>---(?<secDepth>\++))(?:!!)?\h+(.+?))(?=\n)',
'(?<secPrefix>\R|\A)(?<secLine>(?<secDef>---(?<secDepth>\++))(?:!!)?\h+(.+?))(?=\R)',
}
);

Expand Down Expand Up @@ -346,7 +346,7 @@ sub _makeCtx {
map { "(?:" . $ctxRxStrings->{$_} . ")(?{\$ctxData{type} = '$_';})" }
keys %$ctxRxStrings )
. "|(?:\\Z)(?{\$ctxData{type} = '_EOF_';}))(?{\@ctxData{qw(pos text)} = (pos(\$_), \$+{lexText}); \$ctxData{lexemes} = {\%+};})";
$ctxData{regex} = eval "qr/$rxStr/s";
$ctxData{regex} = eval "qr/$rxStr/nus";
Foswiki::Exception::Fatal->throw( text => 'Failed to compile regex: /'
. $rxStr . "/\n"
. Foswiki::Exception::errorStr($@) )
Expand Down

0 comments on commit 9af3ece

Please sign in to comment.