dnl CF_WIDEC_SHIFT version: 4 updated: 2010/10/23 15:52:32
dnl --------------
dnl Compute the shift-mask that we'll use for wide-character indices.  We use
dnl all but the index portion of chtype for storing attributes.
AC_DEFUN([CF_WIDEC_SHIFT],
[
AC_REQUIRE([CF_TYPEOF_CHTYPE])
AC_MSG_CHECKING([for number of bits in chtype])
AC_CACHE_VAL(cf_cv_shift_limit,[
	AC_TRY_RUN([
#include <stdio.h>
int main()
{
	FILE *fp = fopen("cf_test.out", "w");
	if (fp != 0) {
		int n;
		unsigned TYPEOF_CHTYPE x = 1L;
		for (n = 0; ; n++) {
			unsigned long y = (x >> n);
			if (y != 1 || x == 0)
				break;
			x <<= 1;
		}
		fprintf(fp, "%d", n);
		fclose(fp);
	}
	${cf_cv_main_return:-return}(0);
}
		],
		[cf_cv_shift_limit=`cat cf_test.out`],
		[cf_cv_shift_limit=32],
		[cf_cv_shift_limit=32])
		rm -f cf_test.out
	])
AC_MSG_RESULT($cf_cv_shift_limit)
AC_SUBST(cf_cv_shift_limit)

AC_MSG_CHECKING([for width of character-index])
AC_CACHE_VAL(cf_cv_widec_shift,[
if test ".$with_widec" = ".yes" ; then
	cf_attrs_width=39
	if ( expr $cf_cv_shift_limit \> $cf_attrs_width >/dev/null )
	then
		cf_cv_widec_shift=`expr 16 + $cf_cv_shift_limit - $cf_attrs_width`
	else
		cf_cv_widec_shift=16
	fi
else
	cf_cv_widec_shift=8
fi
])
AC_MSG_RESULT($cf_cv_widec_shift)
AC_SUBST(cf_cv_widec_shift)
])dnl
