mason/.perl-lib/TrivGal.pm: Expand a couple of compicated regices.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 11 Jun 2023 15:35:10 +0000 (16:35 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 12 Jun 2023 10:48:36 +0000 (11:48 +0100)
Yes, that is the correct plural.  Fight me.

mason/.perl-lib/TrivGal.pm

index 85bf0cc..193f122 100644 (file)
@@ -69,7 +69,10 @@ export qw{split_path};
 sub split_path ($) {
   my ($path) = @_;
 
-  my ($dir, $base, $ext) = $path =~ m#^(?:(.*)/)?(?:([^/]*)\.)?([^./]*)$#;
+  my ($dir, $base, $ext) =
+    $path =~ m#^ (?: (.*) /)?
+                (?: ([^/]*) \.)?
+                ([^./]*) $#x;
   if (defined $base) { $ext = ".$ext"; }
   else { $base = $ext; $ext = ""; }
   return ($dir, $base, $ext);
@@ -294,7 +297,12 @@ sub listdir ($) {
        $comment = defined $comment ? $comment . "\n" . $_ : $_;
       } else {
        if ($item && $comment) { $item->comment($comment); }
-       my ($indexp, $name, $c) = /^(!\s+)?(\S+)\s*(\S|\S.*\S)?\s*$/;
+       my ($indexp, $name, $c) =
+         /^ (! \s+)?                   # index flag
+            (\S+) \s*                  # filename
+            (\S | \S.*\S )?            # start of the comment
+            \s*
+            $/x;
        $name = urldecode $name;
        my $list;
        if ($name =~ m#/$#) {