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 CC3E022242 for ; Wed, 18 Jul 2018 13:10:22 -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 unWxPTOUk5mQ for ; Wed, 18 Jul 2018 13:10:22 -0400 (EDT) Received: from smtp20.mail.ru (smtp20.mail.ru [94.100.179.251]) (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 85C9D212AA for ; Wed, 18 Jul 2018 13:10:22 -0400 (EDT) Date: Wed, 18 Jul 2018 20:10:25 +0300 From: Alexander Turenko Subject: [tarantool-patches] Re: [PATCH] sql: LIKE & GLOB pattern comparison issue Message-ID: <20180718171024.ry2cltazdl2hsrpc@tkn_work_nb> References: <1530190036-10105-1-git-send-email-hollow653@gmail.com> <20180718024314.be245cmsgklxuvnk@tkn_work_nb> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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: Nikita Tatunov Cc: tarantool-patches@freelists.org, Alex Khatskevich Two minor comments are below. WBR, Alexander Turenko. On Wed, Jul 18, 2018 at 06:57:39PM +0300, Nikita Tatunov wrote: > ср, 18 июл. 2018 г. в 18:53, Alex Khatskevich > <[1]avkhatskevich@tarantool.org>: > > Once you have fixed comments, please apply a new full diff at the end > of email, to > continue review process. > Answer with a full diff to this email please (just paste as a plain > text output of `git diff` command) > On 18.07.2018 18:24, Nikita Tatunov wrote: > > -/* > - * For LIKE and GLOB matching on EBCDIC machines, assume that every > - * character is exactly one byte in size. Also, provde the Utf8Read() > - * macro for fast reading of the next character in the common case > where > - * the next character is ASCII. > +/** > + * Providing there are symbols in string s this macro returns > + * UTF-8 code of character and pushes pointer to the next symbol > + * in the string. Otherwise return code is SQL_END_OF_STRING. Nitpicking: pushes -> promotes? > */ > -#define Utf8Read(s, e) ucnv_getNextUChar(pUtf8conv, &s, e, &status) > +#define Utf8Read(s, e) (s < e ?\ > + ucnv_getNextUChar(pUtf8conv, &s, e, &status) : 0) > + > +#define SQL_END_OF_STRING 0 Always wrap argument usages of a function-like macro within its body with parenthesis (consider example I give in the previous email). It is usual way to handle the fact that a macros works as text replacement, so, say #define SUB(x, y) x - y will give the wrong result for the expression SUB(10, 5 - 3), while #define SUB(x, y) ((x) - (y)) will produce the correct result.