Re: [PATCH 2/2] regex.3: improve REG_STARTEND

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi наб!

On 4/19/23 19:48, наб wrote:
> Explicitly spell out the ranges involved. The original wording always
> confused me, but it's actually very sane.
> 
> Also change the [0]. to -> here to make more obvious the point that
> pmatch is used as a pointer-to-object, not array in this scenario.
> 
> Remove "this doesn't change R_NOTBOL & R_NEWLINE" ‒ so does it change
> R_NOTEOL? No. That's weird and confusing.
> 
> String largeness doesn't matter, known-lengthness does.
> 
> Explicitly spell out the influence on returned matches
> (relative to string, not start of range).
> 
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@xxxxxxxxxxxxxxxxxx>
> ---
>  man3/regex.3 | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/man3/regex.3 b/man3/regex.3
> index d54d6024c..2c8b87aca 100644
> --- a/man3/regex.3
> +++ b/man3/regex.3
> @@ -141,23 +141,20 @@ compilation flag
>  above).
>  .TP
>  .B REG_STARTEND
> -Use
> -.I pmatch[0]
> -on the input string, starting at byte
> -.I pmatch[0].rm_so
> -and ending before byte
> -.IR pmatch[0].rm_eo .
> +Match
> +.RI [ string " + " pmatch->rm_so ", " string " + " pmatch->rm_eo )
> +instead of
> +.RI [ string ", " string " + \fBstrlen\fP(" string )).

Hmmm, I like this!

Let's see if I understand it.  pmatch[] is normally
[[gnu::access(write_only, 4, 3)]]
but if ((.eflags & REG_STARTEND) != 0) it's [1] and
[[gnu::access(read_write, 4)]]?

>  This allows matching embedded NUL bytes
>  and avoids a
>  .BR strlen (3)
> -on large strings.
> -It does not use
> +on known-length strings.
>  .I nmatch
> -on input, and does not change
> -.B REG_NOTBOL
> -or
> -.B REG_NEWLINE
> -processing.
> +is not consulted for this purpose.
> +If any matches are returned, they're relative to
> +.IR string ,
> +not
> +.IR string " + " pmatch->rm_so .

How are such matches returned?  In pmatch[>0]?  Or how?

Cheers,
Alex

>  This flag is a BSD extension, not present in POSIX.
>  .SS Byte offsets
>  Unless

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux