Fix Bug #635 - "Starting ngspice with HOME env variable unset causes segfault".
This commit is contained in:
parent
eda9cadbed
commit
762b131bb3
13
src/main.c
13
src/main.c
|
|
@ -19,6 +19,7 @@
|
||||||
#ifdef HAVE_GNUREADLINE
|
#ifdef HAVE_GNUREADLINE
|
||||||
# include <readline/readline.h>
|
# include <readline/readline.h>
|
||||||
# include <readline/history.h>
|
# include <readline/history.h>
|
||||||
|
# include "../misc/tilde.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* editline development has added the following typdef to readline.h in 06/2018.
|
/* editline development has added the following typdef to readline.h in 06/2018.
|
||||||
|
|
@ -614,11 +615,15 @@ static void
|
||||||
app_rl_init(void)
|
app_rl_init(void)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE)
|
#if defined(HAVE_GNUREADLINE) || defined(HAVE_BSDEDITLINE)
|
||||||
|
char *home;
|
||||||
|
|
||||||
/* --- set up readline params --- */
|
/* --- set up readline params --- */
|
||||||
strcpy(history_file, getenv("HOME"));
|
|
||||||
strcat(history_file, "/.");
|
if (get_local_home(0, &home) < 0)
|
||||||
strcat(history_file, application_name);
|
return;
|
||||||
strcat(history_file, "_history");
|
snprintf(history_file, sizeof history_file, "%s/.%s_history",
|
||||||
|
home, application_name);
|
||||||
|
tfree(home);
|
||||||
|
|
||||||
using_history();
|
using_history();
|
||||||
read_history(history_file);
|
read_history(history_file);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue