summaryrefslogtreecommitdiff
path: root/lib/bigint.pl
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@alpha.hut.fi>1996-10-07 22:03:00 +0300
committerAndy Dougherty <doughera@lafcol.lafayette.edu>1996-10-07 22:03:00 +0300
commit1e2e1ae8d60a2653b0297f8d75f9d4fe5abfc82b (patch)
tree2297b603f6ebbd6de492c26c20c255765c6d8aa4 /lib/bigint.pl
parent6b48aaa47c056913e026307247ee46ad81e899e2 (diff)
downloadperl-1e2e1ae8d60a2653b0297f8d75f9d4fe5abfc82b.tar.gz
LC_COLLATE.
Big patch to add, document, and test LC_COLLATE support. ord() is a dangerous thing.
Diffstat (limited to 'lib/bigint.pl')
-rw-r--r--lib/bigint.pl24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/bigint.pl b/lib/bigint.pl
index e6ba644e3b..a274736e44 100644
--- a/lib/bigint.pl
+++ b/lib/bigint.pl
@@ -103,13 +103,23 @@ sub main'bcmp { #(num_str, num_str) return cond_code
sub cmp { # post-normalized compare for internal use
local($cx, $cy) = @_;
- $cx cmp $cy
- &&
- (
- ord($cy) <=> ord($cx)
- ||
- ($cx cmp ',') * (length($cy) <=> length($cx) || $cy cmp $cx)
- );
+ return 0 if ($cx eq $cy);
+
+ local($sx, $sy) = (substr($cx, 0, 1), substr($cy, 0, 1));
+ local($ld);
+
+ if ($sx eq '+') {
+ return 1 if ($sy eq '-' || $cy eq '+0');
+ $ld = length($cx) - length($cy);
+ return $ld if ($ld);
+ return $cx cmp $cy;
+ } else { # $sx eq '-'
+ return -1 if ($sy eq '+');
+ $ld = length($cy) - length($cx);
+ return $ld if ($ld);
+ return $cy cmp $cx;
+ }
+
}
sub main'badd { #(num_str, num_str) return num_str