Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: src/unicode.h

Issue 2391273002: Fix bad-char handling in utf-8 streaming streams. Also add test. (Closed)
Patch Set: Improve comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_UNICODE_H_ 5 #ifndef V8_UNICODE_H_
6 #define V8_UNICODE_H_ 6 #define V8_UNICODE_H_
7 7
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include "src/globals.h" 9 #include "src/globals.h"
10 #include "src/utils.h" 10 #include "src/utils.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 static const unsigned kBytesSavedByCombiningSurrogates = 2; 154 static const unsigned kBytesSavedByCombiningSurrogates = 2;
155 static const unsigned kSizeOfUnmatchedSurrogate = 3; 155 static const unsigned kSizeOfUnmatchedSurrogate = 3;
156 // The maximum size a single UTF-16 code unit may take up when encoded as 156 // The maximum size a single UTF-16 code unit may take up when encoded as
157 // UTF-8. 157 // UTF-8.
158 static const unsigned kMax16BitCodeUnitSize = 3; 158 static const unsigned kMax16BitCodeUnitSize = 3;
159 static inline uchar ValueOf(const byte* str, size_t length, size_t* cursor); 159 static inline uchar ValueOf(const byte* str, size_t length, size_t* cursor);
160 160
161 typedef uint32_t Utf8IncrementalBuffer; 161 typedef uint32_t Utf8IncrementalBuffer;
162 static uchar ValueOfIncremental(byte next_byte, 162 static uchar ValueOfIncremental(byte next_byte,
163 Utf8IncrementalBuffer* buffer); 163 Utf8IncrementalBuffer* buffer);
164 static uchar ValueOfIncrementalFinish(Utf8IncrementalBuffer* buffer);
164 165
165 // Excludes non-characters from the set of valid code points. 166 // Excludes non-characters from the set of valid code points.
166 static inline bool IsValidCharacter(uchar c); 167 static inline bool IsValidCharacter(uchar c);
167 168
168 static bool Validate(const byte* str, size_t length); 169 static bool Validate(const byte* str, size_t length);
169 }; 170 };
170 171
171 struct Uppercase { 172 struct Uppercase {
172 static bool Is(uchar c); 173 static bool Is(uchar c);
173 }; 174 };
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 static const int kMaxWidth = 1; 224 static const int kMaxWidth = 1;
224 static int Convert(uchar c, 225 static int Convert(uchar c,
225 uchar n, 226 uchar n,
226 uchar* result, 227 uchar* result,
227 bool* allow_caching_ptr); 228 bool* allow_caching_ptr);
228 }; 229 };
229 230
230 } // namespace unibrow 231 } // namespace unibrow
231 232
232 #endif // V8_UNICODE_H_ 233 #endif // V8_UNICODE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698