]> granicus.if.org Git - php/commitdiff
GCC fixes
authorArd Biesheuvel <abies@php.net>
Sat, 12 Jun 2004 22:17:16 +0000 (22:17 +0000)
committerArd Biesheuvel <abies@php.net>
Sat, 12 Jun 2004 22:17:16 +0000 (22:17 +0000)
ext/pdo_firebird/config.m4
ext/pdo_firebird/firebird_driver.c
ext/pdo_firebird/firebird_statement.c
ext/pdo_firebird/php_pdo_firebird_int.h

index 1baee70ac623965ef1eb3a4843ceed839a1a122f..8efbe1b60f62f56128fc96111a6d14ed1655f4bc 100644 (file)
@@ -31,9 +31,19 @@ if test "$PHP_PDO_FIREBIRD" != "no"; then
     -L$FIREBIRD_LIBDIR
   ])
   
+  if test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
+    pdo_inc_path=$prefix/include/php/ext
+  elif test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
+    pdo_inc_path=$abs_srcdir/ext
+  elif test -f ext/pdo/php_pdo_driver.h; then
+    pdo_inc_path=ext
+  else
+   AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
+  fi
+                                 
   PHP_ADD_LIBRARY_WITH_PATH($FIREBIRD_LIBNAME, $FIREBIRD_LIBDIR, PDO_FIREBIRD_SHARED_LIBADD)
   PHP_ADD_INCLUDE($FIREBIRD_INCDIR)
   AC_DEFINE(HAVE_PDO_FIREBIRD,1,[ ])
-  PHP_NEW_EXTENSION(pdo_firebird, pdo_firebird.c firebird_driver.c firebird_statement.c, $ext_shared)
+  PHP_NEW_EXTENSION(pdo_firebird, pdo_firebird.c firebird_driver.c firebird_statement.c, $ext_shared,,-I$pdo_inc_path)
   PHP_SUBST(PDO_FIREBIRD_SHARED_LIBADD)
 fi
index 0fac01a87b942831f7f91acdd703b41215679655..1ee80c6217ba7da5074d51363ef5fc03dd82652c 100644 (file)
@@ -22,6 +22,8 @@
 #include "config.h"
 #endif
 
+#define _GNU_SOURCE
+
 #include "php.h"
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "php_pdo_firebird.h"
 #include "php_pdo_firebird_int.h"
 
-#define _GNU_SOURCE
-
 /* map driver specific error message to PDO error */
 void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC) /* {{{ */
 {
        pdo_firebird_db_handle *H = stmt ? ((pdo_firebird_stmt *)stmt->driver_data)->H 
                : (pdo_firebird_db_handle *)dbh->driver_data;
-       long *error_code = stmt ? &stmt->error_code : &dbh->error_code;
+       enum pdo_error_type *error_code = stmt ? &stmt->error_code : &dbh->error_code;
        
        switch (isc_sqlcode(H->isc_status)) {
 
@@ -273,14 +273,13 @@ static long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len T
 static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, /* {{{ */
        char **quoted, int *quotedlen TSRMLS_DC)
 {
-       pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
        int qcount = 0;
        char const *c;
        
        /* Firebird only requires single quotes to be doubled if string lengths are used */
        
        /* count the number of ' characters */
-       for (c = unquoted; c = strchr(c,'\''); qcount++, c++);
+       for (c = unquoted; (c = strchr(c,'\'')); qcount++, c++);
        
        if (!qcount) {
                return 0;
@@ -292,7 +291,7 @@ static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unqu
                *quoted = c = emalloc(*quotedlen+1);
                
                /* foreach (chunk that ends in a quote) */
-               for (l = unquoted; r = strchr(l,'\''); l = r+1) {
+               for (l = unquoted; (r = strchr(l,'\'')); l = r+1) {
                        
                        /* copy the chunk */
                        strncpy(c, l, r-l);
@@ -362,7 +361,7 @@ static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
                        /* if (the value is really being changed and a transaction is open) */                  
                        if ((Z_LVAL_P(val)?1:0) ^ dbh->auto_commit && dbh->in_txn) {
                                
-                               if (dbh->auto_commit = Z_BVAL_P(val)) {
+                               if ((dbh->auto_commit = Z_BVAL_P(val))) {
                                        /* just keep the running transaction but commit it */
                                        if (isc_commit_retaining(H->isc_status, &H->tr)) {
                                                RECORD_ERROR(dbh);
@@ -401,8 +400,7 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
        pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
 
        switch (attr) {
-               char tmp[200] = "Firebird 1.0/Interbase 6";
-               info_func_t info_func;
+               char tmp[200];
                
                case PDO_ATTR_AUTOCOMMIT:
                        ZVAL_LONG(val,dbh->auto_commit);
@@ -414,20 +412,23 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
 
                case PDO_ATTR_CLIENT_VERSION: {
 #if defined(__GNUC__) || defined(PHP_WIN32)
+                       info_func_t info_func = NULL;
 #ifdef __GNUC__
-                       info_func_t info_func = (info_func_t)dlsym(RTLD_DEFAULT, "isc_get_client_version");
+                       info_func = (info_func_t)dlsym(RTLD_DEFAULT, "isc_get_client_version");
 #else
                        HMODULE l = GetModuleHandle("fbclient");
 
                        if (!l && !(l = GetModuleHandle("gds32"))) {
-                               return 0;
+                               break;
                        }
                        info_func = (info_func_t)GetProcAddress(l, "isc_get_client_version");
 #endif
                        if (info_func) {
                                info_func(tmp);
+                               ZVAL_STRING(val,tmp,1);
+                       } else {
+                               ZVAL_STRING(val,"Firebird 1.0/Interbase 6",1);
                        }
-                       ZVAL_STRING(val,tmp,1);
 #else
                        ZVAL_NULL(val);
 #endif
@@ -458,7 +459,7 @@ static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval
        if (sqlcode) {
                add_next_index_long(info, sqlcode);
 
-               while (l = isc_interprete(&buf[i],&s)) {
+               while ((l = isc_interprete(&buf[i],&s))) {
                        i += l;
                        strcpy(&buf[i++], " ");
                }
@@ -504,7 +505,6 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
                        isc_dpb_user_name, isc_dpb_password, isc_dpb_lc_ctype, isc_dpb_sql_role_name };
                char const *dpb_values[] = { dbh->username, dbh->password, vars[1].optval, vars[2].optval };
                char dpb_buffer[256] = { isc_dpb_version1 }, *dpb;
-               short len;
                
                dpb = dpb_buffer + 1; 
                
index a3f9fe8b47ec40fa595ffdd704938ef769f55241..a3ab575aaa4e3db91b0c17ce7cdd06f7a59a2598 100644 (file)
@@ -109,7 +109,7 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
                return 1;
        } while (0);
 
-       RECORD_ERROR(stmt->dbh);        
+       RECORD_ERROR(stmt);     
 
        return 0;
 }
@@ -163,6 +163,7 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{
        
        return 1;
 }
+/* }}} */
 
 /* internal function to override return types of parameters */
 static void set_param_type(enum pdo_param_type *param_type, XSQLVAR const *var) /* {{{ */
@@ -419,6 +420,8 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
                                return 1;
                        }
                        return 0;
+               default:
+                       ;
        }               
        return 1;
 }
index 8bb6a5cba2c2ea01cfa8a428150b7e92b9cc8677..f67e7b2d9e9f60c7121dc14b5e4aa6711123020d 100644 (file)
@@ -31,7 +31,7 @@
 
 #define PDO_FB_DIALECT 3
 
-#define SHORT_MAX (1 << 8*sizeof(short)-1)
+#define SHORT_MAX (1 << (8*sizeof(short)-1))
 
 #if SIZEOF_LONG == 8
 # define LL_MASK l