aboutsummaryrefslogtreecommitdiffstats
path: root/strftime.c
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
commit6099790621b5fe7c12f5b9a3b4ab5b6e3d952e57 (patch)
tree712d8c4c876f7694b6c9af801348938765b09bc8 /strftime.c
parent405b5272766ae305c0e54267923c6950a739c262 (diff)
downloadruby-6099790621b5fe7c12f5b9a3b4ab5b6e3d952e57.tar.gz
* strftime.c (STRFTIME): should add padding for %[xXrR] etc.
[ruby-dev:37185] fix: #792 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'strftime.c')
-rw-r--r--strftime.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/strftime.c b/strftime.c
index 7913c792a5..e2c8d5fabd 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 != '%') {