/* Definitions for data structures callers pass the regex library. Copyright (C) 1985, 1989-90 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Multi-byte extension added May, 1993 by t^2 (Takahiro Tanimoto) Last change: May 21, 1993 by t^2 */ /* modifis for Ruby by matz@caelum.co.jp */ #ifndef __REGEXP_LIBRARY #define __REGEXP_LIBRARY /* Define number of parens for which we record the beginnings and ends. This affects how much space the `struct re_registers' type takes up. */ #ifndef RE_NREGS #define RE_NREGS 10 #endif #define BYTEWIDTH 8 #define RE_REG_MAX ((1<= 0x80) \ : (re_syntax_options & RE_MBCTYPE_SJIS \ ? (( 0x80 <= (unsigned char) (c) \ && (unsigned char) (c) <= 0x9f) \ || (0xe0 <= (unsigned char) (c))) \ : 0)) /* This data structure is used to represent a compiled pattern. */ struct re_pattern_buffer { char *buffer; /* Space holding the compiled pattern commands. */ long allocated; /* Size of space that `buffer' points to. */ long used; /* Length of portion of buffer actually occupied */ char *fastmap; /* Pointer to fastmap, if any, or zero if none. */ /* re_search uses the fastmap, if there is one, to skip over totally implausible characters. */ char *translate; /* Translate table to apply to all characters before comparing, or zero for no translation. The translation is applied to a pattern when it is compiled and to data when it is matched. */ char *must; /* Pointer to exact pattern which strings should have to be matched. */ long re_nsub; /* Number of subexpressions found by the compiler. */ char fastmap_accurate; /* Set to zero when a new pattern is stored, set to one when the fastmap is updated from it. */ char can_be_null; /* Set to one by compiling fastmap if this pattern might match the null string. It does not necessarily match the null string in that case, but if this is zero, it cannot. 2 as value means can match null string but at end of range or before a character listed in the fastmap. */ }; /* search.c (search_buffer) needs this one value. It is defined both in regex.c and here. */ #define RE_EXACTN_VALUE 1 /* Structure to store register contents data in. Pass the address of such a structure as an argument to re_match, etc., if you want this information back. For i from 1 to RE_NREGS - 1, start[i] records the starting index in the string of where the ith subexpression matched, and end[i] records one after the ending index. start[0] and end[0] are analogous, for the entire pattern. */ struct re_registers { unsigned allocated; unsigned num_regs; int *beg; int *end; }; #ifdef NeXT #define re_match rre_match #endif #ifdef __STDC__ extern char *re_compile_pattern (char *, size_t, struct re_pattern_buffer *); /* Is this really advertised? */ extern void re_compile_fastmap (struct re_pattern_buffer *); extern int re_search (struct re_pattern_buffer *, char*, int, int, int, struct re_registers *); extern int re_match (struct re_pattern_buffer *, char *, int, int, struct re_registers *); extern long re_set_syntax (long syntax); extern void re_copy_registers (struct re_registers*, struct re_registers*); #ifndef RUBY /* 4.2 bsd compatibility. */ extern char *re_comp (char *); extern int re_exec (char *); #endif #else /* !__STDC__ */ extern char *re_compile_pattern (); /* Is this really advertised? */ extern void re_compile_fastmap (); extern int re_search (); extern int re_match (); extern long re_set_syntax(); extern void re_copy_registers (); extern void re_free_registers (); #endif /* __STDC__ */ #ifdef SYNTAX_TABLE extern char *re_syntax_table; #endif #endif /* !__REGEXP_LIBRARY */