| Index: third_party/protobuf/php/ext/google/protobuf/utf8.c
|
| diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs b/third_party/protobuf/php/ext/google/protobuf/utf8.c
|
| similarity index 56%
|
| copy from third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs
|
| copy to third_party/protobuf/php/ext/google/protobuf/utf8.c
|
| index 6c285410d4b40873a2386367cd54621cf1e1c23a..2752a08b05937e6b1f504c4b6855b47deb7bf766 100644
|
| --- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PartialClasses.cs
|
| +++ b/third_party/protobuf/php/ext/google/protobuf/utf8.c
|
| @@ -1,4 +1,3 @@
|
| -#region Copyright notice and license
|
| // Protocol Buffers - Google's data interchange format
|
| // Copyright 2008 Google Inc. All rights reserved.
|
| // https://developers.google.com/protocol-buffers/
|
| @@ -28,32 +27,42 @@
|
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| -#endregion
|
|
|
| -// This file just contains partial classes for any autogenerated classes that need additional support.
|
| -namespace Google.Protobuf.Reflection
|
| -{
|
| - internal partial class FieldDescriptorProto
|
| - {
|
| - // We can't tell the difference between "explicitly set to 0" and "not set"
|
| - // in proto3, but we need to tell the difference for OneofIndex. descriptor.proto
|
| - // is really a proto2 file, but the runtime doesn't know about proto2 semantics...
|
| - // We fake it by defaulting to -1.
|
| - partial void OnConstruction()
|
| - {
|
| - OneofIndex = -1;
|
| - }
|
| - }
|
| +#include <stdbool.h>
|
| +#include <stdint.h>
|
| +
|
| +#include "utf8.h"
|
| +
|
| +static const uint8_t utf8_offset[] = {
|
| + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
| + 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
| + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
| + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
| + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
| + 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
| + 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0,
|
| +};
|
|
|
| - internal partial class FieldOptions
|
| - {
|
| - // We can't tell the difference between "explicitly set to false" and "not set"
|
| - // in proto3, but we need to tell the difference for FieldDescriptor.IsPacked.
|
| - // This won't work if we ever need to support proto2, but at that point we'll be
|
| - // able to remove this hack and use field presence instead.
|
| - partial void OnConstruction()
|
| - {
|
| - Packed = true;
|
| - }
|
| +bool is_structurally_valid_utf8(const char* buf, int len) {
|
| + int i, j;
|
| + uint8_t offset;
|
| +
|
| + i = 0;
|
| + while (i < len) {
|
| + offset = utf8_offset[(uint8_t)buf[i]];
|
| + if (offset == 0 || i + offset > len) {
|
| + return false;
|
| + }
|
| + for (j = i + 1; j < i + offset; j++) {
|
| + if ((buf[j] & 0xc0) != 0x80) {
|
| + return false;
|
| + }
|
| }
|
| -}
|
| + i += offset;
|
| + }
|
| + return i == len;
|
| +}
|
|
|