[tarantool-patches] Re: [PATCH v2 5/5] lua: introduce utf8 built-in globaly visible module
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sat May 5 03:24:41 MSK 2018
On 05/05/2018 03:18, Alexander Turenko wrote:
> Vlad,
>
> Thanks for the fixes. You are rock!
>
> I want to clarify two things, please see below.
>
> WBR, Alexander Turenko.
>
> On Sat, May 05, 2018 at 02:32:27AM +0300, Vladislav Shpilevoy wrote:
>> Hello. Thanks for review.
>>
>> On 05/05/2018 01:33, Alexander Turenko wrote:
>>> Vlad,
>>>
>>> Are you try to run tests from utf8.lua from [1]?
>>>
>>> [1]: https://www.lua.org/tests/lua-5.3.4-tests.tar.gz
>>>
>
> Are you think such testing would be redundant? I don't insist, just want
> to know explicit position.
I think, our existing tests are enough. There is no necessity to duplicate checks.
>
>>>> +
>>>> +/**
>>>> + * Calculate length of a UTF8 string. Length here is symbol count.
>>>> + * Works like utf8.len in Lua 5.3.
>>>> + * @param String to get length.
>>>> + * @param Start byte offset. Must point to the start of symbol. On
>>>> + * invalid symbol an error is returned. Can be negative.
>>>
>>> Can be 1 <= |start| <= #str + 1, right? Is it worth to document? Such
>>> offset equilibristics is not very intuitive (at least for me).
>>
>> No, start can be any, as well as end.
diff --git a/src/lua/utf8.c b/src/lua/utf8.c
index c31171b2c..c84e6ff72 100644
--- a/src/lua/utf8.c
+++ b/src/lua/utf8.c
@@ -144,6 +144,7 @@ utf8_convert_offset(int offset, size_t len)
* Calculate length of a UTF8 string. Length here is symbol count.
* Works like utf8.len in Lua 5.3. Can take negative offsets. A
* negative offset is an offset from the end of string.
+ * Positive position must be inside [1, #str + 1].
* @param String to get length.
* @param Start byte offset. Must point to the start of symbol. On
* invalid symbol an error is returned.
v:tarantool v.shpilevoy$ git diff
diff --git a/src/lua/utf8.c b/src/lua/utf8.c
index c31171b2c..8f0ca65e5 100644
--- a/src/lua/utf8.c
+++ b/src/lua/utf8.c
@@ -144,14 +144,17 @@ utf8_convert_offset(int offset, size_t len)
* Calculate length of a UTF8 string. Length here is symbol count.
* Works like utf8.len in Lua 5.3. Can take negative offsets. A
* negative offset is an offset from the end of string.
+ * Positive position must be inside [1, #str + 1].
* @param String to get length.
* @param Start byte offset. Must point to the start of symbol. On
* invalid symbol an error is returned.
* @param End byte offset. Can point to the middle of symbol.
* Partial symbol is counted too.
* @retval not nil Symbol count.
- * @retval nil, error Error. Byte position of the error is
+ * @retval nil, number Error. Byte position of the error is
* returned in the second value.
+ * @retval nil, string Error. Reason is returned in the second
+ * value.
*/
static int
utf8_len(struct lua_State *L)
More information about the Tarantool-patches
mailing list