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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
6 | 6 |
7 #include "bin/platform.h" | 7 #include "bin/platform.h" |
8 | 8 |
9 #include "bin/file.h" | 9 #include "bin/file.h" |
10 #include "bin/utils.h" | 10 #include "bin/utils.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (env == NULL) { | 96 if (env == NULL) { |
97 OSError error(-1, | 97 OSError error(-1, |
98 "Failed to retrieve environment variables.", | 98 "Failed to retrieve environment variables.", |
99 OSError::kUnknown); | 99 OSError::kUnknown); |
100 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); | 100 Dart_SetReturnValue(args, DartUtils::NewDartOSError(&error)); |
101 } else { | 101 } else { |
102 Dart_Handle result = Dart_NewList(count); | 102 Dart_Handle result = Dart_NewList(count); |
103 if (Dart_IsError(result)) { | 103 if (Dart_IsError(result)) { |
104 Dart_PropagateError(result); | 104 Dart_PropagateError(result); |
105 } | 105 } |
106 for (intptr_t i = 0; i < count; i++) { | 106 intptr_t result_idx = 0; |
107 Dart_Handle str = DartUtils::NewString(env[i]); | 107 for (intptr_t env_idx = 0; env_idx < count; env_idx++) { |
| 108 Dart_Handle str = DartUtils::NewString(env[env_idx]); |
108 if (Dart_IsError(str)) { | 109 if (Dart_IsError(str)) { |
109 Dart_PropagateError(str); | 110 // Silently skip over environment entries that are not valid UTF8 |
| 111 // strings. |
| 112 continue; |
110 } | 113 } |
111 Dart_Handle error = Dart_ListSetAt(result, i, str); | 114 Dart_Handle error = Dart_ListSetAt(result, result_idx, str); |
112 if (Dart_IsError(error)) { | 115 if (Dart_IsError(error)) { |
113 Dart_PropagateError(error); | 116 Dart_PropagateError(error); |
114 } | 117 } |
| 118 result_idx++; |
115 } | 119 } |
116 Dart_SetReturnValue(args, result); | 120 Dart_SetReturnValue(args, result); |
117 } | 121 } |
118 } | 122 } |
119 | 123 |
120 | 124 |
121 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { | 125 void FUNCTION_NAME(Platform_GetVersion)(Dart_NativeArguments args) { |
122 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); | 126 Dart_SetReturnValue(args, Dart_NewStringFromCString(Dart_VersionString())); |
123 } | 127 } |
124 | 128 |
125 } // namespace bin | 129 } // namespace bin |
126 } // namespace dart | 130 } // namespace dart |
127 | 131 |
128 #endif // !defined(DART_IO_DISABLED) | 132 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |