diff options
author | LemonBoy <thatlemon@gmail.com> | 2015-09-09 22:41:17 +0200 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-09-27 16:08:06 -0300 |
commit | 6888fc5fc74936af74fd30042e45652951648ea4 (patch) | |
tree | ceec510b2e54ef5362a739ead1aaf23327848f5d /src/fe-text/gui-readline.c | |
parent | 4764b102ff274f4a8695ced2ff2ebb39bf8d7bc2 (diff) | |
download | irssi-6888fc5fc74936af74fd30042e45652951648ea4.zip |
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.
Diffstat (limited to 'src/fe-text/gui-readline.c')
-rw-r--r-- | src/fe-text/gui-readline.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index 91dec4ea..87c824cf 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -666,15 +666,11 @@ static void sig_input(void) /* use the bracketed paste mode to detect when the user pastes * some text into the entry */ if (paste_use_bracketed_mode != FALSE && paste_buffer->len > 12) { - /* try to find the start/end sequence */ - int seq_start = memmem(paste_buffer->data, - paste_buffer->len * g_array_get_element_size(paste_buffer), - bp_start, sizeof(bp_start)) != NULL, - seq_end = memmem(paste_buffer->data, - 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); + /* try to find the start/end sequence, we know that we + * either find those at the start/end of the buffer or + * we don't find those at all. */ + int seq_start = !memcmp(paste_buffer->data, bp_start, sizeof(bp_start)), + seq_end = !memcmp(paste_buffer->data + paste_buffer->len * g_array_get_element_size(paste_buffer) - sizeof(bp_end), bp_end, sizeof(bp_end)); if (seq_start) { paste_bracketed_mode = TRUE; |