X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fterminal%2Fread-line.c;h=f28fb6fe3912a989a1df8ef74d234ffc402474c4;hb=e6ae2a61e5356694c09f48da74407f8054a04e8d;hp=97427c6c1a59754a1f5ce20cfa31596566b8cb5c;hpb=2d4dd90964061defa92972156ae2a12323708519;p=pspp diff --git a/src/ui/terminal/read-line.c b/src/ui/terminal/read-line.c index 97427c6c1a..f28fb6fe39 100644 --- a/src/ui/terminal/read-line.c +++ b/src/ui/terminal/read-line.c @@ -1,6 +1,5 @@ /* PSPP - computes sample statistics. Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. - Written by Ben Pfaff . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -71,16 +70,18 @@ readln_initialize (void) #if HAVE_READLINE rl_basic_word_break_characters = "\n"; -#ifdef unix + using_history (); + stifle_history (500); if (history_file == NULL) { - history_file = tilde_expand ("~/.pspp_history"); - using_history (); - read_history (history_file); - stifle_history (500); + const char *home_dir = getenv ("HOME"); + if (home_dir != NULL) + { + history_file = xasprintf ("%s/.pspp_history", home_dir); + read_history (history_file); + } } #endif -#endif } /* Close getl. */ @@ -89,7 +90,7 @@ readln_uninitialize (void) { initialised = false; -#if HAVE_READLINE && unix +#if HAVE_READLINE if (history_file != NULL && false == get_testing_mode() ) write_history (history_file); clear_history (); @@ -99,11 +100,13 @@ readln_uninitialize (void) static bool -read_interactive (struct getl_interface *s, struct string *line) +read_interactive (struct getl_interface *s, + struct string *line, enum getl_syntax *syntax) { struct readln_source *is = (struct readln_source *) s ; + *syntax = GETL_INTERACTIVE; return is->interactive_func (line, prompt_get_style ()); } @@ -126,23 +129,9 @@ welcome (void) "conditions.\nThere is ABSOLUTELY NO WARRANTY for PSPP; type \"show " "warranty.\" for details.\n", stdout); puts (stat_version); - -#if HAVE_READLINE && unix - if (history_file == NULL) - { - history_file = tilde_expand ("~/.pspp_history"); - using_history (); - read_history (history_file); - stifle_history (500); - } -#endif + readln_initialize (); } - - - - - /* Gets a line from the user and stores it into LINE. Prompts the user with PROMPT. Returns true if successful, false at end of file.