aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-08-12 20:17:14 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-08-12 20:17:14 +0300
commit4e23fa7b90b56408d480ba8c7556b190757ea2c7 (patch)
tree7763d0dee3681c0a733a490feaf6dbdcf54e3f8d
parent6311c6b4d7ebe989447151a3e0f8b8ae0b5997d3 (diff)
downloadgdbm-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--NEWS9
-rw-r--r--src/gdbmdump.c14
-rw-r--r--src/gdbmexp.c7
3 files changed, 23 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index b883bc7..1ca9a32 100644
--- a/NEWS
+++ b/NEWS
@@ -1,25 +1,30 @@
-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.
Please send gdbm bug reports to <bug-gdbm@gnu.org>.
Version 1.17 - 2018-07-30
* int gdbm_close and gdbm_sync
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
* Maintain sorting order of the available block list after coalescing
This is a very long-standing bug, dated back to the time when optional
coalescing of available blocks with the newly released block was
introduced. Merging the released block with an adjacent block of
available space would clobber the sorting order of the available list.
The bug was discovered due to strict database consistency checks,
introduced in version 1.15.
@@ -475,17 +480,17 @@ Copyright (C) 1990-2017 Free Software Foundation, Inc.
of this document as received, in any medium, provided that the
copyright notice and this permission notice are preserved,
thus giving the recipient permission to redistribute in turn.
Permission is granted to distribute modified versions
of this document, or of portions of it,
under the above conditions, provided also that they
carry prominent notices stating who last changed them.
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"
time-stamp-end: "\n"
end:
diff --git a/src/gdbmdump.c b/src/gdbmdump.c
index daf6a43..2e6f5b0 100644
--- a/src/gdbmdump.c
+++ b/src/gdbmdump.c
@@ -103,35 +103,41 @@ _gdbm_dump_ascii (GDBM_FILE dbf, FILE *fp)
break;
}
}
else
break;
nextkey = gdbm_nextkey (dbf, key);
free (key.dptr);
free (data.dptr);
key = nextkey;
count++;
}
- 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)
+ {
+ 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;
}
int
gdbm_dump_to_file (GDBM_FILE dbf, FILE *fp, int format)
{
int rc;
/* Return immediately if the database needs recovery */
GDBM_ASSERT_CONSISTENCY (dbf, -1);
switch (format)
diff --git a/src/gdbmexp.c b/src/gdbmexp.c
index 25ad5b2..56a792a 100644
--- a/src/gdbmexp.c
+++ b/src/gdbmexp.c
@@ -74,25 +74,30 @@ gdbm_export_to_file (GDBM_FILE dbf, FILE *fp)
goto write_fail;
if (fwrite (data.dptr, data.dsize, 1, fp) != 1)
goto write_fail;
}
nextkey = gdbm_nextkey (dbf, key);
free (key.dptr);
free (data.dptr);
key = nextkey;
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;
return count;
write_fail:
GDBM_SET_ERRNO (NULL, GDBM_FILE_WRITE_ERROR, FALSE);
return -1;
}
int
gdbm_export (GDBM_FILE dbf, const char *exportfile, int flags, int mode)

Return to:

Send suggestions and report system problems to the System administrator.