diff -u nano/files.c nano-histerror/files.c --- nano/files.c Thu Feb 20 22:23:01 2003 +++ nano-histerror/files.c Fri Feb 21 15:37:28 2003 @@ -2892,8 +2892,11 @@ if (homenv != NULL || userage != NULL) { hist = fopen(nanohist, "r"); if (!hist) { - if (errno != ENOENT) + if (errno != ENOENT) { + /* Don't save history when we quit. */ + UNSET(HISTORYLOG); rcfile_error(_("Unable to open ~/.nano_history file, %s"), strerror(errno)); + } free(nanohist); } else { buf = charalloc(1024); diff -u nano/nano.c nano-histerror/nano.c --- nano/nano.c Fri Feb 21 14:54:58 2003 +++ nano-histerror/nano.c Fri Feb 21 15:39:23 2003 @@ -66,18 +66,6 @@ /* What we do when we're all set to exit */ RETSIGTYPE finish(int sigage) { - -#ifndef NANO_SMALL -#ifdef ENABLE_NANORC - /* do here so errors about ./nano_history - don't confuse user */ - if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG)) - save_history(); -#endif - free_history(&search_history); - free_history(&replace_history); -#endif - keypad(edit, TRUE); keypad(bottomwin, TRUE); @@ -93,6 +81,11 @@ /* Restore the old term settings */ tcsetattr(0, TCSANOW, &oldterm); +#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) + if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG)) + save_history(); +#endif + #ifdef DEBUG thanks_for_all_the_fish(); #endif @@ -3317,6 +3310,14 @@ #endif #endif /* ENABLE_NANORC */ +#ifndef NANO_SMALL + history_init(); +#ifdef ENABLE_NANORC + if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG)) + load_history(); +#endif +#endif + #ifndef DISABLE_OPERATINGDIR /* Set up the operating directory. This entails chdir()ing there, so that file reads and writes will be based there. */ @@ -3396,14 +3397,6 @@ keypad(bottomwin, TRUE); } -#ifndef NANO_SMALL - history_init(); -#ifdef ENABLE_NANORC - if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG)) - load_history(); -#endif -#endif - diff -u nano/rcfile.c nano-histerror/rcfile.c --- nano/rcfile.c Wed Feb 19 03:46:01 2003 +++ nano-histerror/rcfile.c Fri Feb 21 15:29:43 2003 @@ -676,6 +676,7 @@ fclose(rcstream); } } + lineno = 0; free(nanorc); #ifdef ENABLE_COLOR