From d78228e5cc04dfeed4cff23324e4c076dd4f78b8 Mon Sep 17 00:00:00 2001 From: teramako Date: Sun, 1 Feb 2009 05:32:30 +0000 Subject: change compVersion to use [https://developer.mozilla.org/En/NsIVersionComparator nsIVersionComparator] git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@29380 d0d07461-0603-4401-acd4-de1884942a52 --- pluginManager.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'pluginManager.js') diff --git a/pluginManager.js b/pluginManager.js index 20d5ed6..a44d158 100644 --- a/pluginManager.js +++ b/pluginManager.js @@ -320,21 +320,9 @@ Plugin.prototype = { // {{{ return 'update complete.'; }, - compVersion: function(a, b){ - a = (a || '').split('.'); - b = (b || '').split('.'); - if (!a.length && b.length) return -1; - if (a.length && !b.length) return 1; - for (let [i, bv] in Iterator(b)) { - var av = i < a.length ? a[i] : 0; - if (av == bv) continue; - if (!isNaN(av) && !isNaN(bv)) { - av = parseInt(av); - bv = parseInt(bv); - } - return av < bv ? -1 : 1; - } - return 0; + compVersion: function(a, b){ + const comparator = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator); + return comparator.compare(a, b); } }; // }}} // }}} -- cgit v1.2.3