419
400
#define REG_ESIZE _REG_ESIZE
420
401
#define REG_ERPAREN _REG_ERPAREN
422
/* struct re_pattern_buffer normally uses member names like `buffer'
423
that POSIX does not allow. In POSIX mode these members have names
424
with leading `re_' (e.g., `re_buffer'). */
425
#ifdef __USE_GNU_REGEX
426
# define _REG_RE_NAME(id) id
427
# define _REG_RM_NAME(id) id
429
# define _REG_RE_NAME(id) re_##id
430
# define _REG_RM_NAME(id) rm_##id
433
/* The user can specify the type of the re_translate member by
434
defining the macro RE_TRANSLATE_TYPE, which defaults to unsigned
435
char *. This pollutes the POSIX name space, so in POSIX mode just
436
use unsigned char *. */
437
#ifdef __USE_GNU_REGEX
438
# ifndef RE_TRANSLATE_TYPE
439
# define RE_TRANSLATE_TYPE unsigned char *
441
# define REG_TRANSLATE_TYPE RE_TRANSLATE_TYPE
443
# define REG_TRANSLATE_TYPE unsigned char *
446
403
/* This data structure represents a compiled pattern. Before calling
447
the pattern compiler, the fields `buffer', `allocated', `fastmap',
448
`translate', and `no_sub' can be set. After the pattern has been
449
compiled, the `re_nsub' field is available. All other fields are
450
private to the regex routines. */
404
the pattern compiler, the fields 'buffer', 'allocated', 'fastmap',
405
and 'translate' can be set. After the pattern has been compiled,
406
the fields 're_nsub', 'not_bol' and 'not_eol' are available. All
407
other fields are private to the regex routines. */
409
#ifndef RE_TRANSLATE_TYPE
410
# define __RE_TRANSLATE_TYPE unsigned char *
412
# define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE
417
# define __REPB_PREFIX(name) name
419
# define __REPB_PREFIX(name) __##name
452
422
struct re_pattern_buffer
454
/* Space that holds the compiled pattern. It is declared as
455
`unsigned char *' because its elements are sometimes used as
457
unsigned char *_REG_RE_NAME (buffer);
459
/* Number of bytes to which `buffer' points. */
460
__re_long_size_t _REG_RE_NAME (allocated);
462
/* Number of bytes actually used in `buffer'. */
463
__re_long_size_t _REG_RE_NAME (used);
424
/* Space that holds the compiled pattern. The type
425
'struct re_dfa_t' is private and is not declared here. */
426
struct re_dfa_t *__REPB_PREFIX(buffer);
428
/* Number of bytes to which 'buffer' points. */
429
__re_long_size_t __REPB_PREFIX(allocated);
431
/* Number of bytes actually used in 'buffer'. */
432
__re_long_size_t __REPB_PREFIX(used);
465
434
/* Syntax setting with which the pattern was compiled. */
466
reg_syntax_t _REG_RE_NAME (syntax);
435
reg_syntax_t __REPB_PREFIX(syntax);
468
437
/* Pointer to a fastmap, if any, otherwise zero. re_search uses the
469
438
fastmap, if there is one, to skip over impossible starting points
471
char *_REG_RE_NAME (fastmap);
440
char *__REPB_PREFIX(fastmap);
473
442
/* Either a translate table to apply to all characters before
474
443
comparing them, or zero for no translation. The translation is
475
444
applied to a pattern when it is compiled and to a string when it
477
REG_TRANSLATE_TYPE _REG_RE_NAME (translate);
446
__RE_TRANSLATE_TYPE __REPB_PREFIX(translate);
479
448
/* Number of subexpressions found by the compiler. */
482
451
/* Zero if this pattern cannot match the empty string, one else.
483
Well, in truth it's used only in `re_search_2', to see whether or
452
Well, in truth it's used only in 're_search_2', to see whether or
484
453
not we should use the fastmap, so we don't set this absolutely
485
perfectly; see `re_compile_fastmap' (the `duplicate' case). */
486
unsigned int _REG_RE_NAME (can_be_null) : 1;
454
perfectly; see 're_compile_fastmap' (the "duplicate" case). */
455
unsigned __REPB_PREFIX(can_be_null) : 1;
488
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
489
for `max (RE_NREGS, re_nsub + 1)' groups.
457
/* If REGS_UNALLOCATED, allocate space in the 'regs' structure
458
for 'max (RE_NREGS, re_nsub + 1)' groups.
490
459
If REGS_REALLOCATE, reallocate space if necessary.
491
460
If REGS_FIXED, use what's there. */
492
#ifdef __USE_GNU_REGEX
493
462
# define REGS_UNALLOCATED 0
494
463
# define REGS_REALLOCATE 1
495
464
# define REGS_FIXED 2
497
unsigned int _REG_RE_NAME (regs_allocated) : 2;
499
/* Set to zero when `re_compile_pattern' compiles a pattern; set to
500
one by `re_compile_fastmap' if it updates the fastmap. */
501
unsigned int _REG_RE_NAME (fastmap_accurate) : 1;
503
/* If set, `re_match_2' does not return information about
466
unsigned __REPB_PREFIX(regs_allocated) : 2;
468
/* Set to zero when 're_compile_pattern' compiles a pattern; set to
469
one by 're_compile_fastmap' if it updates the fastmap. */
470
unsigned __REPB_PREFIX(fastmap_accurate) : 1;
472
/* If set, 're_match_2' does not return information about
504
473
subexpressions. */
505
unsigned int _REG_RE_NAME (no_sub) : 1;
474
unsigned __REPB_PREFIX(no_sub) : 1;
507
476
/* If set, a beginning-of-line anchor doesn't match at the beginning
508
477
of the string. */
509
unsigned int _REG_RE_NAME (not_bol) : 1;
478
unsigned __REPB_PREFIX(not_bol) : 1;
511
480
/* Similarly for an end-of-line anchor. */
512
unsigned int _REG_RE_NAME (not_eol) : 1;
481
unsigned __REPB_PREFIX(not_eol) : 1;
514
483
/* If true, an anchor at a newline matches. */
515
unsigned int _REG_RE_NAME (newline_anchor) : 1;
517
/* [[[end pattern_buffer]]] */
484
unsigned __REPB_PREFIX(newline_anchor) : 1;
520
487
typedef struct re_pattern_buffer regex_t;
489
/* Type for byte offsets within the string. POSIX mandates this. */
490
#ifdef _REGEX_LARGE_OFFSETS
491
/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as
492
ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t
493
is wider than ssize_t, so ssize_t is safe. */
494
typedef ssize_t regoff_t;
496
/* The traditional GNU regex implementation mishandles strings longer
498
typedef int regoff_t;
522
503
/* This is the structure we store register match data in. See
523
504
regex.texinfo for a full description of what registers match. */
524
505
struct re_registers
526
__re_size_t _REG_RM_NAME (num_regs);
527
regoff_t *_REG_RM_NAME (start);
528
regoff_t *_REG_RM_NAME (end);
507
__re_size_t num_regs;
532
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
533
`re_match_2' returns information about at least this many registers
534
the first time a `regs' structure is passed. */
535
#if !defined RE_NREGS && defined __USE_GNU_REGEX
513
/* If 'regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
514
're_match_2' returns information about at least this many registers
515
the first time a 'regs' structure is passed. */
540
522
/* POSIX specification for registers. Aside from the different names than
541
`re_registers', POSIX uses an array of structures, instead of a
523
're_registers', POSIX uses an array of structures, instead of a
542
524
structure of arrays. */