Home | History | Annotate | only in /src/lib/libc/regex
History log of /src/lib/libc/regex
RevisionDateAuthorComments
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.4 27-Feb-1995  cgd add unintrusive Ids
 1.3 30-Jan-1995  cgd clean up import; kill old cruft.
 1.2 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.1 16-Nov-1993  jtc branches: 1.1.1;
Update to Henry's Nov 11 release -- no code changes, only the addition of
a copyright file. I'm checking it in now, rather than waiting for the
next "real" release, since the rest of the files do not have their own
copyright notices.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.4 30-Jan-1995  mycroft Clean up deleted files.
 1.3 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.10 20-Jan-2024  christos Catch up with all the lint warnings since exit on warning was disabled.
Disable 'missing header declaration' and 'nested extern' warnings for now.
 1.9 14-Jan-2016  christos rename to regnsub, regsub is a very popular name.
 1.8 14-Jan-2016  christos add reg{,a}sub
 1.7 14-Nov-1997  mrg add missing .Nm entries. from spz@serpens.swb.de.
 1.6 22-Oct-1997  lukem - use CPPFLAGS instead of CFLAGS
- use ${COMPILE.C} ... instead of ${CC} ${CFLAGS} -c ...
 1.5 27-Feb-1995  cgd branches: 1.5.10;
add unintrusive Ids
 1.4 08-Feb-1995  cgd fix man page specs, per bug 788 from John Smerdon.
 1.3 30-Jan-1995  cgd clean up import; kill old cruft.
 1.2 22-Dec-1994  cgd specify man pages the new way.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.5.10.2 14-Nov-1997  mrg pull up from trunk: add missing .Nm entries. from spz@serpens.swb.de.
 1.5.10.1 09-Nov-1997  lukem sync with trunk (approved by thorpej)
 1.5 30-Jan-1995  mycroft Clean up deleted files.
 1.4 22-Mar-1994  jtc Upgrade regex routines to alpha3.4.
 1.3 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.6 27-Feb-1995  cgd add unintrusive Ids
 1.5 30-Jan-1995  cgd clean up import; kill old cruft.
 1.4 22-Mar-1994  jtc Upgrade regex routines to alpha3.4.
 1.3 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.8 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 26-Jul-1998  mycroft const poisoning.
 1.5 26-Jul-1998  mycroft constify some tables.
 1.4 13-Jul-1997  christos Add missing braces in initializers.
 1.3 27-Feb-1995  cgd add unintrusive Ids
 1.2 30-Jan-1995  cgd clean up import; kill old cruft.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.8 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.6 26-Jul-1998  mycroft const poisoning.
 1.5 26-Jul-1998  mycroft constify some tables.
 1.4 13-Jul-1997  christos Add missing braces in initializers.
 1.3 27-Feb-1995  cgd add unintrusive Ids
 1.2 30-Jan-1995  cgd clean up import; kill old cruft.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.2 30-Jan-1995  mycroft Clean up deleted files.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.2 30-Jan-1995  mycroft Clean up deleted files.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.30 23-Jan-2024  christos handle sizeof(off_t) > sizeof(size_t)
 1.29 25-Feb-2021  christos fix NLS compilation
 1.28 25-Feb-2021  christos Add glue to disable locale code in order to be smaller.
 1.27 24-Feb-2021  christos reduce casts
 1.26 24-Feb-2021  wiz Restore NetBSD RCS Ids.
 1.25 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.24 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.23 09-Oct-2011  christos branches: 1.23.2;
Prevent regcomp/regexec DoS attacks by limiting the amount of memory used
and the level of recursion. Thanks to Maksymilian Arciemowicz for discovery
and help with the implementation.
 1.22 12-Feb-2009  lukem sign-compare fixes
 1.21 08-Feb-2007  junyoung branches: 1.21.22;
ANSIfy.
 1.20 08-Feb-2007  junyoung Nuke __P.
 1.19 02-Dec-2005  yamt constify and remove __UNCONST.
 1.18 03-Apr-2004  christos Avoid infinite recursion on:

echo "foo foo bar bar bar baz" | sed 's/\([^ ]*\)\( *\1\)*/\1/g'

From OpenBSD.
 1.17 26-Mar-2004  enami Redo previous in a different way; cast the character held in int variable
as unsigned char just before passing isalnum() in ISWORD() rather than
fetching it as unsigned char. It is ok since EOF is never passed to ISWORD()
(though it will be a bit inefficient.)

Addresses PR#24929.
 1.16 12-Mar-2004  enami Sprinkle cast to prevent unwanted sign extension. Some of those actually
makes sed invoked during build process an out of bound array access.
 1.15 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.14 22-Jul-2002  christos make this compile with -DREDEBUG again.
 1.13 17-Dec-2001  christos PR/14975: Takayoshi Kochi: memory leak in regexec(3).
Always free m->pmatch and m->lastpos on error.
 1.12 16-Sep-1999  lukem branches: 1.12.10;
* use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.11 20-Jan-1999  christos Avoid overflow when adding a 64 bit quantity to a 32 bit pointer on 32 bit
machines.
 1.10 08-Dec-1998  drochner regoff_t is used like size_t within the code, it should be defined
so instead of off_t. This makes some casts unnecessary.
We can't change the definition now due to binary compatibility, so
prepare for the next libc major version.
 1.9 14-Nov-1998  christos Delint:
- we don't need to use longs; convert to use int32_t.
- remove break statements after returns.
- cast things properly.
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 13-Jul-1997  christos Add missing return NULL;
 1.6 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 30-Jan-1995  cgd clean up import; kill old cruft.
 1.3 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.12.10.2 01-Aug-2002  nathanw Catch up to -current.
 1.12.10.1 28-Jan-2002  nathanw Catch up to -current.
 1.21.22.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.23.2.1 17-Apr-2012  yamt sync with head
 1.3 30-Jan-1995  mycroft Clean up deleted files.
 1.2 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.2 23-Feb-1994  mycroft Clean up deleted files.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.2 30-Jan-1995  mycroft Clean up deleted files.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.2 30-Jan-1995  mycroft Clean up deleted files.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.2 30-Jan-1995  mycroft Clean up deleted files.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.16 04-Dec-2022  uwe re_format(7): Add subsection headings for ERE and BRE

The first paragraph could use some rewording. While BRE may be
obsolete, it's still the default for regcomp(3) and the default for
grep(1), sed(1), etc.
 1.15 28-Aug-2022  uwe re_format(7): Use dagger, not double dagger. Make it superscript.
 1.14 24-Feb-2021  wiz Restore NetBSD RCS Ids.
 1.13 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.12 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.11 22-Aug-2015  wiz Update for v1.10: use '(*)' instead of '#' as dagger replacement.

dholland finds the '#' unintuitive and hard to read.
 1.10 25-Jan-2013  wiz Replace dagger ("\(dg") with hash mark ("#") for marking up differences.
Dagger wasn't displayed on terminals and replaced with a minus, which
was hard to read.

Requested by agc.
 1.9 21-Apr-2009  joerg branches: 1.9.6; 1.9.12;
Convert to mdoc markup.
 1.8 07-Aug-2003  agc branches: 1.8.42;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.7 08-Feb-2002  ross Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.6 16-Sep-2001  wiz Boring whitespace fix.
 1.5 27-Feb-1995  cgd branches: 1.5.22;
add unintrusive Ids
 1.4 30-Jan-1995  cgd clean up import; kill old cruft.
 1.3 01-Apr-1994  cgd re_format name fixes from Mark Weaver
 1.2 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.5.22.3 22-Mar-2002  nathanw Catch up to -current.
 1.5.22.2 08-Mar-2002  nathanw Catch up to -current.
 1.5.22.1 08-Oct-2001  nathanw Catch up to -current.
 1.8.42.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.9.12.1 25-Feb-2013  tls resync with head
 1.9.6.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.49 01-Jan-2025  christos PR/58910: enh at google dot com: Fix signed character issue in character
ranges.
 1.48 30-Aug-2023  christos branches: 1.48.2;
- cast GETNEXT to unsigned where it is being promoted to int to prevent
sign-extension (really it would have been better for PEEK*() and GETNEXT()
to return unsigned char; this would have removed a ton of (uch) casts, but
it is too intrusive for now).
- fix an isalpha that should have been iswalpha
 1.47 21-Dec-2022  wiz Remove unneeded -D_OPENBSD_SOURCE
 1.46 11-Mar-2021  christos recognize the "C" language backslash escapes like gnu does (except b which
is already taken)
 1.45 26-Feb-2021  christos Arrange for tools build
 1.44 25-Feb-2021  christos add missing _
 1.43 25-Feb-2021  christos fix NLS compilation
 1.42 25-Feb-2021  christos Add glue to disable locale code in order to be smaller.
 1.41 25-Feb-2021  christos protect MIN from re-definition
 1.40 24-Feb-2021  christos reduce casts
 1.39 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.38 07-Feb-2019  christos Add some better error handling from FreeBSD, although we don't
suffer from the same issue, since we don't decrement p->next, like
FreeBSD does because we don't have multibyte support (yet). We
choose to do this so we can fail faster and more predictably.

Here's the original FreeBSD message:

When passed the invalid regular expression "a**", the error is
eventually detected and seterr() is called. It sets p->error
appropriatly and p->next and p->end to nuls which is a never used char
nuls[10] which is zeros due to .bss initialization. Unfortunatly,
p_ere_exp() and p_simp_re() both have fall through cases where they set
the error, decrement p->next and access it which means a read from what
ever .bss variable comes before nuls.

Found with regex_test:repet_multi and CHERI bounds checking.

Reviewed by: ngie, pfg, emaste
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D10541
 1.37 07-Feb-2019  christos Fix OOB read from FreeBSD:

The bug is an out-of-bounds read detected with address sanitizer that
happens when 'sp' in p_b_coll_elems() includes NUL byte[s], e.g. if it's
equal to "GS\x00". In that case len will be equal to 4, and the
strncmp(cp->name, sp, len) call will succeed when cp->name is "GS" but the
cp->name[len] == '\0' comparison will cause the read to go out-of-bounds.

Checking the length using strlen() instead eliminates the issue.

The bug was found in LLVM with oss-fuzz:
https://reviews.llvm.org/D39380
 1.36 12-Sep-2015  christos branches: 1.36.16;
use the unsigned char version of the input char in all cases "cap[uc]" to
avoid accessing cap[negative], found by Elliott Hughes
 1.35 17-Feb-2015  joerg Use reallocarr and simplify. Document valid reallocation failures.
 1.34 05-Feb-2015  christos Add and use reallocarray() to prevent a multiplication overflow in allocation.
Reported by Guido Vranken, thanks!
 1.33 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.32 08-Nov-2011  christos branches: 1.32.2; 1.32.6; 1.32.8;
if we don't have any sets yet, don't try to look in them.
 1.31 09-Oct-2011  christos branches: 1.31.2;
pass lint on i386
 1.30 09-Oct-2011  christos Prevent regcomp/regexec DoS attacks by limiting the amount of memory used
and the level of recursion. Thanks to Maksymilian Arciemowicz for discovery
and help with the implementation.
 1.29 12-Feb-2009  lukem sign-compare fixes
 1.28 09-Feb-2007  junyoung branches: 1.28.22;
Rearrange headers for better portability.
 1.27 08-Feb-2007  junyoung ANSIfy.
 1.26 08-Feb-2007  junyoung Nuke __P.
 1.25 19-Mar-2006  christos remove unused label.
 1.24 19-Mar-2006  christos revert previous error check.
 1.23 19-Mar-2006  christos Coverity CID 769: Avoid NULL deref.
 1.22 19-Mar-2006  christos Coverity CID 770: Avoid NULL deref.
 1.21 02-Dec-2005  yamt constify and remove __UNCONST.
 1.20 29-Nov-2005  christos WARNS=4
 1.19 18-Sep-2004  jdolecek make othercase() return int rather than char, to avoid sign extension
bug with character codes >= 128

fixes PR lib/26986 by Alexander Becher
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 07-Jul-2000  itohy Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.
 1.16 22-Jan-2000  mycroft branches: 1.16.4;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.15 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.14 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.13 13-Dec-1998  drochner Minor size_t!=int related cleanup, only effective on the alpha.
btw: the maximum length of an RE is limited by the "int" range, also
on the alpha. "sopno" is "int", and "int"s are used as counters within
the code, so it would need some work to change this. I only don't know
how one could test it...
 1.12 08-Dec-1998  drochner Change some function arguments to appropriate types. This makes lint
happy without casts.
 1.11 14-Nov-1998  christos Delint:
- we don't need to use longs; convert to use int32_t.
- remove break statements after returns.
- cast things properly.
 1.10 26-Jul-1998  mycroft constify some tables.
 1.9 03-Feb-1998  perry remove obsolete register declarations
 1.8 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.7 13-Jul-1997  christos Fix RCSID's
Fix gcc warnings.
Add missing prototypes
#if 0 unused functions
 1.6 27-Feb-1995  cgd add unintrusive Ids
 1.5 30-Jan-1995  cgd clean up import; kill old cruft.
 1.4 22-Mar-1994  jtc Upgrade regex routines to alpha3.4.
 1.3 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.16.4.1 25-Jan-2001  jhawk Pull up revision 1.17 (requested by simonb):
Pass unsigned char (not char) to ctype(3) functions, except isacii(3).
Fixes PR bin/11885.
 1.28.22.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.31.2.2 17-Apr-2012  yamt sync with head
 1.31.2.1 10-Nov-2011  yamt sync with head
 1.32.8.1 21-Feb-2015  martin Apply patch, requested by joerg in ticket #1257:

lib/libc/regex/regcomp.c (patch)

Fix a multiplication overflow in allocation, which has been fixed
differently in rev. 1.34 in -current.
 1.32.6.1 21-Feb-2015  martin Apply patch, requested by joerg in ticket #1257:

lib/libc/regex/regcomp.c (patch)

Fix a multiplication overflow in allocation, which has been fixed
differently in rev. 1.34 in -current.
 1.32.2.1 21-Feb-2015  martin Apply patch, requested by joerg in ticket #1257:

lib/libc/regex/regcomp.c (patch)

Fix a multiplication overflow in allocation, which has been fixed
differently in rev. 1.34 in -current.
 1.36.16.1 10-Jun-2019  christos Sync with HEAD
 1.48.2.1 02-Aug-2025  perseant Sync with HEAD
 1.3 01-Mar-1995  mycroft Clean up deleted files.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.26 05-Nov-2022  riastradh regerror(3): Allow null errbuf if errbuf_size is zero.

The man page says:

If errbuf_size is 0, errbuf is ignored but the return value is still
correct.

POSIX says:

If errbuf_size is 0, regerror() shall ignore the errbuf argument,
and return the size of the buffer needed to hold the generated
string.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/regerror.html

from enh@google.com
 1.25 26-Feb-2021  christos Arrange for tools build
 1.24 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.23 09-Feb-2007  junyoung Rearrange headers for better portability.
 1.22 08-Feb-2007  junyoung ANSIfy.
 1.21 08-Feb-2007  junyoung Nuke __P.
 1.20 02-Dec-2005  yamt constify and remove __UNCONST.
 1.19 29-Nov-2005  christos WARNS=4
 1.18 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.17 17-Nov-2002  itojun use strlcpy where it is more appropriate.
 1.16 22-Jan-2000  mycroft branches: 1.16.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.15 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.14 17-Sep-1999  kleink The previous assertion change was incorrect: the preg argument is permitted to
be NULL (part of the interface definition!) unless errcode is REG_ATOI, which
is a non-portable extension.

Also, remove assertions from the local regatoi() function, as they are either
redundant or will never fail due to the buffer allocation for that argument in
regerror().
 1.13 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.12 08-Dec-1998  drochner correct a comment, minor formatting
 1.11 14-Nov-1998  christos Delint:
- we don't need to use longs; convert to use int32_t.
- remove break statements after returns.
- cast things properly.
 1.10 26-Jul-1998  mycroft const poisoning.
 1.9 26-Jul-1998  mycroft constify some tables.
 1.8 03-Feb-1998  perry remove obsolete register declarations
 1.7 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.6 13-Jul-1997  christos Add braces in initializers.
Fix RCSID's
Remove unused variables
 1.5 23-Jan-1997  mrg - convert unsafe strcpy(), strcat() and sprintf() to the `n' versions.
- some KNF.
 1.4 27-Feb-1995  cgd add unintrusive Ids
 1.3 30-Jan-1995  cgd clean up import; kill old cruft.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.16.6.1 10-Dec-2002  thorpej Sync with HEAD.
 1.3 01-Mar-1995  mycroft Clean up deleted files.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.35 24-Sep-2024  uwe regex.3: brush up markup

Use \N for backreferences in both places for consistency and to make
it more obviously different from \n (besides the different fonts, that
might not be too obvious).

Use \&. instead of .\& to protect punctuation.
 1.34 22-Sep-2024  christos Fix section header (Anonymous)
 1.33 04-Dec-2022  uwe branches: 1.33.4;
Sections 2 and 3 have RETURN VALUES, not DIAGNOSTICS
 1.32 11-Mar-2021  christos Underscore is a word character (thanks uwe@)
 1.31 11-Mar-2021  wiz Remove trailing whitespace.
 1.30 11-Mar-2021  christos improve wording.
 1.29 11-Mar-2021  christos Document the "C" language escapes supported in GNU mode.
 1.28 24-Feb-2021  wiz Restore NetBSD RCS Ids.
 1.27 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.26 26-Feb-2018  kamil Document ragasub(3) & regnsub(3) implementation detail

Added note:
Only 10 elements of the rm array can be used.

Sponsored by <The NetBSD Foundation>
 1.25 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.24 14-Jan-2016  christos catch up with regsub -> regnsub
 1.23 14-Jan-2016  christos add reg{,a}sub
 1.22 17-May-2011  enami Use Pq or Po macro for better output rather than putting raw open paren
at the end of line.
 1.21 22-Mar-2010  joerg Use .In for header files instead of .Ar Pa and variations.
 1.20 11-Apr-2009  wiz Improve markup.
 1.19 11-Apr-2009  joerg Use semantic markup.
 1.18 29-Dec-2003  wiz branches: 1.18.42;
Remove sentence about this being an alpha
version -- after twelve years it is at least beta ;)
The BUGS section is extensive enough even without it.
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 16-Apr-2003  wiz Use
.In header.h
instead of
.Fd #include \*[Lt]header.h\*[Gt]
Much easier to read and write, and supported by groff for ages.
Okayed by ross.
 1.15 05-Feb-2003  kleink Sprinkle some restrict.
 1.14 01-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.13 29-Apr-2002  simonb Remove <sys/types.h> from synopsis, as per latest SUS/Posix specs.
 1.12 07-Feb-2002  ross Generate <>& symbolically.
 1.11 16-Sep-2001  wiz Sort sections and add .Sx in two places.
 1.10 06-Nov-2000  jdolecek branches: 1.10.2;
add missing ' is ' in regerror() explanation
 1.9 29-Aug-1998  lukem branches: 1.9.10;
first pass at fixing up capitalization of function names and
arguments; ensure that each is correct with respect to the
implementation, rather than being correct as per english.
 1.8 06-Feb-1998  perry macroize BSD, NetBSD, FreeBSD and misc cleanup
 1.7 05-Feb-1998  perry add LIBRARY section to man page
 1.6 05-Feb-1998  perry remove illegal quotes from .Dd directives
 1.5 18-Jan-1998  kleink Enhance readability by converting to use -mdoc macros.
 1.4 27-Feb-1995  cgd add unintrusive Ids
 1.3 30-Jan-1995  cgd clean up import; kill old cruft.
 1.2 01-Apr-1994  cgd re_format name fixes from Mark Weaver
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.9.10.1 09-Nov-2000  tv Pullup 1.10 [jdolecek]:
add missing ' is ' in regerror() explanation
 1.10.2.5 18-Oct-2002  nathanw Catch up to -current.
 1.10.2.4 21-Jun-2002  nathanw Catch up to -current.
 1.10.2.3 22-Mar-2002  nathanw Catch up to -current.
 1.10.2.2 08-Mar-2002  nathanw Catch up to -current.
 1.10.2.1 08-Oct-2001  nathanw Catch up to -current.
 1.18.42.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.33.4.1 02-Aug-2025  perseant Sync with HEAD
 1.4 01-Mar-1995  mycroft Clean up deleted files.
 1.3 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.16 01-Jan-2025  christos PR/58910: enh at google dot com: Fix signed character issue in character
ranges.
 1.15 24-Feb-2021  christos branches: 1.15.8;
reduce casts
 1.14 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.13 09-Oct-2011  christos Prevent regcomp/regexec DoS attacks by limiting the amount of memory used
and the level of recursion. Thanks to Maksymilian Arciemowicz for discovery
and help with the implementation.
 1.12 12-Feb-2009  lukem sign-compare fixes
 1.11 26-Mar-2004  enami branches: 1.11.42;
Redo previous in a different way; cast the character held in int variable
as unsigned char just before passing isalnum() in ISWORD() rather than
fetching it as unsigned char. It is ok since EOF is never passed to ISWORD()
(though it will be a bit inefficient.)

Addresses PR#24929.
 1.10 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.9 13-Dec-1998  drochner Minor size_t!=int related cleanup, only effective on the alpha.
btw: the maximum length of an RE is limited by the "int" range, also
on the alpha. "sopno" is "int", and "int"s are used as counters within
the code, so it would need some work to change this. I only don't know
how one could test it...
 1.8 08-Dec-1998  drochner Back out part of the last change. This broke on the alpha (or wherever
sizeof(u_int32_t) != sizeof(*)), at least in cases with re->re_g->nstates
between 32 and 64.
Primary reason for the breakage was that the "states1" definition didn't
work as expected. (It didn't work before either, but this was not noticed
due to sizeof(long)==sizeof(*).)
The alpha can handle larger problems with the "small" state machine model
if a "long" is used as state variable, so it is better to keep the old
definition here. (u_int32_t is left for the "operator" variables.)
Use "int" as "sopno" - this is used as index into the states field, there
is no point in using a fized-size type.
 1.7 14-Nov-1998  christos Delint:
- we don't need to use longs; convert to use int32_t.
- remove break statements after returns.
- cast things properly.
 1.6 06-Apr-1997  cgd qualify opcode constants with long, so that bad things don't happen when long
!= 32 bits. This might need a bit more thought (i.e. why use long here to
begin with, when int32_t might be a better choice), but for now it's good
enough. From Ross Harvey in PR 3450, extended by me to cover the rest of
the opcode constants and masks.
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 30-Jan-1995  cgd clean up import; kill old cruft.
 1.3 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.11.42.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.15.8.1 02-Aug-2025  perseant Sync with HEAD
 1.26 26-Feb-2021  christos Arrange for tools build
 1.25 25-Feb-2021  christos Add glue to disable locale code in order to be smaller.
 1.24 24-Feb-2021  christos reduce casts
 1.23 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.22 13-Mar-2012  christos PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@
 1.21 12-Feb-2009  lukem branches: 1.21.6;
sign-compare fixes
 1.20 09-Feb-2007  junyoung branches: 1.20.22;
Rearrange headers for better portability.
 1.19 08-Feb-2007  junyoung ANSIfy.
 1.18 29-Nov-2005  christos WARNS=4
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.16 17-Dec-2001  christos turn a macro into a simple statement.
 1.15 22-Jan-2000  mycroft branches: 1.15.6;
Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.14 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.13 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.12 08-Dec-1998  drochner Back out part of the last change. This broke on the alpha (or wherever
sizeof(u_int32_t) != sizeof(*)), at least in cases with re->re_g->nstates
between 32 and 64.
Primary reason for the breakage was that the "states1" definition didn't
work as expected. (It didn't work before either, but this was not noticed
due to sizeof(long)==sizeof(*).)
The alpha can handle larger problems with the "small" state machine model
if a "long" is used as state variable, so it is better to keep the old
definition here. (u_int32_t is left for the "operator" variables.)
Use "int" as "sopno" - this is used as index into the states field, there
is no point in using a fized-size type.
 1.11 14-Nov-1998  christos Delint:
- we don't need to use longs; convert to use int32_t.
- remove break statements after returns.
- cast things properly.
 1.10 03-Feb-1998  perry remove obsolete register declarations
 1.9 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.8 13-Jul-1997  christos Fix RCSID's
Remove unused variable
 1.7 19-Dec-1996  cgd fix a slight bogon (found by lint) introduced in rev 1.5 (by me, no less!).
Don't cast 'INC()'s argument's type, since it's an lvalue and cast
variables aren't lvalues.
 1.6 27-Feb-1995  cgd add unintrusive Ids
 1.5 10-Feb-1995  cgd make these safe for a 64-bit world.
 1.4 30-Jan-1995  cgd clean up import; kill old cruft.
 1.3 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.15.6.1 28-Jan-2002  nathanw Catch up to -current.
 1.20.22.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.21.6.1 17-Apr-2012  yamt sync with head
 1.19 26-Feb-2021  christos Arrange for tools build
 1.18 25-Feb-2021  christos Add glue to disable locale code in order to be smaller.
 1.17 24-Feb-2021  christos reduce casts
 1.16 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.15 09-Feb-2007  junyoung Rearrange headers for better portability.
 1.14 08-Feb-2007  junyoung ANSIfy.
 1.13 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.12 22-Jan-2000  mycroft Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.
 1.11 20-Sep-1999  lukem back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.10 16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.9 08-Dec-1998  drochner remove another unneeded cast
 1.8 14-Nov-1998  christos Delint:
- we don't need to use longs; convert to use int32_t.
- remove break statements after returns.
- cast things properly.
 1.7 03-Feb-1998  perry remove obsolete register declarations
 1.6 21-Jul-1997  jtc If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.
 1.5 13-Jul-1997  christos Remove unused variable
Fix RCSID's
 1.4 27-Feb-1995  cgd add unintrusive Ids
 1.3 30-Jan-1995  cgd clean up import; kill old cruft.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.
 1.4 23-Jan-2024  christos handle sizeof(off_t) > sizeof(size_t)
 1.3 29-Feb-2016  aymeric protect __RCSID the same way other reg*.c files do, so that we can use this
file in libnbcompat
 1.2 14-Jan-2016  christos rename to regnsub, regsub is a very popular name.
 1.1 14-Jan-2016  christos add reg{,a}sub
 1.2 01-Mar-1995  mycroft Clean up deleted files.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.2 23-Feb-1994  mycroft Clean up deleted files.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.5 01-Mar-1995  mycroft Clean up deleted files.
 1.4 22-Mar-1994  jtc Upgrade regex routines to alpha3.4.
 1.3 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.9 22-Apr-2021  christos PR/56120: Chris Pinnock: build.sh (-m alpha) release fails on current on
Darwin in libc compilation
We build the regex code in tools without nls. We don't include any nls headers
for that, but on Darwin wint_t gets defined, so we end up with a compilation
error. The cleaner fix would have been to always use regex_foo_t types, but
the minimal fix is to only do this for the tools build, using cpp.
 1.8 25-Feb-2021  christos Add glue to disable locale code in order to be smaller.
 1.7 23-Feb-2021  christos sync with FreeBSD:
- NLS support
- GNU extensions
- bug fixes
 1.6 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.
 1.5 27-Feb-1995  cgd add unintrusive Ids
 1.4 30-Jan-1995  cgd clean up import; kill old cruft.
 1.3 23-Feb-1994  jtc Upgrade regex routines to alpha3.3.
 1.2 11-Nov-1993  jtc Update to Henry's Nov 2, 1993 alpha3.2 release.
 1.1 10-Nov-1993  jtc branches: 1.1.1;
Henry Spencer's POSIX.2 compatibile regular expression matching routines.
 1.1.1.1 30-Jan-1995  cgd regex code from lite. same as we're using, but slightly cleaner.

RSS XML Feed