1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-22 11:17:19 +00:00
freebsd/usr.bin/grep/regex/fastmatch.h
Gabor Kovesdan f20f6f3fdf Update BSD grep to the latest development version. It has some code
backported that was written for the TRE integration project in Google
Summer of Code 2011.  This is a temporary solution until the whole
regex library is not replaced so that BSD grep development can continue
and the backported code gets some review and testing.  This change only
improves scalability slightly, there is no big performance boost yet
but several minor bugs have been found and fixed.

Approved by:	delphij (mentor)
Sposored by:	Google Summer of Code 2011
MFC after:	1 week
2011-10-05 09:56:43 +00:00

109 lines
2.7 KiB
C

/* $FreeBSD$ */
#ifndef FASTMATCH_H
#define FASTMATCH_H 1
#include <limits.h>
#include <regex.h>
#include <stdbool.h>
#include <wchar.h>
typedef struct {
size_t wlen;
size_t len;
wchar_t *wpattern;
bool *wescmap;
unsigned int qsBc[UCHAR_MAX + 1];
unsigned int *bmGs;
char *pattern;
bool *escmap;
unsigned int defBc;
void *qsBc_table;
unsigned int *sbmGs;
const char *re_endp;
/* flags */
bool hasdot;
bool bol;
bool eol;
bool word;
bool icase;
bool newline;
bool nosub;
bool matchall;
bool reversed;
} fastmatch_t;
extern int
tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags);
extern int
tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags);
extern int
tre_fastexec(const fastmatch_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags);
extern void
tre_fastfree(fastmatch_t *preg);
extern int
tre_fixwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags);
extern int
tre_fastwcomp(fastmatch_t *preg, const wchar_t *regex, int cflags);
extern int
tre_fastwexec(const fastmatch_t *preg, const wchar_t *string,
size_t nmatch, regmatch_t pmatch[], int eflags);
/* Versions with a maximum length argument and therefore the capability to
handle null characters in the middle of the strings. */
extern int
tre_fixncomp(fastmatch_t *preg, const char *regex, size_t len, int cflags);
extern int
tre_fastncomp(fastmatch_t *preg, const char *regex, size_t len, int cflags);
extern int
tre_fastnexec(const fastmatch_t *preg, const char *string, size_t len,
size_t nmatch, regmatch_t pmatch[], int eflags);
extern int
tre_fixwncomp(fastmatch_t *preg, const wchar_t *regex, size_t len, int cflags);
extern int
tre_fastwncomp(fastmatch_t *preg, const wchar_t *regex, size_t len, int cflags);
extern int
tre_fastwnexec(const fastmatch_t *preg, const wchar_t *string, size_t len,
size_t nmatch, regmatch_t pmatch[], int eflags);
#define fixncomp tre_fixncomp
#define fastncomp tre_fastncomp
#define fixcomp tre_fixcomp
#define fastcomp tre_fastcomp
#define fixwncomp tre_fixwncomp
#define fastwncomp tre_fastwncomp
#define fixwcomp tre_fixwcomp
#define fastwcomp tre_fastwcomp
#define fastfree tre_fastfree
#define fastnexec tre_fastnexec
#define fastexec tre_fastexec
#define fastwnexec tre_fastwnexec
#define fastwexec tre_fastwexec
#define fixcomp tre_fixcomp
#define fastcomp tre_fastcomp
#define fastexec tre_fastexec
#define fastfree tre_fastfree
#define fixwcomp tre_fixwcomp
#define fastwcomp tre_fastwcomp
#define fastwexec tre_fastwexec
#define fixncomp tre_fixncomp
#define fastncomp tre_fastncomp
#define fastnexec tre_fastnexec
#define fixwncomp tre_fixwncomp
#define fastwncomp tre_fastwncomp
#define fastwnexec tre_fastwnexec
#endif /* FASTMATCH_H */