git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sc: minor code cleanup, var renames, css optimisations
[sheet.git]
/
tools
/
mkdigraphs-vim
diff --git
a/tools/mkdigraphs-vim
b/tools/mkdigraphs-vim
index d47a733e971932963dd5a96bcd8377ee5e2b0e95..b9ab42668896fa77eea51b844da490e904282025 100755
(executable)
--- a/
tools/mkdigraphs-vim
+++ b/
tools/mkdigraphs-vim
@@
-1,10
+1,27
@@
#!/bin/sh
#!/bin/sh
-vim -e -cdigraphs -cq | perl -CSD -nE '
- BEGIN {
+
+VERSION=1.01
+
+if [ "$#" -ne 0 ]
+then
+ echo "Usage: $0 >digraphs-vim.inc.pl"
+ echo 'Collect digraph data from vim, standard output as Perl hash.'
+ exit 64 # EX_USAGE
+fi
+
+vim -e -c'echo version' -cdigraphs -cq | perl -CSD -nE '
+ if ($. == 1) { # head
+ say "# digraphs list from vim version ", s/\s*\z//r;
say "+{";
say "+{";
- }
- say "q{$1} => $3," while /\G(\S\S) (.[^ ]*) +([0-9]+)\s+/g;
- END {
+ } else { # body
+ while (/\G(\S\S) (.[^ ]*) +([0-9]+)\s+/g) {
+ my ($mnem, $chr, $cp) = ($1, $2, $3);
+ $mnem =~ s/(?=[\\}])/\\/g; # escape string delimiter
+ $chrstr = sprintf q("\x{%x}"), $cp;
+ say "q{$mnem} => $chrstr,";
+ }
+ } END { # foot
say "}";
say "}";
+ exit warn "only $. lines of :digraphs output\n" if $. < 6;
}
'
}
'