From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79436 invoked by alias); 6 Aug 2019 22:21:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 79387 invoked by uid 89); 6 Aug 2019 22:21:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=H*F:D*be, HContent-Transfer-Encoding:8bit X-HELO: mailsec111.isp.belgacom.be Received: from mailsec111.isp.belgacom.be (HELO mailsec111.isp.belgacom.be) (195.238.20.107) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Aug 2019 22:21:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1565130117; x=1596666117; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=RS6jFa/Irg+AqZRxZKvomhJQ+EeaG4/NTHFxkEk4kgQ=; b=K2sW0yN/DNajuQlS32DJy0ZZwxujwJ58Y9N7rZVsvL1UqpSqTYxofo5g MaOHDmqAC/e7feerrz/5/B2iyMEwyA==; Received: from 96.218-128-109.adsl-dyn.isp.belgacom.be (HELO md) ([109.128.218.96]) by relay.skynet.be with ESMTP/TLS/AES256-GCM-SHA384; 07 Aug 2019 00:21:53 +0200 Message-ID: <1565130113.1435.10.camel@skynet.be> Subject: Re: [RFAv2 2/2] Add a selftest that checks documentation invariants. From: Philippe Waroquiers To: Tom Tromey Cc: gdb-patches@sourceware.org Date: Tue, 06 Aug 2019 22:21:00 -0000 In-Reply-To: <874l2u9mah.fsf@tromey.com> References: <20190803133921.20154-1-philippe.waroquiers@skynet.be> <20190803133921.20154-3-philippe.waroquiers@skynet.be> <874l2u9mah.fsf@tromey.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00162.txt.bz2 On Tue, 2019-08-06 at 12:33 -0600, Tom Tromey wrote: > > > > > > "Philippe" == Philippe Waroquiers writes: > > Philippe> gdb/ChangeLog > Philippe> * unittests/help-doc-selftests.c: New file. > Philippe> * Makefile.in: Add the new file. > > Thanks for doing this. > > Philippe> +static void > Philippe> +broken_doc_invariant (const char *prefix, const char *name, const char *msg) > Philippe> +{ > Philippe> + fprintf_filtered (gdb_stdout, > Philippe> + "help doc broken invariant: command '%s%s' help doc %s\n", > Philippe> + prefix, name, msg); > > Normally I'd probably complain about being i18n-unfriendly here, but TBH > I don't think that matters much for unit tests. > > Philippe> + /* Walk through the commands. */ > Philippe> + for (c=commandlist;c;c=c->next) fixed. > > This needs some spaces. > > Philippe> + while (*p && *p != '\n') > Philippe> + p++; > > I think this could just be "p = strchr (p, '\n')". I have kept the code above, as strchr returns NULL if no \n is found, but it is normal to have a doc with just the first line (not terminated by a LF). In this case, we must still check that we have a . before the terminating null byte. I have put the following comment to clarify:       /* Position p on the first LF, or on terminating null byte.  */       while (*p && *p != '\n') p++; > > This is ok with those things fixed. I have pushed after having fixed the missing spaces and added the comment. Thanks for the reviews Philippe