Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of intl; | 5 part of intl; |
| 6 /** | 6 /** |
| 7 * Provides the ability to format a number in a locale-specific way. The | 7 * Provides the ability to format a number in a locale-specific way. The |
| 8 * format is specified as a pattern using a subset of the ICU formatting | 8 * format is specified as a pattern using a subset of the ICU formatting |
| 9 * patterns. | 9 * patterns. |
| 10 * | 10 * |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 if (digit != null) { | 703 if (digit != null) { |
| 704 _normalized.writeCharCode(_zero + digit); | 704 _normalized.writeCharCode(_zero + digit); |
| 705 input.next(); | 705 input.next(); |
| 706 } else { | 706 } else { |
| 707 processNonDigit(); | 707 processNonDigit(); |
| 708 } | 708 } |
| 709 checkSuffixes(); | 709 checkSuffixes(); |
| 710 } | 710 } |
| 711 | 711 |
| 712 var normalizedText = _normalized.toString(); | 712 var normalizedText = _normalized.toString(); |
| 713 var parsed = int.parse(normalizedText, onError: (message) => null); | 713 num parsed = int.parse(normalizedText, onError: (message) => null); |
|
Alan Knight
2015/01/27 21:10:18
It's minor but I don't love this. Especially when
| |
| 714 if (parsed == null) parsed = double.parse(normalizedText); | 714 if (parsed == null) parsed = double.parse(normalizedText); |
| 715 return parsed / scale; | 715 return parsed / scale; |
| 716 } | 716 } |
| 717 } | 717 } |
| 718 | 718 |
| 719 /** | 719 /** |
| 720 * Private class that parses the numeric formatting pattern and sets the | 720 * Private class that parses the numeric formatting pattern and sets the |
| 721 * variables in [format] to appropriate values. Instances of this are | 721 * variables in [format] to appropriate values. Instances of this are |
| 722 * transient and store parsing state in instance variables, so can only be used | 722 * transient and store parsing state in instance variables, so can only be used |
| 723 * to parse a single pattern. | 723 * to parse a single pattern. |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1061 String get peek => nextIndex >= input.length ? null : input[nextIndex]; | 1061 String get peek => nextIndex >= input.length ? null : input[nextIndex]; |
| 1062 | 1062 |
| 1063 Iterator<String> get iterator => this; | 1063 Iterator<String> get iterator => this; |
| 1064 | 1064 |
| 1065 static String _validate(input) { | 1065 static String _validate(input) { |
| 1066 if (input is! String) throw new ArgumentError(input); | 1066 if (input is! String) throw new ArgumentError(input); |
| 1067 return input; | 1067 return input; |
| 1068 } | 1068 } |
| 1069 | 1069 |
| 1070 } | 1070 } |
| OLD | NEW |