re2 1.19.2 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/.github/actions/linux-alpine-node-16/Dockerfile +1 -1
  2. package/.github/actions/linux-alpine-node-18/Dockerfile +1 -1
  3. package/.github/actions/linux-alpine-node-20/Dockerfile +1 -1
  4. package/.gitmodules +5 -2
  5. package/README.md +1 -0
  6. package/binding.gyp +82 -25
  7. package/lib/replace.cc +4 -4
  8. package/package.json +1 -1
  9. package/tsconfig.json +2 -1
  10. package/vendor/re2/.bazelrc +16 -0
  11. package/vendor/re2/.github/bazel.sh +24 -0
  12. package/vendor/re2/.github/cmake.sh +12 -0
  13. package/vendor/re2/.github/workflows/ci-bazel.yml +17 -0
  14. package/vendor/re2/.github/workflows/ci-cmake.yml +108 -0
  15. package/vendor/re2/.github/workflows/ci.yml +89 -0
  16. package/vendor/re2/.github/workflows/pr.yml +26 -0
  17. package/vendor/re2/.github/workflows/python.yml +185 -0
  18. package/vendor/re2/AUTHORS +13 -0
  19. package/vendor/re2/BUILD.bazel +280 -0
  20. package/vendor/re2/CMakeLists.txt +268 -0
  21. package/vendor/re2/CONTRIBUTING.md +2 -0
  22. package/vendor/re2/CONTRIBUTORS +41 -0
  23. package/vendor/re2/Makefile +400 -0
  24. package/vendor/{README → re2/README} +5 -0
  25. package/vendor/re2/SECURITY.md +4 -0
  26. package/vendor/re2/WORKSPACE.bazel +62 -0
  27. package/vendor/re2/app/BUILD.bazel +19 -0
  28. package/vendor/re2/app/_re2.cc +94 -0
  29. package/vendor/re2/app/_re2.d.ts +23 -0
  30. package/vendor/re2/app/app.ts +111 -0
  31. package/vendor/re2/app/build.sh +50 -0
  32. package/vendor/re2/app/index.html +5 -0
  33. package/vendor/re2/app/package.json +14 -0
  34. package/vendor/re2/app/rollup.config.js +28 -0
  35. package/vendor/re2/app/tsconfig.json +17 -0
  36. package/vendor/re2/benchlog/benchplot.py +98 -0
  37. package/vendor/re2/benchlog/mktable +155 -0
  38. package/vendor/re2/doc/mksyntaxgo +42 -0
  39. package/vendor/re2/doc/mksyntaxhtml +42 -0
  40. package/vendor/re2/doc/mksyntaxwiki +36 -0
  41. package/vendor/re2/doc/syntax.html +477 -0
  42. package/vendor/re2/doc/syntax.txt +463 -0
  43. package/vendor/re2/lib/git/commit-msg.hook +104 -0
  44. package/vendor/re2/libre2.symbols +19 -0
  45. package/vendor/re2/libre2.symbols.darwin +15 -0
  46. package/vendor/re2/python/BUILD.bazel +36 -0
  47. package/vendor/re2/python/README +1 -0
  48. package/vendor/re2/python/_re2.cc +338 -0
  49. package/vendor/re2/python/re2.py +582 -0
  50. package/vendor/re2/python/re2_test.py +482 -0
  51. package/vendor/re2/python/setup.py +105 -0
  52. package/vendor/re2/{bitmap256.cc → re2/bitmap256.cc} +4 -4
  53. package/vendor/re2/{bitstate.cc → re2/bitstate.cc} +21 -25
  54. package/vendor/re2/{compile.cc → re2/compile.cc} +5 -4
  55. package/vendor/re2/{dfa.cc → re2/dfa.cc} +120 -101
  56. package/vendor/re2/{filtered_re2.cc → re2/filtered_re2.cc} +8 -11
  57. package/vendor/re2/{filtered_re2.h → re2/filtered_re2.h} +5 -4
  58. package/vendor/re2/{fuzzing → re2/fuzzing}/re2_fuzzer.cc +4 -6
  59. package/vendor/re2/{mimics_pcre.cc → re2/mimics_pcre.cc} +0 -1
  60. package/vendor/re2/{nfa.cc → re2/nfa.cc} +34 -37
  61. package/vendor/re2/{onepass.cc → re2/onepass.cc} +25 -27
  62. package/vendor/re2/{parse.cc → re2/parse.cc} +118 -121
  63. package/vendor/re2/{prefilter.cc → re2/prefilter.cc} +2 -3
  64. package/vendor/re2/{prefilter.h → re2/prefilter.h} +0 -1
  65. package/vendor/re2/{prefilter_tree.cc → re2/prefilter_tree.cc} +4 -5
  66. package/vendor/re2/{prefilter_tree.h → re2/prefilter_tree.h} +1 -2
  67. package/vendor/re2/{prog.cc → re2/prog.cc} +20 -21
  68. package/vendor/re2/{prog.h → re2/prog.h} +21 -22
  69. package/vendor/re2/{re2.cc → re2/re2.cc} +51 -62
  70. package/vendor/re2/{re2.h → re2/re2.h} +78 -40
  71. package/vendor/re2/{regexp.cc → re2/regexp.cc} +11 -12
  72. package/vendor/re2/{regexp.h → re2/regexp.h} +9 -10
  73. package/vendor/re2/{set.cc → re2/set.cc} +3 -5
  74. package/vendor/re2/{set.h → re2/set.h} +4 -3
  75. package/vendor/re2/{simplify.cc → re2/simplify.cc} +1 -2
  76. package/vendor/re2/re2/stringpiece.h +24 -0
  77. package/vendor/re2/{testing → re2/testing}/backtrack.cc +22 -25
  78. package/vendor/re2/{testing → re2/testing}/charclass_test.cc +23 -21
  79. package/vendor/re2/{testing → re2/testing}/compile_test.cc +5 -4
  80. package/vendor/re2/{testing → re2/testing}/dfa_test.cc +36 -30
  81. package/vendor/re2/{testing → re2/testing}/dump.cc +8 -8
  82. package/vendor/re2/{testing → re2/testing}/exhaustive1_test.cc +1 -1
  83. package/vendor/re2/{testing → re2/testing}/exhaustive2_test.cc +1 -1
  84. package/vendor/re2/{testing → re2/testing}/exhaustive3_test.cc +1 -1
  85. package/vendor/re2/{testing → re2/testing}/exhaustive_test.cc +1 -1
  86. package/vendor/re2/{testing → re2/testing}/exhaustive_tester.cc +36 -32
  87. package/vendor/re2/{testing → re2/testing}/exhaustive_tester.h +0 -1
  88. package/vendor/re2/{testing → re2/testing}/filtered_re2_test.cc +9 -8
  89. package/vendor/re2/{testing → re2/testing}/mimics_pcre_test.cc +3 -2
  90. package/vendor/re2/{testing → re2/testing}/null_walker.cc +1 -1
  91. package/vendor/re2/{testing → re2/testing}/parse_test.cc +13 -12
  92. package/vendor/re2/{testing → re2/testing}/possible_match_test.cc +15 -14
  93. package/vendor/re2/{testing → re2/testing}/random_test.cc +13 -12
  94. package/vendor/re2/{testing → re2/testing}/re2_arg_test.cc +25 -2
  95. package/vendor/re2/{testing → re2/testing}/re2_test.cc +49 -47
  96. package/vendor/re2/{testing → re2/testing}/regexp_benchmark.cc +144 -145
  97. package/vendor/re2/{testing → re2/testing}/regexp_generator.cc +18 -14
  98. package/vendor/re2/{testing → re2/testing}/regexp_generator.h +3 -4
  99. package/vendor/re2/{testing → re2/testing}/regexp_test.cc +1 -1
  100. package/vendor/re2/{testing → re2/testing}/required_prefix_test.cc +5 -4
  101. package/vendor/re2/{testing → re2/testing}/search_test.cc +3 -2
  102. package/vendor/re2/{testing → re2/testing}/set_test.cc +1 -1
  103. package/vendor/re2/{testing → re2/testing}/simplify_test.cc +3 -2
  104. package/vendor/re2/{testing → re2/testing}/string_generator.cc +3 -3
  105. package/vendor/re2/{testing → re2/testing}/string_generator.h +5 -6
  106. package/vendor/re2/{testing → re2/testing}/string_generator_test.cc +2 -2
  107. package/vendor/re2/{testing → re2/testing}/tester.cc +77 -78
  108. package/vendor/re2/{testing → re2/testing}/tester.h +13 -15
  109. package/vendor/re2/{tostring.cc → re2/tostring.cc} +7 -8
  110. package/vendor/re2/{unicode_casefold.h → re2/unicode_casefold.h} +0 -1
  111. package/vendor/re2/{unicode_groups.h → re2/unicode_groups.h} +0 -1
  112. package/vendor/re2/{walker-inl.h → re2/walker-inl.h} +2 -1
  113. package/vendor/re2/re2.pc.in +9 -0
  114. package/vendor/re2/re2Config.cmake.in +28 -0
  115. package/vendor/re2/runtests +33 -0
  116. package/vendor/re2/testinstall.cc +27 -0
  117. package/vendor/re2/ucs2.diff +567 -0
  118. package/vendor/{util → re2/util}/logging.h +2 -2
  119. package/vendor/{util → re2/util}/pcre.cc +47 -116
  120. package/vendor/{util → re2/util}/pcre.h +53 -63
  121. package/vendor/re2/util/strutil.cc +26 -0
  122. package/vendor/{util → re2/util}/strutil.h +0 -5
  123. package/vendor/re2/stringpiece.cc +0 -65
  124. package/vendor/re2/stringpiece.h +0 -213
  125. package/vendor/util/benchmark.cc +0 -131
  126. package/vendor/util/benchmark.h +0 -156
  127. package/vendor/util/flags.h +0 -26
  128. package/vendor/util/mix.h +0 -41
  129. package/vendor/util/mutex.h +0 -164
  130. package/vendor/util/strutil.cc +0 -149
  131. package/vendor/util/test.cc +0 -34
  132. package/vendor/util/test.h +0 -50
  133. package/vendor/util/util.h +0 -42
  134. /package/vendor/{LICENSE → re2/LICENSE} +0 -0
  135. /package/vendor/re2/{bitmap256.h → re2/bitmap256.h} +0 -0
  136. /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/LICENSE +0 -0
  137. /package/vendor/re2/{fuzzing → re2/fuzzing}/compiler-rt/include/fuzzer/FuzzedDataProvider.h +0 -0
  138. /package/vendor/re2/{make_perl_groups.pl → re2/make_perl_groups.pl} +0 -0
  139. /package/vendor/re2/{make_unicode_casefold.py → re2/make_unicode_casefold.py} +0 -0
  140. /package/vendor/re2/{make_unicode_groups.py → re2/make_unicode_groups.py} +0 -0
  141. /package/vendor/re2/{perl_groups.cc → re2/perl_groups.cc} +0 -0
  142. /package/vendor/re2/{pod_array.h → re2/pod_array.h} +0 -0
  143. /package/vendor/re2/{sparse_array.h → re2/sparse_array.h} +0 -0
  144. /package/vendor/re2/{sparse_set.h → re2/sparse_set.h} +0 -0
  145. /package/vendor/re2/{unicode.py → re2/unicode.py} +0 -0
  146. /package/vendor/re2/{unicode_casefold.cc → re2/unicode_casefold.cc} +0 -0
  147. /package/vendor/re2/{unicode_groups.cc → re2/unicode_groups.cc} +0 -0
  148. /package/vendor/{util → re2/util}/fuzz.cc +0 -0
  149. /package/vendor/{util → re2/util}/malloc_counter.h +0 -0
  150. /package/vendor/{util → re2/util}/rune.cc +0 -0
  151. /package/vendor/{util → re2/util}/utf.h +0 -0
@@ -1,164 +0,0 @@
1
- // Copyright 2007 The RE2 Authors. All Rights Reserved.
2
- // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
4
-
5
- #ifndef UTIL_MUTEX_H_
6
- #define UTIL_MUTEX_H_
7
-
8
- /*
9
- * A simple mutex wrapper, supporting locks and read-write locks.
10
- * You should assume the locks are *not* re-entrant.
11
- */
12
-
13
- #ifdef RE2_NO_THREADS
14
- #include <assert.h>
15
- #define MUTEX_IS_LOCK_COUNTER
16
- #else
17
- #ifdef _WIN32
18
- // Requires Windows Vista or Windows Server 2008 at minimum.
19
- #include <windows.h>
20
- #if defined(WINVER) && WINVER >= 0x0600
21
- #define MUTEX_IS_WIN32_SRWLOCK
22
- #endif
23
- #else
24
- #ifndef _POSIX_C_SOURCE
25
- #define _POSIX_C_SOURCE 200809L
26
- #endif
27
- #include <unistd.h>
28
- #if defined(_POSIX_READER_WRITER_LOCKS) && _POSIX_READER_WRITER_LOCKS > 0
29
- #define MUTEX_IS_PTHREAD_RWLOCK
30
- #endif
31
- #endif
32
- #endif
33
-
34
- #if defined(MUTEX_IS_LOCK_COUNTER)
35
- typedef int MutexType;
36
- #elif defined(MUTEX_IS_WIN32_SRWLOCK)
37
- typedef SRWLOCK MutexType;
38
- #elif defined(MUTEX_IS_PTHREAD_RWLOCK)
39
- #include <pthread.h>
40
- #include <stdlib.h>
41
- typedef pthread_rwlock_t MutexType;
42
- #else
43
- #include <shared_mutex>
44
- typedef std::shared_mutex MutexType;
45
- #endif
46
-
47
- namespace re2 {
48
-
49
- class Mutex {
50
- public:
51
- inline Mutex();
52
- inline ~Mutex();
53
- inline void Lock(); // Block if needed until free then acquire exclusively
54
- inline void Unlock(); // Release a lock acquired via Lock()
55
- // Note that on systems that don't support read-write locks, these may
56
- // be implemented as synonyms to Lock() and Unlock(). So you can use
57
- // these for efficiency, but don't use them anyplace where being able
58
- // to do shared reads is necessary to avoid deadlock.
59
- inline void ReaderLock(); // Block until free or shared then acquire a share
60
- inline void ReaderUnlock(); // Release a read share of this Mutex
61
- inline void WriterLock() { Lock(); } // Acquire an exclusive lock
62
- inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock()
63
-
64
- private:
65
- MutexType mutex_;
66
-
67
- // Catch the error of writing Mutex when intending MutexLock.
68
- Mutex(Mutex *ignored);
69
-
70
- Mutex(const Mutex&) = delete;
71
- Mutex& operator=(const Mutex&) = delete;
72
- };
73
-
74
- #if defined(MUTEX_IS_LOCK_COUNTER)
75
-
76
- Mutex::Mutex() : mutex_(0) { }
77
- Mutex::~Mutex() { assert(mutex_ == 0); }
78
- void Mutex::Lock() { assert(--mutex_ == -1); }
79
- void Mutex::Unlock() { assert(mutex_++ == -1); }
80
- void Mutex::ReaderLock() { assert(++mutex_ > 0); }
81
- void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
82
-
83
- #elif defined(MUTEX_IS_WIN32_SRWLOCK)
84
-
85
- Mutex::Mutex() : mutex_(SRWLOCK_INIT) { }
86
- Mutex::~Mutex() { }
87
- void Mutex::Lock() { AcquireSRWLockExclusive(&mutex_); }
88
- void Mutex::Unlock() { ReleaseSRWLockExclusive(&mutex_); }
89
- void Mutex::ReaderLock() { AcquireSRWLockShared(&mutex_); }
90
- void Mutex::ReaderUnlock() { ReleaseSRWLockShared(&mutex_); }
91
-
92
- #elif defined(MUTEX_IS_PTHREAD_RWLOCK)
93
-
94
- #define SAFE_PTHREAD(fncall) \
95
- do { \
96
- if ((fncall) != 0) abort(); \
97
- } while (0)
98
-
99
- Mutex::Mutex() { SAFE_PTHREAD(pthread_rwlock_init(&mutex_, NULL)); }
100
- Mutex::~Mutex() { SAFE_PTHREAD(pthread_rwlock_destroy(&mutex_)); }
101
- void Mutex::Lock() { SAFE_PTHREAD(pthread_rwlock_wrlock(&mutex_)); }
102
- void Mutex::Unlock() { SAFE_PTHREAD(pthread_rwlock_unlock(&mutex_)); }
103
- void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock(&mutex_)); }
104
- void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock(&mutex_)); }
105
-
106
- #undef SAFE_PTHREAD
107
-
108
- #else
109
-
110
- Mutex::Mutex() { }
111
- Mutex::~Mutex() { }
112
- void Mutex::Lock() { mutex_.lock(); }
113
- void Mutex::Unlock() { mutex_.unlock(); }
114
- void Mutex::ReaderLock() { mutex_.lock_shared(); }
115
- void Mutex::ReaderUnlock() { mutex_.unlock_shared(); }
116
-
117
- #endif
118
-
119
- // --------------------------------------------------------------------------
120
- // Some helper classes
121
-
122
- // MutexLock(mu) acquires mu when constructed and releases it when destroyed.
123
- class MutexLock {
124
- public:
125
- explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
126
- ~MutexLock() { mu_->Unlock(); }
127
- private:
128
- Mutex * const mu_;
129
-
130
- MutexLock(const MutexLock&) = delete;
131
- MutexLock& operator=(const MutexLock&) = delete;
132
- };
133
-
134
- // ReaderMutexLock and WriterMutexLock do the same, for rwlocks
135
- class ReaderMutexLock {
136
- public:
137
- explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
138
- ~ReaderMutexLock() { mu_->ReaderUnlock(); }
139
- private:
140
- Mutex * const mu_;
141
-
142
- ReaderMutexLock(const ReaderMutexLock&) = delete;
143
- ReaderMutexLock& operator=(const ReaderMutexLock&) = delete;
144
- };
145
-
146
- class WriterMutexLock {
147
- public:
148
- explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); }
149
- ~WriterMutexLock() { mu_->WriterUnlock(); }
150
- private:
151
- Mutex * const mu_;
152
-
153
- WriterMutexLock(const WriterMutexLock&) = delete;
154
- WriterMutexLock& operator=(const WriterMutexLock&) = delete;
155
- };
156
-
157
- // Catch bug where variable name is omitted, e.g. MutexLock (&mu);
158
- #define MutexLock(x) static_assert(false, "MutexLock declaration missing variable name")
159
- #define ReaderMutexLock(x) static_assert(false, "ReaderMutexLock declaration missing variable name")
160
- #define WriterMutexLock(x) static_assert(false, "WriterMutexLock declaration missing variable name")
161
-
162
- } // namespace re2
163
-
164
- #endif // UTIL_MUTEX_H_
@@ -1,149 +0,0 @@
1
- // Copyright 1999-2005 The RE2 Authors. All Rights Reserved.
2
- // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
4
-
5
- #include <stdarg.h>
6
- #include <stdio.h>
7
-
8
- #include "util/strutil.h"
9
-
10
- #ifdef _WIN32
11
- #define snprintf _snprintf
12
- #define vsnprintf _vsnprintf
13
- #endif
14
-
15
- namespace re2 {
16
-
17
- // ----------------------------------------------------------------------
18
- // CEscapeString()
19
- // Copies 'src' to 'dest', escaping dangerous characters using
20
- // C-style escape sequences. 'src' and 'dest' should not overlap.
21
- // Returns the number of bytes written to 'dest' (not including the \0)
22
- // or (size_t)-1 if there was insufficient space.
23
- // ----------------------------------------------------------------------
24
- static size_t CEscapeString(const char* src, size_t src_len,
25
- char* dest, size_t dest_len) {
26
- const char* src_end = src + src_len;
27
- size_t used = 0;
28
-
29
- for (; src < src_end; src++) {
30
- if (dest_len - used < 2) // space for two-character escape
31
- return (size_t)-1;
32
-
33
- unsigned char c = *src;
34
- switch (c) {
35
- case '\n': dest[used++] = '\\'; dest[used++] = 'n'; break;
36
- case '\r': dest[used++] = '\\'; dest[used++] = 'r'; break;
37
- case '\t': dest[used++] = '\\'; dest[used++] = 't'; break;
38
- case '\"': dest[used++] = '\\'; dest[used++] = '\"'; break;
39
- case '\'': dest[used++] = '\\'; dest[used++] = '\''; break;
40
- case '\\': dest[used++] = '\\'; dest[used++] = '\\'; break;
41
- default:
42
- // Note that if we emit \xNN and the src character after that is a hex
43
- // digit then that digit must be escaped too to prevent it being
44
- // interpreted as part of the character code by C.
45
- if (c < ' ' || c > '~') {
46
- if (dest_len - used < 5) // space for four-character escape + \0
47
- return (size_t)-1;
48
- snprintf(dest + used, 5, "\\%03o", c);
49
- used += 4;
50
- } else {
51
- dest[used++] = c; break;
52
- }
53
- }
54
- }
55
-
56
- if (dest_len - used < 1) // make sure that there is room for \0
57
- return (size_t)-1;
58
-
59
- dest[used] = '\0'; // doesn't count towards return value though
60
- return used;
61
- }
62
-
63
- // ----------------------------------------------------------------------
64
- // CEscape()
65
- // Copies 'src' to result, escaping dangerous characters using
66
- // C-style escape sequences. 'src' and 'dest' should not overlap.
67
- // ----------------------------------------------------------------------
68
- std::string CEscape(const StringPiece& src) {
69
- const size_t dest_len = src.size() * 4 + 1; // Maximum possible expansion
70
- char* dest = new char[dest_len];
71
- const size_t used = CEscapeString(src.data(), src.size(),
72
- dest, dest_len);
73
- std::string s = std::string(dest, used);
74
- delete[] dest;
75
- return s;
76
- }
77
-
78
- void PrefixSuccessor(std::string* prefix) {
79
- // We can increment the last character in the string and be done
80
- // unless that character is 255, in which case we have to erase the
81
- // last character and increment the previous character, unless that
82
- // is 255, etc. If the string is empty or consists entirely of
83
- // 255's, we just return the empty string.
84
- while (!prefix->empty()) {
85
- char& c = prefix->back();
86
- if (c == '\xff') { // char literal avoids signed/unsigned.
87
- prefix->pop_back();
88
- } else {
89
- ++c;
90
- break;
91
- }
92
- }
93
- }
94
-
95
- static void StringAppendV(std::string* dst, const char* format, va_list ap) {
96
- // First try with a small fixed size buffer
97
- char space[1024];
98
-
99
- // It's possible for methods that use a va_list to invalidate
100
- // the data in it upon use. The fix is to make a copy
101
- // of the structure before using it and use that copy instead.
102
- va_list backup_ap;
103
- va_copy(backup_ap, ap);
104
- int result = vsnprintf(space, sizeof(space), format, backup_ap);
105
- va_end(backup_ap);
106
-
107
- if ((result >= 0) && (static_cast<size_t>(result) < sizeof(space))) {
108
- // It fit
109
- dst->append(space, result);
110
- return;
111
- }
112
-
113
- // Repeatedly increase buffer size until it fits
114
- int length = sizeof(space);
115
- while (true) {
116
- if (result < 0) {
117
- // Older behavior: just try doubling the buffer size
118
- length *= 2;
119
- } else {
120
- // We need exactly "result+1" characters
121
- length = result+1;
122
- }
123
- char* buf = new char[length];
124
-
125
- // Restore the va_list before we use it again
126
- va_copy(backup_ap, ap);
127
- result = vsnprintf(buf, length, format, backup_ap);
128
- va_end(backup_ap);
129
-
130
- if ((result >= 0) && (result < length)) {
131
- // It fit
132
- dst->append(buf, result);
133
- delete[] buf;
134
- return;
135
- }
136
- delete[] buf;
137
- }
138
- }
139
-
140
- std::string StringPrintf(const char* format, ...) {
141
- va_list ap;
142
- va_start(ap, format);
143
- std::string result;
144
- StringAppendV(&result, format, ap);
145
- va_end(ap);
146
- return result;
147
- }
148
-
149
- } // namespace re2
@@ -1,34 +0,0 @@
1
- // Copyright 2009 The RE2 Authors. All Rights Reserved.
2
- // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
4
-
5
- #include <stdio.h>
6
- #include <string>
7
-
8
- #include "util/test.h"
9
-
10
- namespace testing {
11
- std::string TempDir() { return "/tmp/"; }
12
- } // namespace testing
13
-
14
- struct Test {
15
- void (*fn)(void);
16
- const char *name;
17
- };
18
-
19
- static Test tests[10000];
20
- static int ntests;
21
-
22
- void RegisterTest(void (*fn)(void), const char *name) {
23
- tests[ntests].fn = fn;
24
- tests[ntests++].name = name;
25
- }
26
-
27
- int main(int argc, char** argv) {
28
- for (int i = 0; i < ntests; i++) {
29
- printf("%s\n", tests[i].name);
30
- tests[i].fn();
31
- }
32
- printf("PASS\n");
33
- return 0;
34
- }
@@ -1,50 +0,0 @@
1
- // Copyright 2009 The RE2 Authors. All Rights Reserved.
2
- // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
4
-
5
- #ifndef UTIL_TEST_H_
6
- #define UTIL_TEST_H_
7
-
8
- #include "util/util.h"
9
- #include "util/logging.h"
10
-
11
- namespace testing {
12
- std::string TempDir();
13
- } // namespace testing
14
-
15
- #define TEST(x, y) \
16
- void x##y(void); \
17
- TestRegisterer r##x##y(x##y, # x "." # y); \
18
- void x##y(void)
19
-
20
- void RegisterTest(void (*)(void), const char*);
21
-
22
- class TestRegisterer {
23
- public:
24
- TestRegisterer(void (*fn)(void), const char *s) {
25
- RegisterTest(fn, s);
26
- }
27
- };
28
-
29
- // fatal assertions
30
- #define ASSERT_TRUE CHECK
31
- #define ASSERT_FALSE(x) CHECK(!(x))
32
- #define ASSERT_EQ CHECK_EQ
33
- #define ASSERT_NE CHECK_NE
34
- #define ASSERT_LT CHECK_LT
35
- #define ASSERT_LE CHECK_LE
36
- #define ASSERT_GT CHECK_GT
37
- #define ASSERT_GE CHECK_GE
38
-
39
- // nonfatal assertions
40
- // TODO(rsc): Do a better job?
41
- #define EXPECT_TRUE CHECK
42
- #define EXPECT_FALSE(x) CHECK(!(x))
43
- #define EXPECT_EQ CHECK_EQ
44
- #define EXPECT_NE CHECK_NE
45
- #define EXPECT_LT CHECK_LT
46
- #define EXPECT_LE CHECK_LE
47
- #define EXPECT_GT CHECK_GT
48
- #define EXPECT_GE CHECK_GE
49
-
50
- #endif // UTIL_TEST_H_
@@ -1,42 +0,0 @@
1
- // Copyright 2009 The RE2 Authors. All Rights Reserved.
2
- // Use of this source code is governed by a BSD-style
3
- // license that can be found in the LICENSE file.
4
-
5
- #ifndef UTIL_UTIL_H_
6
- #define UTIL_UTIL_H_
7
-
8
- #define arraysize(array) (sizeof(array)/sizeof((array)[0]))
9
-
10
- #ifndef ATTRIBUTE_NORETURN
11
- #if defined(__GNUC__)
12
- #define ATTRIBUTE_NORETURN __attribute__((noreturn))
13
- #elif defined(_MSC_VER)
14
- #define ATTRIBUTE_NORETURN __declspec(noreturn)
15
- #else
16
- #define ATTRIBUTE_NORETURN
17
- #endif
18
- #endif
19
-
20
- #ifndef ATTRIBUTE_UNUSED
21
- #if defined(__GNUC__)
22
- #define ATTRIBUTE_UNUSED __attribute__((unused))
23
- #else
24
- #define ATTRIBUTE_UNUSED
25
- #endif
26
- #endif
27
-
28
- #ifndef FALLTHROUGH_INTENDED
29
- #if defined(__clang__)
30
- #define FALLTHROUGH_INTENDED [[clang::fallthrough]]
31
- #elif defined(__GNUC__) && __GNUC__ >= 7
32
- #define FALLTHROUGH_INTENDED [[gnu::fallthrough]]
33
- #else
34
- #define FALLTHROUGH_INTENDED do {} while (0)
35
- #endif
36
- #endif
37
-
38
- #ifndef NO_THREAD_SAFETY_ANALYSIS
39
- #define NO_THREAD_SAFETY_ANALYSIS
40
- #endif
41
-
42
- #endif // UTIL_UTIL_H_
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes