diff options
| author | cvs2svn <admin@example.com> | 1998-10-19 21:47:12 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 1998-10-19 21:47:12 +0000 |
| commit | 5170039cf1df2194faa85741f0733977525cd5c0 (patch) | |
| tree | c667406046ddb1efca5ed4316b02e43494241660 /src/lib/libc/string/bm.3 | |
| parent | 536c76cbb863bab152f19842ab88772c01e922c7 (diff) | |
| download | openbsd-OPENBSD_2_4_BASE.tar.gz openbsd-OPENBSD_2_4_BASE.tar.bz2 openbsd-OPENBSD_2_4_BASE.zip | |
This commit was manufactured by cvs2git to create tag 'OPENBSD_2_4_BASE'.OPENBSD_2_4_BASE
Diffstat (limited to 'src/lib/libc/string/bm.3')
| -rw-r--r-- | src/lib/libc/string/bm.3 | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/src/lib/libc/string/bm.3 b/src/lib/libc/string/bm.3 new file mode 100644 index 0000000000..c942930163 --- /dev/null +++ b/src/lib/libc/string/bm.3 | |||
| @@ -0,0 +1,113 @@ | |||
| 1 | .\" Copyright (c) 1994 | ||
| 2 | .\" The Regents of the University of California. All rights reserved. | ||
| 3 | .\" | ||
| 4 | .\" This code is derived from software contributed to Berkeley by | ||
| 5 | .\" Andrew Hume of AT&T Bell Laboratories. | ||
| 6 | .\" | ||
| 7 | .\" Redistribution and use in source and binary forms, with or without | ||
| 8 | .\" modification, are permitted provided that the following conditions | ||
| 9 | .\" are met: | ||
| 10 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 11 | .\" notice, this list of conditions and the following disclaimer. | ||
| 12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 14 | .\" documentation and/or other materials provided with the distribution. | ||
| 15 | .\" 3. All advertising materials mentioning features or use of this software | ||
| 16 | .\" must display the following acknowledgement: | ||
| 17 | .\" This product includes software developed by the University of | ||
| 18 | .\" California, Berkeley and its contributors. | ||
| 19 | .\" 4. Neither the name of the University nor the names of its contributors | ||
| 20 | .\" may be used to endorse or promote products derived from this software | ||
| 21 | .\" without specific prior written permission. | ||
| 22 | .\" | ||
| 23 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
| 24 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 25 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 26 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 27 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 28 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 29 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 30 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 31 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 32 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 33 | .\" SUCH DAMAGE. | ||
| 34 | .\" | ||
| 35 | .\" $OpenBSD: bm.3,v 1.2 1996/08/19 08:33:58 tholo Exp $ | ||
| 36 | .\" | ||
| 37 | .TH BM 3 | ||
| 38 | .SH NAME | ||
| 39 | bm_comp, bm_exec, bm_free \- Boyer-Moore string search | ||
| 40 | .SH SYNOPSIS | ||
| 41 | .ft B | ||
| 42 | #include <sys/types.h> | ||
| 43 | .br | ||
| 44 | #include <bm.h> | ||
| 45 | .sp | ||
| 46 | bm_pat * | ||
| 47 | .br | ||
| 48 | bm_comp(u_char *pattern, size_t patlen, u_char freq[256]); | ||
| 49 | .sp | ||
| 50 | u_char * | ||
| 51 | .br | ||
| 52 | bm_exec(bm_pat *pdesc, u_char *text, size_t len); | ||
| 53 | .sp | ||
| 54 | void | ||
| 55 | .br | ||
| 56 | bm_free(bm_pat *pdesc); | ||
| 57 | .SH DESCRIPTION | ||
| 58 | These routines implement an efficient mechanism to find an | ||
| 59 | occurrence of a byte string within another byte string. | ||
| 60 | .PP | ||
| 61 | .I Bm_comp | ||
| 62 | evaluates the | ||
| 63 | .I patlen | ||
| 64 | bytes starting at | ||
| 65 | .IR pattern , | ||
| 66 | and returns a pointer to a structure describing them. | ||
| 67 | The bytes referenced by | ||
| 68 | .I pattern | ||
| 69 | may be of any value. | ||
| 70 | .PP | ||
| 71 | The search takes advantage of the frequency distribution of the | ||
| 72 | bytes in the text to be searched. | ||
| 73 | If specified, | ||
| 74 | .I freq | ||
| 75 | should be an array of 256 values, | ||
| 76 | with higher values indicating that the corresponding character occurs | ||
| 77 | more frequently. | ||
| 78 | (A less than optimal frequency distribution can only result in less | ||
| 79 | than optimal performance, not incorrect results.) | ||
| 80 | If | ||
| 81 | .I freq | ||
| 82 | is NULL, | ||
| 83 | a system default table is used. | ||
| 84 | .PP | ||
| 85 | .I Bm_exec | ||
| 86 | returns a pointer to the leftmost occurrence of the string given to | ||
| 87 | .I bm_comp | ||
| 88 | within | ||
| 89 | .IR text , | ||
| 90 | or NULL if none occurs. | ||
| 91 | The number of bytes in | ||
| 92 | .I text | ||
| 93 | must be specified by | ||
| 94 | .IR len . | ||
| 95 | .PP | ||
| 96 | Space allocated for the returned description is discarded | ||
| 97 | by calling | ||
| 98 | .I bm_free | ||
| 99 | with the returned description as an argument. | ||
| 100 | .PP | ||
| 101 | The asymptotic speed of | ||
| 102 | .I bm_exec | ||
| 103 | is | ||
| 104 | .RI O( len / patlen ). | ||
| 105 | .PP | ||
| 106 | .SH "SEE ALSO" | ||
| 107 | .IR regexp (3), | ||
| 108 | .IR strstr (3) | ||
| 109 | .sp | ||
| 110 | .IR "Fast String Searching" , | ||
| 111 | Hume and Sunday, | ||
| 112 | Software Practice and Experience, | ||
| 113 | Vol. 21, 11 (November 1991) pp. 1221-48. | ||
