aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/xkeyboard-config/tests/ruby/find_match.rb
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/xkeyboard-config/tests/ruby/find_match.rb')
-rw-r--r--xorg-server/xkeyboard-config/tests/ruby/find_match.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/xorg-server/xkeyboard-config/tests/ruby/find_match.rb b/xorg-server/xkeyboard-config/tests/ruby/find_match.rb
new file mode 100644
index 000000000..43af93482
--- /dev/null
+++ b/xorg-server/xkeyboard-config/tests/ruby/find_match.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/ruby
+#
+# $Id$
+# The script finds best matching xkb_symbols in symbols/in
+#
+# Parameters: $0 - the name of the file with new xkb_symbols
+# $1 - max number of non-matching mappings (0 by default)
+#
+
+require "xkbparser.rb"
+
+baseDir = "../.."
+
+symbolsDir = "#{baseDir}/symbols"
+#symbolsDir = "."
+
+parser = Parser.new
+
+allSyms = parser.parse("#{symbolsDir}/inet")
+
+newSyms = parser.parse(ARGV[0])
+limit = ARGV[1].to_i
+
+newSyms.find_all do | key, value |
+
+ if value.hidden?
+ next
+ end
+
+ puts "Existing xkb_symbols matching #{key}: "
+
+ sorted = allSyms.match_symbols(value,limit).sort_by do | symsName, diff |
+ sprintf "%03d_%s", diff.size, symsName
+ end
+
+ sorted.find_all do | symsName, diff |
+ puts " #{symsName}, up to #{allSyms[symsName].size} keys (difference #{diff.size})-> #{diff}"
+ end
+
+end
+
+