mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Added use of $CALCHISTFILE and start of 2.12.7.5
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.
This commit is contained in:
53
CHANGES
53
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 <unistd.h> is needed.
|
||||
Fixed issues relating to compiling on macOS. Fixed issues
|
||||
where <unistd.h> is needed.
|
||||
|
||||
Fixed typos in help/intro and README.md. <<GitHub guilhermgonzaga>>
|
||||
|
||||
Copied missing description lines from help/intro to README.md
|
||||
"What is calc?" section. <<GitHub guilhermgonzaga>>
|
||||
|
||||
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.
|
||||
<<thanks jcul>>
|
||||
|
||||
Fixed minor typo on help/power. <<GitHub thegithubr>>
|
||||
|
||||
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:
|
||||
|
@@ -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
|
||||
|
1
calc.h
1
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 */
|
||||
|
8
calc.man
8
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
|
||||
|
@@ -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
|
||||
#
|
||||
|
@@ -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
|
||||
#
|
||||
|
@@ -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
|
||||
|
14
hist.c
14
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);
|
||||
|
||||
|
@@ -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 */
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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 */
|
||||
|
@@ -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 */
|
||||
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user