From 960bed12a89b59dd55ffd72a97212a2849c9c319 Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Sat, 14 Sep 2013 11:21:38 +0200 Subject: [PATCH] If the user gave a filename for the datafile, don't imply that they want to ignore the serverlist file. --- src/main.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index 262b154..3f79bcb 100644 --- a/src/main.c +++ b/src/main.c @@ -389,24 +389,16 @@ int main(int argc, char *argv[]) } } + config_err = create_user_config_dir(user_config_dir); if (DATA_FILE == NULL ) { - config_err = create_user_config_dir(user_config_dir); - if (config_err) { DATA_FILE = strdup("data"); - SRVLIST_FILE = strdup(PACKAGE_DATADIR "/DHTservers"); } else { DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); - SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1); - - if (DATA_FILE != NULL && SRVLIST_FILE != NULL) { + if (DATA_FILE != NULL) { strcpy(DATA_FILE, user_config_dir); strcat(DATA_FILE, CONFIGDIR); strcat(DATA_FILE, "data"); - - strcpy(SRVLIST_FILE, user_config_dir); - strcat(SRVLIST_FILE, CONFIGDIR); - strcat(SRVLIST_FILE, "DHTservers"); } else { endwin(); fprintf(stderr, "malloc() failed. Aborting...\n"); @@ -415,6 +407,21 @@ int main(int argc, char *argv[]) } } + if (config_err) { + SRVLIST_FILE = strdup(PACKAGE_DATADIR "/DHTservers"); + } else { + SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1); + if (SRVLIST_FILE != NULL) { + strcpy(SRVLIST_FILE, user_config_dir); + strcat(SRVLIST_FILE, CONFIGDIR); + strcat(SRVLIST_FILE, "DHTservers"); + } else { + endwin(); + fprintf(stderr, "malloc() failed. Aborting...\n"); + exit(EXIT_FAILURE); + } + } + free(user_config_dir); init_term();