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

Unified Diff: runtime/bin/stdio.cc

Issue 2585443002: Error checking for Stdio calls (Closed)
Patch Set: Fix Windows Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/stdio.h ('k') | runtime/bin/stdio_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/stdio.cc
diff --git a/runtime/bin/stdio.cc b/runtime/bin/stdio.cc
index 47bd55478ee8f7fbf913abfc7e4daaa20d50be29..aa1c7c2288c52709efa432481f3bd31c5bea08cf 100644
--- a/runtime/bin/stdio.cc
+++ b/runtime/bin/stdio.cc
@@ -20,29 +20,52 @@ namespace bin {
void FUNCTION_NAME(Stdin_ReadByte)(Dart_NativeArguments args) {
ScopedBlockingCall blocker;
- Dart_SetReturnValue(args, Dart_NewInteger(Stdin::ReadByte()));
+ int byte = -1;
+ if (Stdin::ReadByte(&byte)) {
+ Dart_SetReturnValue(args, Dart_NewInteger(byte));
+ } else {
+ Dart_SetReturnValue(args, DartUtils::NewDartOSError());
+ }
}
void FUNCTION_NAME(Stdin_GetEchoMode)(Dart_NativeArguments args) {
- Dart_SetReturnValue(args, Dart_NewBoolean(Stdin::GetEchoMode()));
+ bool enabled = false;
+ if (Stdin::GetEchoMode(&enabled)) {
+ Dart_SetReturnValue(args, Dart_NewBoolean(enabled));
+ } else {
+ Dart_SetReturnValue(args, DartUtils::NewDartOSError());
+ }
}
void FUNCTION_NAME(Stdin_SetEchoMode)(Dart_NativeArguments args) {
bool enabled = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 0));
- Stdin::SetEchoMode(enabled);
+ if (Stdin::SetEchoMode(enabled)) {
+ Dart_SetReturnValue(args, Dart_True());
+ } else {
+ Dart_SetReturnValue(args, DartUtils::NewDartOSError());
+ }
}
void FUNCTION_NAME(Stdin_GetLineMode)(Dart_NativeArguments args) {
- Dart_SetReturnValue(args, Dart_NewBoolean(Stdin::GetLineMode()));
+ bool enabled = false;
+ if (Stdin::GetLineMode(&enabled)) {
+ Dart_SetReturnValue(args, Dart_NewBoolean(enabled));
+ } else {
+ Dart_SetReturnValue(args, DartUtils::NewDartOSError());
+ }
}
void FUNCTION_NAME(Stdin_SetLineMode)(Dart_NativeArguments args) {
bool enabled = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 0));
- Stdin::SetLineMode(enabled);
+ if (Stdin::SetLineMode(enabled)) {
+ Dart_SetReturnValue(args, Dart_True());
+ } else {
+ Dart_SetReturnValue(args, DartUtils::NewDartOSError());
+ }
}
« no previous file with comments | « runtime/bin/stdio.h ('k') | runtime/bin/stdio_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698