Ignore:
Timestamp:
Apr 8, 2007, 8:51:40 PM (18 years ago)
Author:
bird
Message:

Merged in regex from glibc 2.5.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/include/regex.h

    r2240 r3058  
    11/* Definitions for data structures and routines for the regular
    22   expression library.
    3    Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003
     3   Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006
    44   Free Software Foundation, Inc.
    55   This file is part of the GNU C Library.
     
    2828#ifdef __cplusplus
    2929extern "C" {
    30 #endif
    31 
    32 /* POSIX says that <sys/types.h> must be included (by the caller) before
    33    <regex.h>.  */
    34 
    35 #if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
    36 /* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
    37    should be there.  */
    38 # include <stddef.h>
    3930#endif
    4031
     
    209200       | RE_CONTEXT_INVALID_OPS ))
    210201
    211 #define RE_SYNTAX_POSIX_AWK                                             \
     202#define RE_SYNTAX_POSIX_AWK                                             \
    212203  (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS              \
    213204   | RE_INTERVALS           | RE_NO_GNU_OPS)
     
    350341
    351342#ifndef RE_TRANSLATE_TYPE
    352 # define RE_TRANSLATE_TYPE char *
     343# define RE_TRANSLATE_TYPE unsigned char *
    353344#endif
    354345
    355346struct re_pattern_buffer
    356347{
    357 /* [[[begin pattern_buffer]]] */
    358         /* Space that holds the compiled pattern.  It is declared as
    359           `unsigned char *' because its elements are
    360            sometimes used as array indexes.  */
     348  /* Space that holds the compiled pattern.  It is declared as
     349     `unsigned char *' because its elements are sometimes used as
     350     array indexes.  */
    361351  unsigned char *buffer;
    362352
    363         /* Number of bytes to which `buffer' points.  */
     353  /* Number of bytes to which `buffer' points.  */
    364354  unsigned long int allocated;
    365355
    366         /* Number of bytes actually used in `buffer'.  */
     356  /* Number of bytes actually used in `buffer'.  */
    367357  unsigned long int used;
    368358
    369         /* Syntax setting with which the pattern was compiled.  */
     359  /* Syntax setting with which the pattern was compiled.  */
    370360  reg_syntax_t syntax;
    371361
    372         /* Pointer to a fastmap, if any, otherwise zero.  re_search uses
    373            the fastmap, if there is one, to skip over impossible
    374            starting points for matches.  */
     362  /* Pointer to a fastmap, if any, otherwise zero.  re_search uses the
     363     fastmap, if there is one, to skip over impossible starting points
     364     for matches.  */
    375365  char *fastmap;
    376366
    377         /* Either a translate table to apply to all characters before
    378            comparing them, or zero for no translation.  The translation
    379            is applied to a pattern when it is compiled and to a string
    380            when it is matched.  */
     367  /* Either a translate table to apply to all characters before
     368     comparing them, or zero for no translation.  The translation is
     369     applied to a pattern when it is compiled and to a string when it
     370     is matched.  */
    381371  RE_TRANSLATE_TYPE translate;
    382372
    383         /* Number of subexpressions found by the compiler.  */
     373  /* Number of subexpressions found by the compiler.  */
    384374  size_t re_nsub;
    385375
    386         /* Zero if this pattern cannot match the empty string, one else.
    387            Well, in truth it's used only in `re_search_2', to see
    388            whether or not we should use the fastmap, so we don't set
    389            this absolutely perfectly; see `re_compile_fastmap' (the
    390            `duplicate' case).  */
     376  /* Zero if this pattern cannot match the empty string, one else.
     377     Well, in truth it's used only in `re_search_2', to see whether or
     378     not we should use the fastmap, so we don't set this absolutely
     379     perfectly; see `re_compile_fastmap' (the `duplicate' case).  */
    391380  unsigned can_be_null : 1;
    392381
    393         /* If REGS_UNALLOCATED, allocate space in the `regs' structure
    394              for `max (RE_NREGS, re_nsub + 1)' groups.
    395            If REGS_REALLOCATE, reallocate space if necessary.
    396            If REGS_FIXED, use what's there.  */
     382  /* If REGS_UNALLOCATED, allocate space in the `regs' structure
     383     for `max (RE_NREGS, re_nsub + 1)' groups.
     384     If REGS_REALLOCATE, reallocate space if necessary.
     385     If REGS_FIXED, use what's there.  */
    397386#define REGS_UNALLOCATED 0
    398387#define REGS_REALLOCATE 1
     
    400389  unsigned regs_allocated : 2;
    401390
    402         /* Set to zero when `regex_compile' compiles a pattern; set to one
    403            by `re_compile_fastmap' if it updates the fastmap.  */
     391  /* Set to zero when `regex_compile' compiles a pattern; set to one
     392     by `re_compile_fastmap' if it updates the fastmap.  */
    404393  unsigned fastmap_accurate : 1;
    405394
    406         /* If set, `re_match_2' does not return information about
    407            subexpressions.  */
     395  /* If set, `re_match_2' does not return information about
     396     subexpressions.  */
    408397  unsigned no_sub : 1;
    409398
    410         /* If set, a beginning-of-line anchor doesn't match at the
    411            beginning of the string.  */
     399  /* If set, a beginning-of-line anchor doesn't match at the beginning
     400     of the string.  */
    412401  unsigned not_bol : 1;
    413402
    414         /* Similarly for an end-of-line anchor.  */
     403  /* Similarly for an end-of-line anchor.  */
    415404  unsigned not_eol : 1;
    416405
    417         /* If true, an anchor at a newline matches.  */
     406  /* If true, an anchor at a newline matches.  */
    418407  unsigned newline_anchor : 1;
    419 
    420 /* [[[end pattern_buffer]]] */
    421408};
    422409
     
    458445/* Declarations for routines.  */
    459446
    460 /* To avoid duplicating every routine declaration -- once with a
    461    prototype (if we are ANSI), and once without (if we aren't) -- we
    462    use the following macro to declare argument types.  This
    463    unfortunately clutters up the declarations a bit, but I think it's
    464    worth it.  */
    465 
    466 #if __STDC__
    467 
    468 # define _RE_ARGS(args) args
    469 
    470 #else /* not __STDC__ */
    471 
    472 # define _RE_ARGS(args) ()
    473 #error "asdf"
    474 
    475 #endif /* not __STDC__ */
    476 
    477447/* Sets the current default syntax to SYNTAX, and return the old syntax.
    478448   You can also simply assign to the `re_syntax_options' variable.  */
    479 extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
     449extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
    480450
    481451/* Compile the regular expression PATTERN, with length LENGTH
    482452   and syntax given by the global `re_syntax_options', into the buffer
    483453   BUFFER.  Return NULL if successful, and an error string if not.  */
    484 extern const char *re_compile_pattern
    485   _RE_ARGS ((const char *pattern, size_t length,
    486              struct re_pattern_buffer *buffer));
     454extern const char *re_compile_pattern (const char *__pattern, size_t __length,
     455                                       struct re_pattern_buffer *__buffer);
    487456
    488457
     
    490459   accelerate searches.  Return 0 if successful and -2 if was an
    491460   internal error.  */
    492 extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
     461extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
    493462
    494463
     
    498467   match, or -2 for an internal error.  Also return register
    499468   information in REGS (if REGS and BUFFER->no_sub are nonzero).  */
    500 extern int re_search
    501   _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
    502             int length, int start, int range, struct re_registers *regs));
     469extern int re_search (struct re_pattern_buffer *__buffer, const char *__string,
     470                      int __length, int __start, int __range,
     471                      struct re_registers *__regs);
    503472
    504473
    505474/* Like `re_search', but search in the concatenation of STRING1 and
    506475   STRING2.  Also, stop searching at index START + STOP.  */
    507 extern int re_search_2
    508   _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
    509              int length1, const char *string2, int length2,
    510              int start, int range, struct re_registers *regs, int stop));
     476extern int re_search_2 (struct re_pattern_buffer *__buffer,
     477                        const char *__string1, int __length1,
     478                        const char *__string2, int __length2, int __start,
     479                        int __range, struct re_registers *__regs, int __stop);
    511480
    512481
    513482/* Like `re_search', but return how many characters in STRING the regexp
    514483   in BUFFER matched, starting at position START.  */
    515 extern int re_match
    516   _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
    517              int length, int start, struct re_registers *regs));
     484extern int re_match (struct re_pattern_buffer *__buffer, const char *__string,
     485                     int __length, int __start, struct re_registers *__regs);
    518486
    519487
    520488/* Relates to `re_match' as `re_search_2' relates to `re_search'.  */
    521 extern int re_match_2
    522   _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
    523              int length1, const char *string2, int length2,
    524              int start, struct re_registers *regs, int stop));
     489extern int re_match_2 (struct re_pattern_buffer *__buffer,
     490                       const char *__string1, int __length1,
     491                       const char *__string2, int __length2, int __start,
     492                       struct re_registers *__regs, int __stop);
    525493
    526494
     
    537505   PATTERN_BUFFER will allocate its own register data, without
    538506   freeing the old data.  */
    539 extern void re_set_registers
    540   _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
    541              unsigned num_regs, regoff_t *starts, regoff_t *ends));
     507extern void re_set_registers (struct re_pattern_buffer *__buffer,
     508                              struct re_registers *__regs,
     509                              unsigned int __num_regs,
     510                              regoff_t *__starts, regoff_t *__ends);
    542511
    543512#if defined _REGEX_RE_COMP || defined _LIBC
    544513# ifndef _CRAY
    545514/* 4.2 bsd compatibility.  */
    546 extern char *re_comp _RE_ARGS ((const char *));
    547 extern int re_exec _RE_ARGS ((const char *));
     515extern char *re_comp (const char *);
     516extern int re_exec (const char *);
    548517# endif
    549518#endif
     
    562531/* gcc 3.1 and up support the [restrict] syntax.  */
    563532#ifndef __restrict_arr
    564 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
     533# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \
     534     && !defined __GNUG__
    565535#  define __restrict_arr __restrict
    566536# else
     
    570540
    571541/* POSIX compatibility.  */
    572 extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
    573                               const char *__restrict __pattern,
    574                               int __cflags));
    575 
    576 extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
    577                               const char *__restrict __string, size_t __nmatch,
    578                               regmatch_t __pmatch[__restrict_arr],
    579                               int __eflags));
    580 
    581 extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
    582                                   char *__errbuf, size_t __errbuf_size));
    583 
    584 extern void regfree _RE_ARGS ((regex_t *__preg));
     542extern int regcomp (regex_t *__restrict __preg,
     543                    const char *__restrict __pattern,
     544                    int __cflags);
     545
     546extern int regexec (const regex_t *__restrict __preg,
     547                    const char *__restrict __string, size_t __nmatch,
     548                    regmatch_t __pmatch[__restrict_arr],
     549                    int __eflags);
     550
     551extern size_t regerror (int __errcode, const regex_t *__restrict __preg,
     552                        char *__restrict __errbuf, size_t __errbuf_size);
     553
     554extern void regfree (regex_t *__preg);
    585555
    586556
     
    590560
    591561#endif /* regex.h */
    592 
    593 
    594 /*
    595 Local variables:
    596 make-backup-files: t
    597 version-control: t
    598 trim-versions-without-asking: nil
    599 End:
    600  */
Note: See TracChangeset for help on using the changeset viewer.