diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-04-15 18:30:57 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-04-19 18:28:57 +0100 |
commit | f5dc2ee39d6324d3979e3dcea5ee1d718c516a31 (patch) | |
tree | 4256bbe19ebc90b08a744e8cbf7d9674bf9c99da | |
parent | 229597a129f62d5e8a101f1eed95489e2399f741 (diff) | |
download | gdb-f5dc2ee39d6324d3979e3dcea5ee1d718c516a31.zip gdb-f5dc2ee39d6324d3979e3dcea5ee1d718c516a31.tar.gz gdb-f5dc2ee39d6324d3979e3dcea5ee1d718c516a31.tar.bz2 |
gdb: use compiled_regex instead of std::regex
In GDB we should be using compiled_regex instead of std::regex.
Replace one use in producer.c.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* producer.c: Replace 'regex' include with 'gdb_regex.h'.
(producer_is_icc): Replace use of std::regex with gdb's
compiled_regex.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/producer.c | 18 |
2 files changed, 15 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 678ad27..a7f079e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2021-04-19 Andrew Burgess <andrew.burgess@embecosm.com> + + * producer.c: Replace 'regex' include with 'gdb_regex.h'. + (producer_is_icc): Replace use of std::regex with gdb's + compiled_regex. + 2021-04-17 Tom Tromey <tom@tromey.com> PR gdb/23743: diff --git a/gdb/producer.c b/gdb/producer.c index 591509f..cdfd80d 100644 --- a/gdb/producer.c +++ b/gdb/producer.c @@ -20,7 +20,7 @@ #include "defs.h" #include "producer.h" #include "gdbsupport/selftest.h" -#include <regex> +#include "gdb_regex.h" /* See producer.h. */ @@ -91,9 +91,8 @@ producer_is_icc_ge_19 (const char *producer) bool producer_is_icc (const char *producer, int *major, int *minor) { - std::regex i_re ("Intel\\(R\\)"); - std::cmatch i_m; - if ((producer == nullptr) || !std::regex_search (producer, i_m, i_re)) + compiled_regex i_re ("Intel(R)", 0, "producer_is_icc"); + if (producer == nullptr || i_re.exec (producer, 0, nullptr, 0) != 0) return false; /* Prepare the used fields. */ @@ -106,12 +105,13 @@ producer_is_icc (const char *producer, int *major, int *minor) *minor = 0; *major = 0; - std::regex re ("[0-9]+\\.[0-9]+"); - std::cmatch version; - - if (std::regex_search (producer, version, re)) + compiled_regex re ("[0-9]+\\.[0-9]+", REG_EXTENDED, "producer_is_icc"); + regmatch_t version[1]; + if (re.exec (producer, ARRAY_SIZE (version), version, 0) == 0 + && version[0].rm_so != -1) { - sscanf (version.str ().c_str (), "%d.%d", major, minor); + const char *version_str = producer + version[0].rm_so; + sscanf (version_str, "%d.%d", major, minor); return true; } |