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:
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);
|
||||
|
||||
|
Reference in New Issue
Block a user