1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

Merge pull request #1159 from vague666/fix_cmd_cat_bug

Make sure witem exists in cmd_cat when using -window
This commit is contained in:
ailin-nemui 2020-07-10 10:24:06 +02:00 committed by GitHub
commit 70626d86ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,7 +117,8 @@ static void cmd_version(char *data)
/* SYNTAX: CAT [-window] <file> [<seek position>] */
static void cmd_cat(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
{
char *fname, *fposstr, *target;
char *fname, *fposstr;
gboolean target;
GHashTable *optlist;
void *free_arg;
int fpos;
@ -155,15 +156,18 @@ static void cmd_cat(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
return;
}
target = g_hash_table_lookup(optlist, "window") != NULL ? item->name : NULL;
target = g_hash_table_lookup(optlist, "window") != NULL;
g_io_channel_set_encoding(handle, NULL, NULL);
g_io_channel_seek_position(handle, fpos, G_SEEK_SET, NULL);
buf = g_string_sized_new(512);
while (g_io_channel_read_line_string(handle, buf, &tpos, NULL) == G_IO_STATUS_NORMAL) {
buf->str[tpos] = '\0';
printtext(target != NULL ? server : NULL, target, MSGLEVEL_CLIENTCRAP |
MSGLEVEL_NEVER, "%s", buf->str);
if (target)
printtext_window(active_win, MSGLEVEL_CLIENTCRAP | MSGLEVEL_NEVER, "%s",
buf->str);
else
printtext(NULL, NULL, MSGLEVEL_CLIENTCRAP | MSGLEVEL_NEVER, "%s", buf->str);
}
g_string_free(buf, TRUE);
cmd_params_free(free_arg);