diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-30 09:23:45 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-30 09:23:45 +0000 |
commit | a6aa6b67eb4620cac1378eb486ea58b8668a708f (patch) | |
tree | 597cec595cb3f3662ce905c9ceae42a142561558 /strftime.c | |
parent | 242351be25cc4cbc055595335b24fb5d23642d30 (diff) |
merges r20357 from trunk into ruby_1_9_1.
* strftime.c (STRFTIME): should add padding for %[xXrR] etc.
[ruby-dev:37185] fix: #792
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'strftime.c')
-rw-r--r-- | strftime.c | 7 |
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 != '%') { |