fix check for PG constant
authorRemi Collet <remi@php.net>
Fri, 17 Oct 2014 09:01:43 +0000 (11:01 +0200)
committerRemi Collet <remi@php.net>
Fri, 17 Oct 2014 09:04:30 +0000 (11:04 +0200)
config.m4
src/php_pqres.c

index 63dfd228da65794fc09c0d937f9af57140a51162..4e08f67afd82a21d9faaab4b012fef992331270c 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -27,15 +27,21 @@ if test "$PHP_PQ" != "no"; then
                AC_CHECK_PROG(EGREP, egrep, egrep)
        ])
        
                AC_CHECK_PROG(EGREP, egrep, egrep)
        ])
        
-       for PQ_DEF in PGRES_SINGLE_TUPLE PGRES_COPY_BOTH; do
-               AC_MSG_CHECKING(for $PQ_DEF)
-               if $EGREP -q $PQ_DEF $PQ_DIR/include/libpq-fe.h; then
-                       AC_DEFINE([$PQ_DEF], [1], [Have $PQ_DEF])
+       dnl
+       dnl PQ_CHECK_CONST(name)
+       dnl
+       AC_DEFUN([PQ_CHECK_CONST], [
+               AC_MSG_CHECKING(for $1)
+               if $EGREP -q $1 $PQ_DIR/include/libpq-fe.h; then
+                       AC_DEFINE(HAVE_$1, 1, [Have $1])
                        AC_MSG_RESULT(yep)
                else
                        AC_MSG_RESULT(nope)
                fi
                        AC_MSG_RESULT(yep)
                else
                        AC_MSG_RESULT(nope)
                fi
-       done 
+       ])
+
+       PQ_CHECK_CONST(PGRES_SINGLE_TUPLE)
+       PQ_CHECK_CONST(PGRES_COPY_BOTH)
 
        
        dnl
 
        
        dnl
index ae8774db10ca22a3c0ae1ea226bb26e22d8c856b..9dda1073fc149af7d014efd28e25f88ff31ce38d 100644 (file)
@@ -82,7 +82,7 @@ static STATUS php_pqres_iterator_valid(zend_object_iterator *i TSRMLS_DC)
 
        switch (PQresultStatus(obj->intern->res)) {
        case PGRES_TUPLES_OK:
 
        switch (PQresultStatus(obj->intern->res)) {
        case PGRES_TUPLES_OK:
-#if HAVE_PGRES_SINGLE_TUPLE
+#ifdef HAVE_PGRES_SINGLE_TUPLE
        case PGRES_SINGLE_TUPLE:
 #endif
                if (PQntuples(obj->intern->res) <= iter->index) {
        case PGRES_SINGLE_TUPLE:
 #endif
                if (PQntuples(obj->intern->res) <= iter->index) {
@@ -1211,7 +1211,7 @@ PHP_MINIT_FUNCTION(pqres)
 #ifdef HAVE_PGRES_COPY_BOTH
        zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("COPY_BOTH"), PGRES_COPY_BOTH TSRMLS_CC);
 #endif
 #ifdef HAVE_PGRES_COPY_BOTH
        zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("COPY_BOTH"), PGRES_COPY_BOTH TSRMLS_CC);
 #endif
-#if HAVE_PGRES_SINGLE_TUPLE
+#ifdef HAVE_PGRES_SINGLE_TUPLE
        zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("SINGLE_TUPLE"), PGRES_SINGLE_TUPLE TSRMLS_CC);
 #endif
 
        zend_declare_class_constant_long(php_pqres_class_entry, ZEND_STRL("SINGLE_TUPLE"), PGRES_SINGLE_TUPLE TSRMLS_CC);
 #endif