2003-01-03 03:35:31 +08:00
|
|
|
/* Portable <regex.h>.
|
2017-01-01 14:50:51 +08:00
|
|
|
Copyright (C) 2000-2017 Free Software Foundation, Inc.
|
2000-04-04 10:08:52 +08:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 02:08:50 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2000-04-04 10:08:52 +08:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 02:08:50 +08:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2000-04-04 10:08:52 +08:00
|
|
|
|
2015-07-16 02:27:32 +08:00
|
|
|
#ifndef GDB_REGEX_H
|
|
|
|
#define GDB_REGEX_H 1
|
2001-09-02 05:38:05 +08:00
|
|
|
|
2000-04-04 10:08:52 +08:00
|
|
|
#ifdef USE_INCLUDED_REGEX
|
2003-01-03 03:35:31 +08:00
|
|
|
# include "xregex.h"
|
2000-04-04 10:08:52 +08:00
|
|
|
#else
|
2003-01-03 03:35:31 +08:00
|
|
|
/* Request 4.2 BSD regex functions. */
|
|
|
|
# define _REGEX_RE_COMP
|
|
|
|
# include <regex.h>
|
2000-04-04 10:08:52 +08:00
|
|
|
#endif
|
2001-09-02 05:38:05 +08:00
|
|
|
|
2017-06-07 21:21:40 +08:00
|
|
|
/* A compiled regex. This is mainly a wrapper around regex_t. The
|
|
|
|
the constructor throws on regcomp error and the destructor is
|
|
|
|
responsible for calling regfree. The former means that it's not
|
|
|
|
possible to create an instance of compiled_regex that isn't
|
|
|
|
compiled, hence the name. */
|
|
|
|
class compiled_regex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* Compile a regexp and throw an exception on error, including
|
|
|
|
MESSAGE. REGEX and MESSAGE must not be NULL. */
|
|
|
|
compiled_regex (const char *regex, int cflags,
|
|
|
|
const char *message)
|
|
|
|
ATTRIBUTE_NONNULL (2) ATTRIBUTE_NONNULL (4);
|
|
|
|
|
|
|
|
~compiled_regex ();
|
|
|
|
|
2017-09-19 17:10:03 +08:00
|
|
|
DISABLE_COPY_AND_ASSIGN (compiled_regex);
|
2017-06-07 21:21:40 +08:00
|
|
|
|
|
|
|
/* Wrapper around ::regexec. */
|
|
|
|
int exec (const char *string,
|
|
|
|
size_t nmatch, regmatch_t pmatch[],
|
|
|
|
int eflags) const;
|
|
|
|
|
|
|
|
/* Wrapper around ::re_search. (Not const because re_search's
|
|
|
|
regex_t parameter isn't either.) */
|
|
|
|
int search (const char *string, int size, int startpos,
|
|
|
|
int range, struct re_registers *regs);
|
|
|
|
|
|
|
|
private:
|
|
|
|
/* The compiled pattern. */
|
|
|
|
regex_t m_pattern;
|
|
|
|
};
|
2011-01-18 00:50:42 +08:00
|
|
|
|
2015-07-16 02:27:32 +08:00
|
|
|
#endif /* not GDB_REGEX_H */
|