Module Name: othersrc Committed By: agc Date: Tue Oct 5 22:17:15 UTC 2021
Modified Files: othersrc/external/bsd/agcre/dist: libagcre.3 othersrc/external/bsd/agcre/lib: Makefile Log Message: add MLINKS for rev_regexec and reg[an]sub functions To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 othersrc/external/bsd/agcre/dist/libagcre.3 cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/agcre/lib/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: othersrc/external/bsd/agcre/dist/libagcre.3 diff -u othersrc/external/bsd/agcre/dist/libagcre.3:1.4 othersrc/external/bsd/agcre/dist/libagcre.3:1.5 --- othersrc/external/bsd/agcre/dist/libagcre.3:1.4 Tue Oct 5 18:56:24 2021 +++ othersrc/external/bsd/agcre/dist/libagcre.3 Tue Oct 5 22:17:15 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: libagcre.3,v 1.4 2021/10/05 18:56:24 uwe Exp $ +.\" $NetBSD: libagcre.3,v 1.5 2021/10/05 22:17:15 agc Exp $ .\" .\" Copyright (c) 2017,2020,2021 Alistair Crooks <a...@netbsd.org> .\" All rights reserved. @@ -162,6 +162,18 @@ expression, the individual virtual machi will be printed on standard output. .It Dv AGCRE_REG_TRACE Traces execution of the regular expression. +.It Dv AGCRE_REG_CTAGS +This is used where a regular expression pattern was generated by the +.Xr ctags 1 +program, since the syntax generated does not conform to a standard +basic regular expression. +In particular, +.Xr ctags 1 +outputs function location patterns which contain an unescaped +.Ql * +character, whereas basic regular expressions will only +recognise an asterisk as a standard character if it appears +at the start of an expression. .\".It Dv AGCRE_IN_8BITS .\"This indicates to the .\".Fn agcre_regcomp @@ -240,18 +252,6 @@ should therefore use the definition. Anchoring can be specified at expression compile time, and/or at expression execution time. -.It Dv AGCRE_REG_ANCHOR -This is used where a regular expression pattern was generated by the -.Xr ctags 1 -program, since the syntax generated does not conform to a standard -basic regular expression. -In particular, -.Xr ctags 1 -outputs function location patterns which contain an unescaped -.Ql * -character, whereas basic regular expressions will only -recognise an asterisk as a standard character if it appears -at the start of an expression. .\".It Dv AGCRE_IN_8BITS .\"This indicates to the .\".Fn agcre_regexec @@ -318,7 +318,7 @@ and character sets, ranges and character classes. .Pp Because a virtual machine is used, -there are no real limits top the size of regular expression +there are no real limits to the size of regular expression which can be compiled. However, to avoid abuse, certain arbitrary limits are set: .Bl -bullet -offset indent -compact @@ -332,6 +332,51 @@ the maximum number of is set at compile-time to 1024 .El .Pp +To deallocate storage in the compiled regular expression, the +.Fn agcre_regfree +is used. +Once the storage is deallocated, it cannot be used again +without another compilation using +.Fn agcre_regcomp . +.Pp +If storage for the regular expression was allocated using +.Fn agcre_new +then that storage should be deallocated using the +.Xr free 3 +function. +.Pp +The +.Fn agcre_regnsub +and +.Fn agcre_regasub +functions perform substitutions using +.Xr sed 1 +like syntax. +They return the length of +the string that would have been created if there was enough space or -1 on error, setting errno. +The result is +placed in buf which is user-supplied in +.Fn agcre_regnsub +and dynamically allocated in +.Fn agcre_regasub . +The sub argument +contains a substitution string which might refer to the first 9 regular expression strings using +.Ql \e<n> +to refer +to the nth matched item, or +.Ql & +(which is equivalent to +.Ql \e0 ) +to refer to the full match. +The match array must be +at least 10 elements long, +and should contain the result of the matches from a previous +.Fn agcre_regexec +call. +Only 10 +elements of the rm array can be used. +The str argument contains the source string in which transformations will be substituted. +.Pp To show the value of constant-time execution, especially for regular expressions which may be subject to abuse, the standard Index: othersrc/external/bsd/agcre/lib/Makefile diff -u othersrc/external/bsd/agcre/lib/Makefile:1.2 othersrc/external/bsd/agcre/lib/Makefile:1.3 --- othersrc/external/bsd/agcre/lib/Makefile:1.2 Tue Oct 5 01:23:39 2021 +++ othersrc/external/bsd/agcre/lib/Makefile Tue Oct 5 22:17:15 2021 @@ -1,17 +1,19 @@ -# $NetBSD: Makefile,v 1.2 2021/10/05 01:23:39 agc Exp $ +# $NetBSD: Makefile,v 1.3 2021/10/05 22:17:15 agc Exp $ LIB= agcre SRCS+= agcre.c MAN= libagcre.3 agcre_format.7 MLINKS+= libagcre.3 agcre_regcomp.3 MLINKS+= libagcre.3 agcre_regexec.3 +MLINKS+= libagcre.3 agcre_rev_regexec.3 MLINKS+= libagcre.3 agcre_regfree.3 MLINKS+= libagcre.3 agcre_regerror.3 +MLINKS+= libagcre.3 agcre_regnsub.3 +MLINKS+= libagcre.3 agcre_regasub.3 WARNS= 5 CPPFLAGS+= -I${DIST} -PRODUCTION=1 .ifndef PRODUCTION CPPFLAGS+= -g -O0 LDFLAGS+= -g -O0