At 2024-10-05T17:32:44-0500, G. Branden Robinson wrote:
> At 2024-10-05T14:08:12+0000, Lennart Jablonka wrote:
> > The function strstr expects a null-terminated string.  You could use
> > memmem instead of strstr.
> 
> Thanks, yes--I'll do something like that.

That tugged on a bit of loose yarn but it seems to have settled down.

commit 5d33d2a82ea1aa420f80b8dc55db4c54b0213809
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
Date:   Sun Oct 6 11:59:06 2024 -0500

    src/include/stringclass.h: Fix code style nit.

    * src/include/stringclass.h (class string): Fix code style nit:
      `const`-ify argument to `search` public member function.

    Also delete trailing whitespace from file.

commit 12135329da31309c2959108d82643878d232a285
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
Date:   Sun Oct 6 12:15:13 2024 -0500

    src/libs/libgroff/string.cpp: Fix code style nits.

    * src/libs/libgroff/string.cpp (string::search): `const`-ify argument
      and local variable.  Use C++ `static_cast` operator instead of C-style
      type cast.  Explicitly compare variable of pointer type to null
      pointer literal instead of letting it pun down to a Boolean.
      Parenthesize complex expression.

    Also annotate null pointer with `nullptr` comment to ease any future
    transition to C++11, which defines it as a keyword.

commit 89316e9977b0e25df865f2d0fa50329a86356a51
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
Date:   Sun Oct 6 12:05:32 2024 -0500

    bootstrap.conf: Add "memmem" to `gnulib_modules`.

commit 1787ae7081f5496da3a047acc90846a16d84a305
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
Date:   Sun Oct 6 12:06:13 2024 -0500

    [libgroff]: Add `find()` to `string` class.

    * src/include/stringclass.h (class string): Declare new `find` public
      member function; it works like `search` but takes a pointer to `const
      char`, making it a substring locator.

    * src/libs/libgroff/string.cpp (string::find): Implement it.

commit 045d54c8ae1fb0f568c2a1c0579d8fb0c8932ce4
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
Date:   Sun Oct 6 12:35:27 2024 -0500

    [tbl]: Fix potential SEGV in recently added code.

    * src/preproc/tbl/table.cpp (table::add_entry): Refactor to avoid
      overreading memory allocated to `string` objects, which don't
      null-terminate their contents.  Use string class's existing `search`
      and new `find` member functions to perform character and substring
      matches, respectively, instead of `strchr()` and `strstr()`.  As a
      side benefit, the code now looks cleaner and reads easier.

    Fixes a SEGV reported by Lennart Jablonka that I can't reproduce but
    which made sense once he pointed it out.  Problem introduced by me in
    commit a91cd457d9, 26 September.

commit 8ae6a9be43c532ad1796644dce839a25a55f8dab (HEAD -> master)
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
Date:   Sun Oct 6 12:40:15 2024 -0500

    [tbl]: Refactor table entry content validation.

    * src/preproc/tbl/table.cpp (table::add_entry): Refactor match attempts
      for `\R` and `\z` in table entries to use new `find()` member function
      of string class.

Regards,
Branden

Attachment: signature.asc
Description: PGP signature

Reply via email to