Re: [PATCH v2 6/9] regex.3, regex_t.3type, regmatch_t.3type, regoff_t.3type: move in with regex.3

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

 



Hi!

On 4/20/23 01:25, наб wrote:
> They're inextricably linked, not cross-referenced at all,
> and not used anywhere else.
> 
> Now that they (realistically) exist to the reader, add a note

I prefer if the text movement is done in a separate commit that does
the minimum, so that git(1) has it easier to follow the changes.

Also, this is a big change.  Could you please move it closer to the
end of the patch set?

Thanks,

Alex

> on how big nmatch can be; POSIX even says "The application develope
> should note that there is probably no reason for using a value of
> nmatch that is larger than preg−>re_nsub+1.".
> 
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@xxxxxxxxxxxxxxxxxx>
> ---
>  man3/regex.3              | 66 ++++++++++++++++++++++++++++-----------
>  man3type/regex_t.3type    | 64 +------------------------------------
>  man3type/regmatch_t.3type |  2 +-
>  man3type/regoff_t.3type   |  2 +-
>  4 files changed, 51 insertions(+), 83 deletions(-)
> 
> diff --git a/man3/regex.3 b/man3/regex.3
> index fa2669544..b95b3c3b0 100644
> --- a/man3/regex.3
> +++ b/man3/regex.3
> @@ -15,7 +15,7 @@ regcomp, regexec, regerror, regfree \- POSIX regex functions
>  Standard C library
>  .RI ( libc ", " \-lc )
>  .SH SYNOPSIS
> -.nf
> +.EX
>  .B #include <regex.h>
>  .PP
>  .BI "int regcomp(regex_t *restrict " preg ", const char *restrict " regex ,
> @@ -29,7 +29,21 @@ Standard C library
>  .BI "            char " errbuf "[restrict ." errbuf_size "], \
>  size_t " errbuf_size );
>  .BI "void regfree(regex_t *" preg );
> -.fi
> +.PP
> +.B typedef struct {
> +.BR "    size_t    re_nsub;" "  /* Number of parenthesized subexpressions */"
> +.B } regex_t;
> +.PP
> +.B typedef struct {
> +.BR "    regoff_t  rm_so;" "    /* Byte offset from start of string"
> +                           to start of substring */
> +.BR "    regoff_t  rm_eo;" "    /* Byte offset from start of string to"
> +                           the first character after the end of
> +                           substring */
> +.B } regmatch_t;
> +.PP
> +.BR typedef " /* ... */  " regoff_t;
> +.EE
>  .SH DESCRIPTION
>  .SS POSIX regex compiling
>  .BR regcomp ()
> @@ -54,6 +68,21 @@ must always be supplied with the address of a
>  .BR regcomp ()-initialized
>  pattern buffer.
>  .PP
> +After
> +.BR regcomp ()
> +succeeds,
> +.I preg->re_nsub
> +holds the number of subexpressions in
> +.IR regex .
> +Thus, a value of
> +.I preg->re_nsub
> ++ 1
> +passed as
> +.I nmatch
> +to
> +.BR regexec ()
> +is sufficient to capture all matches.
> +.PP
>  .I cflags
>  is the
>  bitwise OR
> @@ -192,22 +221,6 @@ must be at least
>  .IR N+1 .)
>  Any unused structure elements will contain the value \-1.
>  .PP
> -The
> -.I regmatch_t
> -structure which is the type of
> -.I pmatch
> -is defined in
> -.IR <regex.h> .
> -.PP
> -.in +4n
> -.EX
> -typedef struct {
> -    regoff_t rm_so;
> -    regoff_t rm_eo;
> -} regmatch_t;
> -.EE
> -.in
> -.PP
>  Each
>  .I rm_so
>  element that is not \-1 indicates the start offset of the next largest
> @@ -216,6 +229,14 @@ The relative
>  .I rm_eo
>  element indicates the end offset of the match,
>  which is the offset of the first character after the matching text.
> +.PP
> +.I regoff_t
> +is a signed integer type
> +capable of storing the largest value that can be stored in either an
> +.I ptrdiff_t
> +type or a
> +.I ssize_t
> +type.
>  .SS POSIX error reporting
>  .BR regerror ()
>  is used to turn the error codes that can be returned by both
> @@ -338,6 +359,15 @@ T}	Thread safety	MT-Safe
>  POSIX.1-2008.
>  .SH HISTORY
>  POSIX.1-2001.
> +.PP
> +Prior to POSIX.1-2008,
> +.I regoff_t
> +was required to be
> +capable of storing the largest value that can be stored in either an
> +.I off_t
> +type or a
> +.I ssize_t
> +type.
>  .SH EXAMPLES
>  .EX
>  #include <stdint.h>
> diff --git a/man3type/regex_t.3type b/man3type/regex_t.3type
> index 176d2c7a6..c0daaf0ff 100644
> --- a/man3type/regex_t.3type
> +++ b/man3type/regex_t.3type
> @@ -1,63 +1 @@
> -.\" Copyright (c) 2020-2022 by Alejandro Colomar <alx@xxxxxxxxxx>
> -.\" and Copyright (c) 2020 by Michael Kerrisk <mtk.manpages@xxxxxxxxx>
> -.\"
> -.\" SPDX-License-Identifier: Linux-man-pages-copyleft
> -.\"
> -.\"
> -.TH regex_t 3type (date) "Linux man-pages (unreleased)"
> -.SH NAME
> -regex_t, regmatch_t, regoff_t
> -\- regular expression matching
> -.SH LIBRARY
> -Standard C library
> -.RI ( libc )
> -.SH SYNOPSIS
> -.EX
> -.B #include <regex.h>
> -.PP
> -.B typedef struct {
> -.BR "    size_t    re_nsub;" "  /* Number of parenthesized subexpressions */"
> -.B } regex_t;
> -.PP
> -.B typedef struct {
> -.BR "    regoff_t  rm_so;" "    /* Byte offset from start of string"
> -                           to start of substring */
> -.BR "    regoff_t  rm_eo;" "    /* Byte offset from start of string to"
> -                           the first character after the end of
> -                           substring */
> -.B } regmatch_t;
> -.PP
> -.BR typedef " /* ... */  " regoff_t;
> -.EE
> -.SH DESCRIPTION
> -.TP
> -.I regex_t
> -This is a structure type used in regular expression matching.
> -It holds a compiled regular expression,
> -compiled with
> -.BR regcomp (3).
> -.TP
> -.I regmatch_t
> -This is a structure type used in regular expression matching.
> -.TP
> -.I regoff_t
> -It is a signed integer type
> -capable of storing the largest value that can be stored in either an
> -.I ptrdiff_t
> -type or a
> -.I ssize_t
> -type.
> -.SH STANDARDS
> -POSIX.1-2008.
> -.SH HISTORY
> -POSIX.1-2001.
> -.PP
> -Prior to POSIX.1-2008,
> -the type was
> -capable of storing the largest value that can be stored in either an
> -.I off_t
> -type or a
> -.I ssize_t
> -type.
> -.SH SEE ALSO
> -.BR regex (3)
> +.so man3/regex.3
> diff --git a/man3type/regmatch_t.3type b/man3type/regmatch_t.3type
> index dc78f2cf2..c0daaf0ff 100644
> --- a/man3type/regmatch_t.3type
> +++ b/man3type/regmatch_t.3type
> @@ -1 +1 @@
> -.so man3type/regex_t.3type
> +.so man3/regex.3
> diff --git a/man3type/regoff_t.3type b/man3type/regoff_t.3type
> index dc78f2cf2..c0daaf0ff 100644
> --- a/man3type/regoff_t.3type
> +++ b/man3type/regoff_t.3type
> @@ -1 +1 @@
> -.so man3type/regex_t.3type
> +.so man3/regex.3

-- 
<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