]> git.saurik.com Git - apple/libc.git/blobdiff - db/hash/FreeBSD/ndbm.c.patch
Libc-763.11.tar.gz
[apple/libc.git] / db / hash / FreeBSD / ndbm.c.patch
index 7be0d7a831ec5ac0e0e37bd8e476b5d9e7a3ab75..6292cd609871ae53554f35876777d61d290d3c83 100644 (file)
@@ -1,14 +1,16 @@
---- ndbm.c.orig        Wed Oct 22 19:07:02 2003
-+++ ndbm.c     Wed Dec 17 09:24:33 2003
-@@ -51,6 +51,7 @@
+--- ndbm.c.orig        2009-11-06 12:41:16.000000000 -0800
++++ ndbm.c     2009-11-06 12:41:27.000000000 -0800
+@@ -47,6 +47,9 @@ __FBSDID("$FreeBSD: src/lib/libc/db/hash
  #include <string.h>
  #include <errno.h>
  
 +#include <db.h>
++#define _DBM
++typedef DB DBM;
  #include <ndbm.h>
  #include "hash.h"
  
-@@ -62,7 +63,8 @@
+@@ -58,7 +61,8 @@ __FBSDID("$FreeBSD: src/lib/libc/db/hash
  extern DBM *
  dbm_open(file, flags, mode)
        const char *file;
  {
        HASHINFO info;
        char path[MAXPATHLEN];
+@@ -124,10 +128,14 @@ dbm_firstkey(db)
+       int status;
+       datum retkey;
+       DBT dbtretkey, dbtretdata;
++      HTAB *htab = (HTAB *)(db->internal);
+       status = (db->seq)(db, &dbtretkey, &dbtretdata, R_FIRST);
+-      if (status)
++      if (status) {
+               dbtretkey.data = NULL;
++              htab->nextkey_eof = 1;
++      } else
++              htab->nextkey_eof = 0;
+       retkey.dptr = dbtretkey.data;
+       retkey.dsize = dbtretkey.size;
+       return (retkey);
+@@ -142,13 +150,20 @@ extern datum
+ dbm_nextkey(db)
+       DBM *db;
+ {
+-      int status;
++      int status = 1;
+       datum retkey;
+       DBT dbtretkey, dbtretdata;
++      HTAB *htab = (HTAB *)(db->internal);
+-      status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);
+-      if (status)
++      if (htab->nextkey_eof)
+               dbtretkey.data = NULL;
++      else {
++              status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);
++              if (status) {
++                      dbtretkey.data = NULL;
++                      htab->nextkey_eof = 1;
++              }
++      }
+       retkey.dptr = dbtretkey.data;
+       retkey.dsize = dbtretkey.size;
+       return (retkey);