summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-25 15:28:22 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-11-25 15:28:22 +0000
commit1d274eb3a057e148b23f333357082012e579861f (patch)
tree712d8c4c876f7694b6c9af801348938765b09bc8
parent5cbe1ecff0cf8c331b0b39f315ba1f43251585da (diff)
downloadruby-1d274eb3a057e148b23f333357082012e579861f.tar.gz
ruby-1d274eb3a057e148b23f333357082012e579861f.tar.xz
ruby-1d274eb3a057e148b23f333357082012e579861f.zip
* strftime.c (STRFTIME): should add padding for %[xXrR] etc.
[ruby-dev:37185] fix: #792 git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--strftime.c7
2 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index b43b00a1b..96b8c5d47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Nov 26 00:26:30 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * strftime.c (STRFTIME): should add padding for %[xXrR] etc.
+ [ruby-dev:37185] fix: #792
+
Tue Nov 25 16:26:12 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (rb_ary_times): taint (and untrust) status should be
diff --git a/strftime.c b/strftime.c
index 7913c792a..e2c8d5fab 100644
--- a/strftime.c
+++ b/strftime.c
@@ -295,7 +295,12 @@ rb_strftime(char *s, size_t maxsize, const char *format, const struct tm *timept
do { \
i = strftime(s, endp - s, fmt, tm); \
if (!i) return 0; \
- s += i; \
+ if (precision > i) {\
+ memmove(s + precision - i, s, i);\
+ memset(s, padding ? padding : ' ', precision - i); \
+ s += precision; \
+ }\
+ else s += i; \
} while (0)
if (*format != '%') {