dbm 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/dbm/dbm.c +24 -23
- data/ext/dbm/extconf.rb +4 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcbc9c6af29e76a1546f65dd589d42dc37e144ee1b4e79d0246059eefd6b757c
|
4
|
+
data.tar.gz: 73f4ead14bf9420540b06c299a452b2133b90fd889258ca4381cd9cb2fe72d12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1d2da0344a7c3f7540798f94d673298471ad908b657e0bacc5e01c4873133741d2cfcfdd34feb032b2fad5dbcaf0e0dd2da2ab00d24ce269dc1f7f95a442960
|
7
|
+
data.tar.gz: f9d641e66a7bf434afabc723d43f27e52167be3b175fdc379b91c120672caff747b33f9941faa2679b59fb13690045f1370dae7802490edba0cbff12ff99dcf7
|
data/ext/dbm/dbm.c
CHANGED
@@ -39,6 +39,8 @@ struct dbmdata {
|
|
39
39
|
DBM *di_dbm;
|
40
40
|
};
|
41
41
|
|
42
|
+
NORETURN(static void closed_dbm(void));
|
43
|
+
|
42
44
|
static void
|
43
45
|
closed_dbm(void)
|
44
46
|
{
|
@@ -277,12 +279,11 @@ fdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
|
|
277
279
|
not_found:
|
278
280
|
if (NIL_P(ifnone) && rb_block_given_p()) {
|
279
281
|
keystr = rb_str_dup(keystr);
|
280
|
-
OBJ_TAINT(keystr);
|
281
282
|
return rb_yield(keystr);
|
282
283
|
}
|
283
284
|
return ifnone;
|
284
285
|
}
|
285
|
-
return
|
286
|
+
return rb_str_new(value.dptr, value.dsize);
|
286
287
|
}
|
287
288
|
|
288
289
|
/*
|
@@ -342,7 +343,7 @@ fdbm_key(VALUE obj, VALUE valstr)
|
|
342
343
|
val = dbm_fetch(dbm, key);
|
343
344
|
if ((long)val.dsize == RSTRING_LEN(valstr) &&
|
344
345
|
memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0) {
|
345
|
-
return
|
346
|
+
return rb_str_new(key.dptr, key.dsize);
|
346
347
|
}
|
347
348
|
}
|
348
349
|
return Qnil;
|
@@ -375,8 +376,8 @@ fdbm_select(VALUE obj)
|
|
375
376
|
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
376
377
|
VALUE assoc, v;
|
377
378
|
val = dbm_fetch(dbm, key);
|
378
|
-
assoc = rb_assoc_new(
|
379
|
-
|
379
|
+
assoc = rb_assoc_new(rb_str_new(key.dptr, key.dsize),
|
380
|
+
rb_str_new(val.dptr, val.dsize));
|
380
381
|
v = rb_yield(assoc);
|
381
382
|
if (RTEST(v)) {
|
382
383
|
rb_ary_push(new, assoc);
|
@@ -444,7 +445,7 @@ fdbm_delete(VALUE obj, VALUE keystr)
|
|
444
445
|
}
|
445
446
|
|
446
447
|
/* need to save value before dbm_delete() */
|
447
|
-
valstr =
|
448
|
+
valstr = rb_str_new(value.dptr, value.dsize);
|
448
449
|
|
449
450
|
if (dbm_delete(dbm, key)) {
|
450
451
|
dbmp->di_size = -1;
|
@@ -479,8 +480,8 @@ fdbm_shift(VALUE obj)
|
|
479
480
|
key = dbm_firstkey(dbm);
|
480
481
|
if (!key.dptr) return Qnil;
|
481
482
|
val = dbm_fetch(dbm, key);
|
482
|
-
keystr =
|
483
|
-
valstr =
|
483
|
+
keystr = rb_str_new(key.dptr, key.dsize);
|
484
|
+
valstr = rb_str_new(val.dptr, val.dsize);
|
484
485
|
dbm_delete(dbm, key);
|
485
486
|
|
486
487
|
return rb_assoc_new(keystr, valstr);
|
@@ -512,9 +513,9 @@ fdbm_delete_if(VALUE obj)
|
|
512
513
|
|
513
514
|
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
514
515
|
val = dbm_fetch(dbm, key);
|
515
|
-
keystr =
|
516
|
+
keystr = rb_str_new(key.dptr, key.dsize);
|
516
517
|
OBJ_FREEZE(keystr);
|
517
|
-
valstr =
|
518
|
+
valstr = rb_str_new(val.dptr, val.dsize);
|
518
519
|
ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status);
|
519
520
|
if (status != 0) break;
|
520
521
|
if (RTEST(ret)) rb_ary_push(ary, keystr);
|
@@ -581,8 +582,8 @@ fdbm_invert(VALUE obj)
|
|
581
582
|
GetDBM2(obj, dbmp, dbm);
|
582
583
|
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
583
584
|
val = dbm_fetch(dbm, key);
|
584
|
-
keystr =
|
585
|
-
valstr =
|
585
|
+
keystr = rb_str_new(key.dptr, key.dsize);
|
586
|
+
valstr = rb_str_new(val.dptr, val.dsize);
|
586
587
|
rb_hash_aset(hash, valstr, keystr);
|
587
588
|
}
|
588
589
|
return hash;
|
@@ -742,7 +743,7 @@ fdbm_each_value(VALUE obj)
|
|
742
743
|
GetDBM2(obj, dbmp, dbm);
|
743
744
|
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
744
745
|
val = dbm_fetch(dbm, key);
|
745
|
-
rb_yield(
|
746
|
+
rb_yield(rb_str_new(val.dptr, val.dsize));
|
746
747
|
GetDBM2(obj, dbmp, dbm);
|
747
748
|
}
|
748
749
|
return obj;
|
@@ -765,7 +766,7 @@ fdbm_each_key(VALUE obj)
|
|
765
766
|
|
766
767
|
GetDBM2(obj, dbmp, dbm);
|
767
768
|
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
768
|
-
rb_yield(
|
769
|
+
rb_yield(rb_str_new(key.dptr, key.dsize));
|
769
770
|
GetDBM2(obj, dbmp, dbm);
|
770
771
|
}
|
771
772
|
return obj;
|
@@ -792,8 +793,8 @@ fdbm_each_pair(VALUE obj)
|
|
792
793
|
|
793
794
|
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
794
795
|
val = dbm_fetch(dbm, key);
|
795
|
-
keystr =
|
796
|
-
valstr =
|
796
|
+
keystr = rb_str_new(key.dptr, key.dsize);
|
797
|
+
valstr = rb_str_new(val.dptr, val.dsize);
|
797
798
|
rb_yield(rb_assoc_new(keystr, valstr));
|
798
799
|
GetDBM2(obj, dbmp, dbm);
|
799
800
|
}
|
@@ -819,7 +820,7 @@ fdbm_keys(VALUE obj)
|
|
819
820
|
|
820
821
|
ary = rb_ary_new();
|
821
822
|
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
822
|
-
rb_ary_push(ary,
|
823
|
+
rb_ary_push(ary, rb_str_new(key.dptr, key.dsize));
|
823
824
|
}
|
824
825
|
|
825
826
|
return ary;
|
@@ -843,7 +844,7 @@ fdbm_values(VALUE obj)
|
|
843
844
|
ary = rb_ary_new();
|
844
845
|
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
845
846
|
val = dbm_fetch(dbm, key);
|
846
|
-
rb_ary_push(ary,
|
847
|
+
rb_ary_push(ary, rb_str_new(val.dptr, val.dsize));
|
847
848
|
}
|
848
849
|
|
849
850
|
return ary;
|
@@ -929,8 +930,8 @@ fdbm_to_a(VALUE obj)
|
|
929
930
|
ary = rb_ary_new();
|
930
931
|
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
931
932
|
val = dbm_fetch(dbm, key);
|
932
|
-
rb_ary_push(ary, rb_assoc_new(
|
933
|
-
|
933
|
+
rb_ary_push(ary, rb_assoc_new(rb_str_new(key.dptr, key.dsize),
|
934
|
+
rb_str_new(val.dptr, val.dsize)));
|
934
935
|
}
|
935
936
|
|
936
937
|
return ary;
|
@@ -955,8 +956,8 @@ fdbm_to_hash(VALUE obj)
|
|
955
956
|
hash = rb_hash_new();
|
956
957
|
for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
|
957
958
|
val = dbm_fetch(dbm, key);
|
958
|
-
rb_hash_aset(hash,
|
959
|
-
|
959
|
+
rb_hash_aset(hash, rb_str_new(key.dptr, key.dsize),
|
960
|
+
rb_str_new(val.dptr, val.dsize));
|
960
961
|
}
|
961
962
|
|
962
963
|
return hash;
|
@@ -992,7 +993,7 @@ fdbm_reject(VALUE obj)
|
|
992
993
|
* It is based on dbm library in Unix Version 7 but has different API to
|
993
994
|
* support multiple databases in a process.
|
994
995
|
* - {Berkeley DB}[http://en.wikipedia.org/wiki/Berkeley_DB] versions
|
995
|
-
* 1 thru
|
996
|
+
* 1 thru 6, also known as BDB and Sleepycat DB, now owned by Oracle
|
996
997
|
* Corporation.
|
997
998
|
* - Berkeley DB 1.x, still found in 4.4BSD derivatives (FreeBSD, OpenBSD, etc).
|
998
999
|
* - {gdbm}[http://www.gnu.org/software/gdbm/], the GNU implementation of dbm.
|
data/ext/dbm/extconf.rb
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
# db Berkeley DB (libdb)
|
8
8
|
# db2 Berkeley DB (libdb2)
|
9
9
|
# db1 Berkeley DB (libdb1)
|
10
|
+
# db6 Berkeley DB (libdb6)
|
10
11
|
# db5 Berkeley DB (libdb5)
|
11
12
|
# db4 Berkeley DB (libdb4)
|
12
13
|
# db3 Berkeley DB (libdb3)
|
@@ -23,7 +24,7 @@ dir_config("dbm")
|
|
23
24
|
if dblib = with_config("dbm-type", nil)
|
24
25
|
dblib = dblib.split(/[ ,]+/)
|
25
26
|
else
|
26
|
-
dblib = %w(libc db db2 db1 db5 db4 db3 gdbm_compat gdbm qdbm)
|
27
|
+
dblib = %w(libc db db2 db1 db6 db5 db4 db3 gdbm_compat gdbm qdbm)
|
27
28
|
end
|
28
29
|
|
29
30
|
headers = {
|
@@ -34,6 +35,7 @@ headers = {
|
|
34
35
|
"db3" => ["db3/db.h", "db3.h", "db.h"],
|
35
36
|
"db4" => ["db4/db.h", "db4.h", "db.h"],
|
36
37
|
"db5" => ["db5/db.h", "db5.h", "db.h"],
|
38
|
+
"db6" => ["db6/db.h", "db6.h", "db.h"],
|
37
39
|
"gdbm_compat" => ["gdbm-ndbm.h", "gdbm/ndbm.h", "ndbm.h"], # GDBM since 1.8.1
|
38
40
|
"gdbm" => ["gdbm-ndbm.h", "gdbm/ndbm.h", "ndbm.h"], # GDBM until 1.8.0
|
39
41
|
"qdbm" => ["qdbm/relic.h", "relic.h"],
|
@@ -131,7 +133,7 @@ def headers.db_check2(db, hdr)
|
|
131
133
|
hsearch = nil
|
132
134
|
|
133
135
|
case db
|
134
|
-
when /^db[2-
|
136
|
+
when /^db[2-6]?$/
|
135
137
|
hsearch = "-DDB_DBM_HSEARCH"
|
136
138
|
when "gdbm_compat"
|
137
139
|
have_library("gdbm") or return false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukihiro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -67,8 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
|
-
|
71
|
-
rubygems_version: 2.7.3
|
70
|
+
rubygems_version: 3.0.3
|
72
71
|
signing_key:
|
73
72
|
specification_version: 4
|
74
73
|
summary: Provides a wrapper for the UNIX-style Database Manager Library
|