regex.h (25839) | regex.h (66525) |
---|---|
1/* Definitions for data structures and routines for the regular 2 expression library, version 0.12. 3 | 1/* Definitions for data structures and routines for the regular 2 expression library, version 0.12. 3 |
4 Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. | 4 Copyright (C) 1985, 89, 90, 91, 92, 93, 95 Free Software Foundation, Inc. |
5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. */ | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19 USA. */ 20 |
|
16#ifndef __REGEXP_LIBRARY_H__ 17#define __REGEXP_LIBRARY_H__ 18 19/* POSIX says that <sys/types.h> must be included (by the caller) before 20 <regex.h>. */ 21 | 21#ifndef __REGEXP_LIBRARY_H__ 22#define __REGEXP_LIBRARY_H__ 23 24/* POSIX says that <sys/types.h> must be included (by the caller) before 25 <regex.h>. */ 26 |
22#ifdef VMS | 27#if !defined (_POSIX_C_SOURCE) && !defined (_POSIX_SOURCE) && defined (VMS) |
23/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it 24 should be there. */ 25#include <stddef.h> 26#endif 27 28 29/* The following bits are used to determine the regexp syntax we 30 recognize. The set/not-set meanings are chosen so that Emacs syntax --- 90 unchanged lines hidden (view full) --- 121 If not set, then when ending range point collates higher than the 122 starting range point, the range is ignored. */ 123#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) 124 125/* If this bit is set, then an unmatched ) is ordinary. 126 If not set, then an unmatched ) is invalid. */ 127#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) 128 | 28/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it 29 should be there. */ 30#include <stddef.h> 31#endif 32 33 34/* The following bits are used to determine the regexp syntax we 35 recognize. The set/not-set meanings are chosen so that Emacs syntax --- 90 unchanged lines hidden (view full) --- 126 If not set, then when ending range point collates higher than the 127 starting range point, the range is ignored. */ 128#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) 129 130/* If this bit is set, then an unmatched ) is ordinary. 131 If not set, then an unmatched ) is invalid. */ 132#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) 133 |
134/* If this bit is set, succeed as soon as we match the whole pattern, 135 without further backtracking. */ 136#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) 137 |
|
129/* This global variable defines the particular regexp syntax to use (for 130 some interfaces). When a regexp is compiled, the syntax used is 131 stored in the pattern buffer, so changing this does not affect 132 already-compiled regexps. */ 133extern reg_syntax_t re_syntax_options; | 138/* This global variable defines the particular regexp syntax to use (for 139 some interfaces). When a regexp is compiled, the syntax used is 140 stored in the pattern buffer, so changing this does not affect 141 already-compiled regexps. */ 142extern reg_syntax_t re_syntax_options; |
143 144#ifdef emacs 145/* In Emacs, this is the string or buffer in which we 146 are matching. It is used for looking up syntax properties. */ 147extern Lisp_Object re_match_object; 148#endif 149 |
|
134 135/* Define combinations of the above bits for the standard possibilities. 136 (The [[[ comments delimit what gets put into the Texinfo file, so 137 don't delete them!) */ 138/* [[[begin syntaxes]]] */ 139#define RE_SYNTAX_EMACS 0 140 141#define RE_SYNTAX_AWK \ --- 124 unchanged lines hidden (view full) --- 266} reg_errcode_t; 267 268/* This data structure represents a compiled pattern. Before calling 269 the pattern compiler, the fields `buffer', `allocated', `fastmap', 270 `translate', and `no_sub' can be set. After the pattern has been 271 compiled, the `re_nsub' field is available. All other fields are 272 private to the regex routines. */ 273 | 150 151/* Define combinations of the above bits for the standard possibilities. 152 (The [[[ comments delimit what gets put into the Texinfo file, so 153 don't delete them!) */ 154/* [[[begin syntaxes]]] */ 155#define RE_SYNTAX_EMACS 0 156 157#define RE_SYNTAX_AWK \ --- 124 unchanged lines hidden (view full) --- 282} reg_errcode_t; 283 284/* This data structure represents a compiled pattern. Before calling 285 the pattern compiler, the fields `buffer', `allocated', `fastmap', 286 `translate', and `no_sub' can be set. After the pattern has been 287 compiled, the `re_nsub' field is available. All other fields are 288 private to the regex routines. */ 289 |
290#ifndef RE_TRANSLATE_TYPE 291#define RE_TRANSLATE_TYPE char * 292#define RE_TRANSLATE(TBL, C) ((TBL)[C]) 293#define RE_TRANSLATE_P(TBL) (TBL) 294#endif 295 |
|
274struct re_pattern_buffer 275{ 276/* [[[begin pattern_buffer]]] */ 277 /* Space that holds the compiled pattern. It is declared as 278 `unsigned char *' because its elements are 279 sometimes used as array indexes. */ 280 unsigned char *buffer; 281 --- 10 unchanged lines hidden (view full) --- 292 the fastmap, if there is one, to skip over impossible 293 starting points for matches. */ 294 char *fastmap; 295 296 /* Either a translate table to apply to all characters before 297 comparing them, or zero for no translation. The translation 298 is applied to a pattern when it is compiled and to a string 299 when it is matched. */ | 296struct re_pattern_buffer 297{ 298/* [[[begin pattern_buffer]]] */ 299 /* Space that holds the compiled pattern. It is declared as 300 `unsigned char *' because its elements are 301 sometimes used as array indexes. */ 302 unsigned char *buffer; 303 --- 10 unchanged lines hidden (view full) --- 314 the fastmap, if there is one, to skip over impossible 315 starting points for matches. */ 316 char *fastmap; 317 318 /* Either a translate table to apply to all characters before 319 comparing them, or zero for no translation. The translation 320 is applied to a pattern when it is compiled and to a string 321 when it is matched. */ |
300 char *translate; | 322 RE_TRANSLATE_TYPE translate; |
301 302 /* Number of subexpressions found by the compiler. */ 303 size_t re_nsub; 304 305 /* Zero if this pattern cannot match the empty string, one else. 306 Well, in truth it's used only in `re_search_2', to see 307 whether or not we should use the fastmap, so we don't set 308 this absolutely perfectly; see `re_compile_fastmap' (the --- 22 unchanged lines hidden (view full) --- 331 unsigned not_bol : 1; 332 333 /* Similarly for an end-of-line anchor. */ 334 unsigned not_eol : 1; 335 336 /* If true, an anchor at a newline matches. */ 337 unsigned newline_anchor : 1; 338 | 323 324 /* Number of subexpressions found by the compiler. */ 325 size_t re_nsub; 326 327 /* Zero if this pattern cannot match the empty string, one else. 328 Well, in truth it's used only in `re_search_2', to see 329 whether or not we should use the fastmap, so we don't set 330 this absolutely perfectly; see `re_compile_fastmap' (the --- 22 unchanged lines hidden (view full) --- 353 unsigned not_bol : 1; 354 355 /* Similarly for an end-of-line anchor. */ 356 unsigned not_eol : 1; 357 358 /* If true, an anchor at a newline matches. */ 359 unsigned newline_anchor : 1; 360 |
361 /* If true, multi-byte form in the `buffer' should be recognized as a 362 multibyte character. */ 363 unsigned multibyte : 1; 364 |
|
339/* [[[end pattern_buffer]]] */ 340}; 341 342typedef struct re_pattern_buffer regex_t; | 365/* [[[end pattern_buffer]]] */ 366}; 367 368typedef struct re_pattern_buffer regex_t; |
343 344 345/* search.c (search_buffer) in Emacs needs this one opcode value. It is 346 defined both in `regex.c' and here. */ 347#define RE_EXACTN_VALUE 1 | |
348 349/* Type for byte offsets within the string. POSIX mandates this. */ 350typedef int regoff_t; 351 352 353/* This is the structure we store register match data in. See 354 regex.texinfo for a full description of what registers match. */ 355struct re_registers --- 100 unchanged lines hidden (view full) --- 456 457 Unless this function is called, the first search or match using 458 PATTERN_BUFFER will allocate its own register data, without 459 freeing the old data. */ 460extern void re_set_registers 461 _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, 462 unsigned num_regs, regoff_t *starts, regoff_t *ends)); 463 | 369 370/* Type for byte offsets within the string. POSIX mandates this. */ 371typedef int regoff_t; 372 373 374/* This is the structure we store register match data in. See 375 regex.texinfo for a full description of what registers match. */ 376struct re_registers --- 100 unchanged lines hidden (view full) --- 477 478 Unless this function is called, the first search or match using 479 PATTERN_BUFFER will allocate its own register data, without 480 freeing the old data. */ 481extern void re_set_registers 482 _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, 483 unsigned num_regs, regoff_t *starts, regoff_t *ends)); 484 |
464/* 4.2 bsd compatibility. System headers may declare the argument as 465 either "char *" (e.g. Cray unistd.h) or "const char *" (e.g. linux 466 regex.h), so don't prototype them here. */ 467extern char *re_comp (); 468extern int re_exec (); | 485#ifdef _REGEX_RE_COMP 486/* 4.2 bsd compatibility. */ 487/* CVS: don't use prototypes: they may conflict with system headers. */ 488extern char *re_comp _RE_ARGS (()); 489extern int re_exec _RE_ARGS (()); 490#endif |
469 470/* POSIX compatibility. */ 471extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags)); 472extern int regexec 473 _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch, 474 regmatch_t pmatch[], int eflags)); 475extern size_t regerror 476 _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf, --- 12 unchanged lines hidden --- | 491 492/* POSIX compatibility. */ 493extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags)); 494extern int regexec 495 _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch, 496 regmatch_t pmatch[], int eflags)); 497extern size_t regerror 498 _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf, --- 12 unchanged lines hidden --- |