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

Side by Side Diff: third_party/WebKit/Source/platform/text/DecodeEscapeSequences.h

Issue 2811453002: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/text (Closed)
Patch Set: fix Created 3 years, 8 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 /* 1 /*
2 * Copyright (C) 2011 Daniel Bates (dbates@intudata.com). All Rights Reserved. 2 * Copyright (C) 2011 Daniel Bates (dbates@intudata.com). All Rights Reserved.
3 * Copyright (c) 2012 Google, inc. All Rights Reserved. 3 * Copyright (c) 2012 Google, inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const CharType* run_end = run + run_length; 132 const CharType* run_end = run + run_length;
133 while (run < run_end) { 133 while (run < run_end) {
134 if (run[0] == '%') { 134 if (run[0] == '%') {
135 *p++ = (ToASCIIHexValue(run[1]) << 4) | ToASCIIHexValue(run[2]); 135 *p++ = (ToASCIIHexValue(run[1]) << 4) | ToASCIIHexValue(run[2]);
136 run += kSequenceSize; 136 run += kSequenceSize;
137 } else { 137 } else {
138 *p++ = run[0]; 138 *p++ = run[0];
139 run += 1; 139 run += 1;
140 } 140 }
141 } 141 }
142 ASSERT( 142 DCHECK_GE(
143 buffer.size() >= 143 buffer.size(),
144 static_cast<size_t>(p - buffer.Data())); // Prove buffer not overrun. 144 static_cast<size_t>(p - buffer.Data())); // Prove buffer not overrun.
145 return (encoding.IsValid() ? encoding : UTF8Encoding()) 145 return (encoding.IsValid() ? encoding : UTF8Encoding())
146 .Decode(buffer.Data(), p - buffer.Data()); 146 .Decode(buffer.Data(), p - buffer.Data());
147 } 147 }
148 }; 148 };
149 149
150 template <typename EscapeSequence> 150 template <typename EscapeSequence>
151 String DecodeEscapeSequences(const String& string, 151 String DecodeEscapeSequences(const String& string,
152 const WTF::TextEncoding& encoding) { 152 const WTF::TextEncoding& encoding) {
153 StringBuilder result; 153 StringBuilder result;
(...skipping 27 matching lines...) Expand all
181 result.Append(decoded); 181 result.Append(decoded);
182 decoded_position = encoded_run_end; 182 decoded_position = encoded_run_end;
183 } 183 }
184 result.Append(string, decoded_position, length - decoded_position); 184 result.Append(string, decoded_position, length - decoded_position);
185 return result.ToString(); 185 return result.ToString();
186 } 186 }
187 187
188 } // namespace blink 188 } // namespace blink
189 189
190 #endif // DecodeEscapeSequences_h 190 #endif // DecodeEscapeSequences_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/DateTimeFormatTest.cpp ('k') | third_party/WebKit/Source/platform/text/LocaleICU.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698