]> git.saurik.com Git - apple/libc.git/blob - db/hash/FreeBSD/ndbm.c.patch
Libc-594.1.4.tar.gz
[apple/libc.git] / db / hash / FreeBSD / ndbm.c.patch
1 --- ndbm.c.org 2006-09-08 18:47:42.000000000 -0700
2 +++ ndbm.c 2006-09-08 18:48:03.000000000 -0700
3 @@ -51,6 +51,9 @@
4 #include <string.h>
5 #include <errno.h>
6
7 +#include <db.h>
8 +#define _DBM
9 +typedef DB DBM;
10 #include <ndbm.h>
11 #include "hash.h"
12
13 @@ -62,7 +65,8 @@
14 extern DBM *
15 dbm_open(file, flags, mode)
16 const char *file;
17 - int flags, mode;
18 + int flags;
19 + mode_t mode;
20 {
21 HASHINFO info;
22 char path[MAXPATHLEN];
23 @@ -128,10 +132,14 @@
24 int status;
25 datum retkey;
26 DBT dbtretkey, dbtretdata;
27 + HTAB *htab = (HTAB *)(db->internal);
28
29 status = (db->seq)(db, &dbtretkey, &dbtretdata, R_FIRST);
30 - if (status)
31 + if (status) {
32 dbtretkey.data = NULL;
33 + htab->nextkey_eof = 1;
34 + } else
35 + htab->nextkey_eof = 0;
36 retkey.dptr = dbtretkey.data;
37 retkey.dsize = dbtretkey.size;
38 return (retkey);
39 @@ -146,13 +154,20 @@
40 dbm_nextkey(db)
41 DBM *db;
42 {
43 - int status;
44 + int status = 1;
45 datum retkey;
46 DBT dbtretkey, dbtretdata;
47 + HTAB *htab = (HTAB *)(db->internal);
48
49 - status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);
50 - if (status)
51 + if (htab->nextkey_eof)
52 dbtretkey.data = NULL;
53 + else {
54 + status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);
55 + if (status) {
56 + dbtretkey.data = NULL;
57 + htab->nextkey_eof = 1;
58 + }
59 + }
60 retkey.dptr = dbtretkey.data;
61 retkey.dsize = dbtretkey.size;
62 return (retkey);