aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-07-08 11:28:53 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2016-07-08 14:12:34 +0300
commit4aef6b36f862e46723403bc6422ac47058a5ef19 (patch)
treefa7afe6ed8f1abf080fa764bda1bbc81e07f407b /doc
parent260102cf7f75db3c87d04a06eb8054853cacce97 (diff)
downloadgdbm-4aef6b36f862e46723403bc6422ac47058a5ef19.tar.gz
gdbm-4aef6b36f862e46723403bc6422ac47058a5ef19.tar.bz2
Fix error handling in gdbm_fetch, gdbm_firstkey, and gdbm_nextkey.
* src/gdbmfetch.c: Hanlde out of memory error. * src/findkey.c: Set gdbm_errno to GDBM_ITEM_NOT_FOUND if nothing was found. * src/gdbmdelete.c: Don't set gdbm_errno after _gdbm_findkey returns -1. It's been done already. * src/gdbmexp.c (gdbm_export_to_file): Return -1 if gdbm_fetch fails. * src/gdbmseq.c (get_next_key): Set gdbm_errno to GDBM_ITEM_NOT_FOUND if there's no next key. Don't call _gdbm_fatal on out of memory condition. (gdbm_nextkey): Set gdbm_errno to GDBM_ITEM_NOT_FOUND if there's no next key. * src/gdbmtool.c (fetch_handler) (firstkey_handler,nextkey_handler): Check gdbm_errno. * src/gdbmstore.c: Handle error return from _gdbm_findkey. * tests/gtdump.c: Likewise. * tests/gtfetch.c: Likewise. * doc/gdbm.texi: Document changes. * doc/gdbm.3: Likewise. * configure.ac: Version 1.12.90 * NEWS: Update. * .gitignore: Update.
Diffstat (limited to 'doc')
-rw-r--r--doc/gdbm.323
-rw-r--r--doc/gdbm.texi20
2 files changed, 29 insertions, 14 deletions
diff --git a/doc/gdbm.3 b/doc/gdbm.3
index 860829a..98b718b 100644
--- a/doc/gdbm.3
+++ b/doc/gdbm.3
@@ -1,3 +1,3 @@
.\" This file is part of GDBM.
-.\" Copyright (C) 2011, 2013 Free Software Foundation, Inc.
+.\" Copyright (C) 2011, 2013, 2016 Free Software Foundation, Inc.
.\"
@@ -15,3 +15,3 @@
.\" along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
-.TH GDBM 3 "July 6, 2016" "GDBM" "GDBM User Reference"
+.TH GDBM 3 "July 8, 2016" "GDBM" "GDBM User Reference"
.SH NAME
@@ -173,3 +173,3 @@ If the value of 0 is provided, \fBgdbm\fR will use a default function.
The return value is the pointer needed by all other routines to
-access that gdbm file. If the return is the NULL pointer, \fBgdbm_open\fR
+access that gdbm file. If the return is the \fBNULL\fR pointer, \fBgdbm_open\fR
was not successful. The errors can be found in \fIgdbm_errno\fR for gdbm
@@ -220,4 +220,8 @@ the key data.
-If the \fIdptr\fR element of the return value is NULL, no data was
-found. Otherwise the return value is a pointer to the found data.
+If the \fIdptr\fR element of the return value is \fBNULL\fR, the
+\fBgdbm_errno\fR variable should be examined. The value of
+\fBGDBM_ITEM_NOT_FOUND\fR means no data was found for that \fIkey\fR.
+Other value means an error occurred.
+
+Otherwise the return value is a pointer to the found data.
The storage space for the \fIdptr\fR element is allocated using
@@ -261,4 +265,7 @@ key data.
The return values are both of type \fBdatum\fR. If the \fIdptr\fR
-element of the return value is NULL, there is no first key or next key.
-Again notice that \fIdptr\fR points to data allocated by \fBmalloc(3)\fR
+element of the return value is \fBNULL\fR, inspect the
+\fBgdbm_errno\fR. If it is \fBGDBM_ITEM_NOT_FOUND\fR, there is no
+first key or next key. Otherwise, an error occurred.
+
+Again, notice that \fIdptr\fR points to data allocated by \fBmalloc(3)\fR
and \fBgdbm\fR will not free it for you.
@@ -428,3 +435,3 @@ by Philip A. Nelson, Jason Downs and Sergey Poznyakoff.
.SH COPYRIGHT
-Copyright \(co 1990 - 2011 Free Software Foundation, Inc.
+Copyright \(co 1990 - 2016 Free Software Foundation, Inc.
diff --git a/doc/gdbm.texi b/doc/gdbm.texi
index 6322a9b..6fad9d9 100644
--- a/doc/gdbm.texi
+++ b/doc/gdbm.texi
@@ -45,3 +45,3 @@ Boston, MA 02110-1301, USA
-Copyright @copyright{} 1989-1999, 2007-2011 Free Software Foundation, Inc.
+Copyright @copyright{} 1989-1999, 2007-2016 Free Software Foundation, Inc.
@@ -432,3 +432,7 @@ responsibility to free it when no longer needed.
-If the @samp{dptr} is @samp{NULL}, no data was found.
+If the @samp{dptr} is @samp{NULL}, inspect the value of the
+@code{gdbm_errno} variable (@pxref{Variables,gdbm_errno}). If it is
+@samp{GDBM_ITEM_NOT_FOUND}, no data was found. Any other value means an
+error occurred. Use @code{gdbm_strerror} function to convert
+@code{gdbm_errno} to a human-readable string.
@@ -517,4 +521,6 @@ Initiate sequential access to the database @var{dbf}. The returned
value is the first key accessed in the database. If the @samp{dptr}
-field in the returned datum is @samp{NULL}, the database contains no
-data.
+field in the returned datum is @samp{NULL}, inspect the
+@code{gdbm_errno} variable (@pxref{Variables, gdbm_errno}). The value
+of @code{GDBM_ITEM_NOT_FOUND} means that the database contains no
+data. Other value means an error occurred.
@@ -532,4 +538,6 @@ value returned from a previous call to @code{gdbm_nextkey} or
The function returns next key from the database. If the @samp{dptr}
-field in the returned datum is @samp{NULL}, all keys in the database
-has been visited.
+field in the returned datum is @samp{NULL} inspect the
+@code{gdbm_errno} variable (@pxref{Variables, gdbm_errno}). The value
+of @code{GDBM_ITEM_NOT_FOUND} means that all keys in the database
+has been visited. Any other value means an error occurred.

Return to:

Send suggestions and report system problems to the System administrator.