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

Get rid of the non-portable memmem

The sequences we're after are found at the beginning or at the end of the
buffer, there's no need to scan the whole thing.
This commit is contained in:
LemonBoy 2015-09-09 22:41:17 +02:00 committed by dequis
parent 4764b102ff
commit 6888fc5fc7

View File

@ -666,15 +666,11 @@ static void sig_input(void)
/* use the bracketed paste mode to detect when the user pastes /* use the bracketed paste mode to detect when the user pastes
* some text into the entry */ * some text into the entry */
if (paste_use_bracketed_mode != FALSE && paste_buffer->len > 12) { if (paste_use_bracketed_mode != FALSE && paste_buffer->len > 12) {
/* try to find the start/end sequence */ /* try to find the start/end sequence, we know that we
int seq_start = memmem(paste_buffer->data, * either find those at the start/end of the buffer or
paste_buffer->len * g_array_get_element_size(paste_buffer), * we don't find those at all. */
bp_start, sizeof(bp_start)) != NULL, int seq_start = !memcmp(paste_buffer->data, bp_start, sizeof(bp_start)),
seq_end = memmem(paste_buffer->data, seq_end = !memcmp(paste_buffer->data + paste_buffer->len * g_array_get_element_size(paste_buffer) - sizeof(bp_end), bp_end, sizeof(bp_end));
paste_buffer->len * g_array_get_element_size(paste_buffer),
bp_end, sizeof(bp_end)) != NULL;
g_warning("found sequences : start %d end %d", seq_start, seq_end);
if (seq_start) { if (seq_start) {
paste_bracketed_mode = TRUE; paste_bracketed_mode = TRUE;