aboutsummaryrefslogtreecommitdiffstats
path: root/strftime.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-31 03:59:36 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-05-31 03:59:36 +0000
commit8fa30bbd48dd73d711961b226ef62780c21a96be (patch)
treea7746eda163ab172e17267cbb612452663a6e631 /strftime.c
parent69dcd16351786a75982bbeeed6a4b468e702339d (diff)
downloadruby-8fa30bbd48dd73d711961b226ef62780c21a96be.tar.gz
* strftime.c (rb_strftime_with_timespec): improved style consistency.
constified some variables. * test/test_time.rb (TestTime#test_huge_precision): test for #4456. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'strftime.c')
-rw-r--r--strftime.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/strftime.c b/strftime.c
index 8b6473ce38..69ed924325 100644
--- a/strftime.c
+++ b/strftime.c
@@ -170,8 +170,8 @@ max(int a, int b)
static size_t
rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const struct vtm *vtm, VALUE timev, struct timespec *ts, int gmt)
{
- char *endp = s + maxsize;
- char *start = s;
+ const char *const endp = s + maxsize;
+ const char *const start = s;
const char *sp, *tp;
auto char tbuf[100];
long off;
@@ -237,10 +237,7 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str
i = rb_strftime_with_timespec(s, endp - s, (fmt), vtm, timev, ts, gmt); \
if (!i) return 0; \
if (precision > i) {\
- if (start + maxsize < s + precision) { \
- errno = ERANGE; \
- return 0; \
- } \
+ NEEDS(precision); \
memmove(s + precision - i, s, i);\
memset(s, padding ? padding : ' ', precision - i); \
s += precision; \
@@ -618,7 +615,7 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str
if (*format == 'G') {
if (FIXNUM_P(yv)) {
- long y = FIX2LONG(yv);
+ const long y = FIX2LONG(yv);
FMT('0', 0 <= y ? 4 : 5, "ld", y);
}
else {