diff --git a/CHANGES b/CHANGES index 7d66962..e07e5b8 100644 --- a/CHANGES +++ b/CHANGES @@ -15,32 +15,53 @@ The following are the changes from calc version 2.12.7.1 to date: \t tab byte 0x09 in ASCII encoding \v vertical tab byte 0x0b in ASCII encoding - Fixed a segfault when getpwuid() returned NULL during initialization. - Thanks goes to baratharon GitHub user for reporting this issue. + Fixed a segfault when getpwuid() returned NULL during initialization. + Thanks goes to baratharon GitHub user for reporting this issue. - Requiring calc shell scripts to use -s -f at the end of the - initial #! line. + Requiring calc shell scripts to use -s -f at the end of the + initial #! line. - Fixed /tmp/mersenne example in calc(1) man page. + Fixed /tmp/mersenne example in calc(1) man page. - Added make variable ${ARCH_CFLAGS}. The ${ARCH_CFLAGS} is - added after ${CCMISC} and before ${EXTRA_CFLAGS} when building - the ${CFLAGS} for compiling C code. are ${CC} when compiling - C files. The default value is: + Added make variable ${ARCH_CFLAGS}. The ${ARCH_CFLAGS} is + added after ${CCMISC} and before ${EXTRA_CFLAGS} when building + the ${CFLAGS} for compiling C code. are ${CC} when compiling + C files. The default value is: ARCH_CFLAGS= -march=native - which directs C compiler to compile for the native machine. - To disable use of '-march=native', set ARCH_CFLAGS to the empty - string as in: + which directs C compiler to compile for the native machine. + To disable use of '-march=native', set ARCH_CFLAGS to the empty + string as in: make all ARCH_CFLAGS= - To make calc RPMs more portable, they are compiled with an - empty ARCH_CFLAGS. + To make calc RPMs more portable, they are compiled with an + empty ARCH_CFLAGS. - Fixed issues relating to compiling on macOS. Fixed issues - where is needed. + Fixed issues relating to compiling on macOS. Fixed issues + where is needed. + + Fixed typos in help/intro and README.md. <> + + Copied missing description lines from help/intro to README.md + "What is calc?" section. <> + + GCC 7 added a warning on fall throughs in case statements. It's + enabled by -Wextra and treated as an error due to -Wall so it + breaks compilation. See -Wimplicit-fallthrough in the GCC + manual. The default value is 3, which means a comment matching + some specific regexes is enough to disable the warning. + Fixed spaces vs tabs and use FALLTHRU as it's used elsewhere. + Fixed one FALLTHRU comment that was inconsistent with others. + <> + + Fixed minor typo on help/power. <> + + By default, the calc history file is located in ~/.calc_history. + Now, if the environment variable $CALCHISTFILE is defined + and is non-empty, then calc history file will be defined + by the $CALCHISTFILE environment variable. The following are the changes from calc version 2.12.6.10: to 2.12.7.0: diff --git a/Makefile.ship b/Makefile.ship index 3689b5d..9c8cd96 100644 --- a/Makefile.ship +++ b/Makefile.ship @@ -1054,7 +1054,7 @@ EXT= # The default calc versions # -VERSION= 2.12.7.4 +VERSION= 2.12.7.5 # Names of shared libraries with versions # @@ -5475,6 +5475,7 @@ hist.o: have_unistd.h hist.o: have_unused.h hist.o: hist.c hist.o: hist.h +hist.o: lib_calc.h hist.o: longbits.h hist.o: nametype.h hist.o: qmath.h diff --git a/calc.h b/calc.h index 3165f13..180b464 100644 --- a/calc.h +++ b/calc.h @@ -48,6 +48,7 @@ #define HOME "HOME" /* environment variable for home dir */ #define PAGER "PAGER" /* environment variable for help */ #define SHELL "SHELL" /* environment variable for shell */ +#define CALCHISTFILE "CALCHISTFILE" /* history file environment variable */ #define DEFAULTCALCBINDINGS "bindings" /* default calc bindings file */ #define DEFAULTCALCHELP "help" /* help file that -h prints */ #define DEFAULTSHELL "sh" /* default shell to use */ diff --git a/calc.man b/calc.man index 25602a2..db57279 100644 --- a/calc.man +++ b/calc.man @@ -1103,6 +1103,14 @@ Default value: binding This variable is not used if calc was compiled with GNU-readline support. In that case, the standard readline mechanisms (see readline(3)) are used. .sp +.TP 5 +CALCHISTFILE +Location of the calc history file. +.sp +Default value: ~/.calc_history +.sp +This variable is not used if calc was compiled with GNU-readline support. +.sp .SH CREDIT \& .br diff --git a/custom/Makefile b/custom/Makefile index 2de4ecc..6b86fb3 100644 --- a/custom/Makefile +++ b/custom/Makefile @@ -348,7 +348,7 @@ EXT= # The default calc versions # -VERSION= 2.12.7.4 +VERSION= 2.12.7.5 # Names of shared libraries with versions # diff --git a/custom/Makefile.head b/custom/Makefile.head index 1dff4be..2c8fce9 100644 --- a/custom/Makefile.head +++ b/custom/Makefile.head @@ -348,7 +348,7 @@ EXT= # The default calc versions # -VERSION= 2.12.7.4 +VERSION= 2.12.7.5 # Names of shared libraries with versions # diff --git a/help/environment b/help/environment index 41d458d..e414988 100644 --- a/help/environment +++ b/help/environment @@ -7,7 +7,8 @@ Environment variables / ./ ../ ~ - If this variable does not exist, a compiled value + If this variable does not exist, or if this + variable is an empty string, a compiled value is used. Typically compiled in value is: .:./cal:~/cal:${CALC_SHAREDIR}:${CUSTOMCALDIR} @@ -27,7 +28,8 @@ Environment variables line), calc searches for files along the :-separated $CALCRC environment variable. - If this variable does not exist, a compiled value + If this variable does not exist, or if this + variable is an empty string, a compiled value is used. Typically compiled in value is: ${CALC_SHAREDIR}/startup:~/.calcrc:./.calcinit @@ -66,7 +68,8 @@ Environment variables This value is taken to be the home directory of the current user. It is used when files begin with '~/'. - If this variable does not exist, the home directory password + If this variable does not exist, or if this + variable is an empty string, the home directory password entry of the current user is used. If that information is not available, '.' is used. @@ -75,7 +78,8 @@ Environment variables When invoking help, this environment variable is used to display a help file. - If this variable does not exist, a compiled value + If this variable does not exist, or if this + variable is an empty string, a compiled value is used. Typically compiled in value is something such as 'more', 'less', 'pg' or 'cat'. @@ -84,11 +88,20 @@ Environment variables When a !-command is used, the program indicated by this environment variable is used. - If this variable does not exist, a compiled value + If this variable does not exist, or if this + variable is an empty string, a compiled value is used. Typically compiled in value is something such as 'sh' is used. -## Copyright (C) 1999 Landon Curt Noll + CALCHISTFILE + + This value is taken to be the calc history file. + + If this variable does not exist, or if this + variable is an empty string, then ~/.calc_history + is used. + +## Copyright (C) 1999,2021 Landon Curt Noll ## ## Calc is open software; you can redistribute it and/or modify it under ## the terms of the version 2.1 of the GNU Lesser General Public License diff --git a/hist.c b/hist.c index 8c74058..d5df1d3 100644 --- a/hist.c +++ b/hist.c @@ -51,6 +51,7 @@ #endif #include "calc.h" +#include "lib_calc.h" #include "hist.h" #include "have_string.h" @@ -1461,9 +1462,6 @@ quit_calc(void) */ -/* name of history file */ -char *my_calc_history = NULL; - size_t hist_getline(char *prompt, char *buf, size_t len) { @@ -1504,8 +1502,8 @@ my_stifle_history (void) /* only save last number of entries */ stifle_history(HISTORY_LEN); - if (my_calc_history) - write_history(my_calc_history); + if (calc_history) + write_history(calc_history); } @@ -1519,10 +1517,12 @@ hist_init(char UNUSED *filename) using_history(); /* name of history file */ - my_calc_history = tilde_expand("~/.calc_history"); + if (calc_history == NULL) { + calc_history = tilde_expand("~/.calc_history"); + } /* read previous history */ - read_history(my_calc_history); + read_history(calc_history); atexit(my_stifle_history); diff --git a/lib_calc.c b/lib_calc.c index d5ffd1e..c18285c 100644 --- a/lib_calc.c +++ b/lib_calc.c @@ -145,6 +145,7 @@ char *calcbindings = NULL; /* $CALCBINDINGS or default */ char *home = NULL; /* $HOME or default */ char *pager = NULL; /* $PAGER or default */ char *shell = NULL; /* $SHELL or default */ +char *calc_history = NULL; /* $CALCHISTFILE or ~/.calc_history */ int stdin_tty = FALSE; /* TRUE if stdin is a tty */ int havecommands = FALSE; /* TRUE if have one or more cmd args */ long stoponerror = 0; /* >0 => stop, <0 => continue, ==0 => use -c */ @@ -546,6 +547,12 @@ initenv(void) shell = (c ? strdup(c) : NULL); if (shell == NULL || *shell == '\0') shell = DEFAULTSHELL; + + /* determine the $CALCHISTFILE value */ + c = (no_env ? NULL : getenv(CALCHISTFILE)); + calc_history = (c ? strdup(c) : NULL); + if (calc_history == NULL || *calc_history == '\0') + calc_history = NULL; /* will use ~/.calc_history */ } diff --git a/lib_calc.h b/lib_calc.h index 8c4a44d..2a510c4 100644 --- a/lib_calc.h +++ b/lib_calc.h @@ -74,4 +74,9 @@ EXTERN int calc_print_scanwarn_msg; /* number of parse/scan warnings found */ EXTERN unsigned long calc_warn_cnt; +/* + * calc history file + */ +EXTERN char *calc_history; + #endif /* !INCLUDE_MATH_ERROR_H */ diff --git a/version.c b/version.c index 44ca543..1ec46fe 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 7 /* major software level under library version */ -#define MINOR_PATCH 4 /* minor software level or 0 if not patched */ +#define MINOR_PATCH 5 /* minor software level or 0 if not patched */ /*