mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Irssi::print() doesn't call printtext() with args (.., "%s", text)
since it broke %_ etc. formats. But instead of crashing every time someone prints %s with Irssi::print(), irssi now checks all those formats and prints them as-is. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1028 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
e50535a64e
commit
86b714881c
@ -30,15 +30,23 @@ void
|
|||||||
print(str, level=MSGLEVEL_CLIENTNOTICE)
|
print(str, level=MSGLEVEL_CLIENTNOTICE)
|
||||||
char *str
|
char *str
|
||||||
int level;
|
int level;
|
||||||
|
PREINIT:
|
||||||
|
char *fixed;
|
||||||
CODE:
|
CODE:
|
||||||
printtext(NULL, NULL, level, "%s", str);
|
fixed = perl_fix_formats(str);
|
||||||
|
printtext(NULL, NULL, level, fixed);
|
||||||
|
g_free(fixed);
|
||||||
|
|
||||||
void
|
void
|
||||||
print_window(str, level=MSGLEVEL_CLIENTNOTICE)
|
print_window(str, level=MSGLEVEL_CLIENTNOTICE)
|
||||||
char *str
|
char *str
|
||||||
int level;
|
int level;
|
||||||
|
PREINIT:
|
||||||
|
char *fixed;
|
||||||
CODE:
|
CODE:
|
||||||
printtext_window(active_win, level, "%s", str);
|
fixed = perl_fix_formats(str);
|
||||||
|
printtext_window(active_win, level, fixed);
|
||||||
|
g_free(fixed);
|
||||||
|
|
||||||
void
|
void
|
||||||
command(cmd, server=active_win->active_server, item=active_win->active)
|
command(cmd, server=active_win->active_server, item=active_win->active)
|
||||||
@ -107,8 +115,12 @@ print(server, channel, str, level)
|
|||||||
char *channel
|
char *channel
|
||||||
char *str
|
char *str
|
||||||
int level
|
int level
|
||||||
|
PREINIT:
|
||||||
|
char *fixed;
|
||||||
CODE:
|
CODE:
|
||||||
printtext(server, channel, level, "%s", str);
|
fixed = perl_fix_formats(str);
|
||||||
|
printtext(server, channel, level, fixed);
|
||||||
|
g_free(fixed);
|
||||||
|
|
||||||
Irssi::Windowitem
|
Irssi::Windowitem
|
||||||
window_item_find(server, name)
|
window_item_find(server, name)
|
||||||
@ -276,5 +288,9 @@ print(item, str, level=MSGLEVEL_CLIENTNOTICE)
|
|||||||
Irssi::Windowitem item
|
Irssi::Windowitem item
|
||||||
int level
|
int level
|
||||||
char *str
|
char *str
|
||||||
|
PREINIT:
|
||||||
|
char *fixed;
|
||||||
CODE:
|
CODE:
|
||||||
printtext(item->server, item->name, level, "%s", str);
|
fixed = perl_fix_formats(str);
|
||||||
|
printtext(item->server, item->name, level, fixed);
|
||||||
|
g_free(fixed);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#undef _
|
#undef _
|
||||||
#undef VERSION
|
#undef VERSION
|
||||||
|
#define HAVE_CONFIG_H
|
||||||
#include "../module.h"
|
#include "../module.h"
|
||||||
|
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
@ -435,6 +435,41 @@ void printformat_perl(TEXT_DEST_REC *dest, char *format, char **arglist)
|
|||||||
g_free(module);
|
g_free(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* change all %s strings to %%s */
|
||||||
|
char *perl_fix_formats(char *str)
|
||||||
|
{
|
||||||
|
char *ret, *out;
|
||||||
|
|
||||||
|
out = ret = g_malloc(strlen(str)*2+1);
|
||||||
|
while (*str != '\0') {
|
||||||
|
if (*str == '%') {
|
||||||
|
str++;
|
||||||
|
switch (*str) {
|
||||||
|
case 's':
|
||||||
|
case 'd':
|
||||||
|
case 'f':
|
||||||
|
case 'u':
|
||||||
|
case 'l':
|
||||||
|
case '%':
|
||||||
|
*out++ = '%';
|
||||||
|
*out++ = '%';
|
||||||
|
if (*str == '%')
|
||||||
|
str += 2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
*out++ = '%';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out++ = *str++;
|
||||||
|
}
|
||||||
|
*out = '\0';
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void perl_command(const char *cmd, SERVER_REC *server, WI_ITEM_REC *item)
|
void perl_command(const char *cmd, SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
const char *cmdchars;
|
const char *cmdchars;
|
||||||
|
@ -42,6 +42,9 @@ void irssi_add_plains(PLAIN_OBJECT_INIT_REC *objects);
|
|||||||
|
|
||||||
char *perl_get_use_list(void);
|
char *perl_get_use_list(void);
|
||||||
|
|
||||||
|
/* change all %s strings to %%s */
|
||||||
|
char *perl_fix_formats(char *str);
|
||||||
|
|
||||||
void perl_common_init(void);
|
void perl_common_init(void);
|
||||||
void perl_common_deinit(void);
|
void perl_common_deinit(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user