From c60a05fc9c9a80792c81914676d13ebb5bc28a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 16 Oct 2015 11:52:39 +0000 Subject: [PATCH] [GB.DB.SQLITE2] * BUG: Listing databases without specifying the host does not crash anymore. [GB.DB.SQLITE3] * BUG: Listing databases without specifying the host does not crash anymore. git-svn-id: svn://localhost/gambas/trunk@7412 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.db.sqlite2/src/main.cpp | 27 +++++++++++++-------------- gb.db.sqlite3/src/main.c | 21 +++++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gb.db.sqlite2/src/main.cpp b/gb.db.sqlite2/src/main.cpp index 04eafa92c..4cef43413 100644 --- a/gb.db.sqlite2/src/main.cpp +++ b/gb.db.sqlite2/src/main.cpp @@ -1975,22 +1975,21 @@ static int database_list(DB_DATABASE *db, char ***databases) /* Hostname contains home area */ dbhome = (char *)conn->getHostName(); - WalkDirectory( dbhome, databases ); - - /* Checks GAMBAS_SQLITE_DBHOME if set, or Current Working Directory */ - /* Might have to come back and seperate */ - dbhome = GetDatabaseHome(); - if (dbhome){ - //GB.Error("Unable to get databases: &1", "Can't find current directory"); - WalkDirectory( dbhome, databases ); - GB.Free(POINTER(&dbhome)); + if (dbhome && *dbhome) + { + WalkDirectory( dbhome, databases ); } - - /*if (getcwd(cwd, MAX_PATH) != NULL){ - if (strcmp(cwd, dbhome) != 0){ - WalkDirectory( cwd, databases ); + else + { + /* Checks GAMBAS_SQLITE_DBHOME if set, or Current Working Directory */ + /* Might have to come back and seperate */ + dbhome = GetDatabaseHome(); + if (dbhome){ + //GB.Error("Unable to get databases: &1", "Can't find current directory"); + WalkDirectory( dbhome, databases ); + GB.Free(POINTER(&dbhome)); } - }*/ + } return GB.Count(databases); } diff --git a/gb.db.sqlite3/src/main.c b/gb.db.sqlite3/src/main.c index c0d53af80..cba7c8908 100644 --- a/gb.db.sqlite3/src/main.c +++ b/gb.db.sqlite3/src/main.c @@ -2165,17 +2165,18 @@ static int database_list(DB_DATABASE *db, char ***databases) GB.NewArray(databases, sizeof(char *), 0); /* Hostname contains home area */ - dbhome = conn->host; - walk_directory(dbhome, databases); - - /* Checks GAMBAS_SQLITE_DBHOME if set, or Current Working Directory */ - /* Might have to come back and seperate */ - dbhome = get_database_home(); - if (dbhome) + if (conn->host && *conn->host) { - //GB.Error("Unable to get databases: &1", "Can't find current directory"); - walk_directory(dbhome, databases); - GB.Free(POINTER(&dbhome)); + walk_directory(conn->host, databases); + } + else + { + dbhome = get_database_home(); + if (dbhome) + { + walk_directory(dbhome, databases); + GB.Free(POINTER(&dbhome)); + } } return GB.Count(databases);