OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library fasta.quote; | 5 library fasta.quote; |
6 | 6 |
7 import 'errors.dart' show | 7 import 'errors.dart' show |
8 inputError, | 8 inputError, |
9 internalError; | 9 internalError; |
10 | 10 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 code = 0; | 211 code = 0; |
212 for (int j = 0; j < 7; j++) { | 212 for (int j = 0; j < 7; j++) { |
213 if (codeUnits.length == ++i) return error(i, incompleteSequence); | 213 if (codeUnits.length == ++i) return error(i, incompleteSequence); |
214 int digit = codeUnits[i]; | 214 int digit = codeUnits[i]; |
215 if (j != 0 && digit == $CLOSE_CURLY_BRACKET) break; | 215 if (j != 0 && digit == $CLOSE_CURLY_BRACKET) break; |
216 if (!isHexDigit(digit)) return error(i, invalidCharacter); | 216 if (!isHexDigit(digit)) return error(i, invalidCharacter); |
217 code = (code << 4) + hexDigitValue(digit); | 217 code = (code << 4) + hexDigitValue(digit); |
218 } | 218 } |
219 } else { | 219 } else { |
220 // Expect exactly 4 hex digits. | 220 // Expect exactly 4 hex digits. |
221 if (codeUnits.length < i + 4) return error(i, incompleteSequence); | 221 if (codeUnits.length <= i + 4) return error(i, incompleteSequence); |
222 code = 0; | 222 code = 0; |
223 for (int j = 0; j < 4; j++) { | 223 for (int j = 0; j < 4; j++) { |
224 int digit = codeUnits[i]; | 224 int digit = codeUnits[++i]; |
225 if (!isHexDigit(digit)) return error(i, invalidCharacter); | 225 if (!isHexDigit(digit)) return error(i, invalidCharacter); |
226 code = (code << 4) + hexDigitValue(digit); | 226 code = (code << 4) + hexDigitValue(digit); |
227 } | 227 } |
228 } | 228 } |
229 } else { | 229 } else { |
230 // Nothing, escaped character is passed through; | 230 // Nothing, escaped character is passed through; |
231 } | 231 } |
232 if (code > 0x10FFFF) return error(i, invalidCodePoint); | 232 if (code > 0x10FFFF) return error(i, invalidCodePoint); |
233 } | 233 } |
234 result[resultOffset++] = code; | 234 result[resultOffset++] = code; |
235 } | 235 } |
236 return new String.fromCharCodes(result, 0, resultOffset); | 236 return new String.fromCharCodes(result, 0, resultOffset); |
237 } | 237 } |
OLD | NEW |