grpc 1.31.0.pre1 → 1.31.0.pre2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +2 -2
  3. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -4
  4. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +5 -4
  5. data/src/ruby/lib/grpc/version.rb +1 -1
  6. data/third_party/re2/re2/bitmap256.h +117 -0
  7. data/third_party/re2/re2/bitstate.cc +385 -0
  8. data/third_party/re2/re2/compile.cc +1279 -0
  9. data/third_party/re2/re2/dfa.cc +2130 -0
  10. data/third_party/re2/re2/filtered_re2.cc +121 -0
  11. data/third_party/re2/re2/filtered_re2.h +109 -0
  12. data/third_party/re2/re2/mimics_pcre.cc +197 -0
  13. data/third_party/re2/re2/nfa.cc +713 -0
  14. data/third_party/re2/re2/onepass.cc +623 -0
  15. data/third_party/re2/re2/parse.cc +2464 -0
  16. data/third_party/re2/re2/perl_groups.cc +119 -0
  17. data/third_party/re2/re2/pod_array.h +55 -0
  18. data/third_party/re2/re2/prefilter.cc +710 -0
  19. data/third_party/re2/re2/prefilter.h +108 -0
  20. data/third_party/re2/re2/prefilter_tree.cc +407 -0
  21. data/third_party/re2/re2/prefilter_tree.h +139 -0
  22. data/third_party/re2/re2/prog.cc +988 -0
  23. data/third_party/re2/re2/prog.h +436 -0
  24. data/third_party/re2/re2/re2.cc +1362 -0
  25. data/third_party/re2/re2/re2.h +1002 -0
  26. data/third_party/re2/re2/regexp.cc +980 -0
  27. data/third_party/re2/re2/regexp.h +659 -0
  28. data/third_party/re2/re2/set.cc +154 -0
  29. data/third_party/re2/re2/set.h +80 -0
  30. data/third_party/re2/re2/simplify.cc +657 -0
  31. data/third_party/re2/re2/sparse_array.h +392 -0
  32. data/third_party/re2/re2/sparse_set.h +264 -0
  33. data/third_party/re2/re2/stringpiece.cc +65 -0
  34. data/third_party/re2/re2/stringpiece.h +210 -0
  35. data/third_party/re2/re2/tostring.cc +351 -0
  36. data/third_party/re2/re2/unicode_casefold.cc +582 -0
  37. data/third_party/re2/re2/unicode_casefold.h +78 -0
  38. data/third_party/re2/re2/unicode_groups.cc +6269 -0
  39. data/third_party/re2/re2/unicode_groups.h +67 -0
  40. data/third_party/re2/re2/walker-inl.h +246 -0
  41. data/third_party/re2/util/benchmark.h +156 -0
  42. data/third_party/re2/util/flags.h +26 -0
  43. data/third_party/re2/util/logging.h +109 -0
  44. data/third_party/re2/util/malloc_counter.h +19 -0
  45. data/third_party/re2/util/mix.h +41 -0
  46. data/third_party/re2/util/mutex.h +148 -0
  47. data/third_party/re2/util/pcre.cc +1025 -0
  48. data/third_party/re2/util/pcre.h +681 -0
  49. data/third_party/re2/util/rune.cc +260 -0
  50. data/third_party/re2/util/strutil.cc +149 -0
  51. data/third_party/re2/util/strutil.h +21 -0
  52. data/third_party/re2/util/test.h +50 -0
  53. data/third_party/re2/util/utf.h +44 -0
  54. data/third_party/re2/util/util.h +42 -0
  55. metadata +78 -29
@@ -0,0 +1,260 @@
1
+ /*
2
+ * The authors of this software are Rob Pike and Ken Thompson.
3
+ * Copyright (c) 2002 by Lucent Technologies.
4
+ * Permission to use, copy, modify, and distribute this software for any
5
+ * purpose without fee is hereby granted, provided that this entire notice
6
+ * is included in all copies of any software which is or includes a copy
7
+ * or modification of this software and in all copies of the supporting
8
+ * documentation for such software.
9
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
10
+ * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
11
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
12
+ * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
13
+ */
14
+
15
+ #include <stdarg.h>
16
+ #include <string.h>
17
+
18
+ #include "util/utf.h"
19
+
20
+ namespace re2 {
21
+
22
+ enum
23
+ {
24
+ Bit1 = 7,
25
+ Bitx = 6,
26
+ Bit2 = 5,
27
+ Bit3 = 4,
28
+ Bit4 = 3,
29
+ Bit5 = 2,
30
+
31
+ T1 = ((1<<(Bit1+1))-1) ^ 0xFF, /* 0000 0000 */
32
+ Tx = ((1<<(Bitx+1))-1) ^ 0xFF, /* 1000 0000 */
33
+ T2 = ((1<<(Bit2+1))-1) ^ 0xFF, /* 1100 0000 */
34
+ T3 = ((1<<(Bit3+1))-1) ^ 0xFF, /* 1110 0000 */
35
+ T4 = ((1<<(Bit4+1))-1) ^ 0xFF, /* 1111 0000 */
36
+ T5 = ((1<<(Bit5+1))-1) ^ 0xFF, /* 1111 1000 */
37
+
38
+ Rune1 = (1<<(Bit1+0*Bitx))-1, /* 0000 0000 0111 1111 */
39
+ Rune2 = (1<<(Bit2+1*Bitx))-1, /* 0000 0111 1111 1111 */
40
+ Rune3 = (1<<(Bit3+2*Bitx))-1, /* 1111 1111 1111 1111 */
41
+ Rune4 = (1<<(Bit4+3*Bitx))-1,
42
+ /* 0001 1111 1111 1111 1111 1111 */
43
+
44
+ Maskx = (1<<Bitx)-1, /* 0011 1111 */
45
+ Testx = Maskx ^ 0xFF, /* 1100 0000 */
46
+
47
+ Bad = Runeerror,
48
+ };
49
+
50
+ int
51
+ chartorune(Rune *rune, const char *str)
52
+ {
53
+ int c, c1, c2, c3;
54
+ long l;
55
+
56
+ /*
57
+ * one character sequence
58
+ * 00000-0007F => T1
59
+ */
60
+ c = *(unsigned char*)str;
61
+ if(c < Tx) {
62
+ *rune = c;
63
+ return 1;
64
+ }
65
+
66
+ /*
67
+ * two character sequence
68
+ * 0080-07FF => T2 Tx
69
+ */
70
+ c1 = *(unsigned char*)(str+1) ^ Tx;
71
+ if(c1 & Testx)
72
+ goto bad;
73
+ if(c < T3) {
74
+ if(c < T2)
75
+ goto bad;
76
+ l = ((c << Bitx) | c1) & Rune2;
77
+ if(l <= Rune1)
78
+ goto bad;
79
+ *rune = l;
80
+ return 2;
81
+ }
82
+
83
+ /*
84
+ * three character sequence
85
+ * 0800-FFFF => T3 Tx Tx
86
+ */
87
+ c2 = *(unsigned char*)(str+2) ^ Tx;
88
+ if(c2 & Testx)
89
+ goto bad;
90
+ if(c < T4) {
91
+ l = ((((c << Bitx) | c1) << Bitx) | c2) & Rune3;
92
+ if(l <= Rune2)
93
+ goto bad;
94
+ *rune = l;
95
+ return 3;
96
+ }
97
+
98
+ /*
99
+ * four character sequence (21-bit value)
100
+ * 10000-1FFFFF => T4 Tx Tx Tx
101
+ */
102
+ c3 = *(unsigned char*)(str+3) ^ Tx;
103
+ if (c3 & Testx)
104
+ goto bad;
105
+ if (c < T5) {
106
+ l = ((((((c << Bitx) | c1) << Bitx) | c2) << Bitx) | c3) & Rune4;
107
+ if (l <= Rune3)
108
+ goto bad;
109
+ *rune = l;
110
+ return 4;
111
+ }
112
+
113
+ /*
114
+ * Support for 5-byte or longer UTF-8 would go here, but
115
+ * since we don't have that, we'll just fall through to bad.
116
+ */
117
+
118
+ /*
119
+ * bad decoding
120
+ */
121
+ bad:
122
+ *rune = Bad;
123
+ return 1;
124
+ }
125
+
126
+ int
127
+ runetochar(char *str, const Rune *rune)
128
+ {
129
+ /* Runes are signed, so convert to unsigned for range check. */
130
+ unsigned long c;
131
+
132
+ /*
133
+ * one character sequence
134
+ * 00000-0007F => 00-7F
135
+ */
136
+ c = *rune;
137
+ if(c <= Rune1) {
138
+ str[0] = static_cast<char>(c);
139
+ return 1;
140
+ }
141
+
142
+ /*
143
+ * two character sequence
144
+ * 0080-07FF => T2 Tx
145
+ */
146
+ if(c <= Rune2) {
147
+ str[0] = T2 | static_cast<char>(c >> 1*Bitx);
148
+ str[1] = Tx | (c & Maskx);
149
+ return 2;
150
+ }
151
+
152
+ /*
153
+ * If the Rune is out of range, convert it to the error rune.
154
+ * Do this test here because the error rune encodes to three bytes.
155
+ * Doing it earlier would duplicate work, since an out of range
156
+ * Rune wouldn't have fit in one or two bytes.
157
+ */
158
+ if (c > Runemax)
159
+ c = Runeerror;
160
+
161
+ /*
162
+ * three character sequence
163
+ * 0800-FFFF => T3 Tx Tx
164
+ */
165
+ if (c <= Rune3) {
166
+ str[0] = T3 | static_cast<char>(c >> 2*Bitx);
167
+ str[1] = Tx | ((c >> 1*Bitx) & Maskx);
168
+ str[2] = Tx | (c & Maskx);
169
+ return 3;
170
+ }
171
+
172
+ /*
173
+ * four character sequence (21-bit value)
174
+ * 10000-1FFFFF => T4 Tx Tx Tx
175
+ */
176
+ str[0] = T4 | static_cast<char>(c >> 3*Bitx);
177
+ str[1] = Tx | ((c >> 2*Bitx) & Maskx);
178
+ str[2] = Tx | ((c >> 1*Bitx) & Maskx);
179
+ str[3] = Tx | (c & Maskx);
180
+ return 4;
181
+ }
182
+
183
+ int
184
+ runelen(Rune rune)
185
+ {
186
+ char str[10];
187
+
188
+ return runetochar(str, &rune);
189
+ }
190
+
191
+ int
192
+ fullrune(const char *str, int n)
193
+ {
194
+ if (n > 0) {
195
+ int c = *(unsigned char*)str;
196
+ if (c < Tx)
197
+ return 1;
198
+ if (n > 1) {
199
+ if (c < T3)
200
+ return 1;
201
+ if (n > 2) {
202
+ if (c < T4 || n > 3)
203
+ return 1;
204
+ }
205
+ }
206
+ }
207
+ return 0;
208
+ }
209
+
210
+
211
+ int
212
+ utflen(const char *s)
213
+ {
214
+ int c;
215
+ long n;
216
+ Rune rune;
217
+
218
+ n = 0;
219
+ for(;;) {
220
+ c = *(unsigned char*)s;
221
+ if(c < Runeself) {
222
+ if(c == 0)
223
+ return n;
224
+ s++;
225
+ } else
226
+ s += chartorune(&rune, s);
227
+ n++;
228
+ }
229
+ return 0;
230
+ }
231
+
232
+ char*
233
+ utfrune(const char *s, Rune c)
234
+ {
235
+ long c1;
236
+ Rune r;
237
+ int n;
238
+
239
+ if(c < Runesync) /* not part of utf sequence */
240
+ return strchr((char*)s, c);
241
+
242
+ for(;;) {
243
+ c1 = *(unsigned char*)s;
244
+ if(c1 < Runeself) { /* one byte rune */
245
+ if(c1 == 0)
246
+ return 0;
247
+ if(c1 == c)
248
+ return (char*)s;
249
+ s++;
250
+ continue;
251
+ }
252
+ n = chartorune(&r, s);
253
+ if(r == c)
254
+ return (char*)s;
255
+ s += n;
256
+ }
257
+ return 0;
258
+ }
259
+
260
+ } // namespace re2
@@ -0,0 +1,149 @@
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
@@ -0,0 +1,21 @@
1
+ // Copyright 2016 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_STRUTIL_H_
6
+ #define UTIL_STRUTIL_H_
7
+
8
+ #include <string>
9
+
10
+ #include "re2/stringpiece.h"
11
+ #include "util/util.h"
12
+
13
+ namespace re2 {
14
+
15
+ std::string CEscape(const StringPiece& src);
16
+ void PrefixSuccessor(std::string* prefix);
17
+ std::string StringPrintf(const char* format, ...);
18
+
19
+ } // namespace re2
20
+
21
+ #endif // UTIL_STRUTIL_H_
@@ -0,0 +1,50 @@
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_