| regex.h | | regex.h | |
| /* | | /* | |
|
| regex.h - POSIX.2 compatible regexp interface | | regex.h - POSIX.2 compatible regexp interface and TRE extensions | |
| | | | |
| Copyright (C) 2001-2003 Ville Laurikari <vl@iki.fi>. | | Copyright (C) 2001-2003 Ville Laurikari <vl@iki.fi>. | |
| | | | |
| This program is free software; you can redistribute it and/or modify | | This program is free software; you can redistribute it and/or modify | |
| it under the terms of the GNU General Public License version 2 (June | | it under the terms of the GNU General Public License version 2 (June | |
| 1991) as published by the Free Software Foundation. | | 1991) as published by the Free Software Foundation. | |
| | | | |
| This program is distributed in the hope that it will be useful, | | This program is distributed in the hope that it will be useful, | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| GNU General Public License for more details. | | GNU General Public License for more details. | |
| | | | |
| You should have received a copy of the GNU General Public License | | You should have received a copy of the GNU General Public License | |
| along with this program; if not, write to the Free Software | | along with this program; if not, write to the Free Software | |
| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| | | | |
| */ | | */ | |
| | | | |
|
| #ifndef _REGEX_H | | #ifndef TRE_REGEX_H | |
| #define _REGEX_H 1 | | #define TRE_REGEX_H 1 | |
| | | | |
| | | #include "tre-config.h" | |
| | | | |
| | | #ifdef HAVE_SYS_TYPES_H | |
| | | #include <sys/types.h> | |
| | | #endif /* HAVE_SYS_TYPES_H */ | |
| | | | |
| | | #ifdef TRE_USE_SYSTEM_REGEX_H | |
| | | /* Include the system regex.h to make TRE ABI compatible with the | |
| | | system regex. */ | |
| | | #include TRE_SYSTEM_REGEX_H_PATH | |
| | | #endif /* TRE_USE_SYSTEM_REGEX_H */ | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
|
| #include "tre-config.h" | | #ifdef TRE_USE_SYSTEM_REGEX_H | |
| | | | |
| | | #ifndef REG_OK | |
| | | #define REG_OK 0 | |
| | | #endif /* !REG_OK */ | |
| | | | |
| | | #ifndef HAVE_REG_ERRCODE_T | |
| | | typedef int reg_errcode_t; | |
| | | #endif /* !HAVE_REG_ERRCODE_T */ | |
| | | | |
| | | #else /* !TRE_USE_SYSTEM_REGEX_H */ | |
| | | | |
| | | /* If the we're not using system regex.h, we need to define the | |
| | | structs and enums ourselves. */ | |
| | | | |
| typedef int regoff_t; | | typedef int regoff_t; | |
| typedef struct { | | typedef struct { | |
| size_t re_nsub; /* Number of parenthesized subexpressions. */ | | size_t re_nsub; /* Number of parenthesized subexpressions. */ | |
| void *value; /* For internal use only. */ | | void *value; /* For internal use only. */ | |
| } regex_t; | | } regex_t; | |
| | | | |
| typedef struct { | | typedef struct { | |
| regoff_t rm_so; | | regoff_t rm_so; | |
| regoff_t rm_eo; | | regoff_t rm_eo; | |
| } regmatch_t; | | } regmatch_t; | |
| | | | |
|
| | | typedef enum { | |
| | | REG_OK = 0, /* No error. */ | |
| | | /* POSIX regcomp() return error codes. (In the order listed in the | |
| | | standard.) */ | |
| | | REG_NOMATCH, /* No match. */ | |
| | | REG_BADPAT, /* Invalid regexp. */ | |
| | | REG_ECOLLATE, /* Unknown collating element. */ | |
| | | REG_ECTYPE, /* Unknown character class name. */ | |
| | | REG_EESCAPE, /* Trailing backslash. */ | |
| | | REG_ESUBREG, /* Invalid back reference. */ | |
| | | REG_EBRACK, /* "[]" imbalance */ | |
| | | REG_EPAREN, /* "\(\)" or "()" imbalance */ | |
| | | REG_EBRACE, /* "\{\}" or "{}" imbalance */ | |
| | | REG_BADBR, /* Invalid content of {} */ | |
| | | REG_ERANGE, /* Invalid use of range operator */ | |
| | | REG_ESPACE, /* Out of memory. */ | |
| | | REG_BADRPT | |
| | | } reg_errcode_t; | |
| | | | |
| | | /* POSIX regcomp() flags. */ | |
| | | #define REG_EXTENDED 1 | |
| | | #define REG_ICASE (REG_EXTENDED << 1) | |
| | | #define REG_NEWLINE (REG_ICASE << 1) | |
| | | #define REG_NOSUB (REG_NEWLINE << 1) | |
| | | | |
| | | /* POSIX regexec() flags. */ | |
| | | #define REG_NOTBOL 1 | |
| | | #define REG_NOTEOL (REG_NOTBOL << 1) | |
| | | | |
| | | #endif /* !TRE_USE_SYSTEM_REGEX_H */ | |
| | | | |
| | | /* The maximum number of iterations in a bound expression. */ | |
| | | #undef RE_DUP_MAX | |
| | | #define RE_DUP_MAX 255 | |
| | | | |
| /* The POSIX.2 regexp functions */ | | /* The POSIX.2 regexp functions */ | |
| int regcomp(regex_t *preg, const char *regex, int cflags); | | int regcomp(regex_t *preg, const char *regex, int cflags); | |
| int regexec(const regex_t *preg, const char *string, size_t nmatch, | | int regexec(const regex_t *preg, const char *string, size_t nmatch, | |
| regmatch_t pmatch[], int eflags); | | regmatch_t pmatch[], int eflags); | |
| size_t regerror(int errcode, const regex_t *preg, char *errbuf, | | size_t regerror(int errcode, const regex_t *preg, char *errbuf, | |
| size_t errbuf_size); | | size_t errbuf_size); | |
| void regfree(regex_t *preg); | | void regfree(regex_t *preg); | |
| | | | |
| #ifdef TRE_WCHAR | | #ifdef TRE_WCHAR | |
| #ifdef HAVE_WCHAR_H | | #ifdef HAVE_WCHAR_H | |
| | | | |
| skipping to change at line 102 | | skipping to change at line 162 | |
| regamatch_t *match, regaparams_t params, int eflags); | | regamatch_t *match, regaparams_t params, int eflags); | |
| #ifdef TRE_WCHAR | | #ifdef TRE_WCHAR | |
| /* Wide character approximate matching. */ | | /* Wide character approximate matching. */ | |
| int regawexec(const regex_t *preg, const wchar_t *string, | | int regawexec(const regex_t *preg, const wchar_t *string, | |
| regamatch_t *match, regaparams_t params, int eflags); | | regamatch_t *match, regaparams_t params, int eflags); | |
| int regawnexec(const regex_t *preg, const wchar_t *string, size_t len, | | int regawnexec(const regex_t *preg, const wchar_t *string, size_t len, | |
| regamatch_t *match, regaparams_t params, int eflags); | | regamatch_t *match, regaparams_t params, int eflags); | |
| #endif /* TRE_WCHAR */ | | #endif /* TRE_WCHAR */ | |
| #endif /* TRE_APPROX */ | | #endif /* TRE_APPROX */ | |
| | | | |
|
| typedef enum { | | | |
| REG_OK = 0, /* No error. */ | | | |
| /* POSIX regcomp() return error codes. (In the order listed in the | | | |
| standard.) */ | | | |
| REG_NOMATCH, /* No match. */ | | | |
| REG_BADPAT, /* Invalid regexp. */ | | | |
| REG_ECOLLATE, /* Unknown collating element. */ | | | |
| REG_ECTYPE, /* Unknown character class name. */ | | | |
| REG_EESCAPE, /* Trailing backslash. */ | | | |
| REG_ESUBREG, | | | |
| REG_EBRACK, /* "[]" imbalance */ | | | |
| REG_EPAREN, /* "\(\)" or "()" imbalance */ | | | |
| REG_EBRACE, /* "\{\}" or "{}" imbalance */ | | | |
| REG_BADBR, /* Invalid content of {} */ | | | |
| REG_ERANGE, /* Invalid use of range operator */ | | | |
| REG_ESPACE, /* Out of memory. */ | | | |
| REG_BADRPT | | | |
| } reg_errcode_t; | | | |
| | | | |
| /* The maximum number of iterations in a bound expression. */ | | | |
| #undef RE_DUP_MAX | | | |
| #define RE_DUP_MAX 255 | | | |
| | | | |
| /* POSIX regcomp() flags. */ | | | |
| #define REG_EXTENDED 1 | | | |
| #define REG_ICASE (REG_EXTENDED << 1) | | | |
| #define REG_NEWLINE (REG_ICASE << 1) | | | |
| #define REG_NOSUB (REG_NEWLINE << 1) | | | |
| | | | |
| /* POSIX regexec() flags. */ | | | |
| #define REG_NOTBOL 1 | | | |
| #define REG_NOTEOL (REG_NOTBOL << 1) | | | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| } | | } | |
| #endif | | #endif | |
|
| #endif /* _REGEX_H */ | | #endif /* TRE_REGEX_H */ | |
| | | | |
| /* EOF */ | | /* EOF */ | |
| | | | |
End of changes. 6 change blocks. |
| 38 lines changed or deleted | | 65 lines changed or added | |
|