aboutsummaryrefslogtreecommitdiffstats
path: root/history.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-12-05 16:34:33 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-12-05 16:34:33 +0000
commit5b608d8f0fa72cca41ab0c9a81bb33c21f6684e4 (patch)
treef5bfb0da5747f86e4d65ff4ba38268f1448af5a2 /history.c
parentfix indent (diff)
downloadw3m-5b608d8f0fa72cca41ab0c9a81bb33c21f6684e4.tar.gz
w3m-5b608d8f0fa72cca41ab0c9a81bb33c21f6684e4.zip
[w3m-dev 03530] save history
* history.c (saveHistory): save tmpfile and rename From: Takahashi Youichirou <nikuq@hk.airnet.ne.jp>
Diffstat (limited to '')
-rw-r--r--history.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/history.c b/history.c
index 2ecc731..4f242fa 100644
--- a/history.c
+++ b/history.c
@@ -1,4 +1,4 @@
-/* $Id: history.c,v 1.7 2002/01/26 17:24:01 ukai Exp $ */
+/* $Id: history.c,v 1.8 2002/12/05 16:34:33 ukai Exp $ */
#include "fm.h"
#ifdef USE_HISTORY
@@ -54,10 +54,12 @@ saveHistory(Hist *hist, size_t size)
{
FILE *f;
HistItem *item;
+ char *tmpf;
if (hist == NULL || hist->list == NULL)
return;
- if ((f = fopen(rcFile(HISTORY_FILE), "w")) == NULL) {
+ tmpf = tmpfname(TMPF_DFL, NULL)->ptr;
+ if ((f = fopen(tmpf, "w")) == NULL) {
disp_err_message("Can't open history", FALSE);
return;
}
@@ -67,6 +69,7 @@ saveHistory(Hist *hist, size_t size)
for (; item; item = item->next)
fprintf(f, "%s\n", (char *)item->ptr);
fclose(f);
+ rename(tmpf, rcFile(HISTORY_FILE));
}
#endif /* USE_HISTORY */