diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-08-12 20:17:14 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-08-12 20:17:14 +0300 |
commit | 4e23fa7b90b56408d480ba8c7556b190757ea2c7 (patch) | |
tree | 7763d0dee3681c0a733a490feaf6dbdcf54e3f8d | |
parent | 6311c6b4d7ebe989447151a3e0f8b8ae0b5997d3 (diff) | |
download | gdbm-4e23fa7b90b56408d480ba8c7556b190757ea2c7.tar.gz gdbm-4e23fa7b90b56408d480ba8c7556b190757ea2c7.tar.bz2 |
Bugfix
* src/gdbmdump.c (_gdbm_dump_ascii): Clear the GDBM_ITEM_NOT_FOUND error.
* src/gdbmexp.c (gdbm_export_to_file): Likewise.
* NEWS: Update.
-rw-r--r-- | NEWS | 9 | ||||
-rw-r--r-- | src/gdbmdump.c | 20 | ||||
-rw-r--r-- | src/gdbmexp.c | 7 |
3 files changed, 26 insertions, 10 deletions
@@ -1,3 +1,3 @@ -GNU dbm NEWS -- history of user-visible changes. 2018-07-30 +GNU dbm NEWS -- history of user-visible changes. 2018-08-12 Copyright (C) 1990-2018 Free Software Foundation, Inc. See the end of file for copying conditions. @@ -12,4 +12,9 @@ Both functions now return 0 on success. On error, they return -1 and set gdbm_errno and errno to the appropriate error codes. +* Fix bug in gdbm_dump function + +The function did not clear the GDBM_ITEM_NOT_FOUND error marker, which +is set upon its normal termination. + Version 1.16 - 2018-06-27 @@ -485,5 +490,5 @@ Local variables: mode: outline paragraph-separate: "[ ]*$" -eval: (add-hook 'write-file-hooks 'time-stamp) +eval: (add-hook 'write-file-functions 'time-stamp) time-stamp-start: "changes. " time-stamp-format: "%:y-%02m-%02d" diff --git a/src/gdbmdump.c b/src/gdbmdump.c index daf6a43..2e6f5b0 100644 --- a/src/gdbmdump.c +++ b/src/gdbmdump.c @@ -113,15 +113,21 @@ _gdbm_dump_ascii (GDBM_FILE dbf, FILE *fp) } - if (rc == 0 && (rc = gdbm_last_errno (dbf)) == 0) + /* FIXME: Something like that won't hurt, although load does not + use it currently. */ + fprintf (fp, "#:count=%lu\n", (unsigned long) count); + fprintf (fp, "# End of data\n"); + + if (rc == 0) { - - /* FIXME: Something like that won't hurt, although load does not - use it currently. */ - fprintf (fp, "#:count=%lu\n", (unsigned long) count); - fprintf (fp, "# End of data\n"); + rc = gdbm_last_errno (dbf); + if (rc == GDBM_ITEM_NOT_FOUND) + { + gdbm_clear_error (dbf); + gdbm_errno = GDBM_NO_ERROR; + rc = 0; + } } free (buffer); - return rc ? -1 : 0; } diff --git a/src/gdbmexp.c b/src/gdbmexp.c index 25ad5b2..56a792a 100644 --- a/src/gdbmexp.c +++ b/src/gdbmexp.c @@ -84,5 +84,10 @@ gdbm_export_to_file (GDBM_FILE dbf, FILE *fp) count++; } - if (gdbm_errno != GDBM_ITEM_NOT_FOUND) + if (gdbm_last_errno (dbf) == GDBM_ITEM_NOT_FOUND) + { + gdbm_clear_error (dbf); + gdbm_errno = GDBM_NO_ERROR; + } + else return -1; |