From e2815379180b01e8de852fa2ad799cbcf7746fe0 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Sun, 27 Oct 2013 15:08:23 +0000 Subject: [PATCH] logfile should be initialised from LOGFILE_VAR if that is set. We can also rearrange things to remove the need for the add_ext variable, hopefully also making the logic a bit more clear. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@423 13b04d17-f746-0410-82c6-800466cd88b0 --- source/window.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/source/window.c b/source/window.c index 4903e53..dcf30a5 100644 --- a/source/window.c +++ b/source/window.c @@ -3426,7 +3426,6 @@ Window *window_list (Window *window, char **args, char *usage) */ static Window *window_log (Window *window, char **args, char *usage) { - int add_ext = 1; char logfile[MAXPATHLEN]; if (get_boolean("LOG", args, &window->log)) @@ -3434,24 +3433,24 @@ static Window *window_log (Window *window, char **args, char *usage) if (window->logfile) { - add_ext = 0; strlcpy(logfile, window->logfile, sizeof logfile); } - else if (!get_string_var(LOGFILE_VAR)) - *logfile = 0; - - if (add_ext) + else { - strlcat(logfile, ".", sizeof logfile); + char *logfile_base = get_string_var(LOGFILE_VAR); + + if (!logfile_base) + logfile_base = empty_string; + if (window->current_channel) - strlcat(logfile, window->current_channel, sizeof logfile); + snprintf(logfile, sizeof logfile, "%s.%s", logfile_base, + window->current_channel); else if (window->query_nick) - strlcat(logfile, window->query_nick, sizeof logfile); + snprintf(logfile, sizeof logfile, "%s.%s", logfile_base, + window->query_nick); else - { - strlcat(logfile, "Window_", sizeof logfile); - strlcat(logfile, ltoa(window->refnum), sizeof logfile); - } + snprintf(logfile, sizeof logfile, "%s.Window_%u", logfile_base, + window->refnum); } strip_chars(logfile, "|\\:", '-'); do_log(window->log, logfile, &window->log_fp);