summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-08-16 11:28:50 +0200
committerSebastien Helleu <flashcode@flashtux.org>2009-08-16 11:28:50 +0200
commit25b9f1d7145ff37c21b2222fb48059276d14f275 (patch)
treec6a46d47ccf1825bda21861e75997554b6cbb9e6 /src/plugins
parent24432e78e001ea69cdc7f1512fc74ab580fba8ae (diff)
downloadweechat-25b9f1d7145ff37c21b2222fb48059276d14f275.zip
Fix bug with special chars in buffers for logger filenames (bug #25721)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/logger/logger-config.c8
-rw-r--r--src/plugins/logger/logger-config.h1
-rw-r--r--src/plugins/logger/logger.c29
3 files changed, 27 insertions, 11 deletions
diff --git a/src/plugins/logger/logger-config.c b/src/plugins/logger/logger-config.c
index 102921acd..d88e36262 100644
--- a/src/plugins/logger/logger-config.c
+++ b/src/plugins/logger/logger-config.c
@@ -43,6 +43,7 @@ struct t_config_option *logger_config_file_auto_log;
struct t_config_option *logger_config_file_name_lower_case;
struct t_config_option *logger_config_file_path;
struct t_config_option *logger_config_file_mask;
+struct t_config_option *logger_config_file_replacement_char;
struct t_config_option *logger_config_file_info_lines;
struct t_config_option *logger_config_file_time_format;
@@ -381,6 +382,13 @@ logger_config_init ()
"buffer variables are permitted"),
NULL, 0, 0, "$plugin.$name.weechatlog", NULL, 0, NULL, NULL,
&logger_config_change_file_option_restart_log, NULL, NULL, NULL);
+ logger_config_file_replacement_char = weechat_config_new_option (
+ logger_config_file, ptr_section,
+ "replacement_char", "string",
+ N_("replacement char for special chars in filename built with mask "
+ "(like directory delimiter)"),
+ NULL, 0, 0, "_", NULL, 0, NULL, NULL,
+ &logger_config_change_file_option_restart_log, NULL, NULL, NULL);
logger_config_file_info_lines = weechat_config_new_option (
logger_config_file, ptr_section,
"info_lines", "boolean",
diff --git a/src/plugins/logger/logger-config.h b/src/plugins/logger/logger-config.h
index f1f87390e..0a0f1db18 100644
--- a/src/plugins/logger/logger-config.h
+++ b/src/plugins/logger/logger-config.h
@@ -29,6 +29,7 @@ extern struct t_config_option *logger_config_file_auto_log;
extern struct t_config_option *logger_config_file_name_lower_case;
extern struct t_config_option *logger_config_file_path;
extern struct t_config_option *logger_config_file_mask;
+extern struct t_config_option *logger_config_file_replacement_char;
extern struct t_config_option *logger_config_file_info_lines;
extern struct t_config_option *logger_config_file_time_format;
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 62d17e9e0..8319f3afb 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -244,7 +244,7 @@ logger_get_mask_for_buffer (struct t_gui_buffer *buffer)
char *
logger_get_filename (struct t_gui_buffer *buffer)
{
- char *res, *mask_decoded;
+ char *res, *mask_decoded, *mask_decoded2;
const char *mask;
const char *dir_separator, *weechat_dir;
char *log_path, *log_path2, *pos_last_sep;
@@ -288,17 +288,24 @@ logger_get_filename (struct t_gui_buffer *buffer)
if (dir_separator && weechat_dir && log_path && log_path2)
{
- length = strlen (log_path2) + strlen (mask_decoded) + 1;
- res = malloc (length);
- if (res)
+ mask_decoded2 = weechat_string_replace (mask_decoded,
+ dir_separator,
+ weechat_config_string (logger_config_file_replacement_char));
+ if (mask_decoded2)
{
- snprintf (res, length, "%s%s", log_path2, mask_decoded);
- 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];
+ 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);
}
}