[macruby-changes] [2520] MacRuby/trunk/time.c
source_changes at macosforge.org
source_changes at macosforge.org
Tue Sep 8 19:25:45 PDT 2009
Revision: 2520
http://trac.macosforge.org/projects/ruby/changeset/2520
Author: lsansonetti at apple.com
Date: 2009-09-08 19:25:45 -0700 (Tue, 08 Sep 2009)
Log Message:
-----------
changed Time#_load again to conform to stupid rubyspec
Modified Paths:
--------------
MacRuby/trunk/time.c
Modified: MacRuby/trunk/time.c
===================================================================
--- MacRuby/trunk/time.c 2009-09-09 02:25:01 UTC (rev 2519)
+++ MacRuby/trunk/time.c 2009-09-09 02:25:45 UTC (rev 2520)
@@ -2221,18 +2221,15 @@
time_mload(VALUE time, VALUE str)
{
struct time_object *tobj;
- unsigned long p, s;
time_t sec;
long usec;
- unsigned char *buf;
struct tm tm;
- int i, gmt;
+ int gmt;
long nsec;
- VALUE submicro;
time_modify(time);
- submicro = rb_attr_get(str, id_submicro);
+ VALUE submicro = rb_attr_get(str, id_submicro);
#if 0 // TODO
if (submicro != Qnil) {
st_delete(rb_generic_ivar_table(str), (st_data_t*)&id_submicro, 0);
@@ -2243,17 +2240,19 @@
StringValue(str);
assert(*(VALUE *)str == rb_cByteString);
- buf = (unsigned char *)rb_bytestring_byte_pointer(str);
- if (rb_bytestring_length(str) != 8 + 1) {
+ unsigned char *buf = (unsigned char *)rb_bytestring_byte_pointer(str);
+ const size_t buflen = rb_bytestring_length(str);
+ if (buflen != 8 && buflen != 9) {
rb_raise(rb_eTypeError, "marshaled time format differ");
}
- p = s = 0;
- for (i=0; i<4; i++) {
- p |= buf[i]<<(8*i);
+ unsigned long p = 0;
+ unsigned long s = 0;
+ for (int i = 0; i < 4; i++) {
+ p |= buf[i] << (8 * i);
}
- for (i=4; i<8; i++) {
- s |= buf[i]<<(8*(i-4));
+ for (int i = 4; i < 8; i++) {
+ s |= buf[i] << (8 * (i - 4));
}
if ((p & (1UL<<31)) == 0) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090908/a97717eb/attachment.html>
More information about the macruby-changes
mailing list