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 E3CD225C5F for ; Thu, 24 Jan 2019 16:32:57 -0500 (EST) 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 c0Q7QndWCZjX for ; Thu, 24 Jan 2019 16:32:57 -0500 (EST) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.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 A3FEE25C53 for ; Thu, 24 Jan 2019 16:32:57 -0500 (EST) Subject: [tarantool-patches] Re: [PATCH v2 2/3] lua-yaml: fix boolean/null representation in yaml From: Vladislav Shpilevoy References: <15b711cb55d34fff1f010fd6df1aa32248f65735.1548123025.git.alexander.turenko@tarantool.org> <3da6fc29-991d-e475-0777-49eacb764b94@tarantool.org> Message-ID: <565ea7fe-051d-b6c3-f52b-0f976fe1e5e2@tarantool.org> Date: Fri, 25 Jan 2019 00:32:42 +0300 MIME-Version: 1.0 In-Reply-To: <3da6fc29-991d-e475-0777-49eacb764b94@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Language: en-US Content-Transfer-Encoding: 8bit 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: tarantool-patches@freelists.org, Alexander Turenko >     static inline int >     yaml_parse_null(const char *str, size_t len, bool *is_null); > >> +   if (len == 1 && str[0] == '~') >> +      return YAML_NULL; >> +   if (len == 4 && (strcmp(str, "null") == 0 || strcmp(str, "Null") == 0 || > > 5. Hmm. Length of "null" and "Null" is 3, not 4. As I understand, > len does not count terminating zero. And I can prove it - load_scalar() > in case if !strcmp(tag, "str") does lua_pushlstring(loader->L, str, length), > so length == strlen(str). > > Even if I am mistaken about it, why two lines above you consider len > of "~" as 1, not 2? Sorry, my fault. I was too tired. Of course, strlen('null') == 4. I counted 'll' for one. But please, still consider my point about strcmp -> memcmp. > >> +       strcmp(str, "NULL") == 0)) >> +      return YAML_NULL; >> +   return YAML_NO_MATCH; >> +} >> +