[前][次][番号順一覧][スレッド一覧]

ruby-changes:35014

From: suke <ko1@a...>
Date: Thu, 7 Aug 2014 21:52:39 +0900 (JST)
Subject: [ruby-changes:35014] suke:r47096 (trunk): * ext/win32ole/win32ole_typelib.c (foletypelib_version): return

suke	2014-08-07 21:52:25 +0900 (Thu, 07 Aug 2014)

  New Revision: 47096

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47096

  Log:
    * ext/win32ole/win32ole_typelib.c (foletypelib_version): return
      version string.
    
    * test/win32ole/test_win32ole_typelib.rb (test_version): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/ext/win32ole/win32ole_typelib.c
    trunk/test/win32ole/test_win32ole_typelib.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47095)
+++ ChangeLog	(revision 47096)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Aug  7 21:42:49 2014  Masaki Suketa <masaki.suketa@n...>
+
+	* ext/win32ole/win32ole_typelib.c (foletypelib_version): return
+	  version string.
+
+	* test/win32ole/test_win32ole_typelib.rb (test_version): ditto.
+
 Thu Aug  7 15:13:13 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* lib/cgi.rb: remove needless condition for old ruby version.
Index: ext/win32ole/win32ole_typelib.c
===================================================================
--- ext/win32ole/win32ole_typelib.c	(revision 47095)
+++ ext/win32ole/win32ole_typelib.c	(revision 47096)
@@ -299,34 +299,34 @@ oletypelib_search_registry2(VALUE self, https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_typelib.c#L299
         RegCloseKey(hversion);
     } else {
         fver = 0.0;
-	    for(j = 0; ;j++) {
-	        ver = reg_enum_key(hguid, j);
-	        if (ver == Qnil)
-	            break;
-	        err = reg_open_vkey(hguid, ver, &hversion);
-	        if (err != ERROR_SUCCESS)
-	            continue;
-	        tlib = reg_get_val(hversion, NULL);
-	        if (tlib == Qnil) {
-	             RegCloseKey(hversion);
-	             continue;
-	        }
-	        if (fver < atof(StringValuePtr(ver))) {
-	            fver = atof(StringValuePtr(ver));
-	            version = ver;
-	            typelib = tlib;
-	        }
-	        RegCloseKey(hversion);
-	    }
+        for(j = 0; ;j++) {
+            ver = reg_enum_key(hguid, j);
+            if (ver == Qnil)
+                break;
+            err = reg_open_vkey(hguid, ver, &hversion);
+            if (err != ERROR_SUCCESS)
+                continue;
+            tlib = reg_get_val(hversion, NULL);
+            if (tlib == Qnil) {
+                RegCloseKey(hversion);
+                continue;
+            }
+            if (fver < atof(StringValuePtr(ver))) {
+                fver = atof(StringValuePtr(ver));
+                version = ver;
+                typelib = tlib;
+            }
+            RegCloseKey(hversion);
+        }
     }
     RegCloseKey(hguid);
     RegCloseKey(htypelib);
     if (typelib != Qnil) {
-	hr = oletypelib_from_guid(guid, version, &pTypeLib);
-	if (SUCCEEDED(hr)) {
-	    found = Qtrue;
-	    oletypelib_set_member(self, pTypeLib);
-	}
+        hr = oletypelib_from_guid(guid, version, &pTypeLib);
+        if (SUCCEEDED(hr)) {
+            found = Qtrue;
+            oletypelib_set_member(self, pTypeLib);
+        }
     }
     return found;
 }
@@ -472,27 +472,25 @@ make_version_str(VALUE major, VALUE mino https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole_typelib.c#L472
 
 /*
  *  call-seq:
- *     WIN32OLE_TYPELIB#version -> The type library version.
+ *     WIN32OLE_TYPELIB#version -> The type library version String object.
  *
  *  Returns the type library version.
  *
  *     tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
- *     puts tlib.version #-> 1.3
+ *     puts tlib.version #-> "1.3"
  */
 static VALUE
 foletypelib_version(VALUE self)
 {
     TLIBATTR *pTLibAttr;
-    VALUE major;
-    VALUE minor;
     ITypeLib *pTypeLib;
+    VALUE version;
 
     pTypeLib = itypelib(self);
     oletypelib_get_libattr(pTypeLib, &pTLibAttr);
-    major = INT2NUM(pTLibAttr->wMajorVerNum);
-    minor = INT2NUM(pTLibAttr->wMinorVerNum);
+    version = rb_sprintf("%d.%d", pTLibAttr->wMajorVerNum, pTLibAttr->wMinorVerNum);
     pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
-    return rb_Float(make_version_str(major, minor));
+    return version;
 }
 
 /*
Index: test/win32ole/test_win32ole_typelib.rb
===================================================================
--- test/win32ole/test_win32ole_typelib.rb	(revision 47095)
+++ test/win32ole/test_win32ole_typelib.rb	(revision 47096)
@@ -66,7 +66,7 @@ if defined?(WIN32OLE_TYPELIB) https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole_typelib.rb#L66
 
     def test_version
       tlib = WIN32OLE_TYPELIB.new("Microsoft Shell Controls And Automation")
-      assert_equal(1.0, tlib.version)
+      assert_equal("1.0", tlib.version)
     end
 
     def test_major_version

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]