#! /bin/sh

# produce width.t as follows:
# sh genutables + [ 300 320 400 410 500 510 ] ...
	# use newest version of Unicode data to append

# check width.c: ambiguous_* with:
# sh genutables -amb 320 400 ...
	# use newest version of Unicode data to check
	# note: has been stable since 400

comb=false
spac=false
ass=false
amb=false

case "$1" in
-c)	comb=true
	shift;;
-s)	spac=true
	shift;;
-amb)	amb=true
	shift;;
-a)	ass=true
	shift;;
"")	comb=true
	spac=true
	ass=true
	#amb=true
	shift

	set - .
	;;
esac

for dir in ${*-[0-9][0-9][0-9]}
do
  case "$dir" in
  ".")	ver=`sed -e '/^\# Blocks-/ s,[^0-9],,g' -e t -e d Blocks.txt`;;
  *)	ver=`echo $dir | sed -e "s,[^0-9],,g"`;;
  esac

  if $comb && [ -f $dir/u_comb.t ]
  then	echo
	echo "static struct interval"
	echo "combining_$ver [] ="
	cat $dir/u_comb.t
  fi

  if $spac && [ -f $dir/u_spaccomb.t ]
  then	echo
	echo "static struct interval"
	echo "spacing_combining_$ver [] ="
	cat $dir/u_spaccomb.t
  fi

  if $ass && [ -f $dir/u_assigned.t ]
  then	echo
	echo "static struct interval"
	echo "assigned_$ver [] ="
	cat $dir/u_assigned.t
  fi

  if $amb && [ -f $dir/u_ambig.t ]
  then	echo
	echo "static struct interval"
	echo "ambiguous_$ver [] ="
	cat $dir/u_ambig.t
  fi

done
