summaryrefslogtreecommitdiffstats
path: root/pym/portage_versions.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-08-15 02:50:35 +0000
committerZac Medico <zmedico@gentoo.org>2007-08-15 02:50:35 +0000
commit1d76e08db94e0760dafcbd22335340e783c9de5e (patch)
treedef5ed3a0ad1acfc69db34ec906632fc7620d3eb /pym/portage_versions.py
parentd4d3ff3cdf0b48d9f1656c8ebed277ee1a3c3f2a (diff)
downloadportage-1d76e08db94e0760dafcbd22335340e783c9de5e.tar.gz
portage-1d76e08db94e0760dafcbd22335340e783c9de5e.tar.bz2
portage-1d76e08db94e0760dafcbd22335340e783c9de5e.zip
For bug #188449, since python floats have limited range, we multiply both floating point representations by a constant so that they are transformed into whole numbers. This allows the practically infinite range of a python int to be exploited. The multiplication is done by padding both literal strings with zeros as necessary to ensure equal length. (trunk r7606)
svn path=/main/branches/2.1.2/; revision=7607
Diffstat (limited to 'pym/portage_versions.py')
-rw-r--r--pym/portage_versions.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/pym/portage_versions.py b/pym/portage_versions.py
index 52db5e747..91b8cc164 100644
--- a/pym/portage_versions.py
+++ b/pym/portage_versions.py
@@ -98,8 +98,17 @@ def vercmp(ver1, ver2, silent=1):
list2.append(int(vlist2[i]))
# now we have to use floats so 1.02 compares correctly against 1.1
else:
- list1.append(float("0."+vlist1[i]))
- list2.append(float("0."+vlist2[i]))
+ # list1.append(float("0."+vlist1[i]))
+ # list2.append(float("0."+vlist2[i]))
+ # Since python floats have limited range, we multiply both
+ # floating point representations by a constant so that they are
+ # transformed into whole numbers. This allows the practically
+ # infinite range of a python int to be exploited. The
+ # multiplication is done by padding both literal strings with
+ # zeros as necessary to ensure equal length.
+ max_len = max(len(vlist1[i]), len(vlist2[i]))
+ list1.append(int(vlist1[i].ljust(max_len, "0")))
+ list2.append(int(vlist2[i].ljust(max_len, "0")))
# and now the final letter
if len(match1.group(5)):