Skip to content

Commit

Permalink
Normalize gmp_cmp() to -1/0/+1
Browse files Browse the repository at this point in the history
  • Loading branch information
Girgias committed Nov 10, 2024
1 parent 8abb26d commit dc163dd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ext/gmp/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,8 @@ static int gmp_compare(zval *op1, zval *op2) /* {{{ */
}
return ZEND_UNCOMPARABLE;
}
return mpz_cmp(gmp_op1, gmp_op2);

return ZEND_THREEWAY_COMPARE(mpz_cmp(gmp_op1, gmp_op2), 0);
}
/* }}} */

Expand Down Expand Up @@ -1429,7 +1430,7 @@ ZEND_FUNCTION(gmp_cmp)
GMP_Z_PARAM_INTO_MPZ_PTR(gmpnum_b)
ZEND_PARSE_PARAMETERS_END();

RETURN_LONG(mpz_cmp(gmpnum_a, gmpnum_b));
RETURN_LONG(ZEND_THREEWAY_COMPARE(mpz_cmp(gmpnum_a, gmpnum_b), 0));
}
/* }}} */

Expand Down

0 comments on commit dc163dd

Please sign in to comment.