digraphs: extended regexps for all xorg parsing
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 4 Jun 2017 22:01:26 +0000 (00:01 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sun, 11 Jun 2017 00:49:19 +0000 (02:49 +0200)
tools/mkdigraphs-xorg

index 1ce8c69d1d06563f1f099e1c0f84d01b973ac349..aeed5fe036226bc9c86e888357cd529097fe39d6 100755 (executable)
@@ -3,6 +3,7 @@ use 5.014;
 use warnings;
 use utf8;
 use open IO => ':utf8', ':std';
 use warnings;
 use utf8;
 use open IO => ':utf8', ':std';
+use re '/msx';
 use Data::Dump 'pp';
 
 our $VERSION = '1.01';
 use Data::Dump 'pp';
 
 our $VERSION = '1.01';
@@ -18,7 +19,7 @@ while (readline $keysymh) {
                \A  [#]define[ ]XK_ (?<name>[a-zA-Z_0-9]+)
                \h+ 0x(?<value>[0-9a-f]+)
                \h* [/][*] [\h(] U[+] (?<unicode>[0-9A-F]{4,6})
                \A  [#]define[ ]XK_ (?<name>[a-zA-Z_0-9]+)
                \h+ 0x(?<value>[0-9a-f]+)
                \h* [/][*] [\h(] U[+] (?<unicode>[0-9A-F]{4,6})
-       }msx or next;
+       } or next;
        $keysym{ $+{name} } = chr hex $+{unicode};
 }
 
        $keysym{ $+{name} } = chr hex $+{unicode};
 }
 
@@ -26,12 +27,12 @@ say "# automatically generated by $0";
 say '+{';
 
 while ($_ = readline) {
 say '+{';
 
 while ($_ = readline) {
-       my ($mnem, $chr, $trail) = /^<Multi_key>\h(.*?)\h+:\h"([^"]+)"\h*(.*)/
+       my ($mnem, $chr, $trail) = m/\A <Multi_key> \h (.*?) \h+ : \h "([^"]+)" \h* (.*)/
                or next;
        $chr =~ s/\\(.)/$1/g;
                or next;
        $chr =~ s/\\(.)/$1/g;
-       $mnem !~ /<dead|<KP_|<U[0-9A-Fa-f]{4}/ or next;  # skip non-standard keys
-       $mnem =~ s{<([^>]+)> ?}{$keysym{$1} // die "reference to unknown keysym $1\n"}eg;
-       $mnem !~ /[^ -\x7F]/ or next;  # skip unicode
+       $mnem !~ m/<dead | <KP_ | <U[0-9A-Fa-f]{4}/ or next;  # skip non-standard keys
+       $mnem =~ s{<([^>]+)> \h?}{$keysym{$1} // die "reference to unknown keysym $1\n"}eg;
+       $mnem !~ m/[^\x20-\x7F]/ or next;  # skip unicode
 #      (state $seen = {})->{$chr}++ and next;
        printf "%s => %s,\n", pp($mnem), pp($chr);
 }
 #      (state $seen = {})->{$chr}++ and next;
        printf "%s => %s,\n", pp($mnem), pp($chr);
 }