use / to detect -0.0; fix error-checking bugs

svn: r2571
This commit is contained in:
Matthew Flatt 2006-04-01 13:22:24 +00:00
parent 7ba6ab2bb8
commit c1ba7dc426
3 changed files with 10 additions and 19 deletions

View File

@ -613,21 +613,12 @@ double scheme_real_to_double(Scheme_Object *r)
} }
static static
/* Inlining seems to trip over a bug in gcc 3.4.x, #ifndef NO_INLINE_KEYWORD
and it's not worth the trouble. MSC_IZE(inline)
#ifndef NO_INLINE_KEYWORD #endif
# ifndef DONT_INLINE_NZERO_TEST
MSC_IZE(inline)
# endif
#endif */
int minus_zero_p(double d) int minus_zero_p(double d)
{ {
/* Relies on 4-byte "int": */ return (1 / d) < 0;
if (((int *) mzALIAS &d)[0] == ((int *) mzALIAS &scheme_floating_point_nzero)[0]
&& ((int *) mzALIAS &d)[1] == ((int *) mzALIAS &scheme_floating_point_nzero)[1])
return 1;
return 0;
} }
int scheme_minus_zero_p(double d) int scheme_minus_zero_p(double d)

View File

@ -1917,7 +1917,7 @@ static Scheme_Object *real_to_bytes (int argc, Scheme_Object *argv[])
size = SCHEME_INT_VAL(argv[1]); size = SCHEME_INT_VAL(argv[1]);
else else
size = 0; size = 0;
if ((size != 2) && (size != 4) &&(size != 8)) if ((size != 4) && (size != 8))
scheme_wrong_type("real->floating-point-bytes", "exact 4 or 8", 1, argc, argv); scheme_wrong_type("real->floating-point-bytes", "exact 4 or 8", 1, argc, argv);
if (argc > 2) if (argc > 2)

View File

@ -103,11 +103,6 @@ X_(make, string) (int argc, Scheme_Object *argv[])
len = scheme_extract_index("make-" XSTRINGSTR, 0, argc, argv, -1, 0); len = scheme_extract_index("make-" XSTRINGSTR, 0, argc, argv, -1, 0);
if (len == -1) {
scheme_raise_out_of_memory("make-" XSTRINGSTR, "making " XSTR "string of length %s",
scheme_make_provided_string(argv[0], 0, NULL));
}
if (argc == 2) { if (argc == 2) {
if (!CHARP(argv[1])) if (!CHARP(argv[1]))
scheme_wrong_type("make-" XSTRINGSTR, CHAR_STR, 1, argc, argv); scheme_wrong_type("make-" XSTRINGSTR, CHAR_STR, 1, argc, argv);
@ -115,6 +110,11 @@ X_(make, string) (int argc, Scheme_Object *argv[])
} else } else
fill = 0; fill = 0;
if (len == -1) {
scheme_raise_out_of_memory("make-" XSTRINGSTR, "making " XSTR "string of length %s",
scheme_make_provided_string(argv[0], 0, NULL));
}
str = X(scheme_alloc, _string)(len, fill); str = X(scheme_alloc, _string)(len, fill);
return str; return str;
} }