summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/object.c b/object.c
index 61492ef674..1c0a03b19a 100644
--- a/object.c
+++ b/object.c
@@ -2213,6 +2213,9 @@ rb_cstr_to_dbl(p, badcheck)
const char *q;
char *end;
double d;
+ const char *ellipsis = "";
+ int w;
+#define OutOfRange() (((w = end - p) > 20) ? (w = 20, ellipsis = "...") : (ellipsis = ""))
if (!p) return 0.0;
q = p;
@@ -2224,7 +2227,8 @@ rb_cstr_to_dbl(p, badcheck)
}
d = strtod(p, &end);
if (errno == ERANGE) {
- rb_warn("Float %*s out of range", end-p, p);
+ OutOfRange();
+ rb_warn("Float %.*s%s out of range", w, p, ellipsis);
errno = 0;
}
if (p == end) {
@@ -2258,18 +2262,20 @@ rb_cstr_to_dbl(p, badcheck)
p = buf;
d = strtod(p, &end);
if (errno == ERANGE) {
- rb_warn("Float %*s out of range", end-p, p);
+ OutOfRange();
+ rb_warn("Float %.*s%s out of range", w, p, ellipsis);
errno = 0;
}
if (badcheck) {
- if (p == end) goto bad;
+ if (!end || p == end) goto bad;
while (*end && ISSPACE(*end)) end++;
if (*end) goto bad;
}
}
if (errno == ERANGE) {
errno = 0;
- rb_raise(rb_eArgError, "Float %s out of range", q);
+ OutOfRange();
+ rb_raise(rb_eArgError, "Float %.*s%s out of range", w, q, ellipsis);
}
return d;
}