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