Removed last warning due to use of not-always-available function 'strcasestr'
This commit is contained in:
@@ -38,6 +38,7 @@ DRIVER_INIT(basic_driver) {
|
|||||||
static inline ptr_list *add_to_ptr_list(ptr_list *list, void *value_ptr);
|
static inline ptr_list *add_to_ptr_list(ptr_list *list, void *value_ptr);
|
||||||
static inline void free_ptr_list(ptr_list *list, void(* free_head)(void *));
|
static inline void free_ptr_list(ptr_list *list, void(* free_head)(void *));
|
||||||
static inline int max(int a, int b);
|
static inline int max(int a, int b);
|
||||||
|
static inline int sql_is_insert(const char *sql);
|
||||||
|
|
||||||
// Driver Start
|
// Driver Start
|
||||||
static ErlDrvData start(ErlDrvPort port, char* cmd) {
|
static ErlDrvData start(ErlDrvPort port, char* cmd) {
|
||||||
@@ -582,7 +583,7 @@ static void sql_exec_async(void *_async_command) {
|
|||||||
dataset[term_count - 3] = ERL_DRV_NIL;
|
dataset[term_count - 3] = ERL_DRV_NIL;
|
||||||
dataset[term_count - 2] = ERL_DRV_LIST;
|
dataset[term_count - 2] = ERL_DRV_LIST;
|
||||||
dataset[term_count - 1] = 3;
|
dataset[term_count - 1] = 3;
|
||||||
} else if (strcasestr(sqlite3_sql(statement), "INSERT")) {
|
} else if (sql_is_insert(sqlite3_sql(statement))) {
|
||||||
sqlite3_int64 rowid = sqlite3_last_insert_rowid(drv->db);
|
sqlite3_int64 rowid = sqlite3_last_insert_rowid(drv->db);
|
||||||
term_count += 6;
|
term_count += 6;
|
||||||
if (term_count > term_allocated) {
|
if (term_count > term_allocated) {
|
||||||
@@ -671,3 +672,14 @@ static inline void free_ptr_list(ptr_list *list, void(* free_head)(void *)) {
|
|||||||
static inline int max(int a, int b) {
|
static inline int max(int a, int b) {
|
||||||
return a >= b ? a : b;
|
return a >= b ? a : b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int sql_is_insert(const char *sql) {
|
||||||
|
// neither strcasestr nor strnicmp are portable, so have to do this
|
||||||
|
int i;
|
||||||
|
char *insert = "insert";
|
||||||
|
for (i = 0; i < 6; i++) {
|
||||||
|
if ((tolower(sql[i]) != insert[i]) && (sql[i] != ' '))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#include <erl_driver.h>
|
#include <erl_driver.h>
|
||||||
#include <erl_interface.h>
|
#include <erl_interface.h>
|
||||||
#include <ei.h>
|
#include <ei.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#if SQLITE_VERSION_NUMBER < 3006001
|
#if SQLITE_VERSION_NUMBER < 3006001
|
||||||
|
|||||||
Reference in New Issue
Block a user