146185892Smrg#!/bin/sh
246185892Smrg
346185892Smrg#
446185892Smrg# This script compares the group names which "have to be", according to the descriptions in base.xml -
546185892Smrg# and actually existing in the symbol files. Some differences are ok (like extra double quotes or 
646185892Smrg# extra escaping character) - but all the rest should be in sync.
746185892Smrg#
846185892Smrg
946185892Smrgcd $(dirname $0)
1046185892SmrgROOT=".."
1146185892Smrg
1246185892Smrg# temporary files
1346185892Smrgregistry_names=reg_names.lst
1446185892Smrggroup_names=grp_names.lst
1546185892Smrgregistry_names_base=${registry_names}.base
1646185892Smrgregistry_names_extras=${registry_names}.extras
1746185892Smrg
1846185892Smrgxsltproc reg2ll.xsl $ROOT/rules/base.xml        > $registry_names_base
1946185892Smrgxsltproc reg2ll.xsl $ROOT/rules/base.extras.xml | grep -v sun_type > $registry_names_extras
2046185892Smrg
2146185892Smrgcat $registry_names_base $registry_names_extras | \
2246185892Smrg  sort | \
2346185892Smrg  uniq | \
2446185892Smrg  grep -v -e '^$' \
2546185892Smrg          -e '^custom:' > $registry_names
2646185892Smrgrm -f $registry_names_base $registry_names_extras
2746185892Smrg
2846185892Smrgfor sym in $ROOT/symbols/*; do
2946185892Smrg  if [ -f $sym ]; then
3046185892Smrg    id="`basename $sym`"
3146185892Smrg    export id
3246185892Smrg    gawk 'BEGIN{
3346185892Smrg  FS = "\"";
3446185892Smrg  id = ENVIRON["id"];
3546185892Smrg  isDefault = 0;
3646185892Smrg  isHwSpecificDefault = 0;
3746185892Smrg  isUnregistered = 0;
3846185892Smrg}
3946185892Smrg/#HW-SPECIFIC/{
4046185892Smrg  isHwSpecificDefault = 1;
4146185892Smrg}
4246185892Smrg/#UNREGISTERED/{
4346185892Smrg  isUnregistered = 1;
4446185892Smrg}
4546185892Smrg/^[[:space:]]*\/\//{
4646185892Smrg  next 
4746185892Smrg}
4846185892Smrg/.*default.*/{
4946185892Smrg  isDefault = 1;
5046185892Smrg}
5146185892Smrg/xkb_symbols/{
5246185892Smrg  variant = $2;
5346185892Smrg}/^[[:space:]]*name\[Group1\][[:space:]]*=/{
5446185892Smrg  if (isUnregistered == 1) {
5546185892Smrg    isUnregistered = 0;
5646185892Smrg  } else if (isDefault == 1)
5746185892Smrg  {
5846185892Smrg    printf "%s:\"%s\"\n",id,$2;
5946185892Smrg    isDefault=0;
6046185892Smrg  } else
6146185892Smrg  {
6246185892Smrg    name=$2;
6346185892Smrg    if (isHwSpecificDefault == 1) {
6446185892Smrg      isHwSpecificDefault = 0;
6546185892Smrg      printf "%s:\"%s\"\n", id, name;
6646185892Smrg    } else {
6746185892Smrg      printf "%s(%s):\"%s\"\n", id, variant, name;
6846185892Smrg    }
6946185892Smrg  }
7046185892Smrg}' $sym
7146185892Smrg  fi
7246185892Smrgdone | sort | uniq > $group_names
7346185892Smrg
7446185892Smrgdiff -u $registry_names $group_names
7546185892Smrgrc=$?
7646185892Smrg
7746185892Smrgif [ $rc != 0 ] ; then
7846185892Smrg  echo "Legend: '-' is for rules/base.*xml.in, '+' is for symbols/*"
7946185892Smrgfi
8046185892Smrg
8146185892Smrgrm -f $registry_names $group_names
8246185892Smrg
8346185892Smrgexit $rc
84