Unit GnuRegex

# description // // Translated from GNU Regex 0.12 regex.h // // Author: // Ezio Vernacotola // River Software House S.r.l. // via degli Agricoltori, 57 // 00052 CIVITAVECCHIA (RM) // ITALY // email: ezio@etruria.net // // Date: 15 Sep 1996 // {# freeware} {# include 'regex.dll'

Classes

Functions

regcomp - POSIX compatibility.
regerror -
regexec -
regfree -
re_comp - 4.
re_compile_fastmap - Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches.
re_compile_pattern - Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER.
re_exec -
re_match - Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START.
re_match_2 - Relates to `re_match' as `re_search_2' relates to `re_search'.
re_search - Search in the string STRING (with length LENGTH) for the pattern compiled into BUFFER.
re_search_2 - Like `re_search', but search in the concatenation of STRING1 and STRING2.
re_set_registers -
re_set_syntax - Sets the current default syntax to SYNTAX, and return the old syntax.

Types

aregoff_t
paregoff_t
pregoff_t
regex_t
regmatch_t
regoff_t
reg_errcode_t
reg_syntax_t
re_pattern_buffer
re_registers

Constants

REG_EXTENDED
REG_ICASE
REG_NEWLINE
REG_NOSUB
REG_NOTBOL
REG_NOTEOL
RE_BACKSLASH_ESCAPE_IN_LISTS
RE_BK_PLUS_QM
RE_CHAR_CLASSES
RE_CONTEXT_INDEP_ANCHORS
RE_CONTEXT_INDEP_OPS
RE_CONTEXT_INVALID_OPS
RE_DOT_NEWLINE
RE_DOT_NOT_NULL
RE_HAT_LISTS_NOT_NEWLINE
RE_INTERVALS
RE_LIMITED_OPS
RE_NEWLINE_ALT
RE_NO_BK_BRACES
RE_NO_BK_PARENS
RE_NO_BK_REFS
RE_NO_BK_VBAR
RE_NO_EMPTY_RANGES
RE_NREGS
RE_SYNTAX_AWK
RE_SYNTAX_ED
RE_SYNTAX_EGREP
RE_SYNTAX_EMACS
RE_SYNTAX_GREP
RE_SYNTAX_POSIX_AWK
RE_SYNTAX_POSIX_BASIC
RE_SYNTAX_POSIX_EGREP
RE_SYNTAX_POSIX_EXTENDED
RE_SYNTAX_POSIX_MINIMAL_BASIC
RE_SYNTAX_POSIX_MINIMAL_EXTENDED
RE_SYNTAX_SED
RE_UNMATCHED_RIGHT_PAREN_ORD
_RE_SYNTAX_POSIX_COMMON

Variables


Functions


function regcomp(var preg : regex_t; const pattern : pchar; cflags : integer): integer;

POSIX compatibility.

function regerror(errcode : integer; const preg : regex_t; errbuf : pchar; errbuf_size : cardinal): integer;


function regexec(const preg : regex_t; const s : pchar; nmatch : cardinal; pmatch : array of regmatch_t; eflags : integer) : integer;


procedure regfree(var preg : regex_t );


function re_comp(const s: pchar) : pchar;

4.2 bsd compatibility.

function re_compile_fastmap(var buffer : re_pattern_buffer): integer;

Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error.

function re_compile_pattern(const pattern: pchar; length: integer; var buffer : re_pattern_buffer): pchar;

Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not.

function re_exec(const s: pchar) : integer;


function re_match(var buffer : re_pattern_buffer; const s : pchar; length, start : integer; var regs : re_registers) : integer;

Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START.

function re_match_2(var buffer : re_pattern_buffer; const string1 : pchar; length1 : integer; const string2: pchar; length2, start : integer; var regs : re_registers; stop : integer) : integer;

Relates to `re_match' as `re_search_2' relates to `re_search'.

function re_search(var buffer : re_pattern_buffer; const s: pchar; length, start, range : integer; var regs : re_registers) : integer;

Search in the string STRING (with length LENGTH) for the pattern compiled into BUFFER. Start searching at position START, for RANGE characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero).

function re_search_2(var buffer : re_pattern_buffer; const string1 : pchar; length1 : integer; const string2 : pchar; length2, start, range : integer ) : integer;

Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP.

procedure re_set_registers(var buffer : re_pattern_buffer; var regs : re_registers; num_regs : cardinal; var starts : regoff_t; var ends : regoff_t );


function re_set_syntax(syntax : reg_syntax_t) : reg_syntax_t;

Sets the current default syntax to SYNTAX, and return the old syntax.

Types


aregoff_t = array[0..0] of regoff_t;

paregoff_t = ^aregoff_t

pregoff_t = ^regoff_t

regex_t = re_pattern_buffer 

regmatch_t = record
rm_so : regoff_t;
rm_eo : regoff_t ;
end;
POSIX specification for registers. Aside from the different names than `re_registers', POSIX uses an array of structures, instead of a structure of arrays. */
regoff_t = integer

reg_errcode_t = (
    REG_NOERROR,	  // Success.
    REG_NOMATCH,	  // Didn't find a match (for regexec).

    // POSIX regcomp return error codes.  In the order listed in the
    //   standard.
    REG_BADPAT,		  // Invalid pattern.
    REG_ECOLLATE,	  // Not implemented.
    REG_ECTYPE,		  // Invalid character class name.
    REG_EESCAPE,	  // Trailing backslash.
    REG_ESUBREG,	  // Invalid back reference.
    REG_EBRACK,		  // Unmatched left bracket.
    REG_EPAREN,		  // Parenthesis imbalance.
    REG_EBRACE,		  // Unmatched \//.
    REG_BADBR,		  // Invalid contents of \//\
    REG_ERANGE,		  // Invalid range end.
    REG_ESPACE,		  // Ran out of memory.
    REG_BADRPT,		  // No preceding re for repetition op.

    // Error codes we've added.
    REG_EEND,		  // Premature end.
    REG_ESIZE,		  // Compiled pattern bigger than 2^16 bytes.
    REG_ERPAREN		  // Unmatched ) or \); not returned from regcomp.
  );

reg_syntax_t = cardinal

re_pattern_buffer = record
buffer : pchar;
allocated : cardinal;
used : cardinal;
syntax : reg_syntax_t ;
fastmap : pchar;
translate : pchar;
re_nsub : cardinal;
flags : byte;
end;
Unmatched ) or \); not returned from regcomp.
re_registers = record
num_regs : cardinal;
start : paregoff_t;
endr : paregoff_t;
end;

Constants

REG_EXTENDED = 1

POSIX `cflags' bits (i.e., information for `regcomp').

REG_ICASE = (REG_EXTENDED shl 1)

REG_NEWLINE = (REG_ICASE shl 1)

REG_NOSUB = (REG_NEWLINE shl 1)

REG_NOTBOL = 1

POSIX `eflags' bits (i.e., information for regexec).

REG_NOTEOL = (1 shl 1)

RE_BACKSLASH_ESCAPE_IN_LISTS = 1

RE_BK_PLUS_QM = (RE_BACKSLASH_ESCAPE_IN_LISTS shl 1)

RE_CHAR_CLASSES = (RE_BK_PLUS_QM shl 1)

RE_CONTEXT_INDEP_ANCHORS = (RE_CHAR_CLASSES shl 1)

RE_CONTEXT_INDEP_OPS = (RE_CONTEXT_INDEP_ANCHORS shl 1)

RE_CONTEXT_INVALID_OPS = (RE_CONTEXT_INDEP_OPS shl 1)

RE_DOT_NEWLINE = (RE_CONTEXT_INVALID_OPS shl 1)

RE_DOT_NOT_NULL = (RE_DOT_NEWLINE shl 1)

RE_HAT_LISTS_NOT_NEWLINE = (RE_DOT_NOT_NULL shl 1)

RE_INTERVALS = (RE_HAT_LISTS_NOT_NEWLINE shl 1)

RE_LIMITED_OPS = (RE_INTERVALS shl 1)

RE_NEWLINE_ALT = (RE_LIMITED_OPS shl 1)

RE_NO_BK_BRACES = (RE_NEWLINE_ALT shl 1)

RE_NO_BK_PARENS = (RE_NO_BK_BRACES shl 1)

RE_NO_BK_REFS = (RE_NO_BK_PARENS shl 1)

RE_NO_BK_VBAR = (RE_NO_BK_REFS shl 1)

RE_NO_EMPTY_RANGES = (RE_NO_BK_VBAR shl 1)

RE_NREGS = 30

RE_SYNTAX_AWK = (RE_BACKSLASH_ESCAPE_IN_LISTS or RE_DOT_NOT_NULL or RE_NO_BK_PARENS or RE_NO_BK_REFS or RE_NO_BK_VBAR or RE_NO_EMPTY_RANGES or RE_UNMATCHED_RIGHT_PAREN_ORD)

RE_SYNTAX_ED = RE_SYNTAX_POSIX_BASIC

RE_SYNTAX_EGREP = (RE_CHAR_CLASSES or RE_CONTEXT_INDEP_ANCHORS or RE_CONTEXT_INDEP_OPS or RE_HAT_LISTS_NOT_NEWLINE or RE_NEWLINE_ALT or RE_NO_BK_PARENS or RE_NO_BK_VBAR)

RE_SYNTAX_EMACS = 0

RE_SYNTAX_GREP = (RE_BK_PLUS_QM or RE_CHAR_CLASSES or RE_HAT_LISTS_NOT_NEWLINE or RE_INTERVALS or RE_NEWLINE_ALT)

RE_SYNTAX_POSIX_AWK = (RE_SYNTAX_POSIX_EXTENDED or RE_BACKSLASH_ESCAPE_IN_LISTS)

RE_SYNTAX_POSIX_BASIC = (_RE_SYNTAX_POSIX_COMMON or RE_BK_PLUS_QM)

RE_SYNTAX_POSIX_EGREP = (RE_SYNTAX_EGREP or RE_INTERVALS or RE_NO_BK_BRACES)

RE_SYNTAX_POSIX_EXTENDED = (_RE_SYNTAX_POSIX_COMMON or RE_CONTEXT_INDEP_ANCHORS or RE_CONTEXT_INDEP_OPS or RE_NO_BK_BRACES or RE_NO_BK_PARENS or RE_NO_BK_VBAR or RE_UNMATCHED_RIGHT_PAREN_ORD)

RE_SYNTAX_POSIX_MINIMAL_BASIC = (_RE_SYNTAX_POSIX_COMMON or RE_LIMITED_OPS)

RE_SYNTAX_POSIX_MINIMAL_EXTENDED = (_RE_SYNTAX_POSIX_COMMON or RE_CONTEXT_INDEP_ANCHORS or RE_CONTEXT_INVALID_OPS or RE_NO_BK_BRACES or RE_NO_BK_PARENS or RE_NO_BK_REFS or RE_NO_BK_VBAR or RE_UNMATCHED_RIGHT_PAREN_ORD)

RE_SYNTAX_SED = RE_SYNTAX_POSIX_BASIC

RE_UNMATCHED_RIGHT_PAREN_ORD = (RE_NO_EMPTY_RANGES shl 1)

_RE_SYNTAX_POSIX_COMMON = (RE_CHAR_CLASSES or RE_DOT_NEWLINE or RE_DOT_NOT_NULL or RE_INTERVALS or RE_NO_EMPTY_RANGES)


Variables