Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Defines | Typedefs | Functions

regex.h File Reference

#include "mb/pg_wchar.h"
Include dependency graph for regex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  regex_t
struct  regmatch_t
struct  rm_detail_t

Defines

#define _REGEX_H_
#define REG_UBACKREF   000001
#define REG_ULOOKAHEAD   000002
#define REG_UBOUNDS   000004
#define REG_UBRACES   000010
#define REG_UBSALNUM   000020
#define REG_UPBOTCH   000040
#define REG_UBBS   000100
#define REG_UNONPOSIX   000200
#define REG_UUNSPEC   000400
#define REG_UUNPORT   001000
#define REG_ULOCALE   002000
#define REG_UEMPTYMATCH   004000
#define REG_UIMPOSSIBLE   010000
#define REG_USHORTEST   020000
#define REG_BASIC   000000
#define REG_EXTENDED   000001
#define REG_ADVF   000002
#define REG_ADVANCED   000003
#define REG_QUOTE   000004
#define REG_NOSPEC   REG_QUOTE
#define REG_ICASE   000010
#define REG_NOSUB   000020
#define REG_EXPANDED   000040
#define REG_NLSTOP   000100
#define REG_NLANCH   000200
#define REG_NEWLINE   000300
#define REG_PEND   000400
#define REG_EXPECT   001000
#define REG_BOSONLY   002000
#define REG_DUMP   004000
#define REG_FAKE   010000
#define REG_PROGRESS   020000
#define REG_NOTBOL   0001
#define REG_NOTEOL   0002
#define REG_STARTEND   0004
#define REG_FTRACE   0010
#define REG_MTRACE   0020
#define REG_SMALL   0040
#define REG_OKAY   0
#define REG_NOMATCH   1
#define REG_BADPAT   2
#define REG_ECOLLATE   3
#define REG_ECTYPE   4
#define REG_EESCAPE   5
#define REG_ESUBREG   6
#define REG_EBRACK   7
#define REG_EPAREN   8
#define REG_EBRACE   9
#define REG_BADBR   10
#define REG_ERANGE   11
#define REG_ESPACE   12
#define REG_BADRPT   13
#define REG_ASSERT   15
#define REG_INVARG   16
#define REG_MIXED   17
#define REG_BADOPT   18
#define REG_ETOOBIG   19
#define REG_ECOLORS   20
#define REG_ATOI   101
#define REG_ITOA   102
#define REG_PREFIX   (-1)
#define REG_EXACT   (-2)

Typedefs

typedef long regoff_t

Functions

int pg_regcomp (regex_t *, const pg_wchar *, size_t, int, Oid)
int pg_regexec (regex_t *, const pg_wchar *, size_t, size_t, rm_detail_t *, size_t, regmatch_t[], int)
int pg_regprefix (regex_t *, pg_wchar **, size_t *)
void pg_regfree (regex_t *)
size_t pg_regerror (int, const regex_t *, char *, size_t)
void pg_set_regex_collation (Oid collation)

Define Documentation

#define _REGEX_H_

Definition at line 2 of file regex.h.

#define REG_ADVANCED   000003
#define REG_ADVF   000002

Definition at line 102 of file regex.h.

Referenced by lexescape(), lexstart(), next(), and prefixes().

#define REG_ASSERT   15

Definition at line 151 of file regex.h.

Referenced by brackpart(), next(), parseqatom(), pickss(), and repeat().

#define REG_ATOI   101

Definition at line 158 of file regex.h.

Referenced by pg_regerror().

#define REG_BADBR   10

Definition at line 147 of file regex.h.

Referenced by next(), parseqatom(), and scannum().

#define REG_BADOPT   18

Definition at line 154 of file regex.h.

Referenced by prefixes().

#define REG_BADPAT   2

Definition at line 139 of file regex.h.

Referenced by prefixes().

#define REG_BADRPT   13

Definition at line 150 of file regex.h.

Referenced by next(), parseqatom(), and prefixes().

#define REG_BASIC   000000

Definition at line 100 of file regex.h.

#define REG_BOSONLY   002000

Definition at line 114 of file regex.h.

Referenced by next().

#define REG_DUMP   004000

Definition at line 115 of file regex.h.

Referenced by pg_regcomp().

#define REG_EBRACE   9

Definition at line 146 of file regex.h.

Referenced by next().

#define REG_EBRACK   7

Definition at line 144 of file regex.h.

Referenced by next().

#define REG_ECOLLATE   3

Definition at line 140 of file regex.h.

Referenced by brackpart(), and element().

#define REG_ECOLORS   20

Definition at line 156 of file regex.h.

Referenced by newcolor().

#define REG_ECTYPE   4

Definition at line 141 of file regex.h.

Referenced by brackpart(), and cclass().

#define REG_EESCAPE   5

Definition at line 142 of file regex.h.

Referenced by brenext(), lexdigits(), lexescape(), and next().

#define REG_EPAREN   8

Definition at line 145 of file regex.h.

Referenced by parse(), and parseqatom().

#define REG_ERANGE   11

Definition at line 148 of file regex.h.

Referenced by brackpart(), and range().

#define REG_ESPACE   12
#define REG_ESUBREG   6

Definition at line 143 of file regex.h.

Referenced by parseqatom().

#define REG_ETOOBIG   19

Definition at line 155 of file regex.h.

Referenced by newstate().

#define REG_EXACT   (-2)

Definition at line 162 of file regex.h.

Referenced by pg_regprefix(), and regexp_fixed_prefix().

#define REG_EXPANDED   000040

Definition at line 108 of file regex.h.

Referenced by brenext(), lexstart(), next(), pg_regcomp(), prefixes(), and skip().

#define REG_EXPECT   001000

Definition at line 113 of file regex.h.

Referenced by cfind(), find(), and pg_regexec().

#define REG_EXTENDED   000001

Definition at line 101 of file regex.h.

Referenced by lexstart(), next(), parse_re_flags(), parseqatom(), and pg_regcomp().

#define REG_FAKE   010000

Definition at line 116 of file regex.h.

Referenced by eclass().

#define REG_FTRACE   0010

Definition at line 127 of file regex.h.

Referenced by longest(), and shortest().

#define REG_ICASE   000010
#define REG_INVARG   16

Definition at line 152 of file regex.h.

Referenced by pg_regcomp(), and pg_regexec().

#define REG_ITOA   102

Definition at line 159 of file regex.h.

Referenced by pg_regerror().

#define REG_MIXED   17

Definition at line 153 of file regex.h.

#define REG_MTRACE   0020

Definition at line 128 of file regex.h.

#define REG_NEWLINE   000300

Definition at line 111 of file regex.h.

Referenced by lexstart().

#define REG_NLANCH   000200

Definition at line 110 of file regex.h.

Referenced by parseqatom(), and pg_regcomp().

#define REG_NLSTOP   000100

Definition at line 109 of file regex.h.

Referenced by cbracket(), parseqatom(), and pg_regcomp().

#define REG_NOMATCH   1
#define REG_NOSPEC   REG_QUOTE

Definition at line 105 of file regex.h.

#define REG_NOSUB   000020

Definition at line 107 of file regex.h.

Referenced by next(), NIAddAffix(), and pg_regexec().

#define REG_NOTBOL   0001

Definition at line 124 of file regex.h.

#define REG_NOTEOL   0002

Definition at line 125 of file regex.h.

#define REG_OKAY   0
#define REG_PEND   000400

Definition at line 112 of file regex.h.

#define REG_PREFIX   (-1)

Definition at line 161 of file regex.h.

Referenced by pg_regprefix(), and regexp_fixed_prefix().

#define REG_PROGRESS   020000

Definition at line 117 of file regex.h.

#define REG_QUOTE   000004

Definition at line 104 of file regex.h.

Referenced by lexstart(), pg_regcomp(), and prefixes().

#define REG_SMALL   0040

Definition at line 129 of file regex.h.

#define REG_STARTEND   0004

Definition at line 126 of file regex.h.

#define REG_UBACKREF   000001

Definition at line 60 of file regex.h.

Referenced by brenext(), and lexescape().

#define REG_UBBS   000100

Definition at line 66 of file regex.h.

Referenced by next().

#define REG_UBOUNDS   000004

Definition at line 62 of file regex.h.

Referenced by brenext(), and next().

#define REG_UBRACES   000010

Definition at line 63 of file regex.h.

Referenced by next().

#define REG_UBSALNUM   000020

Definition at line 64 of file regex.h.

Referenced by brenext(), and next().

#define REG_UEMPTYMATCH   004000

Definition at line 71 of file regex.h.

#define REG_UIMPOSSIBLE   010000

Definition at line 72 of file regex.h.

Referenced by pg_regexec(), and pg_regprefix().

#define REG_ULOCALE   002000

Definition at line 70 of file regex.h.

Referenced by element(), lexescape(), and next().

#define REG_ULOOKAHEAD   000002

Definition at line 61 of file regex.h.

Referenced by next().

#define REG_UNONPOSIX   000200

Definition at line 67 of file regex.h.

Referenced by brenext(), lexescape(), next(), prefixes(), and skip().

#define REG_UPBOTCH   000040

Definition at line 65 of file regex.h.

Referenced by parseqatom().

#define REG_USHORTEST   020000

Definition at line 73 of file regex.h.

Referenced by pg_regcomp().

#define REG_UUNPORT   001000

Definition at line 69 of file regex.h.

Referenced by brackpart(), and lexescape().

#define REG_UUNSPEC   000400

Definition at line 68 of file regex.h.

Referenced by brenext(), next(), and parsebranch().


Typedef Documentation

typedef long regoff_t

Definition at line 48 of file regex.h.


Function Documentation

int pg_regcomp ( regex_t ,
const pg_wchar ,
size_t  ,
int  ,
Oid   
)
size_t pg_regerror ( int  ,
const regex_t ,
char *  ,
size_t   
)

Definition at line 60 of file regerror.c.

References rerr::code, rerr::explain, rerr::name, REG_ATOI, REG_ITOA, rerrs, and unk.

Referenced by check_ident_usermap(), NIAddAffix(), parse_ident_line(), RE_compile(), RE_compile_and_cache(), RE_wchar_execute(), regexp_fixed_prefix(), and replace_text_regexp().

{
    struct rerr *r;
    const char *msg;
    char        convbuf[sizeof(unk) + 50];      /* 50 = plenty for int */
    size_t      len;
    int         icode;

    switch (errcode)
    {
        case REG_ATOI:          /* convert name to number */
            for (r = rerrs; r->code >= 0; r++)
                if (strcmp(r->name, errbuf) == 0)
                    break;
            sprintf(convbuf, "%d", r->code);    /* -1 for unknown */
            msg = convbuf;
            break;
        case REG_ITOA:          /* convert number to name */
            icode = atoi(errbuf);       /* not our problem if this fails */
            for (r = rerrs; r->code >= 0; r++)
                if (r->code == icode)
                    break;
            if (r->code >= 0)
                msg = r->name;
            else
            {                   /* unknown; tell him the number */
                sprintf(convbuf, "REG_%u", (unsigned) icode);
                msg = convbuf;
            }
            break;
        default:                /* a real, normal error code */
            for (r = rerrs; r->code >= 0; r++)
                if (r->code == errcode)
                    break;
            if (r->code >= 0)
                msg = r->explain;
            else
            {                   /* unknown; say so */
                sprintf(convbuf, unk, errcode);
                msg = convbuf;
            }
            break;
    }

    len = strlen(msg) + 1;      /* space needed, including NUL */
    if (errbuf_size > 0)
    {
        if (errbuf_size > len)
            strcpy(errbuf, msg);
        else
        {                       /* truncate to fit */
            strncpy(errbuf, msg, errbuf_size - 1);
            errbuf[errbuf_size - 1] = '\0';
        }
    }

    return len;
}

int pg_regexec ( regex_t ,
const pg_wchar ,
size_t  ,
size_t  ,
rm_detail_t ,
size_t  ,
regmatch_t  [],
int   
)
void pg_regfree ( regex_t  ) 

Definition at line 49 of file regfree.c.

References NULL, and regex_t::re_fns.

Referenced by createTrgmNFA(), load_ident(), and RE_compile_and_cache().

{
    if (re == NULL)
        return;
    (*((struct fns *) re->re_fns)->free) (re);
}

int pg_regprefix ( regex_t ,
pg_wchar **  ,
size_t *   
)
void pg_set_regex_collation ( Oid  collation  ) 

Definition at line 231 of file regc_pg_locale.c.

References DEFAULT_COLLATION_OID, ereport, errcode(), errhint(), errmsg(), ERROR, GetDatabaseEncoding(), lc_ctype_is_c(), OidIsValid, pg_newlocale_from_collation(), pg_regex_collation, pg_regex_locale, pg_regex_strategy, and PG_UTF8.

Referenced by pg_regcomp(), pg_regexec(), and pg_regprefix().

{
    if (lc_ctype_is_c(collation))
    {
        /* C/POSIX collations use this path regardless of database encoding */
        pg_regex_strategy = PG_REGEX_LOCALE_C;
        pg_regex_locale = 0;
        pg_regex_collation = C_COLLATION_OID;
    }
    else
    {
        if (collation == DEFAULT_COLLATION_OID)
            pg_regex_locale = 0;
        else if (OidIsValid(collation))
        {
            /*
             * NB: pg_newlocale_from_collation will fail if not HAVE_LOCALE_T;
             * the case of pg_regex_locale != 0 but not HAVE_LOCALE_T does not
             * have to be considered below.
             */
            pg_regex_locale = pg_newlocale_from_collation(collation);
        }
        else
        {
            /*
             * This typically means that the parser could not resolve a
             * conflict of implicit collations, so report it that way.
             */
            ereport(ERROR,
                    (errcode(ERRCODE_INDETERMINATE_COLLATION),
                     errmsg("could not determine which collation to use for regular expression"),
                     errhint("Use the COLLATE clause to set the collation explicitly.")));
        }

#ifdef USE_WIDE_UPPER_LOWER
        if (GetDatabaseEncoding() == PG_UTF8)
        {
            if (pg_regex_locale)
                pg_regex_strategy = PG_REGEX_LOCALE_WIDE_L;
            else
                pg_regex_strategy = PG_REGEX_LOCALE_WIDE;
        }
        else
#endif   /* USE_WIDE_UPPER_LOWER */
        {
            if (pg_regex_locale)
                pg_regex_strategy = PG_REGEX_LOCALE_1BYTE_L;
            else
                pg_regex_strategy = PG_REGEX_LOCALE_1BYTE;
        }

        pg_regex_collation = collation;
    }
}