From 54a7a3f7bcf302e43cc5a0ca21fd2c1cbb069d76 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Fri, 19 Oct 2018 19:33:57 -0700 Subject: [PATCH] Release 2.12.6.10 Added a patch to replaces the manual search for include files in $(INCDIR) in the have_*.h targets with compiler invocations. Thanks goes to Helmut Grohne who implemented the patch and posted it to the Debian bug tracker and Martin Buck (m at rtin-buck dor de) for forwarding it to us. The check_include make rule was fixed to not assume /usr/include. The qprintnum() function now takes outdigits as a 3rd argument. Most of the time, this 3rd argument is just conf->outdigits. But when it comes to the experimental '%g', this value can change. This avoids having to modify conf->outdigits. --- CHANGES | 18 +++++++++- Makefile.ship | 81 +++++++++++--------------------------------- comfunc.c | 4 +-- custom/Makefile | 2 +- custom/Makefile.head | 2 +- func.c | 2 +- qio.c | 31 +++++------------ qmath.h | 2 +- qmod.c | 2 +- value.c | 6 ++-- version.c | 2 +- 11 files changed, 56 insertions(+), 96 deletions(-) diff --git a/CHANGES b/CHANGES index 222d515..a2f3935 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,20 @@ -The following are the changes from calc version 2.12.6.9 to date: +The following are the changes from calc version 2.12.6.10 to date: + + Added a patch to replaces the manual search for include files + in $(INCDIR) in the have_*.h targets with compiler invocations. + Thanks goes to Helmut Grohne who + implemented the patch and posted it to the Debian bug tracker + and Martin Buck (m at rtin-buck dor de) for forwarding it to us. + + The check_include make rule was fixed to not assume /usr/include. + + The qprintnum() function now takes outdigits as a 3rd argument. + Most of the time, this 3rd argument is just conf->outdigits. + But when it comes to the experimental '%g', this value can + change. This avoids having to modify conf->outdigits. + + +The following are the changes from calc version 2.12.6.9 to 2.12.6.9: Fixed a number of core dump bugs related to the calculation of tan(), cot(), sec(), csc(), tanh(), coth(), sech(), and csch(), diff --git a/Makefile.ship b/Makefile.ship index 88a8bc7..9a824ff 100644 --- a/Makefile.ship +++ b/Makefile.ship @@ -1054,7 +1054,7 @@ EXT= # The default calc versions # -VERSION= 2.12.6.9 +VERSION= 2.12.6.10 # Names of shared libraries with versions # @@ -2179,25 +2179,15 @@ TARGETS= ${EARLY_TARGETS} ${BLD_TYPE} ${LATE_TARGETS} all: check_include ${BLD_TYPE} CHANGES check_include: - $(Q) if [ ! -d ${INCDIR} ]; then \ - echo "ERROR: critical directory missing: /usr/include" 1>&2; \ - echo "Without this critical directory, we cannot compile." 1>&2; \ - echo 1>&2; \ + $(Q) if ! echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ + echo "ERROR: The critical include file is missing." 1>&2; \ + echo "Without critical include files, we cannot compile." 1>&2; \ echo "Perhaps your system isn't setup to compile C source?" 1>&2; \ - echo "For example, Apple OS X / darwin requres that XCode" 1>&2; \ - echo "must be installed and that you run the command:" 1>&2; \ echo 1>&2; \ - echo " xcode-select --install" 1>&2; \ + echo "For example, Apple macOS / Darwin requres that XCode" 1>&2; \ + echo "must be installed." 1>&2; \ echo 1>&2; \ - exit 1; \ - fi - $(Q) if [ ! -f ${INCDIR}/stdio.h ]; then \ - echo "ERROR: critical include files are missing" 1>&2; \ - echo "Without this critical directory, we cannot compile." 1>&2; \ - echo 1>&2; \ - echo "Perhaps your system isn't setup to compile C source?" 1>&2; \ - echo "For example, Apple OS X / darwin requres that XCode" 1>&2; \ - echo "must be installed and that you run the command:" 1>&2; \ + echo "Also macOS users might later to run this command:" 1>&2; \ echo 1>&2; \ echo " xcode-select --install" 1>&2; \ echo 1>&2; \ @@ -2477,22 +2467,13 @@ endian_calc.h: endian${EXT} ${MAKE_FILE} ${Q} echo '' >> endian_calc.h ${Q} echo '/* what byte order are we? */' >> endian_calc.h -${Q} if [ X"${CALC_BYTE_ORDER}" = X ]; then \ - if [ -f ${INCDIR}/endian.h ]; then \ + if echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '#include ' >> endian_calc.h; \ echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \ - elif [ -f ${INCDIR}/machine/endian.h ]; then \ + elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '#include ' >> endian_calc.h; \ echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \ - elif [ -f ${INCDIR}/sys/endian.h ]; then \ - echo '#include ' >> endian_calc.h; \ - echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \ - elif [ -f /usr/include/endian.h ]; then \ - echo '#include ' >> endian_calc.h; \ - echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \ - elif [ -f /usr/include/machine/endian.h ]; then \ - echo '#include ' >> endian_calc.h; \ - echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \ - elif [ -f /usr/include/sys/endian.h ]; then \ + elif echo '#include ' | ${CC} -E- >/dev/null 2>&1; then \ echo '#include ' >> endian_calc.h; \ echo '#define CALC_BYTE_ORDER BYTE_ORDER' >> endian_calc.h; \ else \ @@ -2559,9 +2540,7 @@ have_times.h: ${MAKE_FILE} echo '#define HAVE_TIMES_H /* yes */' >> have_times.h; \ elif [ X"${HAVE_TIMES_H}" = X"NO" ]; then \ echo '#undef HAVE_TIMES_H /* no */' >> have_times.h; \ - elif [ -f ${INCDIR}/times.h ]; then \ - echo '#define HAVE_TIMES_H /* yes */' >> have_times.h; \ - elif [ -f /usr/include/times.h ]; then \ + elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '#define HAVE_TIMES_H /* yes */' >> have_times.h; \ else \ echo '#undef HAVE_TIMES_H /* no */' >> have_times.h; \ @@ -2570,9 +2549,7 @@ have_times.h: ${MAKE_FILE} echo '#define HAVE_SYS_TIMES_H /* yes */' >> have_times.h; \ elif [ X"${HAVE_SYS_TIMES_H}" = X"NO" ]; then \ echo '#undef HAVE_SYS_TIMES_H /* no */' >> have_times.h; \ - elif [ -f ${INCDIR}/sys/times.h ]; then \ - echo '#define HAVE_SYS_TIMES_H /* yes */' >> have_times.h; \ - elif [ -f /usr/include/sys/times.h ]; then \ + elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '#define HAVE_SYS_TIMES_H /* yes */' >> have_times.h; \ else \ echo '#undef HAVE_SYS_TIMES_H /* no */' >> have_times.h; \ @@ -2581,9 +2558,7 @@ have_times.h: ${MAKE_FILE} echo '#define HAVE_TIME_H /* yes */' >> have_times.h; \ elif [ X"${HAVE_TIME_H}" = X"NO" ]; then \ echo '#undef HAVE_TIME_H /* no */' >> have_times.h; \ - elif [ -f ${INCDIR}/time.h ]; then \ - echo '#define HAVE_TIME_H /* yes */' >> have_times.h; \ - elif [ -f /usr/include/time.h ]; then \ + elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '#define HAVE_TIME_H /* yes */' >> have_times.h; \ else \ echo '#undef HAVE_TIME_H /* no */' >> have_times.h; \ @@ -2592,9 +2567,7 @@ have_times.h: ${MAKE_FILE} echo '#define HAVE_SYS_TIME_H /* yes */' >> have_times.h; \ elif [ X"${HAVE_SYS_TIME_H}" = X"NO" ]; then \ echo '#undef HAVE_SYS_TIME_H /* no */' >> have_times.h; \ - elif [ -f ${INCDIR}/sys/time.h ]; then \ - echo '#define HAVE_SYS_TIME_H /* yes */' >> have_times.h; \ - elif [ -f /usr/include/sys/time.h ]; then \ + elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '#define HAVE_SYS_TIME_H /* yes */' >> have_times.h; \ else \ echo '#undef HAVE_SYS_TIME_H /* no */' >> have_times.h; \ @@ -2630,9 +2603,7 @@ have_stdlib.h: ${MAKE_FILE} echo '#define HAVE_STDLIB_H /* yes */' >> have_stdlib.h; \ elif [ X"${HAVE_STDLIB_H}" = X"NO" ]; then \ echo '#undef HAVE_STDLIB_H /* no */' >> have_stdlib.h; \ - elif [ -f ${INCDIR}/stdlib.h ]; then \ - echo '#define HAVE_STDLIB_H /* yes */' >> have_stdlib.h; \ - elif [ -f /usr/include/stdlib.h ]; then \ + elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '#define HAVE_STDLIB_H /* yes */' >> have_stdlib.h; \ else \ echo '#undef HAVE_STDLIB_H /* no */' >> have_stdlib.h; \ @@ -2668,9 +2639,7 @@ have_unistd.h: ${MAKE_FILE} echo '#define HAVE_UNISTD_H /* yes */' >> have_unistd.h; \ elif [ X"${HAVE_UNISTD_H}" = X"NO" ]; then \ echo '#undef HAVE_UNISTD_H /* no */' >> have_unistd.h; \ - elif [ -f ${INCDIR}/unistd.h ]; then \ - echo '#define HAVE_UNISTD_H /* yes */' >> have_unistd.h; \ - elif [ -f /usr/include/unistd.h ]; then \ + elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '#define HAVE_UNISTD_H /* yes */' >> have_unistd.h; \ else \ echo '#undef HAVE_UNISTD_H /* no */' >> have_unistd.h; \ @@ -2706,9 +2675,7 @@ have_string.h: ${MAKE_FILE} echo '#define HAVE_STRING_H /* yes */' >> have_string.h; \ elif [ X"${HAVE_STRING_H}" = X"NO" ]; then \ echo '#undef HAVE_STRING_H /* no */' >> have_string.h; \ - elif [ -f ${INCDIR}/string.h ]; then \ - echo '#define HAVE_STRING_H /* yes */' >> have_string.h; \ - elif [ -f /usr/include/string.h ]; then \ + elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '#define HAVE_STRING_H /* yes */' >> have_string.h; \ else \ echo '#undef HAVE_STRING_H /* no */' >> have_string.h; \ @@ -2748,22 +2715,12 @@ terminal.h: ${MAKE_FILE} echo '#undef USE_TERMIOS /* */' >> terminal.h; \ echo '#undef USE_TERMIO /* */' >> terminal.h; \ echo '#undef USE_SGTTY /* */' >> terminal.h; \ - elif [ -f ${INCDIR}/termios.h ]; then \ + elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '/* use termios */' >> terminal.h; \ echo '#define USE_TERMIOS /* */' >> terminal.h; \ echo '#undef USE_TERMIO /* */' >> terminal.h; \ echo '#undef USE_SGTTY /* */' >> terminal.h; \ - elif [ -f ${INCDIR}/termio.h ]; then \ - echo '/* use termio */' >> terminal.h; \ - echo '#undef USE_TERMIOS /* */' >> terminal.h; \ - echo '#define USE_TERMIO /* */' >> terminal.h; \ - echo '#undef USE_SGTTY /* */' >> terminal.h; \ - elif [ -f /usr/include/termios.h ]; then \ - echo '/* use termios */' >> terminal.h; \ - echo '#define USE_TERMIOS /* */' >> terminal.h; \ - echo '#undef USE_TERMIO /* */' >> terminal.h; \ - echo '#undef USE_SGTTY /* */' >> terminal.h; \ - elif [ -f /usr/include/termio.h ]; then \ + elif echo '#include ' | ${CC} -E - >/dev/null 2>&1; then \ echo '/* use termio */' >> terminal.h; \ echo '#undef USE_TERMIOS /* */' >> terminal.h; \ echo '#define USE_TERMIO /* */' >> terminal.h; \ diff --git a/comfunc.c b/comfunc.c index 1ca8a5a..0df272f 100644 --- a/comfunc.c +++ b/comfunc.c @@ -1182,7 +1182,7 @@ comprint(COMPLEX *c) return; } if (!qiszero(c->real) || qiszero(c->imag)) - qprintnum(c->real, MODE_DEFAULT); + qprintnum(c->real, MODE_DEFAULT, conf->outdigits); qtmp = c->imag[0]; if (qiszero(&qtmp)) return; @@ -1192,7 +1192,7 @@ comprint(COMPLEX *c) math_chr('-'); qtmp.num.sign = 0; } - qprintnum(&qtmp, MODE_DEFAULT); + qprintnum(&qtmp, MODE_DEFAULT, conf->outdigits); math_chr('i'); } diff --git a/custom/Makefile b/custom/Makefile index 8b9ffcf..8ee2bdd 100644 --- a/custom/Makefile +++ b/custom/Makefile @@ -348,7 +348,7 @@ EXT= # The default calc versions # -VERSION= 2.12.6.9 +VERSION= 2.12.6.10 # Names of shared libraries with versions # diff --git a/custom/Makefile.head b/custom/Makefile.head index d8dddf8..57db8e0 100644 --- a/custom/Makefile.head +++ b/custom/Makefile.head @@ -348,7 +348,7 @@ EXT= # The default calc versions # -VERSION= 2.12.6.9 +VERSION= 2.12.6.10 # Names of shared libraries with versions # diff --git a/func.c b/func.c index 6f8ebb0..d29b1f1 100644 --- a/func.c +++ b/func.c @@ -335,7 +335,7 @@ f_str(VALUE *vp) break; case V_NUM: math_divertio(); - qprintnum(vp->v_num, MODE_DEFAULT); + qprintnum(vp->v_num, MODE_DEFAULT, conf->outdigits); cp = math_getdivertedio(); result.v_str = makestring(cp); break; diff --git a/qio.c b/qio.c index a63c189..f17d9ee 100644 --- a/qio.c +++ b/qio.c @@ -183,7 +183,7 @@ qprintf(char *fmt, ...) * Integers are always printed as themselves. */ void -qprintnum(NUMBER *q, int outmode) +qprintnum(NUMBER *q, int outmode, LEN outdigits) { NUMBER tmpval; long prec, exp; @@ -202,13 +202,13 @@ qprintnum(NUMBER *q, int outmode) case MODE_REAL: prec = qdecplaces(q); - if ((prec < 0) || (prec > conf->outdigits)) { + if ((prec < 0) || (prec > outdigits)) { if (conf->tilde_ok) PUTCHAR('~'); } if (conf->fullzero || (prec < 0) || - (prec > conf->outdigits)) - prec = conf->outdigits; + (prec > outdigits)) + prec = outdigits; qprintff(q, 0L, prec); break; @@ -225,7 +225,7 @@ qprintnum(NUMBER *q, int outmode) tmpval.num.sign = 0; exp = qilog10(&tmpval); if (exp == 0) { /* in range to output as real */ - qprintnum(q, MODE_REAL); + qprintnum(q, MODE_REAL, outdigits); return; } tmpval.num = _one_; @@ -237,35 +237,22 @@ qprintnum(NUMBER *q, int outmode) q = qmul(q, &tmpval); zfree(tmpval.num); zfree(tmpval.den); - qprintnum(q, MODE_REAL); + qprintnum(q, MODE_REAL, outdigits); qfree(q); PRINTF1("e%ld", exp); break; case MODE_REAL_AUTO: { - /* - * XXX - re-write to not modify conf->outdigits - * - * Modifying the configuration value could be dangerious - * when a calculation is aborted within an opcode. - * Better to use qprintfg() use inline code that - * does not depend on changing conf->outdigits. - */ const int P = conf->outdigits ? conf->outdigits : 1; - long olddigits; tmpval = *q; tmpval.num.sign = 0; exp = qilog10(&tmpval); - olddigits = conf->outdigits; if (P > exp && exp >= -P) { - conf->outdigits = P - 1 - exp; - qprintnum(q, MODE_REAL); + qprintnum(q, MODE_REAL, P - 1 - exp); } else { - conf->outdigits = P - 1; - qprintnum(q, MODE_EXP); + qprintnum(q, MODE_EXP, P - 1); } - conf->outdigits = olddigits; break; } @@ -288,7 +275,7 @@ qprintnum(NUMBER *q, int outmode) if (outmode2 != MODE2_OFF) { PUTSTR(" /* "); - qprintnum(q, outmode2); + qprintnum(q, outmode2, outdigits); PUTSTR(" */"); } } diff --git a/qmath.h b/qmath.h index 45ae7ab..b7782aa 100644 --- a/qmath.h +++ b/qmath.h @@ -67,7 +67,7 @@ E_FUNC FULL qtou(NUMBER *q); E_FUNC SFULL qtos(NUMBER *q); E_FUNC long qparse(char *str, int flags); E_FUNC void qfreenum(NUMBER *q); -E_FUNC void qprintnum(NUMBER *q, int mode); +E_FUNC void qprintnum(NUMBER *q, int mode, LEN outdigits); E_FUNC void qprintff(NUMBER *q, long width, long precision); E_FUNC void qprintfe(NUMBER *q, long width, long precision); E_FUNC void qprintfr(NUMBER *q, long width, BOOL force); diff --git a/qmod.c b/qmod.c index 7a5208a..9f30699 100644 --- a/qmod.c +++ b/qmod.c @@ -404,7 +404,7 @@ showredcdata(void) for (i = 0, rcp = redc_cache; i < MAXREDC; i++, rcp++) { if (rcp->age > 0) { printf("%-8ld%-8ld", i, rcp->age); - qprintnum(rcp->rnum, 0); + qprintnum(rcp->rnum, 0, conf->outdigits); printf("\n"); } } diff --git a/value.c b/value.c index 95c0917..40c2f6a 100644 --- a/value.c +++ b/value.c @@ -2774,7 +2774,7 @@ printvalue(VALUE *vp, int flags) } switch (type) { case V_NUM: - qprintnum(vp->v_num, MODE_DEFAULT); + qprintnum(vp->v_num, MODE_DEFAULT, conf->outdigits); if (conf->traceflags & TRACE_LINKS) math_fmt("#%ld", vp->v_num->links); break; @@ -2835,7 +2835,7 @@ printvalue(VALUE *vp, int flags) if (userfunc("octet_print", vp)) break; qtemp = itoq((long) *vp->v_octet); - qprintnum(qtemp, MODE_DEFAULT); + qprintnum(qtemp, MODE_DEFAULT, conf->outdigits); qfree(qtemp); break; case V_OPTR: @@ -2888,7 +2888,7 @@ printestr(VALUE *vp) math_chr('"'); return; case V_NUM: - qprintnum(vp->v_num, MODE_FRAC); + qprintnum(vp->v_num, MODE_FRAC, conf->outdigits); return; case V_COM: mode = math_setmode(MODE_FRAC); diff --git a/version.c b/version.c index 6d76c75..0cce3d4 100644 --- a/version.c +++ b/version.c @@ -45,7 +45,7 @@ static char *program; #define MAJOR_VER 2 /* major library version */ #define MINOR_VER 12 /* minor library version */ #define MAJOR_PATCH 6 /* major software level under library version */ -#define MINOR_PATCH 9 /* minor software level or 0 if not patched */ +#define MINOR_PATCH 10 /* minor software level or 0 if not patched */ /*