projects
/
yaz-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Import library now called yaz3.lib (yaz3d.lib for debug version).
[yaz-moved-to-github.git]
/
client
/
fhistory.c
diff --git
a/client/fhistory.c
b/client/fhistory.c
index
0020f76
..
0094fd0
100644
(file)
--- a/
client/fhistory.c
+++ b/
client/fhistory.c
@@
-2,7
+2,7
@@
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: fhistory.c,v 1.1 2007-01-24 11:50:18 adam Exp $
+ * $Id: fhistory.c,v 1.4 2007-05-06 20:12:19 adam Exp $
*/
/** \file fhistory.c
* \brief file history implementation
*/
/** \file fhistory.c
* \brief file history implementation
@@
-26,7
+26,7
@@
struct file_history {
file_history_t file_history_new()
{
file_history_t file_history_new()
{
- file_history_t fh = xmalloc(sizeof(*fh));
+ file_history_t fh = (file_history_t) xmalloc(sizeof(*fh));
fh->wr = wrbuf_alloc();
return fh;
}
fh->wr = wrbuf_alloc();
return fh;
}
@@
-75,7
+75,10
@@
int file_history_save(file_history_t fh)
char* homedir = getenv("HOME");
char fname[1024];
int ret = 0;
char* homedir = getenv("HOME");
char fname[1024];
int ret = 0;
+ int sz = wrbuf_len(fh->wr);
+ if (!sz)
+ return 0;
sprintf(fname, "%.500s%s%s", homedir ? homedir : "",
homedir ? "/" : "", ".yazclient.history");
sprintf(fname, "%.500s%s%s", homedir ? homedir : "",
homedir ? "/" : "", ".yazclient.history");
@@
-86,8
+89,8
@@
int file_history_save(file_history_t fh)
}
else
{
}
else
{
- size_t w = fwrite(wrbuf_buf(fh->wr), 1, wrbuf_len(fh->wr), f);
- if (w != wrbuf_len(fh->wr))
+ size_t w = fwrite(wrbuf_buf(fh->wr), 1, sz, f);
+ if (w != sz)
ret = -1;
if (fclose(f))
ret = -1;
ret = -1;
if (fclose(f))
ret = -1;
@@
-108,7
+111,7
@@
int file_history_trav(file_history_t fh, void *client_data,
if (wrbuf_buf(fh->wr)[i] == '\n')
{
wrbuf_buf(fh->wr)[i] = '\0';
if (wrbuf_buf(fh->wr)[i] == '\n')
{
wrbuf_buf(fh->wr)[i] = '\0';
- callback(client_data, wrbuf_buf(fh->wr) + off);
+ callback(client_data, wrbuf_cstr(fh->wr) + off);
wrbuf_buf(fh->wr)[i] = '\n';
i++;
break;
wrbuf_buf(fh->wr)[i] = '\n';
i++;
break;