man.bsd.lv manual page server

Manual Page Search Parameters

BM(3) Library Functions Manual BM(3)

bm_comp, bm_exec, bm_freeBoyer-Moore string search

library “libc”

#include <sys/types.h>
#include <bm.h>

bm_pat *
bm_comp(unsigned char *pattern, size_t patlen, unsigned char freq[256]);

unsigned char *
bm_exec(bm_pat *pdesc, unsigned char *text, size_t len);

void
bm_free(bm_pat *pdesc);

These routines implement an efficient mechanism to find an occurrence of a byte string within another byte string.

() evaluates the patlen bytes starting at pattern, and returns a pointer to a structure describing them. The bytes referenced by pattern may be of any value.

The search takes advantage of the frequency distribution of the bytes in the text to be searched. If specified, freq should be an array of 256 values, with higher values indicating that the corresponding character occurs more frequently. (A less than optimal frequency distribution can only result in less than optimal performance, not incorrect results.) If freq is NULL, a system default table is used.

() returns a pointer to the leftmost occurrence of the string given to bm_comp() within text, or NULL if none occurs. The number of bytes in text must be specified by len.

Space allocated for the returned description is discarded by calling () with the returned description as an argument.

The asymptotic speed of () is O(len/patlen).

regexp(3), strstr(3)

Hume and Sunday, Fast String Searching, Software Practice and Experience, Vol. 21, 11, pp. 1221-48, November 1991.

April 8, 2001 NetBSD-9.2