summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-13 01:49:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-13 01:49:16 +0000
commit9e778a8ad5de8026a6e02f406ca2098c45313e80 (patch)
tree3d8fed3efa99c929d27dcea196dfd81ed1e28e84
parentee7993afb44557fcb86510f4cdeb162ae0ee7c53 (diff)
win32ole.c: fix long conversion
* ext/win32ole/win32ole.c (ole_val2variant): get rid of repeated conversions and fix a compile error due to V_I8 in old VC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/win32ole/win32ole.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index dbed05f8e5..90268975ff 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -1269,13 +1269,16 @@ ole_val2variant(VALUE val, VARIANT *var)
V_BSTR(var) = ole_vstr2wc(val);
break;
case T_FIXNUM:
- V_I4(var) = NUM2LONG(val);
- if (V_I4(var) == NUM2LONG(val)) {
- V_VT(var) = VT_I4;
- }
- else {
- V_I8(var) = NUM2LONG(val);
- V_VT(var) = VT_I8;
+ V_VT(var) = VT_I4;
+ {
+ long v = NUM2LONG(val);
+ V_I4(var) = (LONG)v;
+#if SIZEOF_LONG > 4
+ if (V_I4(var) != v) {
+ V_I8(var) = NUM2LONG(val);
+ V_VT(var) = VT_I8;
+ }
+#endif
}
break;
case T_BIGNUM: