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 dart.io; | 5 part of dart.io; |
6 | 6 |
7 class _Platform { | 7 class _Platform { |
8 external static int _numberOfProcessors(); | 8 external static int _numberOfProcessors(); |
9 external static String _pathSeparator(); | 9 external static String _pathSeparator(); |
10 external static String _operatingSystem(); | 10 external static String _operatingSystem(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 | 51 |
52 static List<String> get executableArguments => _executableArguments(); | 52 static List<String> get executableArguments => _executableArguments(); |
53 | 53 |
54 static Map<String, String> get environment { | 54 static Map<String, String> get environment { |
55 if (_environmentCache == null) { | 55 if (_environmentCache == null) { |
56 var env = _environment(); | 56 var env = _environment(); |
57 if (env is !OSError) { | 57 if (env is !OSError) { |
58 var isWindows = operatingSystem == 'windows'; | 58 var isWindows = operatingSystem == 'windows'; |
59 var result = isWindows ? new _CaseInsensitiveStringMap() : new Map(); | 59 var result = isWindows ? new _CaseInsensitiveStringMap() : new Map(); |
60 for (var str in env) { | 60 for (var str in env) { |
61 // When running on Windows through cmd.exe there are strange | 61 // When running on Windows through cmd.exe there are strange |
Lasse Reichstein Nielsen
2015/01/05 11:45:43
Remove "strange". They are not strange, just ... m
Søren Gjesse
2015/01/05 12:32:14
Done.
| |
62 // environment variables that are used to record the current | 62 // environment variables that are used to record the current |
63 // working directory for each drive and the exit code for the | 63 // working directory for each drive and the exit code for the |
64 // last command. As an example: '=A:=A:\subdir' records the | 64 // last command. As an example: '=A:=A:\subdir' records the |
65 // current working directory on the 'A' drive. In order to | 65 // current working directory on the 'A' drive. These environment |
66 // handle these correctly we search for a second occurrence of | 66 // variables are ignored. |
67 // of '=' in the string if the first occurrence is at index 0. | 67 // |
68 // On Mac OS an entry of just '=' has been seen. | |
Lasse Reichstein Nielsen
2015/01/05 11:45:43
Add: Entries with no '=' should not happen. If it
Søren Gjesse
2015/01/05 12:32:14
Done.
| |
68 var equalsIndex = str.indexOf('='); | 69 var equalsIndex = str.indexOf('='); |
69 if (equalsIndex == 0) { | 70 if (equalsIndex == 0 || equalsIndex == -1) { |
Lasse Reichstein Nielsen
2015/01/05 11:45:43
equalsIndex <= 0
?
But switch the condition and a
Søren Gjesse
2015/01/05 12:32:14
Done.
| |
70 equalsIndex = str.indexOf('=', 1); | 71 continue; |
71 } | 72 } |
72 assert(equalsIndex != -1); | |
73 result[str.substring(0, equalsIndex)] = | 73 result[str.substring(0, equalsIndex)] = |
74 str.substring(equalsIndex + 1); | 74 str.substring(equalsIndex + 1); |
75 } | 75 } |
76 _environmentCache = new UnmodifiableMapView<String, String>(result); | 76 _environmentCache = new UnmodifiableMapView<String, String>(result); |
77 } else { | 77 } else { |
78 _environmentCache = env; | 78 _environmentCache = env; |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 if (_environmentCache is OSError) { | 82 if (_environmentCache is OSError) { |
(...skipping 26 matching lines...) Expand all Loading... | |
109 V remove(String key) => _map.remove(key.toUpperCase()); | 109 V remove(String key) => _map.remove(key.toUpperCase()); |
110 void clear() => _map.clear(); | 110 void clear() => _map.clear(); |
111 void forEach(void f(String key, V value)) => _map.forEach(f); | 111 void forEach(void f(String key, V value)) => _map.forEach(f); |
112 Iterable<String> get keys => _map.keys; | 112 Iterable<String> get keys => _map.keys; |
113 Iterable<V> get values => _map.values; | 113 Iterable<V> get values => _map.values; |
114 int get length => _map.length; | 114 int get length => _map.length; |
115 bool get isEmpty => _map.isEmpty; | 115 bool get isEmpty => _map.isEmpty; |
116 bool get isNotEmpty => _map.isNotEmpty; | 116 bool get isNotEmpty => _map.isNotEmpty; |
117 String toString() => _map.toString(); | 117 String toString() => _map.toString(); |
118 } | 118 } |
OLD | NEW |