summaryrefslogtreecommitdiffstats
path: root/lib/libc/regex (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Make CHIN() Boolean-valued and use this to turn an expression with atb2021-01-032-5/+5
| | | | | | quintuple negation into one with a simple negation. From miod, ok millert
* Turn macros into inline functions so that there is no need to document intb2021-01-031-5/+21
| | | | | | comments that they will evaluate their arguments multiple times. From miod, ok millert
* Remove two now-unused functions; a result of the categories removal.millert2021-01-021-39/+2
| | | | From miod@, OK tb@
* More regular error handling with the REQUIRE macro.millert2020-12-311-5/+4
| | | | | | | Changing it from ((condition) || function call) to an if() wrapped in a do/while is easier to read and more stylistically consistent. The seterr() function no longer needs to return a value. From miod@, OK tb@
* Remove unused categories in re_guts; they are written to but never read.millert2020-12-312-45/+3
| | | | From miod@, OK tb@
* Strings in struct parse can be const, they are never modified.millert2020-12-311-15/+11
| | | | | Also, the temporary array in nonnewline() can be made static const. From miod@, OK tb@
* regcomp.c uses the "start + count < end" idiom to check that there aretb2020-12-301-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | "count" bytes available in an array of char "start" and "end" both point to. This is fine, unless "start + count" goes beyond the last element of the array. In this case, pedantic interpretation of the C standard makes the comparison of such a pointer against "end" undefined, and optimizers from hell will happily remove as much code as possible because of this. An example of this occurs in regcomp.c's bothcases(), which defines bracket[3], sets "next" to "bracket" and "end" to "bracket + 2". Then it invokes p_bracket(), which starts with "if (p->next + 5 < p->end)"... Because bothcases() and p_bracket() are static functions in regcomp.c, there is a real risk of miscompilation if aggressive inlining happens. The following diff rewrites the "start + count < end" constructs into "end - start > count". Assuming "end" and "start" are always pointing in the array (such as "bracket[3]" above), "end - start" is well-defined and can be compared without trouble. As a bonus, MORE2() implies MORE() therefore SEETWO() can be simplified a bit. from miod, ok millert
* Constify the strings in regerror.c and make use of the strlcpy()tb2020-12-301-14/+14
| | | | | | return value to avoid a redundant strlen() call. from miod, ok millert
* cclasses[] multis field is always an empty string. Remove it and codetb2020-12-303-88/+16
| | | | | | dealing with it. This code was incomplete anyway. from miod, ok millert
* Constify the strings in cnames[]. No functional change.tb2020-12-302-5/+5
| | | | from miod, ok millert
* Fix an off-by-one error in the marking of the O_CH operator followingmillert2020-12-281-2/+2
| | | | | an OOR2 operator. Also includes a regress test for the issue. From FreeBSD via miod@
* Do some easy .data -> .rodata/.data.rel.ro conversionsguenther2020-10-132-10/+10
| | | | ok millert@ deraadt@
* Fix typo in last commit.millert2019-02-051-2/+2
|
* Avoid an out of bounds read when regcomp() is passed a bad expression.millert2019-02-051-1/+5
| | | | | | | | When an invalid regular expression is passed, seterr() is called which sets p->error to the appropriate error code and sets p->next and p->end to nuls[]. However, p->next is decremented in the default case in p_ere_exp() and p_simp_re() which makes it point to one byte before nuls[]. From FreeBSD. OK tedu@ deraadt@
* Drop a const-bomb on regexec. It's probably not a good idea to remove amartijn2018-07-112-56/+63
| | | | | | const promise when processing it in the regex engine. Minor tweak and OK schwarze@
* fix oob read; form llvm via Vlad Tsyrklevich; ok millert@otto2017-10-301-3/+3
|
* Clarify code by eliminating unused #define's MUSTSEE, MUSTNOTSEE and inliningkrw2016-12-221-6/+3
| | | | | | MUSTEAT. ok tom@
* Adopt relevant part of NetBSD's r1.7 commit to discard unused results of thekrw2016-12-211-2/+2
| | | | | | | expressions generated by the REQUIRE() macro. Thus eliminating from build output 100 lines or so of gcc complaints about "computed but not used". cluebat & ok tom@
* Delete casts to off_t and size_t that are implied by assignmentsguenther2016-09-212-5/+4
| | | | | | | or prototypes. Ditto for some of the char* and void* casts too. verified no change to instructions on ILP32 (i386) and LP64 (amd64) ok natano@ abluhm@ deraadt@ millert@
* Change the way regexec handles REG_STARTEND combined with REG_NOTBOL.martijn2016-05-262-20/+62
| | | | | | | | | | | | | The new code sees this combination as a continuation of string at offset pmatch[0].rm_so, instead of a new string which starts at that offset. This change fixes a search quirk in vi and is needed for upcoming fixes in ed/sed/vi. This new behaviour is also used in gnu regex. Lots of help from schwarze@ Manpage bits by schwarze@ OK schwarze@ and millert@
* KNF with respect to indentation; no code changeschwarze2016-05-251-28/+27
|
* Fix another one-byte buffer underflow (read access only).schwarze2016-05-251-7/+4
| | | | | | | | | | | | This change touches code that only runs when REG_BASIC is given and the regular expression is anchored with [[:<:]] or \< _and_ uses backreferences. Simplify the logic while here, already looking at the previous character if REG_STARTEND and REG_NOTBOL are both in use, in anticipation of martijn@'s upcoming patch which will further improve REG_STARTEND. OK millert@ martijn@ Also tested by Pedro Giffuni (pfg) on FreeBSD.
* Fix a one-byte buffer underflow (read access only).schwarze2016-05-171-4/+4
| | | | | | | | | | This change touches code that only runs when REG_BASIC is given and the regular expression is anchored with ^ _and_ uses backreferences. The segfault could only be triggered when the ^ anchor was inside a leading () subexpression quantified with *. OK martijn@ Patch also proofread by Pedro Giffuni <pfg at FreeBSD dot org>.
* Remove old cruft.zhuk2016-05-041-95/+0
| | | | okay millert@
* for some time now mandoc has not required MLINKS to functionjmc2016-03-301-3/+1
| | | | | | | | | | | | correctly - logically complete that now by removing MLINKS from base; authors need only to ensure there is an entry in NAME for any function/ util being added. MLINKS will still work, and remain for perl to ease upgrades; ok nicm (curses) bcook (ssl) ok schwarze, who provided a lot of feedback and assistance ok tb natano jung
* Remove NULL-checks before free() and needless argument casts.mmcc2015-12-281-5/+3
| | | | ok tb@
* Remove NULL-checks before free() and unnecessary argument casts.mmcc2015-12-281-8/+5
| | | | ok tb@
* Remove NULL-checks before free() and a few related dead assignments.mmcc2015-12-282-6/+4
| | | | ok and valuable input from millert@
* update NAME section to include all documented functions,jmc2015-11-101-3/+3
| | | | | | or otherwise change Dt to reflect the name of an existing function; feedback/ok schwarze
* delete old lint ARGSUSED commentsguenther2015-11-012-5/+2
|
* Avoid .Ns right after .Pf, it's pointless.schwarze2015-09-141-3/+3
| | | | In some cases, do additional cleanup in the immediate vicinity.
* Wrap <langinfo.h> and <regexp.h> so internal calls go direct andguenther2015-09-141-1/+2
| | | | the symbols are weak
* Reduce usage of predefined strings in manpages.bentley2015-02-281-6/+6
| | | | | | | | | | | Predefined strings are not very portable across troff implementations, and they make the source much harder to read. Usually the intended character can be written directly. No output changes, except for two instances where the incorrect escape was used in the first place. tweaks + ok schwarze@
* put back some information what the character classes actually mean;schwarze2014-12-091-2/+5
| | | | | | while here, remove the lie that regex(3) character classes would depend on the locale; ok jmc@
* no more ctype(3);jmc2014-12-091-7/+4
|
* reallocarray() -- a little tricky to reviewderaadt2014-10-181-3/+3
| | | | ok doug millert
* Userland reallocarray() audit.doug2014-10-111-2/+3
| | | | | | | Avoid potential integer overflow in the size argument of malloc() and realloc() by using reallocarray() to avoid unchecked multiplication. ok deraadt@
* use reallocarray(NULL, a, b) instead of malloc(a, b), which gives usderaadt2014-10-091-5/+5
| | | | | proper mult int overflow detection. The existing code already handles malloc failure properly, of course.
* zap trailing whitespace;jmc2014-09-101-3/+3
|
* document \<word\> as being non standardjsg2014-09-101-2/+8
| | | | | from Pedro F. Giffuni in FreeBSD pr 153257 ok millert@ tedu@
* add \<word\> support to regcomp. prompted by renewed interest from jsgtedu2014-09-081-2/+28
| | | | | | because such support is reportedly common and in somewhat wide use. undocumented for now because we don't endorse this. ok jsg millert
* reallocarray for things which are arrays. ok deraadttedu2014-05-061-8/+8
|
* Use consistent phrasing for bitmask flags.guenther2014-01-221-5/+6
| | | | tweaking and ok millert@ jmc@
* obvious .Pa fixes; found with mandocdb(8)schwarze2014-01-211-3/+3
|
* The print() routine here can be passed at least some of the non-charactersguenther2013-11-281-6/+17
| | | | | | | | | | OUT to EOW, making its domain CHAR_MIN...CODEMAX. It makes sense to have pchar() take the same domain and output those non-characters appropriately, so the (unsigned char) cast for isprint() goes in pchar(). Constipate pchar() while we're here, and let print() pass through NUL to it, as it knows how to output it unambiguously. ok otto@ millert@
* unsigned char cast for ctype; ok guentherderaadt2013-11-261-2/+2
|
* more library historyschwarze2013-07-171-4/+13
| | | | | facts checked by sobrado@ style tweaks and ok jmc@
* [[:>:]] anchors the character preceding it to end of word, not thejmc2013-06-051-3/+3
| | | | | | character following it; From: Peter Fraser
* Use the fancy .In macro for includes. From Jan Klemkow. ok jmc schwarzetedu2013-06-051-4/+4
|
* silence some warnings by adding prototypes, casts, and headers astedu2013-04-175-11/+14
| | | | appropriate. in regex, stop using the struct hack for a fixed size array