1
0
Fork 0
mirror of git://git.psyced.org/git/psyced synced 2024-08-15 03:25:10 +00:00

bignum_cmp

This commit is contained in:
psyc://psyced.org/~lynX 2010-03-09 18:55:51 +01:00
parent 8c6522112a
commit a0a9e533cf
4 changed files with 31 additions and 9 deletions

View file

@ -1222,6 +1222,25 @@ string decode_embedded_charset(string text) {
return text;
}
// things only the twitter gateway needs...
//
// this is compatible to Perl's <=> operator:
// Binary "<=>" returns -1, 0, or 1 depending on whether the left argument
// is numerically less than, equal to, or greater than the right argument.
int bignum_cmp(string a, string b) {
int i;
if (a == b) return 0;
// calling strlen is probably faster than
// allocating a local variable to "cache" it
if (strlen(a) > strlen(b)) return 1;
if (strlen(a) < strlen(b)) return -1;
for (i=0; i<strlen(a); i++) {
if (a[i] == b[i]) continue;
if (a[i] > b[i]) return 1;
if (a[i] < b[i]) return -1;
}
}
#endif // __PIKE__
object library_object() {