1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Allow using Irssi::signal_add('command ...', ..) so irssi won't crash when

the script is unloaded.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2167 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-11-29 22:12:28 +00:00 committed by cras
parent 4ebe07e0d1
commit 6976bec3d9

View File

@ -252,8 +252,8 @@ SIG_FUNC_DECL(2, last);
#define perl_signal_get_func(rec) \
(priority_get_func((rec)->priority))
void perl_signal_add_to_int(const char *signal, const char *func,
int priority, int add_signal)
static void perl_signal_add_to_int(const char *signal, const char *func,
int priority, int command)
{
PERL_SIGNAL_REC *rec;
GHashTable *table;
@ -264,6 +264,13 @@ void perl_signal_add_to_int(const char *signal, const char *func,
g_return_if_fail(func != NULL);
g_return_if_fail(priority >= 0 && priority <= 2);
if (!command && strncmp(signal, "command ", 8) == 0) {
/* we used Irssi::signal_add() instead of
Irssi::command_bind() - oh well, allow this.. */
command_bind(signal+8, NULL, priority_get_func(priority));
command = TRUE;
}
rec = g_new(PERL_SIGNAL_REC, 1);
rec->signal_id = signal_get_uniq_id(signal);
rec->signal = g_strdup(signal);
@ -278,7 +285,7 @@ void perl_signal_add_to_int(const char *signal, const char *func,
siglist = g_new0(GSList *, 1);
g_hash_table_insert(table, signal_idp, siglist);
if (add_signal) {
if (!command) {
signal_add_to_id(MODULE_NAME, priority, rec->signal_id,
perl_signal_get_func(rec));
}
@ -289,7 +296,7 @@ void perl_signal_add_to_int(const char *signal, const char *func,
void perl_signal_add_to(const char *signal, const char *func, int priority)
{
perl_signal_add_to_int(signal, func, priority, TRUE);
perl_signal_add_to_int(signal, func, priority, FALSE);
}
static void perl_signal_destroy(PERL_SIGNAL_REC *rec)
@ -362,7 +369,7 @@ void perl_command_bind_to(const char *cmd, const char *category,
command_bind(cmd, category, priority_get_func(priority));
signal = g_strconcat("command ", cmd, NULL);
perl_signal_add_to_int(signal, func, priority, FALSE);
perl_signal_add_to_int(signal, func, priority, TRUE);
g_free(signal);
}