summaryrefslogtreecommitdiff
path: root/src/plugins/logger
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-08-22 19:19:31 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-08-22 19:19:31 +0200
commit77fa0c4b9ef9f38b78f8646a83053bb174e7c4bc (patch)
treeeec54a88cbd1852cb174cba6795eb75e6f569fe9 /src/plugins/logger
parent2487d8a58e1eeb54699056484c1d45150a876f13 (diff)
downloadweechat-77fa0c4b9ef9f38b78f8646a83053bb174e7c4bc.zip
Fix bug with directory separator in logger mask
Diffstat (limited to 'src/plugins/logger')
-rw-r--r--src/plugins/logger/logger.c74
1 files changed, 48 insertions, 26 deletions
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 8319f3afb..d9f88246d 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -244,13 +244,20 @@ logger_get_mask_for_buffer (struct t_gui_buffer *buffer)
char *
logger_get_filename (struct t_gui_buffer *buffer)
{
- char *res, *mask_decoded, *mask_decoded2;
+ char *res, *mask2, *mask_decoded, *mask_decoded2, *mask_decoded3;
const char *mask;
const char *dir_separator, *weechat_dir;
char *log_path, *log_path2, *pos_last_sep;
int length;
res = NULL;
+ mask2 = NULL;
+ mask_decoded = NULL;
+ mask_decoded2 = NULL;
+ mask_decoded3 = NULL;
+
+ dir_separator = weechat_info_get ("dir_separator", "");
+ weechat_dir = weechat_info_get ("weechat_dir", "");
/* get filename mask for buffer */
mask = logger_get_mask_for_buffer (buffer);
@@ -263,9 +270,25 @@ logger_get_filename (struct t_gui_buffer *buffer)
weechat_buffer_get_string (buffer, "name"));
return NULL;
}
- mask_decoded = weechat_buffer_string_replace_local_var (buffer, mask);
+
+ mask2 = weechat_string_replace (mask, dir_separator, "\01");
+ if (!mask2)
+ goto end;
+
+ mask_decoded = weechat_buffer_string_replace_local_var (buffer, mask2);
if (!mask_decoded)
- return NULL;
+ goto end;
+
+ mask_decoded2 = weechat_string_replace (mask_decoded,
+ dir_separator,
+ weechat_config_string (logger_config_file_replacement_char));
+ if (!mask_decoded2)
+ goto end;
+
+ mask_decoded3 = weechat_string_replace (mask_decoded2,
+ "\01", dir_separator);
+ if (!mask_decoded3)
+ goto end;
if (weechat_logger_plugin->debug)
{
@@ -274,46 +297,45 @@ logger_get_filename (struct t_gui_buffer *buffer)
"decoded mask = \"%s\"",
LOGGER_PLUGIN_NAME,
weechat_buffer_get_string (buffer, "name"),
- mask, mask_decoded);
+ mask, mask_decoded3);
}
if (weechat_config_boolean (logger_config_file_name_lower_case))
- weechat_string_tolower (mask_decoded);
+ weechat_string_tolower (mask_decoded3);
- dir_separator = weechat_info_get ("dir_separator", "");
- weechat_dir = weechat_info_get ("weechat_dir", "");
log_path = weechat_string_replace (weechat_config_string (logger_config_file_path),
"~", getenv ("HOME"));
log_path2 = weechat_string_replace (log_path, "%h", weechat_dir);
if (dir_separator && weechat_dir && log_path && log_path2)
{
- mask_decoded2 = weechat_string_replace (mask_decoded,
- dir_separator,
- weechat_config_string (logger_config_file_replacement_char));
- if (mask_decoded2)
+ length = strlen (log_path2) + strlen (mask_decoded3) + 1;
+ res = malloc (length);
+ if (res)
{
- length = strlen (log_path2) + strlen (mask_decoded2) + 1;
- res = malloc (length);
- if (res)
- {
- snprintf (res, length, "%s%s", log_path2, mask_decoded2);
- pos_last_sep = strrchr (res, dir_separator[0]);
- if (pos_last_sep)
- pos_last_sep[0] = '\0';
- weechat_mkdir_parents (res, 0700);
- if (pos_last_sep)
- pos_last_sep[0] = dir_separator[0];
- }
- free (mask_decoded2);
+ snprintf (res, length, "%s%s", log_path2, mask_decoded3);
+ pos_last_sep = strrchr (res, dir_separator[0]);
+ if (pos_last_sep)
+ pos_last_sep[0] = '\0';
+ weechat_mkdir_parents (res, 0700);
+ if (pos_last_sep)
+ pos_last_sep[0] = dir_separator[0];
}
}
-
+
+end:
if (log_path)
free (log_path);
if (log_path2)
free (log_path2);
- free (mask_decoded);
+ if (mask2)
+ free (mask2);
+ if (mask_decoded)
+ free (mask_decoded);
+ if (mask_decoded2)
+ free (mask_decoded2);
+ if (mask_decoded3)
+ free (mask_decoded3);
return res;
}