* ext/sdbm/_sdbm.c (SEEDUPS, BADMESS): make settable using command

line options.

* ext/sdbm/_sdbm.c (makroom): suppress unused result warning.

* ext/sdbm/extconf.rb: disable BADMESS, a library should not emit
  messages directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-10-16 01:06:13 +00:00
parent 92a7cf0455
commit 7e0920723c
3 changed files with 23 additions and 7 deletions

View File

@ -1,3 +1,13 @@
Sat Oct 16 10:06:08 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/sdbm/_sdbm.c (SEEDUPS, BADMESS): make settable using command
line options.
* ext/sdbm/_sdbm.c (makroom): suppress unused result warning.
* ext/sdbm/extconf.rb: disable BADMESS, a library should not emit
messages directly.
Sat Oct 16 08:39:03 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> Sat Oct 16 08:39:03 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dln.c (dln_strerror): get English message first, instead of * dln.c (dln_strerror): get English message first, instead of

View File

@ -39,9 +39,14 @@
* important tuning parms (hah) * important tuning parms (hah)
*/ */
#define SEEDUPS /* always detect duplicates */ #ifndef SEEDUPS
#define BADMESS /* generate a message for worst case: #define SEEDUPS 1 /* always detect duplicates */
#endif
#ifndef BADMESS
#define BADMESS 1 /* generate a message for worst case:
cannot make room after SPLTMAX splits */ cannot make room after SPLTMAX splits */
#endif
/* /*
* misc * misc
*/ */
@ -67,7 +72,7 @@ static int delpair proto((char *, datum));
static int chkpage proto((char *)); static int chkpage proto((char *));
static datum getnkey proto((char *, int)); static datum getnkey proto((char *, int));
static void splpage proto((char *, char *, long)); static void splpage proto((char *, char *, long));
#ifdef SEEDUPS #if SEEDUPS
static int duppair proto((char *, datum)); static int duppair proto((char *, datum));
#endif #endif
@ -302,7 +307,7 @@ sdbm_store(register DBM *db, datum key, datum val, int flags)
*/ */
if (flags == DBM_REPLACE) if (flags == DBM_REPLACE)
(void) delpair(db->pagbuf, key); (void) delpair(db->pagbuf, key);
#ifdef SEEDUPS #if SEEDUPS
else if (duppair(db->pagbuf, key)) else if (duppair(db->pagbuf, key))
return 1; return 1;
#endif #endif
@ -421,8 +426,8 @@ makroom(register DBM *db, long int hash, int need)
* if we are here, this is real bad news. After SPLTMAX splits, * if we are here, this is real bad news. After SPLTMAX splits,
* we still cannot fit the key. say goodnight. * we still cannot fit the key. say goodnight.
*/ */
#ifdef BADMESS #if BADMESS
(void) write(2, "sdbm: cannot insert after SPLTMAX attempts.\n", 44); (void) (write(2, "sdbm: cannot insert after SPLTMAX attempts.\n", 44) < 0);
#endif #endif
return 0; return 0;
@ -698,7 +703,7 @@ getpair(char *pag, datum key)
return val; return val;
} }
#ifdef SEEDUPS #if SEEDUPS
static int static int
duppair(char *pag, datum key) duppair(char *pag, datum key)
{ {

View File

@ -1,3 +1,4 @@
require 'mkmf' require 'mkmf'
$defs << "-D""BADMESS=0"
create_makefile("sdbm") create_makefile("sdbm")