diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-03 03:14:27 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-03 03:14:27 +0000 |
commit | 9a0cb802523549298df7c49dbcd5705fb477113b (patch) | |
tree | da58ae60cf89cba96174d051a8552843b5323429 /ext/date | |
parent | 85e866978fb54cddf2692a9d3e439c709956eb62 (diff) | |
download | ruby-9a0cb802523549298df7c49dbcd5705fb477113b.tar.gz |
* ext/date/date_{parse,strptime}.c [ruby-dev:45303].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/date')
-rw-r--r-- | ext/date/date_parse.c | 22 | ||||
-rw-r--r-- | ext/date/date_strptime.c | 7 |
2 files changed, 15 insertions, 14 deletions
diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c index 903163003c..b282dbbc11 100644 --- a/ext/date/date_parse.c +++ b/ext/date/date_parse.c @@ -89,10 +89,10 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc) size_t l; s = RSTRING_PTR(y); - while (!issign(*s) && !isdigit(*s)) + while (!issign((unsigned char)*s) && !isdigit((unsigned char)*s)) s++; bp = s; - if (issign(*s)) + if (issign((unsigned char)*s)) s++; l = strspn(s, "0123456789"); ep = s + l; @@ -138,7 +138,7 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc) VALUE iy; s = RSTRING_PTR(y); - while (!issign(*s) && !isdigit(*s)) + while (!issign((unsigned char)*s) && !isdigit((unsigned char)*s)) s++; bp = s; if (issign(*s)) { @@ -170,7 +170,7 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc) VALUE im; s = RSTRING_PTR(m); - while (!isdigit(*s)) + while (!isdigit((unsigned char)*s)) s++; bp = s; l = strspn(s, "0123456789"); @@ -192,7 +192,7 @@ s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc) VALUE id; s = RSTRING_PTR(d); - while (!isdigit(*s)) + while (!isdigit((unsigned char)*s)) s++; bp = s; l = strspn(s, "0123456789"); @@ -381,14 +381,14 @@ date_zone_to_diff(VALUE str) dest = d = ALLOCA_N(char, l + 1); for (i = 0; i < l; i++) { - if (isspace(s[i]) || s[i] == '\0') { + if (isspace((unsigned char)s[i]) || s[i] == '\0') { if (!sp) *d++ = ' '; sp = 1; } else { - if (isalpha(s[i])) - *d++ = tolower(s[i]); + if (isalpha((unsigned char)s[i])) + *d++ = tolower((unsigned char)s[i]); else *d++ = s[i]; sp = 0; @@ -1413,7 +1413,7 @@ parse_ddd_cb(VALUE m, VALUE hash) s3 = s1; zone = rb_str_new2(s3); set_hash("zone", zone); - if (isdigit(*s1)) + if (isdigit((unsigned char)*s1)) *--s1 = '+'; set_hash("offset", date_zone_to_diff(rb_str_new2(s1))); } @@ -1520,9 +1520,9 @@ check_class(VALUE s) flags = 0; for (i = 0; i < RSTRING_LEN(s); i++) { - if (isalpha(RSTRING_PTR(s)[i])) + if (isalpha((unsigned char)RSTRING_PTR(s)[i])) flags |= HAVE_ALPHA; - if (isdigit(RSTRING_PTR(s)[i])) + if (isdigit((unsigned char)RSTRING_PTR(s)[i])) flags |= HAVE_DIGIT; if (RSTRING_PTR(s)[i] == '-') flags |= HAVE_DASH; diff --git a/ext/date/date_strptime.c b/ext/date/date_strptime.c index eaec8e716b..c6a5969172 100644 --- a/ext/date/date_strptime.c +++ b/ext/date/date_strptime.c @@ -58,14 +58,15 @@ static const char *extz_pats[] = { static int num_pattern_p(const char *s) { - if (isdigit(*s)) + if (isdigit((unsigned char)*s)) return 1; if (*s == '%') { s++; if (*s == 'E' || *s == 'O') s++; if (*s && - (strchr("CDdeFGgHIjkLlMmNQRrSsTUuVvWwXxYy", *s) || isdigit(*s))) + (strchr("CDdeFGgHIjkLlMmNQRrSsTUuVvWwXxYy", *s) || + isdigit((unsigned char)*s))) return 1; } return 0; @@ -624,7 +625,7 @@ date__strptime_internal(const char *str, size_t slen, case '\v': case '\f': case '\r': - while (isspace(str[si])) + while (isspace((unsigned char)str[si])) si++; fi++; break; |