This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFAv2 2/2] Add a selftest that checks documentation invariants.


On Tue, 2019-08-06 at 12:33 -0600, Tom Tromey wrote:
> > > > > > "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]