Skip to content

Commit 0b5b947

Browse files
committed
Normalize gmp_cmp() to -1/0/+1
1 parent 89eaa1f commit 0b5b947

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/gmp/gmp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ static int gmp_compare(zval *op1, zval *op2) /* {{{ */
481481
}
482482
return ZEND_UNCOMPARABLE;
483483
}
484-
return mpz_cmp(gmp_op1, gmp_op2);
484+
485+
return ZEND_THREEWAY_COMPARE(mpz_cmp(gmp_op1, gmp_op2), 0);
485486
}
486487
/* }}} */
487488

@@ -1436,7 +1437,7 @@ ZEND_FUNCTION(gmp_cmp)
14361437
GMP_Z_PARAM_INTO_MPZ_PTR(gmpnum_b)
14371438
ZEND_PARSE_PARAMETERS_END();
14381439

1439-
RETURN_LONG(mpz_cmp(gmpnum_a, gmpnum_b));
1440+
RETURN_LONG(ZEND_THREEWAY_COMPARE(mpz_cmp(gmpnum_a, gmpnum_b), 0));
14401441
}
14411442
/* }}} */
14421443

0 commit comments

Comments
 (0)