chiark / gitweb /
fix wrong bug# (oops!)
[xfonts-traditional.git] / mkrules
diff --git a/mkrules b/mkrules
index 734e2a2..a0d08de 100755 (executable)
--- a/mkrules
+++ b/mkrules
@@ -6,12 +6,27 @@ rm -f rules/*.rules rules/foundries.new
 
 chars () {
        for c in $rest; do
-               ord=`perl -e 'print ord($ARGV[0]),"\n" or die $!' "$c"`
+               case " $c " in
+               " "?" ")
+                       ord=`perl -e 'print ord($ARGV[0]),"\n" or die $!' "$c"`
+                       ;;
+               " "d?*" ")
+                       ord="${c#d}"
+                       c=`perl -e 'printf "%c", $ARGV[0]' "$ord"`
+                       ;;
+               *)
+                       echo >&2 "??? $c"
+                       exit 1
+                       ;;
+               esac
                ./printrule >&3 "$bad" "$good" $height \
                        "^ENCODING $ord$" $partial "$c"
        done
 }
 
+seenrules=/
+seenfoundries=/
+
 while read keyword rest; do
        case "$keyword" in
        '#'|'') continue ;;
@@ -40,14 +55,34 @@ while read keyword rest; do
                        print or die $!;
                        exit;
                ' <$good`
-               printf "%s %s" "$oldfoundry" "$newfoundry" >>rules/foundries.new
-               exec 3>rules/$newfoundry,$key.rules
-               echo >&3 '# -*- perl -*-'
-               echo >&3 '# autogenerated by mkrules'
-               echo >&3 'sub {'
+               case "$seenfoundries" in
+               */"$oldfoundry,$newfoundry"/*)
+                       ;;
+               */"$oldfoundry,"*)
+                       echo >&2 "inconsistent foundry mapping"
+                       exit 1
+                       ;;
+               *)
+                       seenfoundries=$seenfoundries$oldfoundry,$newfoundry/
+                       printf >>rules/foundries.new \
+                               "%s %s\n" "$oldfoundry" "$newfoundry"
+                       ;;
+               esac
+               case "$seenrules" in
+               */"$newfoundry,$key"/*)
+                       exec 3>>rules/$newfoundry,$key.rules
+                       ;;
+               *)
+                       exec 3>rules/$newfoundry,$key.rules
+                       echo >&3 '# -*- perl -*-'
+                       echo >&3 '# autogenerated by mkrules'
+                       echo >&3 'sub {'
+                       seenrules=$seenrules$newfoundry,$key/
+                       ;;
+               esac
+               echo >&3 "    # $pcf"
                ;;
        endrules)
-               echo >&3 '}'
                exec 3</dev/null
                ;;
        entire)
@@ -58,6 +93,9 @@ while read keyword rest; do
                partial=1
                chars
                ;;
+       verbatim)
+               echo >&3 "    $rest"
+               ;;
        *)
                echo >&2 "??? $keyword"
                exit 1
@@ -65,4 +103,12 @@ while read keyword rest; do
        esac
 done
 
+while :; do
+       case "$seenrules" in /) break ;; esac
+       seenrules=${seenrules#/}
+       rulefile=${seenrules%%/*}
+       seenrules=/${seenrules#*/}
+       echo "}" >>rules/$rulefile.rules
+done
+
 mv rules/foundries.new rules/foundries