diff options
author | deraadt <> | 1995-10-18 08:42:23 +0000 |
---|---|---|
committer | deraadt <> | 1995-10-18 08:42:23 +0000 |
commit | 0527d29da443886d92e9a418180c5b25a5f8d270 (patch) | |
tree | 86b3a64928451a669cefa27900e5884036b4e349 /src/lib/libc/string/bm.3 | |
download | openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.tar.gz openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.tar.bz2 openbsd-0527d29da443886d92e9a418180c5b25a5f8d270.zip |
initial import of NetBSD tree
Diffstat (limited to 'src/lib/libc/string/bm.3')
-rw-r--r-- | src/lib/libc/string/bm.3 | 114 |
1 files changed, 114 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..2264a6a1c4 --- /dev/null +++ b/src/lib/libc/string/bm.3 | |||
@@ -0,0 +1,114 @@ | |||
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 | .\" from: @(#)bm.3 8.4 (Berkeley) 6/21/94 | ||
36 | .\" $Id: bm.3,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $ | ||
37 | .\" | ||
38 | .TH BM 3 | ||
39 | .SH NAME | ||
40 | bm_comp, bm_exec, bm_free \- Boyer-Moore string search | ||
41 | .SH SYNOPSIS | ||
42 | .ft B | ||
43 | #include <sys/types.h> | ||
44 | .br | ||
45 | #include <bm.h> | ||
46 | .sp | ||
47 | bm_pat * | ||
48 | .br | ||
49 | bm_comp(u_char *pattern, size_t patlen, u_char freq[256]); | ||
50 | .sp | ||
51 | u_char * | ||
52 | .br | ||
53 | bm_exec(bm_pat *pdesc, u_char *text, size_t len); | ||
54 | .sp | ||
55 | void | ||
56 | .br | ||
57 | bm_free(bm_pat *pdesc); | ||
58 | .SH DESCRIPTION | ||
59 | These routines implement an efficient mechanism to find an | ||
60 | occurrence of a byte string within another byte string. | ||
61 | .PP | ||
62 | .I Bm_comp | ||
63 | evaluates the | ||
64 | .I patlen | ||
65 | bytes starting at | ||
66 | .IR pattern , | ||
67 | and returns a pointer to a structure describing them. | ||
68 | The bytes referenced by | ||
69 | .I pattern | ||
70 | may be of any value. | ||
71 | .PP | ||
72 | The search takes advantage of the frequency distribution of the | ||
73 | bytes in the text to be searched. | ||
74 | If specified, | ||
75 | .I freq | ||
76 | should be an array of 256 values, | ||
77 | with higher values indicating that the corresponding character occurs | ||
78 | more frequently. | ||
79 | (A less than optimal frequency distribution can only result in less | ||
80 | than optimal performance, not incorrect results.) | ||
81 | If | ||
82 | .I freq | ||
83 | is NULL, | ||
84 | a system default table is used. | ||
85 | .PP | ||
86 | .I Bm_exec | ||
87 | returns a pointer to the leftmost occurrence of the string given to | ||
88 | .I bm_comp | ||
89 | within | ||
90 | .IR text , | ||
91 | or NULL if none occurs. | ||
92 | The number of bytes in | ||
93 | .I text | ||
94 | must be specified by | ||
95 | .IR len . | ||
96 | .PP | ||
97 | Space allocated for the returned description is discarded | ||
98 | by calling | ||
99 | .I bm_free | ||
100 | with the returned description as an argument. | ||
101 | .PP | ||
102 | The asymptotic speed of | ||
103 | .I bm_exec | ||
104 | is | ||
105 | .RI O( len / patlen ). | ||
106 | .PP | ||
107 | .SH "SEE ALSO" | ||
108 | .IR regexp (3), | ||
109 | .IR strstr (3) | ||
110 | .sp | ||
111 | .IR "Fast String Searching" , | ||
112 | Hume and Sunday, | ||
113 | Software Practice and Experience, | ||
114 | Vol. 21, 11 (November 1991) pp. 1221-48. | ||