summaryrefslogtreecommitdiff
path: root/ext/sdbm/_sdbm.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-16 01:06:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-16 01:06:13 +0000
commit7e0920723c0915673bcb52e1d4f4f3338ad68697 (patch)
tree63ca6463cf870e2e080adb1ae856d6b5626cbc0c /ext/sdbm/_sdbm.c
parent92a7cf0455f716b7e5031d1a9ee60b14c3bef92a (diff)
* 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
Diffstat (limited to 'ext/sdbm/_sdbm.c')
-rw-r--r--ext/sdbm/_sdbm.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/ext/sdbm/_sdbm.c b/ext/sdbm/_sdbm.c
index 0df95ece8f5..efab2dcb798 100644
--- a/ext/sdbm/_sdbm.c
+++ b/ext/sdbm/_sdbm.c
@@ -39,9 +39,14 @@
* important tuning parms (hah)
*/
-#define SEEDUPS /* always detect duplicates */
-#define BADMESS /* generate a message for worst case:
+#ifndef SEEDUPS
+#define SEEDUPS 1 /* always detect duplicates */
+#endif
+#ifndef BADMESS
+#define BADMESS 1 /* generate a message for worst case:
cannot make room after SPLTMAX splits */
+#endif
+
/*
* misc
*/
@@ -67,7 +72,7 @@ static int delpair proto((char *, datum));
static int chkpage proto((char *));
static datum getnkey proto((char *, int));
static void splpage proto((char *, char *, long));
-#ifdef SEEDUPS
+#if SEEDUPS
static int duppair proto((char *, datum));
#endif
@@ -302,7 +307,7 @@ sdbm_store(register DBM *db, datum key, datum val, int flags)
*/
if (flags == DBM_REPLACE)
(void) delpair(db->pagbuf, key);
-#ifdef SEEDUPS
+#if SEEDUPS
else if (duppair(db->pagbuf, key))
return 1;
#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,
* we still cannot fit the key. say goodnight.
*/
-#ifdef BADMESS
- (void) write(2, "sdbm: cannot insert after SPLTMAX attempts.\n", 44);
+#if BADMESS
+ (void) (write(2, "sdbm: cannot insert after SPLTMAX attempts.\n", 44) < 0);
#endif
return 0;
@@ -698,7 +703,7 @@ getpair(char *pag, datum key)
return val;
}
-#ifdef SEEDUPS
+#if SEEDUPS
static int
duppair(char *pag, datum key)
{