From: Alejandro Colomar <alx.manpages@gmail.com>
To: наб <nabijaczleweli@nabijaczleweli.xyz>
Cc: GNU C Library <libc-alpha@sourceware.org>,
Siddhesh Poyarekar <siddhesh@gotplt.org>
Subject: Re: regexec(3): REG_STARTEND is not documented
Date: Fri, 21 Apr 2023 03:47:06 +0200 [thread overview]
Message-ID: <b9f13f4f-81aa-af1e-41bb-5ae8998bd15d@gmail.com> (raw)
In-Reply-To: <7j64b34c7gjtltgqp4iyha335pkfwelj7miemozm6xcd3oy7ic@tdchlurmv2kk>
[-- Attachment #1.1: Type: text/plain, Size: 2225 bytes --]
On 4/21/23 03:41, наб wrote:
> Hi!
>
> On Fri, Apr 21, 2023 at 03:28:42AM +0200, Alejandro Colomar wrote:
>> On 4/21/23 03:15, наб wrote:
>>> On Fri, Apr 21, 2023 at 03:07:00AM +0200, Alejandro Colomar wrote:
>>>> Here's a related question:
>>>> regmatch_t pmatch = {
>>>> .rm_so = string,
>>>> .rm_eo = string + 42, // Assume this offset is valid
>>>> };
>>>> regexec(preg, string, 0, pmatch, REG_STARTEND);
>>>> Should regexec(3) write to the 1st element in pmatch[] because it knows
>>>> it exists (otherwise the call would be UB because it needs to read it)?
>>> (Which would run counter to how POSIX defines the API.)
>>>
>>>> Or is passing 0 in nmatch effectively another way of performing
>>>> REG_NOSUB behavior without actually using the flag?
>>> Hilariously enough, quoth 4.4BSD-Lite regex(3) again,
>>> which phrases it exactly like you do:
>>> If REG_NOSUB was specified in the compilation of the RE, or if nmatch
>>> is 0, regexec ignores the pmatch argument (but see below for the case
>>> where REG_STARTEND is specified).
>> Touche; it looks like your right. That sentence is unambiguous. BTW, is the
>> reference to some other text about REG_STARTEND the one quoted first
>> (above)?
> That's the first mention of [np]match afterward, yeah. The file's
> massive, so I've attached it here, you can read more brain-destroying
> minutiae there; it's modern-enough mdoc(7) that anything should render
> it sensibly.
>
> I've also noticed (even later, did I mention they couldn't stop writing?):
> If REG_STARTEND is specified, pmatch must point to at least one reg‐
> match_t (even if nmatch is 0 or REG_NOSUB was specified), to hold the
> input offsets for REG_STARTEND. Use for output is still entirely con‐
> trolled by nmatch; if nmatch is 0 or REG_NOSUB was specified, the value
> of pmatch[0] will not be changed by a successful regexec.
Holly antelope! At least we can't have doubts of the intended interface :)
It seems to confirm everything you suspected ;)
>
> Best,
> наб
--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-04-21 1:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-21 0:45 Alejandro Colomar
2023-04-21 1:07 ` Alejandro Colomar
2023-04-21 1:15 ` наб
2023-04-21 1:28 ` Alejandro Colomar
2023-04-21 1:41 ` наб
2023-04-21 1:47 ` Alejandro Colomar [this message]
2023-04-21 11:59 ` Siddhesh Poyarekar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b9f13f4f-81aa-af1e-41bb-5ae8998bd15d@gmail.com \
--to=alx.manpages@gmail.com \
--cc=libc-alpha@sourceware.org \
--cc=nabijaczleweli@nabijaczleweli.xyz \
--cc=siddhesh@gotplt.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).