aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-09-24 03:16:51 -0700
committerGravatar GitHub <noreply@github.com> 2023-09-24 03:16:51 -0700
commitb6a4161cc5773c3ebf8222d38e9dfaf3d195f6a5 (patch)
tree079b1582e92fbe67f3b52929ac34015da0cecb55 /src
parenta5908e9f2704f801587115007c2bec5788bd718a (diff)
downloadbun-b6a4161cc5773c3ebf8222d38e9dfaf3d195f6a5.tar.gz
bun-b6a4161cc5773c3ebf8222d38e9dfaf3d195f6a5.tar.zst
bun-b6a4161cc5773c3ebf8222d38e9dfaf3d195f6a5.zip
Fixes #5985 (#5986)
* Fixes #5985 * Update confirm-fixture.js --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/FFI.zig3
-rw-r--r--src/bun.js/bindings/bindings.zig2
-rw-r--r--src/bun.js/webcore.zig9
3 files changed, 9 insertions, 5 deletions
diff --git a/src/bun.js/bindings/FFI.zig b/src/bun.js/bindings/FFI.zig
index 9d16bd78e..da98438ba 100644
--- a/src/bun.js/bindings/FFI.zig
+++ b/src/bun.js/bindings/FFI.zig
@@ -20,8 +20,9 @@ pub const EncodedJSValue = union_EncodedJSValue;
pub export var ValueUndefined: EncodedJSValue = EncodedJSValue{
.asInt64 = @as(i64, @bitCast(@as(c_longlong, @as(c_int, 2) | @as(c_int, 8)))),
};
+pub const TrueI64 = @as(i64, @bitCast(@as(c_longlong, (@as(c_int, 2) | @as(c_int, 4)) | @as(c_int, 1))));
pub export var ValueTrue: EncodedJSValue = EncodedJSValue{
- .asInt64 = @as(i64, @bitCast(@as(c_longlong, (@as(c_int, 2) | @as(c_int, 4)) | @as(c_int, 1)))),
+ .asInt64 = TrueI64,
};
pub const JSContext = ?*anyopaque;
pub inline fn JSVALUE_IS_CELL(arg_val: EncodedJSValue) bool {
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index 6c1e11e34..60f8f9376 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -3034,7 +3034,7 @@ pub const JSValue = enum(JSValueReprInt) {
zero = 0,
undefined = @as(JSValueReprInt, @bitCast(@as(i64, 0xa))),
null = @as(JSValueReprInt, @bitCast(@as(i64, 0x2))),
- true = @as(JSValueReprInt, @bitCast(@as(i64, 0x4))),
+ true = FFI.TrueI64,
false = @as(JSValueReprInt, @bitCast(@as(i64, 0x6))),
_,
diff --git a/src/bun.js/webcore.zig b/src/bun.js/webcore.zig
index 168c4339b..411d3ed2e 100644
--- a/src/bun.js/webcore.zig
+++ b/src/bun.js/webcore.zig
@@ -107,9 +107,11 @@ fn confirm(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callcon
// 6. Pause until the user responds either positively or negatively.
var stdin = std.io.getStdIn();
- var reader = stdin.reader();
+ var unbuffered_reader = stdin.reader();
+ var buffered = std.io.bufferedReader(unbuffered_reader);
+ var reader = buffered.reader();
- const first_byte = reader.readByte() catch {
+ var first_byte = reader.readByte() catch {
return .false;
};
@@ -122,13 +124,14 @@ fn confirm(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callcon
'y', 'Y' => {
const next_byte = reader.readByte() catch {
// They may have said yes, but the stdin is invalid.
+
return .false;
};
if (next_byte == '\n') {
// 8. If the user responded positively, return true;
// otherwise, the user responded negatively: return false.
- return .false;
+ return .true;
}
},
else => {},