From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id D9A2823F44 for ; Fri, 4 May 2018 20:45:50 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9eKKXB2S1Dvr for ; Fri, 4 May 2018 20:45:50 -0400 (EDT) Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 9068223F43 for ; Fri, 4 May 2018 20:45:50 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v2 5/5] lua: introduce utf8 built-in globaly visible module References: <562a24d9c42df6701e85d50b06a47d57e6d884bf.1524955403.git.v.shpilevoy@tarantool.org> <20180504223322.y7i5ymo46hcd7usu@tkn_work_nb> <20180505001815.2qaim6cgkya4pnx6@tkn_work_nb> <20180505003806.jqmdzfo7w5qvzuge@tkn_work_nb> From: Vladislav Shpilevoy Message-ID: <63a02f92-d42c-0a64-56b0-d4307d449082@tarantool.org> Date: Sat, 5 May 2018 03:45:46 +0300 MIME-Version: 1.0 In-Reply-To: <20180505003806.jqmdzfo7w5qvzuge@tkn_work_nb> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: Alexander Turenko Cc: tarantool-patches@freelists.org On 05/05/2018 03:38, Alexander Turenko wrote: > On Sat, May 05, 2018 at 03:24:41AM +0300, Vladislav Shpilevoy wrote: >> >> >>> >>>>>> + >>>>>> +/** >>>>>> + * 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) >> >> > > [0, #str] for the end position. > > Excuse me for nitpicking. diff --git a/src/lua/utf8.c b/src/lua/utf8.c index 8f0ca65e5..d124e5321 100644 --- a/src/lua/utf8.c +++ b/src/lua/utf8.c @@ -144,12 +144,12 @@ 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]. + * Positive position must be inside . * @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. + * @param Start byte offset in [1, #str + 1]. Must point to the + * start of symbol. On invalid symbol an error is returned. + * @param End byte offset in [0, #str]. Can point to the middle of + * symbol. Partial symbol is counted too. * @retval not nil Symbol count. * @retval nil, number Error. Byte position of the error is * returned in the second value. > > WBR, Alexander Turenko. >