This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Use an equivalent 'if' condition
[perl5.git] / cpan / DB_File / DB_File.xs
index 679c416..6e6e154 100644 (file)
@@ -6,7 +6,7 @@
 
  All comments/suggestions/problems are welcome
 
-     Copyright (c) 1995-2013 Paul Marquess. All rights reserved.
+     Copyright (c) 1995-2018 Paul Marquess. All rights reserved.
      This program is free software; you can redistribute it and/or
      modify it under the same terms as Perl itself.
 
 #  include "ppport.h"
 #endif
 
+int DB_File___unused() { return 0; }
+
 /* Mention DB_VERSION_MAJOR_CFG, DB_VERSION_MINOR_CFG, and
    DB_VERSION_PATCH_CFG here so that Configure pulls them all in. */
 
 #    include <db.h>
 #endif
 
+#ifndef PERL_UNUSED_ARG
+#  define PERL_UNUSED_ARG(x) ((void)x)
+#endif
+
 /* Wall starts with 5.7.x */
 
 #if PERL_REVISION > 5 || (PERL_REVISION == 5 && PERL_VERSION >= 7)
 #  ifndef DB_VERSION_MAJOR
 
 #    undef  dNOOP
-#    define dNOOP extern int Perl___notused
+#    ifdef __cplusplus
+#        define dNOOP (void)0
+#    else
+#        define dNOOP extern int DB_File___notused()
+#    endif
 
     /* Ditto for dXSARGS. */
 #    undef  dXSARGS
@@ -260,7 +270,7 @@ typedef db_recno_t  recno_t;
 #if DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 5
 #  define R_SETCURSOR  0x800000
 #else
-#  define R_SETCURSOR  (-100)
+#  define R_SETCURSOR  (DB_OPFLAGS_MASK)
 #endif
 
 #define R_RECNOSYNC     0
@@ -304,7 +314,7 @@ typedef db_recno_t  recno_t;
 #if DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 5
 #    define flagSet(flags, bitmask)    ((flags) & (bitmask))
 #else
-#    define flagSet(flags, bitmask)    (((flags) & DB_OPFLAGS_MASK) == (bitmask))
+#    define flagSet(flags, bitmask)    (((flags) & DB_OPFLAGS_MASK) == (u_int)(bitmask))
 #endif
 
 #else /* db version 1.x */
@@ -526,7 +536,6 @@ u_int               flags ;
     if (flagSet(flags, R_CURSOR)) {
        return ((db->cursor)->c_put)(db->cursor, &key, &value, DB_CURRENT);
     }
-
     if (flagSet(flags, R_SETCURSOR)) {
        if ((db->dbp)->put(db->dbp, NULL, &key, &value, 0) != 0)
                return -1 ;
@@ -595,6 +604,12 @@ const DBT * key2 ;
     int retval ;
     int count ;
     
+#ifdef AT_LEAST_DB_3_2
+    PERL_UNUSED_ARG(db);
+#endif
+#ifdef AT_LEAST_DB_6_0
+    PERL_UNUSED_ARG(locp);
+#endif
 
     if (CurrentDB->in_compare) {
         tidyUp(CurrentDB);
@@ -680,6 +695,10 @@ const DBT * key2 ;
     int retval ;
     int count ;
     
+#ifdef AT_LEAST_DB_3_2
+    PERL_UNUSED_ARG(db);
+#endif
+
     if (CurrentDB->in_prefix){
         tidyUp(CurrentDB);
         croak ("DB_File btree_prefix: recursion detected\n") ;
@@ -769,6 +788,10 @@ HASH_CB_SIZE_TYPE size ;
     int retval = 0;
     int count ;
 
+#ifdef AT_LEAST_DB_3_2
+    PERL_UNUSED_ARG(db);
+#endif
+
     if (CurrentDB->in_hash){
         tidyUp(CurrentDB);
         croak ("DB_File hash callback: recursion detected\n") ;
@@ -824,6 +847,9 @@ db_errcall_cb(const char * db_errpfx, char * buffer)
     dTHX;
 #endif    
     SV * sv = perl_get_sv(ERR_BUFF, FALSE) ;
+#ifdef AT_LEAST_DB_4_3
+    PERL_UNUSED_ARG(dbenv);
+#endif
     if (sv) {
         if (db_errpfx)
             sv_setpvf(sv, "%s: %s", db_errpfx, buffer) ;
@@ -1413,10 +1439,10 @@ SV *   sv ;
                    value = (int)SvIV(*svp) ;
 
                if (fixed) {
-                   status = dbp->set_re_pad(dbp, value) ;
+                   (void)dbp->set_re_pad(dbp, value) ;
                }
                else {
-                   status = dbp->set_re_delim(dbp, value) ;
+                   (void)dbp->set_re_delim(dbp, value) ;
                }
 
             }
@@ -1425,12 +1451,12 @@ SV *   sv ;
                svp = hv_fetch(action, "reclen", 6, FALSE);
               if (svp) {
                   u_int32_t len =  my_SvUV32(*svp) ;
-                   status = dbp->set_re_len(dbp, len) ;
+                   (void)dbp->set_re_len(dbp, len) ;
               }    
           }
          
            if (name != NULL) {
-               status = dbp->set_re_source(dbp, name) ;
+               (void)dbp->set_re_source(dbp, name) ;
                name = NULL ;
            }   
 
@@ -1443,7 +1469,7 @@ SV *   sv ;
                name = NULL ;
          
 
-           status = dbp->set_flags(dbp, (u_int32_t)DB_RENUMBER) ;
+           (void)dbp->set_flags(dbp, (u_int32_t)DB_RENUMBER) ;
          
                if (flags){
                    (void)dbp->set_flags(dbp, (u_int32_t)flags) ;
@@ -1526,6 +1552,9 @@ BOOT:
     SV * sv_err = perl_get_sv(ERR_BUFF, GV_ADD|GV_ADDMULTI) ; 
 #endif
     MY_CXT_INIT;
+#ifdef WANT_ERROR
+    PERL_UNUSED_VAR(sv_err); /* huh? we just retrieved it... */
+#endif
     __getBerkeleyDBInfo() ;
  
     DBT_clear(empty) ; 
@@ -1602,6 +1631,7 @@ db_DELETE(db, key, flags=0)
        PREINIT:
          dMY_CXT;
        INIT:
+         (void)flags;
          CurrentDB = db ;
 
 
@@ -1650,6 +1680,7 @@ db_STORE(db, key, value, flags=0)
        PREINIT:
          dMY_CXT;
        INIT:
+         (void)flags;
          CurrentDB = db ;