[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 50/55: Fix indentation in scm_sum.
From: |
Andy Wingo |
Subject: |
[Guile-commits] 50/55: Fix indentation in scm_sum. |
Date: |
Thu, 23 May 2019 11:52:45 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit 66ffd93dcf6becb325c467e7c80c035677132e59
Author: Mark H Weaver <address@hidden>
Date: Mon May 6 21:13:18 2019 -0400
Fix indentation in scm_sum.
---
libguile/numbers.c | 135 +++++++++++++++++++++++++++--------------------------
1 file changed, 68 insertions(+), 67 deletions(-)
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 3983501..709724e 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -7548,80 +7548,81 @@ scm_sum (SCM x, SCM y)
{
scm_t_inum xx = SCM_I_INUM (x);
return scm_c_make_rectangular (xx + SCM_COMPLEX_REAL (y),
- SCM_COMPLEX_IMAG (y));
+ SCM_COMPLEX_IMAG (y));
}
else if (SCM_FRACTIONP (y))
return scm_i_make_ratio (scm_sum (SCM_FRACTION_NUMERATOR (y),
- scm_product (x,
SCM_FRACTION_DENOMINATOR (y))),
- SCM_FRACTION_DENOMINATOR (y));
+ scm_product (x,
SCM_FRACTION_DENOMINATOR (y))),
+ SCM_FRACTION_DENOMINATOR (y));
else
return scm_wta_dispatch_2 (g_sum, x, y, SCM_ARGn, s_sum);
- } else if (SCM_BIGP (x))
- {
- if (SCM_I_INUMP (y))
- {
- scm_t_inum inum;
- int bigsgn;
- add_big_inum:
- inum = SCM_I_INUM (y);
- if (inum == 0)
- return x;
- bigsgn = mpz_sgn (SCM_I_BIG_MPZ (x));
- if (inum < 0)
- {
- SCM result = scm_i_mkbig ();
- mpz_sub_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), - inum);
- scm_remember_upto_here_1 (x);
- /* we know the result will have to be a bignum */
- if (bigsgn == -1)
- return result;
- return scm_i_normbig (result);
- }
- else
- {
- SCM result = scm_i_mkbig ();
- mpz_add_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), inum);
- scm_remember_upto_here_1 (x);
- /* we know the result will have to be a bignum */
- if (bigsgn == 1)
- return result;
- return scm_i_normbig (result);
- }
- }
- else if (SCM_BIGP (y))
- {
- SCM result = scm_i_mkbig ();
- int sgn_x = mpz_sgn (SCM_I_BIG_MPZ (x));
- int sgn_y = mpz_sgn (SCM_I_BIG_MPZ (y));
- mpz_add (SCM_I_BIG_MPZ (result),
- SCM_I_BIG_MPZ (x),
- SCM_I_BIG_MPZ (y));
- scm_remember_upto_here_2 (x, y);
- /* we know the result will have to be a bignum */
- if (sgn_x == sgn_y)
- return result;
- return scm_i_normbig (result);
- }
- else if (SCM_REALP (y))
- {
- double result = mpz_get_d (SCM_I_BIG_MPZ (x)) + SCM_REAL_VALUE (y);
- scm_remember_upto_here_1 (x);
- return scm_i_from_double (result);
- }
- else if (SCM_COMPLEXP (y))
- {
- double real_part = (mpz_get_d (SCM_I_BIG_MPZ (x))
- + SCM_COMPLEX_REAL (y));
- scm_remember_upto_here_1 (x);
- return scm_c_make_rectangular (real_part, SCM_COMPLEX_IMAG (y));
- }
- else if (SCM_FRACTIONP (y))
- return scm_i_make_ratio (scm_sum (SCM_FRACTION_NUMERATOR (y),
+ }
+ else if (SCM_BIGP (x))
+ {
+ if (SCM_I_INUMP (y))
+ {
+ scm_t_inum inum;
+ int bigsgn;
+ add_big_inum:
+ inum = SCM_I_INUM (y);
+ if (inum == 0)
+ return x;
+ bigsgn = mpz_sgn (SCM_I_BIG_MPZ (x));
+ if (inum < 0)
+ {
+ SCM result = scm_i_mkbig ();
+ mpz_sub_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), - inum);
+ scm_remember_upto_here_1 (x);
+ /* we know the result will have to be a bignum */
+ if (bigsgn == -1)
+ return result;
+ return scm_i_normbig (result);
+ }
+ else
+ {
+ SCM result = scm_i_mkbig ();
+ mpz_add_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), inum);
+ scm_remember_upto_here_1 (x);
+ /* we know the result will have to be a bignum */
+ if (bigsgn == 1)
+ return result;
+ return scm_i_normbig (result);
+ }
+ }
+ else if (SCM_BIGP (y))
+ {
+ SCM result = scm_i_mkbig ();
+ int sgn_x = mpz_sgn (SCM_I_BIG_MPZ (x));
+ int sgn_y = mpz_sgn (SCM_I_BIG_MPZ (y));
+ mpz_add (SCM_I_BIG_MPZ (result),
+ SCM_I_BIG_MPZ (x),
+ SCM_I_BIG_MPZ (y));
+ scm_remember_upto_here_2 (x, y);
+ /* we know the result will have to be a bignum */
+ if (sgn_x == sgn_y)
+ return result;
+ return scm_i_normbig (result);
+ }
+ else if (SCM_REALP (y))
+ {
+ double result = mpz_get_d (SCM_I_BIG_MPZ (x)) + SCM_REAL_VALUE (y);
+ scm_remember_upto_here_1 (x);
+ return scm_i_from_double (result);
+ }
+ else if (SCM_COMPLEXP (y))
+ {
+ double real_part = (mpz_get_d (SCM_I_BIG_MPZ (x))
+ + SCM_COMPLEX_REAL (y));
+ scm_remember_upto_here_1 (x);
+ return scm_c_make_rectangular (real_part, SCM_COMPLEX_IMAG (y));
+ }
+ else if (SCM_FRACTIONP (y))
+ return scm_i_make_ratio (scm_sum (SCM_FRACTION_NUMERATOR (y),
scm_product (x,
SCM_FRACTION_DENOMINATOR (y))),
SCM_FRACTION_DENOMINATOR (y));
- else
- return scm_wta_dispatch_2 (g_sum, x, y, SCM_ARGn, s_sum);
- }
+ else
+ return scm_wta_dispatch_2 (g_sum, x, y, SCM_ARGn, s_sum);
+ }
else if (SCM_REALP (x))
{
if (SCM_I_INUMP (y))
- [Guile-commits] 47/55: Reimplement SCM_MAKE_CHAR to evaluate its argument only once., (continued)
- [Guile-commits] 47/55: Reimplement SCM_MAKE_CHAR to evaluate its argument only once., Andy Wingo, 2019/05/23
- [Guile-commits] 51/55: Avoid 'with-latin1-locale' in binary I/O tests., Andy Wingo, 2019/05/23
- [Guile-commits] 15/55: Use 'scm_from_utf8_{string, symbol, keyword}' for C string literals., Andy Wingo, 2019/05/23
- [Guile-commits] 23/55: SRFI-19: Check for incompatible types in time comparisons., Andy Wingo, 2019/05/23
- [Guile-commits] 34/55: Don't mutate read-only string in ports test, Andy Wingo, 2019/05/23
- [Guile-commits] 36/55: Fix strftime compile with null threads, Andy Wingo, 2019/05/23
- [Guile-commits] 25/55: SRFI-19: Minor refactor of leap second table lookups., Andy Wingo, 2019/05/23
- [Guile-commits] 45/55: Update user-visible copyright years., Andy Wingo, 2019/05/23
- [Guile-commits] 46/55: Fix gc.test "after-gc-hook gets called" failures., Andy Wingo, 2019/05/23
- [Guile-commits] 55/55: Update iconv.m4 from gnulib., Andy Wingo, 2019/05/23
- [Guile-commits] 50/55: Fix indentation in scm_sum.,
Andy Wingo <=
- [Guile-commits] 48/55: Add 'scm_c_make_char' and use it where appropriate., Andy Wingo, 2019/05/23
- [Guile-commits] 07/55: Improve the documentation for 'nil?'., Andy Wingo, 2019/05/23
- [Guile-commits] 17/55: Fix typo in strings.h., Andy Wingo, 2019/05/23
- [Guile-commits] 18/55: scm_seed_to_random_state: Support wide string arguments., Andy Wingo, 2019/05/23
- [Guile-commits] 35/55: Remove redefinition of when & unless in snarf-check-and-output-texi, Andy Wingo, 2019/05/23
- [Guile-commits] 41/55: Make locale monetary conversion tests be less strict on terminal whitespace, Andy Wingo, 2019/05/23
- [Guile-commits] 39/55: Add a fallback value for the locale-monetary-decimal-point, Andy Wingo, 2019/05/23
- [Guile-commits] 40/55: Handle newlib C library's langinfo constant names, Andy Wingo, 2019/05/23
- [Guile-commits] 19/55: SRFI-19: Fix TAI->UTC conversions, leap second handling, etc., Andy Wingo, 2019/05/23