Refactor window_log(). Use strlcat rather than strmcat. Rename a variable

and remove a buffer on the stack.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@421 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Tim Cava
2013-10-26 15:30:09 +00:00
parent 9a5f10b8c5
commit 37f59831a2

View File

@@ -3426,37 +3426,35 @@ Window *window_list (Window *window, char **args, char *usage)
*/ */
static Window *window_log (Window *window, char **args, char *usage) static Window *window_log (Window *window, char **args, char *usage)
{ {
char *logfile;
int add_ext = 1; int add_ext = 1;
char buffer[BIG_BUFFER_SIZE + 1]; char logfile[MAXPATHLEN];
if (get_boolean("LOG", args, &window->log)) if (get_boolean("LOG", args, &window->log))
return NULL; return NULL;
if ((logfile = window->logfile)) if (window->logfile)
{
add_ext = 0; add_ext = 0;
else if (!(logfile = get_string_var(LOGFILE_VAR))) strlcpy(logfile, window->logfile, sizeof logfile);
logfile = empty_string; }
else if (!get_string_var(LOGFILE_VAR))
strlcpy(buffer, logfile, sizeof buffer); *logfile = 0;
if (add_ext) if (add_ext)
{ {
char *title = empty_string; strlcat(logfile, ".", sizeof logfile);
if (window->current_channel)
strmcat(buffer, ".", BIG_BUFFER_SIZE); strlcat(logfile, window->current_channel, sizeof logfile);
if ((title = window->current_channel)) else if (window->query_nick)
strmcat(buffer, title, BIG_BUFFER_SIZE); strlcat(logfile, window->query_nick, sizeof logfile);
else if ((title = window->query_nick))
strmcat(buffer, title, BIG_BUFFER_SIZE);
else else
{ {
strmcat(buffer, "Window_", BIG_BUFFER_SIZE); strlcat(logfile, "Window_", sizeof logfile);
strmcat(buffer, ltoa(window->refnum), BIG_BUFFER_SIZE); strlcat(logfile, ltoa(window->refnum), sizeof logfile);
} }
} }
strip_chars(buffer, "|\\:", '-'); strip_chars(logfile, "|\\:", '-');
do_log(window->log, buffer, &window->log_fp); do_log(window->log, logfile, &window->log_fp);
if (!window->log_fp) if (!window->log_fp)
window->log = 0; window->log = 0;