#! /bin/sh
# ucgen --- generate the files needed by the TOM String classes.
# Written by Pieter J. Schoenmakers <tiggr@ics.ele.tue.nl>
#
# Copyright (C) 1996 Pieter J. Schoenmakers.
#
# This file is part of TOM.  TOM is distributed under the terms of the
# TOM License, a copy of which can be found in the TOM distribution; see
# the file LICENSE.
#
# $Id: ucgen,v 1.4 1998/01/05 00:56:03 tiggr Exp $

TOM_LIB_OPTIONS=${TOM_LIB_OPTIONS-":gc-pth 15000"}
UC=${UC:-"uc"}

while test $# -ne 0
do
  case $1 in
  -u)
      shift
      UNICODEDATA=$1
      ;;
  -m)
      shift
      ISOMAP=$1
      ;;
  -p)
      shift
      PREFIX=$1
      ;;
  *)
      echo $0 '-u unicode-data-file [-m iso-map-file] [-p output-prefix]' >&2
      exit 2
      ;;
  esac
  shift
done

if test -z "$ISOMAP"; then
	PREFIX=${PREFIX:-"unicode"}
else
	PREFIX=${PREFIX:-${ISOMAP}}
	ISOMAP="-m $ISOMAP"
	# We have a mapping, thus we can create a mapping file!
	$UC map $TOM_LIB_OPTIONS -u $UNICODEDATA $ISOMAP -o ${PREFIX}.map
fi

(cat << EOF
digit digit
islower lower
isupper upper
letter letter
numeric numeric
punctuation punctuation
space space
EOF
) | while read predicate suffix
do
  $UC $predicate $TOM_LIB_OPTIONS -u $UNICODEDATA $ISOMAP \
	-o ${PREFIX}.p.$suffix
done

for conversion in lower upper title
do
  $UC $conversion $TOM_LIB_OPTIONS -u $UNICODEDATA $ISOMAP \
	-o ${PREFIX}.c.$conversion
done
