From 8250e8275f99138a8f1eccd34e0d7c9781294b93 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 23 Oct 2024 11:16:18 +1000 Subject: [PATCH] database: allow for multiple entries in a database path Split the given database path by colon, same as PATH behavior, to allow callers to pass multiple database paths. --- libwacom/libwacom-database.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libwacom/libwacom-database.c b/libwacom/libwacom-database.c index 152b554a..027552ba 100644 --- a/libwacom/libwacom-database.c +++ b/libwacom/libwacom-database.c @@ -1132,10 +1132,10 @@ stylus_compare(WacomStylusId *a, WacomStylusId *b) } static WacomDeviceDatabase * -database_new_for_paths (const char **datadirs) +database_new_for_paths (char * const *datadirs) { WacomDeviceDatabase *db; - const char **datadir; + char * const *datadir; db = g_new0 (WacomDeviceDatabase, 1); db->device_ht = g_hash_table_new_full (g_str_hash, @@ -1174,17 +1174,20 @@ database_new_for_paths (const char **datadirs) LIBWACOM_EXPORT WacomDeviceDatabase * libwacom_database_new_for_path (const char *datadir) { - const char *datadirs[] = { - datadir, - NULL, - }; - return database_new_for_paths(datadirs); + WacomDeviceDatabase *db; + char **paths = g_strsplit(datadir, ":", 0); + + db = database_new_for_paths(paths); + + g_strfreev(paths); + + return db; } LIBWACOM_EXPORT WacomDeviceDatabase * libwacom_database_new (void) { - const char *datadir[] = { + char *datadir[] = { ETCDIR, DATADIR, NULL,