New function for range checking of integers.

This commit is contained in:
jgarcia 2006-11-01 17:44:14 +00:00
parent 0ff208f28e
commit 29f9b6c04d
5 changed files with 26 additions and 2 deletions

View file

@ -581,6 +581,7 @@ EXPORTS
fixint
fixnnint
ecl_fixnum_in_range
make_integer
make_unsigned_integer
make_ratio

View file

@ -587,6 +587,7 @@ EXPORTS
fixint
fixnnint
ecl_fixnum_in_range
make_integer
make_unsigned_integer
make_ratio

View file

@ -150,10 +150,13 @@ ECL 1.0:
assert_type_character(), assert_type_symbol().
- Lisp functions which disappear: si:set-compiled-function-name,
si:extended-string-concatenate, si:wrong-type-argument.
si:extended-string-concatenate.
- New C functions: ecl_stream_to_handle(), ecl_base_char_code(),
ecl_type_error(), ecl_check_cl_type(), ecl_check_type_string().
ecl_type_error(), ecl_check_cl_type(), ecl_check_type_string(),
ecl_fixnum_in_range().
- New Lisp functions: si:wrong-type-argument.
- Functions renamed: backup_fopen() -> ecl_backup_fopen()
char_code() -> ecl_char_code(), cl_log1() -> ecl_log1(),

View file

@ -78,6 +78,23 @@ fixnnint(cl_object x)
@':datum', x);
}
cl_fixnum
ecl_fixnum_in_range(cl_object fun, const char *what, cl_object value,
cl_fixnum min, cl_fixnum max)
{
do {
if (FIXNUMP(value)) {
cl_fixnum output = value;
if ((min <= output) && (output <= max)) {
return output;
}
}
value = ecl_type_error(fun, what, value,
cl_list(3,@'integer',MAKE_FIXNUM(min),
MAKE_FIXNUM(max)));
} while(1);
}
cl_object
make_integer(cl_fixnum l)
{

View file

@ -850,6 +850,8 @@ extern cl_object one_minus(cl_object x);
extern cl_fixnum fixint(cl_object x);
extern cl_index fixnnint(cl_object x);
extern cl_fixnum ecl_fixnum_in_range(cl_object fun, const char *what, cl_object value,
cl_fixnum min, cl_fixnum max);
extern cl_object make_integer(cl_fixnum i);
extern cl_object make_unsigned_integer(cl_index i);
extern cl_object make_ratio(cl_object num, cl_object den);