17
17
You should have received a copy of the GNU General Public License along
18
18
with this program; if not, write to the Free Software Foundation,
19
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
435
435
/* Declarations for routines. */
437
/* To avoid duplicating every routine declaration -- once with a
438
prototype (if we are ANSI), and once without (if we aren't) -- we
439
use the following macro to declare argument types. This
440
unfortunately clutters up the declarations a bit, but I think it's
445
# define _RE_ARGS(args) args
447
#else /* not __STDC__ */
449
# define _RE_ARGS(args) ()
451
#endif /* not __STDC__ */
453
437
/* Sets the current default syntax to SYNTAX, and return the old syntax.
454
438
You can also simply assign to the `re_syntax_options' variable. */
455
extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
439
extern reg_syntax_t re_set_syntax (reg_syntax_t syntax);
457
441
/* Compile the regular expression PATTERN, with length LENGTH
458
442
and syntax given by the global `re_syntax_options', into the buffer
459
443
BUFFER. Return NULL if successful, and an error string if not. */
460
extern const char *re_compile_pattern
461
_RE_ARGS ((const char *pattern, size_t length,
462
struct re_pattern_buffer *buffer));
444
extern const char *re_compile_pattern (const char *pattern, size_t length,
445
struct re_pattern_buffer *buffer);
465
448
/* Compile a fastmap for the compiled pattern in BUFFER; used to
466
449
accelerate searches. Return 0 if successful and -2 if was an
467
450
internal error. */
468
extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
451
extern int re_compile_fastmap (struct re_pattern_buffer *buffer);
471
454
/* Search in the string STRING (with length LENGTH) for the pattern
473
456
characters. Return the starting position of the match, -1 for no
474
457
match, or -2 for an internal error. Also return register
475
458
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
477
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
478
int length, int start, int range, struct re_registers *regs));
459
extern int re_search (struct re_pattern_buffer *buffer, const char *string,
460
int length, int start, int range,
461
struct re_registers *regs);
481
464
/* Like `re_search', but search in the concatenation of STRING1 and
482
465
STRING2. Also, stop searching at index START + STOP. */
483
extern int re_search_2
484
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
485
int length1, const char *string2, int length2,
486
int start, int range, struct re_registers *regs, int stop));
466
extern int re_search_2 (struct re_pattern_buffer *buffer, const char *string1,
467
int length1, const char *string2, int length2,
468
int start, int range, struct re_registers *regs,
489
472
/* Like `re_search', but return how many characters in STRING the regexp
490
473
in BUFFER matched, starting at position START. */
492
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
493
int length, int start, struct re_registers *regs));
474
extern int re_match (struct re_pattern_buffer *buffer, const char *string,
475
int length, int start, struct re_registers *regs);
496
478
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
497
extern int re_match_2
498
_RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
499
int length1, const char *string2, int length2,
500
int start, struct re_registers *regs, int stop));
479
extern int re_match_2 (struct re_pattern_buffer *buffer, const char *string1,
480
int length1, const char *string2, int length2,
481
int start, struct re_registers *regs, int stop);
503
484
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
512
493
Unless this function is called, the first search or match using
513
494
PATTERN_BUFFER will allocate its own register data, without
514
495
freeing the old data. */
515
extern void re_set_registers
516
_RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
517
unsigned num_regs, regoff_t *starts, regoff_t *ends));
496
extern void re_set_registers (struct re_pattern_buffer *buffer,
497
struct re_registers *regs, unsigned num_regs,
498
regoff_t *starts, regoff_t *ends);
519
500
#if defined _REGEX_RE_COMP || defined _LIBC
521
502
/* 4.2 bsd compatibility. */
522
extern char *re_comp _RE_ARGS ((const char *));
523
extern int re_exec _RE_ARGS ((const char *));
503
extern char *re_comp (const char *);
504
extern int re_exec (const char *);
547
528
/* POSIX compatibility. */
548
extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
549
const char *__restrict __pattern,
552
extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
553
const char *__restrict __string, size_t __nmatch,
554
regmatch_t __pmatch[__restrict_arr],
557
extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
558
char *__errbuf, size_t __errbuf_size));
560
extern void regfree _RE_ARGS ((regex_t *__preg));
529
extern int regcomp (regex_t *__restrict __preg,
530
const char *__restrict __pattern,
533
extern int regexec (const regex_t *__restrict __preg,
534
const char *__restrict __string, size_t __nmatch,
535
regmatch_t __pmatch[__restrict_arr],
538
extern size_t regerror (int __errcode, const regex_t *__preg,
539
char *__errbuf, size_t __errbuf_size);
541
extern void regfree (regex_t *__preg);
563
544
#ifdef __cplusplus