From: "i.koptelov" <ivan.koptelov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: "n.pettik" <korablev@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH] sql: LIKE/LENGTH process '\0'
Date: Wed, 20 Feb 2019 18:47:01 +0300 [thread overview]
Message-ID: <427EE913-3E58-413F-A645-DBF83C809334@tarantool.org> (raw)
In-Reply-To: <25649276-74CD-46E7-A1EB-F4CE299E637C@tarantool.org>
Thanks to Alexander, I fixed my patch to use a function
from icu to count the length of the string.
Changes:
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index 233ea2901..8ddb9780f 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -149,16 +149,7 @@ utf8_char_count(const unsigned char *str, int byte_len)
{
int symbol_count = 0;
for (int i = 0; i < byte_len;) {
- if ((str[i] & 0x80) == 0)
- i += 1;
- else if ((str[i] & 0xe0) == 0xc0)
- i += 2;
- else if ((str[i] & 0xf0) == 0xe0)
- i += 3;
- else if ((str[i] & 0xf8) == 0xf0)
- i += 4;
- else
- i += 1;
+ U8_FWD_1_UNSAFE(str, i);
symbol_count++;
}
return symbol_count;
diff --git a/test/sql-tap/badutf1.test.lua b/test/sql-tap/badutf1.test.lua
index 67c1071b3..d104efaa9 100755
--- a/test/sql-tap/badutf1.test.lua
+++ b/test/sql-tap/badutf1.test.lua
@@ -255,7 +255,7 @@ test:do_test(
return test:execsql2("SELECT length('\x61\xc0\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80') AS x")
end, {
-- <badutf-3.5>
- "X", 11
+ "X", 12
-- </badutf-3.5>
})
@@ -265,7 +265,7 @@ test:do_test(
return test:execsql2("SELECT length('\xc0\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80') AS x")
end, {
-- <badutf-3.6>
- "X", 10
+ "X", 11
-- </badutf-3.6>
})
next prev parent reply other threads:[~2019-02-20 15:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-29 9:56 [tarantool-patches] " Ivan Koptelov
2019-01-29 16:35 ` [tarantool-patches] " n.pettik
2019-02-04 12:34 ` Ivan Koptelov
2019-02-05 13:50 ` n.pettik
2019-02-07 15:14 ` i.koptelov
2019-02-11 13:15 ` n.pettik
2019-02-13 15:46 ` i.koptelov
2019-02-14 12:57 ` n.pettik
2019-02-20 13:54 ` i.koptelov
2019-02-20 15:47 ` i.koptelov [this message]
2019-02-20 16:04 ` n.pettik
2019-02-20 18:08 ` Vladislav Shpilevoy
2019-02-20 19:24 ` i.koptelov
2019-02-22 12:59 ` n.pettik
2019-02-25 11:09 ` i.koptelov
2019-02-25 15:10 ` n.pettik
2019-02-26 13:33 ` i.koptelov
2019-02-26 17:50 ` n.pettik
2019-02-26 18:44 ` i.koptelov
2019-02-26 20:16 ` Vladislav Shpilevoy
2019-03-04 11:59 ` i.koptelov
2019-03-04 15:30 ` Kirill Yukhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=427EE913-3E58-413F-A645-DBF83C809334@tarantool.org \
--to=ivan.koptelov@tarantool.org \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='[tarantool-patches] Re: [PATCH] sql: LIKE/LENGTH process '\''\0'\''' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox