summaryrefslogtreecommitdiff
path: root/lib/libc/regex
Commit message (Collapse)AuthorAgeFilesLines
* Fix memory leak introduced with regcomp.c rev 1.14.Daniel C. Sobral2000-07-021-0/+6
| | | | Notes: svn path=/head/; revision=62417
* Enhance the optimization provided by pre-matching. Fix style bugs withDaniel C. Sobral2000-07-023-12/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | previous commits. At the time we search the pattern for the "must" string, we now compute the longest offset from the beginning of the pattern at which the must string might be found. If that offset is found to be infinite (through use of "+" or "*"), we set it to -1 to disable the heuristics applied later. After we are done with pre-matching, we use that offset and the point in the text at which the must string was found to compute the earliest point at which the pattern might be found. Special care should be taken here. The variable "start" is passed to the automata-processing functions fast() and slow() to indicate the point in the text at which they should start working from. The real beginning of the text is passed in a struct match variable m, which is used to check for anchors. That variable, though, is initialized with "start", so we must not adjust "start" before "m" is properly initialized. Simple tests showed a speed increase from 100% to 400%, but they were biased in that regexec() was called for the whole file instead of line by line, and parenthized subexpressions were not searched for. This change adds a single integer to the size of the "guts" structure, and does not change the ABI. Further improvements possible: Since the speed increase observed here is so huge, one intuitive optimization would be to introduce a bias in the function that computes the "must" string so as to prefer a smaller string with a finite offset over a larger one with an infinite offset. Tests have shown this to be a bad idea, though, as the cost of false pre-matches far outweights the benefits of a must offset, even in biased situations. A number of other improvements suggest themselves, though: * identify the cases where the pattern is identical to the must string, and avoid entering fast() and slow() in these cases. * compute the maximum offset from the must string to the end of the pattern, and use that to set the point at which fast() and slow() should give up trying to find a match, and return then return to pre-matching. * return all the way to pre-matching if a "match" was found and later invalidated by back reference processing. Since back references are evil and should be avoided anyway, this is of little use. Notes: svn path=/head/; revision=62391
* Remove from the notes a bug that it's said to have been fixed.Daniel C. Sobral2000-07-021-5/+0
| | | | | | | | | PR: 15561 Submitted by: Martin Kammerhofer <mkamm@gmx.net> Confirmed by: ache Notes: svn path=/head/; revision=62389
* Initialize variables used by the Boyer-Moore algorithm.Daniel C. Sobral2000-06-291-0/+2
| | | | | | | | | | This should fix core dumps when the must pattern is of length three or less. Bug found by: knu Notes: svn path=/head/; revision=62263
* Add Boyler-Moore algorithm to pre-matching test.Daniel C. Sobral2000-06-293-6/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BM algorithm works by scanning the pattern from right to left, and jumping as many characters as viable based on the text's mismatched character and the pattern's already matched suffix. This typically enable us to test only a fraction of the text's characters, but has a worse performance than the straight-forward method for small patterns. Because of this, the BM algorithm will only be used if the pattern size is at least 4 characters. Notice that this pre-matching is done on the largest substring of the regular expression that _must_ be present on the text for a succesful match to be possible at all. For instance, "(xyzzy|grues)" will yield a null "must" substring, and, therefore, not benefit from the BM algorithm at all. Because of the lack of intelligence of the algorithm that finds the "must" string, things like "charjump|matchjump" will also yield a null string. To optimize that, "(char|match)jump" should be used. The setup time (at regcomp()) for the BM algorithm will most likely outweight any benefits for one-time matches. Given the slow regex(3) we have, this is unlikely to be even perceptible, though. The size of a regex_t structure is increased by 2*sizeof(char*) + 256*sizeof(int) + strlen(must)*sizeof(int). This is all inside the regex_t's "guts", which is allocated dynamically by regcomp(). If allocation of either of the two tables fail, the other one is freed. In this case, the straight-forward algorithm is used for pre-matching. Tests exercising the code path affected have shown a speed increase of 50% for "must" strings of length four or five. API and ABI remain unchanged by this commit. The patch submitted on the PR was not used, as it was non-functional. PR: 14342 Notes: svn path=/head/; revision=62232
* $Id$ -> $FreeBSD$Peter Wemm1999-08-283-3/+3
| | | | Notes: svn path=/head/; revision=50476
* remove <ctype.h> - not neededAndrey A. Chernov1999-07-261-1/+0
| | | | Notes: svn path=/head/; revision=49099
* unsigned char cleanupAndrey A. Chernov1999-07-261-17/+17
| | | | | | | | | | fix wrong index from p_simp_re() PR: 8790 Submitted by: Alexander Viro <viro@math.psu.edu> (partially) Notes: svn path=/head/; revision=49094
* Add $Id$, to make it simpler for members of the translation teams toNik Clayton1999-07-122-0/+2
| | | | | | | | | | | | | | | | | | | | track. The $Id$ line is normally at the bottom of the main comment block in the man page, separated from the rest of the manpage by an empty comment, like so; .\" $Id$ .\" If the immediately preceding comment is a @(#) format ID marker than the the $Id$ will line up underneath it with no intervening blank lines. Otherwise, an additional blank line is inserted. Approved by: bde Notes: svn path=/head/; revision=48794
* Replace memory leaking instances of realloc with non-leaking reallocf.Warner Losh1998-09-161-4/+4
| | | | | | | | | | | | | | In some cases replace if (a == null) a = malloc(x); else a = realloc(a, x); with simple reallocf(a, x). Per ANSI-C, this is guaranteed to be the same thing. I've been running these on my system here w/o ill effects for some time. However, the CTM-express is at part 6 of 34 for the CAM changes, so I've not been able to do a build world with the CAM in the tree with these changes. Shouldn't impact anything, but... Notes: svn path=/head/; revision=39327
* int -> long changes that reduce the diffs with the NetBSD version toJohn Birrell1998-05-142-34/+34
| | | | | | | work in a 64-bit environment. Notes: svn path=/head/; revision=36043
* Note that '+' and '?' are not special characters in basic REs but theySteve Price1998-02-141-2/+5
| | | | | | | | | | can be simulated using bounds. PR: 5708 Submitted by: Oliver Fromme <oliver.fromme@heim3.tu-clausthal.de> Notes: svn path=/head/; revision=33352
* Removed the subdirectory paths from the definitions of MAN[1-9]. TheyBruce Evans1997-10-151-4/+3
| | | | | | | | were a workaround for limitations in bsd.man.mk that were fixed about 2 years ago. Notes: svn path=/head/; revision=30447
* Changed all paths to be relative to src/lib instead of src/lib/libcJohn Birrell1997-05-031-2/+6
| | | | | | | | | | | | | so that all these makefiles can be used to build libc_r too. Added .if ${LIB} == "c" tests to restrict man page builds to libc to avoid needlessly building them with libc_r too. Split libc Makefile into Makefile and Makefile.inc to allow the libc_r Makefile to include Makefile.inc too. Notes: svn path=/head/; revision=25401
* Speedup in case locale not usedAndrey A. Chernov1997-04-041-5/+11
| | | | Notes: svn path=/head/; revision=24637
* collate_range_cmp -> __collate_range_cmpAndrey A. Chernov1996-10-311-4/+5
| | | | Notes: svn path=/head/; revision=19277
* Correctly use .Fn instead of .Nm to reference function namesMike Pritchard1996-08-221-1/+3
| | | | | | | | | | | in a bunch of man pages. Use the correct .Bx (BSD UNIX) or .At (AT&T UNIX) macros instead of explicitly specifying the version in the text in a bunch of man pages. Notes: svn path=/head/; revision=17782
* Convert to newly aded collate compare functionAndrey A. Chernov1996-08-121-4/+4
| | | | Notes: svn path=/head/; revision=17552
* Remove static collcmp, use new internal function nowAndrey A. Chernov1996-08-121-37/+4
| | | | Notes: svn path=/head/; revision=17532
* Use collate data for national alpha character ranges like [a-z]Andrey A. Chernov1996-08-111-4/+45
| | | | Notes: svn path=/head/; revision=17514
* Short value is better for hash due to easy overflow in 8bit charactersAndrey A. Chernov1996-08-111-1/+1
| | | | Notes: svn path=/head/; revision=17509
* Use locale for character classes instead of hardcoded valuesAndrey A. Chernov1996-08-114-37/+89
| | | | | | | Misc 8bit cleanup Notes: svn path=/head/; revision=17508
* General -Wall warning cleanup, part I.Jordan K. Hubbard1996-07-125-165/+169
| | | | | | | Submitted-By: Kent Vander Velden <graphix@iastate.edu> Notes: svn path=/head/; revision=17141
* 8bit clean fixesAndrey A. Chernov1996-03-251-3/+5
| | | | Notes: svn path=/head/; revision=14815
* More cleanup.Poul-Henning Kamp1995-10-223-4/+1
| | | | | | | Uhm, I also forgot: I took "EXTRA_SANITY" out of malloc.c Notes: svn path=/head/; revision=11664
* Remove trailing whitespace.Rodney W. Grimes1995-05-302-2/+2
| | | | Notes: svn path=/head/; revision=8870
* First crack at making libc work with the new make macros. It compiles onGarrett Wollman1994-08-051-2/+2
| | | | | | | | my machine, and a simple static (genassym) and shared (sysctl) executable both work. Still to be done: RPCand YP merge. Notes: svn path=/head/; revision=1849
* BSD 4.4 Lite Lib SourcesRodney W. Grimes1994-05-2714-0/+4642
Notes: svn path=/cvs2svn/branches/unlabeled-1.1.1/; revision=1573