1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* time.c (rb_strftime): removed meaningless volatile modifiers, and

concatenate successive nul characters at once.  [ruby-dev:27472]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-10-22 04:27:48 +00:00
parent 1cc1c2f77e
commit e85b4d45a2
2 changed files with 13 additions and 11 deletions

View file

@ -1,10 +1,13 @@
Sat Oct 22 13:08:21 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
Sat Oct 22 13:26:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* object.c (sym_inspect), parse.y (parser_yylex, rb_symname_p): check
if valid as a symbol name more strictly. [ruby-dev:27478]
* test/ruby/test_symbol.rb: tests for [ruby-core:03573].
* time.c (rb_strftime): removed meaningless volatile modifiers, and
concatenate successive nul characters at once. [ruby-dev:27472]
Fri Oct 21 19:21:56 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* rubysig.h (CHECK_INTS): fixed typo. (I believe bit-or is improper)

19
time.c
View file

@ -1743,12 +1743,11 @@ time_to_a(time)
#define SMALLBUF 100
static int
rb_strftime(buf, format, time)
char ** volatile buf;
char * volatile format;
struct tm * volatile time;
char **buf;
const char *format;
struct tm *time;
{
volatile int size;
int len, flen;
int size, len, flen;
(*buf)[0] = '\0';
flen = strlen(format);
@ -1820,8 +1819,8 @@ time_strftime(time, format)
VALUE time, format;
{
struct time_object *tobj;
char buffer[SMALLBUF];
char *fmt, *buf = buffer;
char buffer[SMALLBUF], *buf = buffer;
const char *fmt;
long len;
VALUE str;
@ -1838,19 +1837,19 @@ time_strftime(time, format)
}
else if (strlen(fmt) < len) {
/* Ruby string may contain \0's. */
char *p = fmt, *pe = fmt + len;
const char *p = fmt, *pe = fmt + len;
str = rb_str_new(0, 0);
while (p < pe) {
len = rb_strftime(&buf, p, &tobj->tm);
rb_str_cat(str, buf, len);
p += strlen(p) + 1;
if (p <= pe)
rb_str_cat(str, "\0", 1);
if (buf != buffer) {
free(buf);
buf = buffer;
}
for (fmt = p; p < pe && !*p; ++p);
if (p > fmt) rb_str_cat(str, fmt, p - fmt);
}
return str;
}