diff options
author | thegeorg <thegeorg@yandex-team.com> | 2024-06-02 23:59:48 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2024-06-03 00:11:57 +0300 |
commit | 933f6cbf4f95da7762f11e135c0f5c357e6e95e4 (patch) | |
tree | 7f9ad14f21d9efce738d5f5aa255af0dc983e164 /contrib/libs/re2/util | |
parent | b1fd17a0e5fc98b32b49324f04e99e5318609e47 (diff) | |
download | ydb-933f6cbf4f95da7762f11e135c0f5c357e6e95e4.tar.gz |
Update contrib/libs/re2 to 2024-06-01
8d72a1e5220ffe0bb7a82257f422606184202ad0
Diffstat (limited to 'contrib/libs/re2/util')
-rw-r--r-- | contrib/libs/re2/util/logging.h | 109 | ||||
-rw-r--r-- | contrib/libs/re2/util/pcre.cc | 5 | ||||
-rw-r--r-- | contrib/libs/re2/util/pcre.h | 32 |
3 files changed, 19 insertions, 127 deletions
diff --git a/contrib/libs/re2/util/logging.h b/contrib/libs/re2/util/logging.h deleted file mode 100644 index 946962b39b..0000000000 --- a/contrib/libs/re2/util/logging.h +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2009 The RE2 Authors. All Rights Reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#ifndef UTIL_LOGGING_H_ -#define UTIL_LOGGING_H_ - -// Simplified version of Google's logging. - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <ostream> -#include <sstream> - -#include "absl/base/attributes.h" - -// Debug-only checking. -#define DCHECK(condition) assert(condition) -#define DCHECK_EQ(val1, val2) assert((val1) == (val2)) -#define DCHECK_NE(val1, val2) assert((val1) != (val2)) -#define DCHECK_LE(val1, val2) assert((val1) <= (val2)) -#define DCHECK_LT(val1, val2) assert((val1) < (val2)) -#define DCHECK_GE(val1, val2) assert((val1) >= (val2)) -#define DCHECK_GT(val1, val2) assert((val1) > (val2)) - -// Always-on checking -#define CHECK(x) if(x){}else LogMessageFatal(__FILE__, __LINE__).stream() << "Check failed: " #x -#define CHECK_LT(x, y) CHECK((x) < (y)) -#define CHECK_GT(x, y) CHECK((x) > (y)) -#define CHECK_LE(x, y) CHECK((x) <= (y)) -#define CHECK_GE(x, y) CHECK((x) >= (y)) -#define CHECK_EQ(x, y) CHECK((x) == (y)) -#define CHECK_NE(x, y) CHECK((x) != (y)) - -#define LOG_INFO LogMessage(__FILE__, __LINE__) -#define LOG_WARNING LogMessage(__FILE__, __LINE__) -#define LOG_ERROR LogMessage(__FILE__, __LINE__) -#define LOG_FATAL LogMessageFatal(__FILE__, __LINE__) -#define LOG_QFATAL LOG_FATAL - -// It seems that one of the Windows header files defines ERROR as 0. -#ifdef _WIN32 -#define LOG_0 LOG_INFO -#endif - -#ifdef NDEBUG -#define LOG_DFATAL LOG_ERROR -#else -#define LOG_DFATAL LOG_FATAL -#endif - -#define LOG(severity) LOG_ ## severity.stream() - -#define VLOG(x) if((x)>0){}else LOG_INFO.stream() - -class LogMessage { - public: - LogMessage(const char* file, int line) - : flushed_(false) { - stream() << file << ":" << line << ": "; - } - void Flush() { - stream() << "\n"; - std::string s = str_.str(); - size_t n = s.size(); - if (fwrite(s.data(), 1, n, stderr) < n) {} // shut up gcc - flushed_ = true; - } - ~LogMessage() { - if (!flushed_) { - Flush(); - } - } - std::ostream& stream() { return str_; } - - private: - bool flushed_; - std::ostringstream str_; - - LogMessage(const LogMessage&) = delete; - LogMessage& operator=(const LogMessage&) = delete; -}; - -// Silence "destructor never returns" warning for ~LogMessageFatal(). -// Since this is a header file, push and then pop to limit the scope. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4722) -#endif - -class LogMessageFatal : public LogMessage { - public: - LogMessageFatal(const char* file, int line) - : LogMessage(file, line) {} - ABSL_ATTRIBUTE_NORETURN ~LogMessageFatal() { - Flush(); - abort(); - } - private: - LogMessageFatal(const LogMessageFatal&) = delete; - LogMessageFatal& operator=(const LogMessageFatal&) = delete; -}; - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#endif // UTIL_LOGGING_H_ diff --git a/contrib/libs/re2/util/pcre.cc b/contrib/libs/re2/util/pcre.cc index 27aee3dc48..94a88b7c94 100644 --- a/contrib/libs/re2/util/pcre.cc +++ b/contrib/libs/re2/util/pcre.cc @@ -16,8 +16,9 @@ #include <utility> #include "absl/flags/flag.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" -#include "util/logging.h" #include "util/pcre.h" // Silence warnings about the wacky formatting in the operator() functions. @@ -25,7 +26,7 @@ #pragma GCC diagnostic ignored "-Wmisleading-indentation" #endif -#define PCREPORT(level) LOG(level) +#define PCREPORT(level) ABSL_LOG(level) // Default PCRE limits. // Defaults chosen to allow a plausible amount of CPU and diff --git a/contrib/libs/re2/util/pcre.h b/contrib/libs/re2/util/pcre.h index 72c02bf8e1..aa63c7db79 100644 --- a/contrib/libs/re2/util/pcre.h +++ b/contrib/libs/re2/util/pcre.h @@ -39,10 +39,10 @@ // supplied pattern exactly. // // Example: successful match -// CHECK(PCRE::FullMatch("hello", "h.*o")); +// ABSL_CHECK(PCRE::FullMatch("hello", "h.*o")); // // Example: unsuccessful match (requires full match): -// CHECK(!PCRE::FullMatch("hello", "e")); +// ABSL_CHECK(!PCRE::FullMatch("hello", "e")); // // ----------------------------------------------------------------------- // UTF-8 AND THE MATCHING INTERFACE: @@ -58,7 +58,7 @@ // // Example: // PCRE re(utf8_pattern, PCRE::UTF8); -// CHECK(PCRE::FullMatch(utf8_string, re)); +// ABSL_CHECK(PCRE::FullMatch(utf8_string, re)); // // ----------------------------------------------------------------------- // MATCHING WITH SUBSTRING EXTRACTION: @@ -68,22 +68,22 @@ // Example: extracts "ruby" into "s" and 1234 into "i" // int i; // std::string s; -// CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i)); +// ABSL_CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i)); // // Example: fails because string cannot be stored in integer -// CHECK(!PCRE::FullMatch("ruby", "(.*)", &i)); +// ABSL_CHECK(!PCRE::FullMatch("ruby", "(.*)", &i)); // // Example: fails because there aren't enough sub-patterns: -// CHECK(!PCRE::FullMatch("ruby:1234", "\\w+:\\d+", &s)); +// ABSL_CHECK(!PCRE::FullMatch("ruby:1234", "\\w+:\\d+", &s)); // // Example: does not try to extract any extra sub-patterns -// CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s)); +// ABSL_CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s)); // // Example: does not try to extract into NULL -// CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i)); +// ABSL_CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i)); // // Example: integer overflow causes failure -// CHECK(!PCRE::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i)); +// ABSL_CHECK(!PCRE::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i)); // // ----------------------------------------------------------------------- // PARTIAL MATCHES @@ -92,12 +92,12 @@ // to match any substring of the text. // // Example: simple search for a string: -// CHECK(PCRE::PartialMatch("hello", "ell")); +// ABSL_CHECK(PCRE::PartialMatch("hello", "ell")); // // Example: find first number in a string // int number; -// CHECK(PCRE::PartialMatch("x*100 + 20", "(\\d+)", &number)); -// CHECK_EQ(number, 100); +// ABSL_CHECK(PCRE::PartialMatch("x*100 + 20", "(\\d+)", &number)); +// ABSL_CHECK_EQ(number, 100); // // ----------------------------------------------------------------------- // PPCRE-COMPILED PCREGULAR EXPPCRESSIONS @@ -157,7 +157,7 @@ // // Example: // int a, b, c, d; -// CHECK(PCRE::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)", +// ABSL_CHECK(PCRE::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)", // Octal(&a), Hex(&b), CRadix(&c), CRadix(&d)); // will leave 64 in a, b, c, and d. @@ -379,7 +379,7 @@ class PCRE { // text. E.g., // // std::string s = "yabba dabba doo"; - // CHECK(PCRE::Replace(&s, "b+", "d")); + // ABSL_CHECK(PCRE::Replace(&s, "b+", "d")); // // will leave "s" containing "yada dabba doo" // @@ -393,7 +393,7 @@ class PCRE { // re-matching. E.g., // // std::string s = "yabba dabba doo"; - // CHECK(PCRE::GlobalReplace(&s, "b+", "d")); + // ABSL_CHECK(PCRE::GlobalReplace(&s, "b+", "d")); // // will leave "s" containing "yada dada doo" // @@ -417,7 +417,7 @@ class PCRE { // * The @p rewrite string doesn't have any syntax errors // ('\' followed by anything besides [0-9] and '\'). // Making this test will guarantee that "replace" and "extract" - // operations won't LOG(ERROR) or fail because of a bad rewrite + // operations won't ABSL_LOG(ERROR) or fail because of a bad rewrite // string. // @param rewrite The proposed rewrite string. // @param error An error message is recorded here, iff we return false. |