summaryrefslogtreecommitdiff
path: root/tests/genLists4Comparison.sh
blob: bfee9da28d9ec75571128cb5f39214100f18a94f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh

# This script compares the group names that are mentioned in base*.xml with the ones
# that actually exist in the symbol files.  Some differences are okay -- like extra
# quotes or an extra escaping character -- but apart from that they should match.

cd $(dirname $0)
ROOT=".."

# temporary files
registry_names=reg_names.lst
group_names=grp_names.lst
registry_names_base=${registry_names}.base
registry_names_extras=${registry_names}.extras

xsltproc reg2ll.xsl $ROOT/rules/base.xml        > $registry_names_base
xsltproc reg2ll.xsl $ROOT/rules/base.extras.xml | grep -v sun_type > $registry_names_extras

cat $registry_names_base $registry_names_extras | \
  sort | \
  uniq | \
  grep -v -e '^$' \
          -e '^custom:' > $registry_names
rm -f $registry_names_base $registry_names_extras

for sym in $ROOT/symbols/*; do
  if [ -f $sym ]; then
    id="`basename $sym`"
    export id
    gawk 'BEGIN{
  FS = "\"";
  id = ENVIRON["id"];
  isDefault = 0;
  isHwSpecificDefault = 0;
  isUnregistered = 0;
}
/#HW-SPECIFIC/{
  isHwSpecificDefault = 1;
}
/#UNREGISTERED/{
  isUnregistered = 1;
}
/^[[:space:]]*\/\//{
  next
}
/.*default.*/{
  isDefault = 1;
}
/xkb_symbols/{
  variant = $2;
}/^[[:space:]]*name\[[Gg]roup1\][[:space:]]*=/{
  if (isUnregistered == 1) {
    isUnregistered = 0;
  } else if (isDefault == 1)
  {
    printf "%s:\"%s\"\n",id,$2;
    isDefault=0;
  } else
  {
    name=$2;
    if (isHwSpecificDefault == 1) {
      isHwSpecificDefault = 0;
      printf "%s:\"%s\"\n", id, name;
    } else {
      printf "%s(%s):\"%s\"\n", id, variant, name;
    }
  }
}' $sym
  fi
done | sort | uniq > $group_names

diff -u $registry_names $group_names
rc=$?

if [ $rc != 0 ] ; then
  echo "Legend: '-' is for rules/base*.xml, '+' is for symbols/*"
fi

rm -f $registry_names $group_names

exit $rc