mirror of
git://jb55.com/damus
synced 2024-10-04 19:00:42 +00:00
nostrdb/search: make search case insensitive
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
d541153e4c
commit
8679c9f293
@ -369,6 +369,20 @@ static inline int push_sized_str(struct cursor *cursor, const char *str, int len
|
|||||||
return cursor_push(cursor, (u8*)str, len);
|
return cursor_push(cursor, (u8*)str, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int cursor_push_lowercase(struct cursor *cur, const char *str, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (unlikely(cur->p + len >= cur->end))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
cur->p[i] = tolower(str[i]);
|
||||||
|
|
||||||
|
cur->p += len;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int cursor_push_str(struct cursor *cursor, const char *str)
|
static inline int cursor_push_str(struct cursor *cursor, const char *str)
|
||||||
{
|
{
|
||||||
return cursor_push(cursor, (u8*)str, (int)strlen(str));
|
return cursor_push(cursor, (u8*)str, (int)strlen(str));
|
||||||
|
@ -164,8 +164,8 @@ static int ndb_make_text_search_key(unsigned char *buf, int bufsize,
|
|||||||
if (!push_varint(&cur, word_len))
|
if (!push_varint(&cur, word_len))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// non-null terminated string
|
// non-null terminated, lowercase string
|
||||||
if (!cursor_push(&cur, (unsigned char*)str, word_len))
|
if (!cursor_push_lowercase(&cur, str, word_len))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// the index of the word in the content so that we can do more accurate
|
// the index of the word in the content so that we can do more accurate
|
||||||
|
Loading…
Reference in New Issue
Block a user