autolog: change some characters illegal in Windows filenames to underscores

git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@5085 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Jilles Tjoelker 2009-08-13 21:16:22 +00:00 committed by jilles
parent 04097e1681
commit 3c30196ad4

View File

@ -393,14 +393,14 @@ static void autologs_close_all(void)
} }
} }
/* '%' -> '%%', '/' -> '_' */ /* '%' -> '%%', badness -> '_' */
static char *escape_target(const char *target) static char *escape_target(const char *target)
{ {
char *str, *p; char *str, *p;
p = str = g_malloc(strlen(target)*2+1); p = str = g_malloc(strlen(target)*2+1);
while (*target != '\0') { while (*target != '\0') {
if (*target == '/') if (strchr("/\\|*?\"<>:", *target))
*p++ = '_'; *p++ = '_';
else { else {
if (*target == '%') if (*target == '%')
@ -429,6 +429,8 @@ static void autolog_open(SERVER_REC *server, const char *server_tag,
/* '/' -> '_' - don't even accidentally try to log to /* '/' -> '_' - don't even accidentally try to log to
#../../../file if you happen to join to such channel.. #../../../file if you happen to join to such channel..
similar for some characters that are metacharacters
and/or illegal in Windows filenames.
'%' -> '%%' - so strftime() won't mess with them */ '%' -> '%%' - so strftime() won't mess with them */
fixed_target = escape_target(target); fixed_target = escape_target(target);