fix string-ref' and bytes-ref' error message

Closes PR 11064, since the problem that triggered the bad
 error message is also fixed
This commit is contained in:
Matthew Flatt 2011-01-16 20:00:39 -07:00
parent 15381e761a
commit 07a7916142
2 changed files with 3 additions and 2 deletions

View File

@ -960,7 +960,8 @@ void scheme_out_of_string_range(const char *name, const char *which,
"%s: %sindex %s out of range [%d, %d] for %s%s: %t",
name, which,
scheme_make_provided_string(i, 2, NULL),
start, len,
((start < 0) ? 0 : start),
((start < 0) ? (len - 1) : len),
is_byte ? "byte-" : "",
SCHEME_CHAPERONE_VECTORP(s) ? "vector" : "string",
sstr, slen);

View File

@ -245,7 +245,7 @@ X_(scheme_checked, string_ref) (int argc, Scheme_Object *argv[])
i = scheme_extract_index(XSTRINGSTR "-ref", 1, argc, argv, len, 0);
if (i >= len) {
scheme_out_of_string_range(XSTRINGSTR "-ref", "", argv[1], argv[0], 0, len - 1);
scheme_out_of_string_range(XSTRINGSTR "-ref", "", argv[1], argv[0], -1, len);
return NULL;
}