summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-03-11 18:09:33 +0100
committerSebastien Helleu <flashcode@flashtux.org>2013-03-11 18:09:33 +0100
commitafc1dd4f6b0ff1768b3e3565b2db5c3bfb182259 (patch)
tree21d87c0c1e30d97dfbd8f37da468a41522aac4d4
parentcc3fb2602402b71c741fc17021fa75543a448dbf (diff)
downloadweechat-afc1dd4f6b0ff1768b3e3565b2db5c3bfb182259.zip
api: fix bug in string_match when mask begins and ends with "*"
The bug was string_match returning 0 (instead of 1) if mask begins and ends with "*" and if string and mask have same length (except both "*") with same content: string_match("abc", "*abc*", 0) == 0 // BUG: it should return 1 string_match("abcd", "*abc*", 0) == 1 // OK
-rw-r--r--ChangeLog3
-rw-r--r--src/core/wee-string.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4f85f3eae..9111a3162 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
-v0.4.1-dev, 2013-03-09
+v0.4.1-dev, 2013-03-11
This document lists all changes for each version.
@@ -29,6 +29,7 @@ Version 0.4.1 (under dev!)
weechat.history.max_buffer_lines_minutes is set (bug #38197)
* core: use default hash/comparison callback for keys of type
integer/pointer/time in hashtable
+* api: fix bug in string_match when mask begins and ends with "*"
* api: allow hashtable with keys that are not strings in function
hashtable_add_to_infolist
* api: fix function string_mask_to_regex: escape all special chars used in regex
diff --git a/src/core/wee-string.c b/src/core/wee-string.c
index 4b3b255c7..443f22f02 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -412,7 +412,7 @@ string_match (const char *string, const char *mask, int case_sensitive)
if ((mask[0] == '*') && (last == '*'))
{
/* not enough chars in string to match */
- if (len_string < len_mask - 1)
+ if (len_string < len_mask - 2)
return 0;
/* keep only relevant chars in mask for searching string */
mask2 = string_strndup (mask + 1, len_mask - 2);