summaryrefslogtreecommitdiff
path: root/ext/dbm/extconf.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-08 14:34:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-08 14:34:39 +0000
commit0e4c2ce84111e538318e67ceb45c3a34e8394ed3 (patch)
treedba392d69460820eb21d004464d08c26e2b72bc0 /ext/dbm/extconf.rb
parent4342469e8c5a32bc45b7748f5745b92b101901a1 (diff)
* ext/dbm/dbm.c (fdbm_fetch, fdbm_key, fdbm_delete, fdbm_store)
(fdbm_has_key, fdbm_has_value): get rid of overflow. * ext/gdbm/gdbm.c (rb_gdbm_fetch2, rb_gdbm_nextkey) (rb_gdbm_delete, fgdbm_store, fgdbm_has_key): ditto. * ext/dbm/dbm.c (fdbm_delete_if): hide intermediate objects. * ext/gdbm/gdbm.c (fgdbm_delete_if): ditto. * ext/dbm/extconf.rb: check size of datum.dsize to get rid of overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dbm/extconf.rb')
-rw-r--r--ext/dbm/extconf.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index be4d030..419ea65 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -21,7 +21,10 @@ headers = {
"qdbm" => ["relic.h", "qdbm/relic.h"],
}
-$dbm_headers = []
+class << headers
+ attr_accessor :found
+end
+headers.found = []
def headers.db_check(db)
db_prefix = nil
@@ -46,7 +49,7 @@ def headers.db_check(db)
have_func(db_prefix+"dbm_clearerr") unless have_gdbm
$defs << hsearch if hsearch
$defs << '-DDBM_HDR="<'+hdr+'>"'
- $dbm_headers << hdr
+ @found << hdr
true
else
false
@@ -56,7 +59,12 @@ end
if dblib.any? {|db| headers.db_check(db)}
have_header("cdefs.h")
have_header("sys/cdefs.h")
- have_func("dbm_pagfno", $dbm_headers)
- have_func("dbm_dirfno", $dbm_headers)
+ have_func("dbm_pagfno", headers.found)
+ have_func("dbm_dirfno", headers.found)
+ if try_static_assert("sizeof(conftest_key.dsize) <= sizeof(int)", [[cpp_include(headers.found), "static datum conftest_key;"]])
+ $defs << "-DSIZEOF_DSIZE=SIZEOF_INT"
+ else
+ $defs << "-DSIZEOF_DSIZE=SIZEOF_LONG"
+ end
create_makefile("dbm")
end