X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=client%2Ffhistory.c;h=b75c03d8725685fae6e200edac7eeac0174f9f59;hp=0020f76fc483ea5acb3bff672418a621b1669d5f;hb=d42f045690a68380de575447bf9755f922ec734d;hpb=11594352845d8e70c9d668c20fde891a1d45f3d6 diff --git a/client/fhistory.c b/client/fhistory.c index 0020f76..b75c03d 100644 --- 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. * - * $Id: fhistory.c,v 1.1 2007-01-24 11:50:18 adam Exp $ + * $Id: fhistory.c,v 1.2 2007-01-24 23:09:48 adam Exp $ */ /** \file fhistory.c * \brief file history implementation @@ -75,7 +75,10 @@ int file_history_save(file_history_t fh) 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"); @@ -86,8 +89,8 @@ int file_history_save(file_history_t fh) } 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;