summaryrefslogtreecommitdiff
path: root/ext/date/date_strptime.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/date/date_strptime.c')
-rw-r--r--ext/date/date_strptime.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ext/date/date_strptime.c b/ext/date/date_strptime.c
index 877baea435..4383eb6fa1 100644
--- a/ext/date/date_strptime.c
+++ b/ext/date/date_strptime.c
@@ -79,14 +79,17 @@ read_digits(const char *s, VALUE *n, size_t width)
{
size_t l;
- l = strspn(s, "0123456789");
+ if (!width)
+ return 0;
+
+ l = 0;
+ while (ISDIGIT(s[l])) {
+ if (++l == width) break;
+ }
if (l == 0)
return 0;
- if (width < l)
- l = width;
-
if ((4 * l * sizeof(char)) <= (sizeof(long)*CHAR_BIT)) {
const char *os = s;
long v;