aboutsummaryrefslogtreecommitdiff
path: root/src/string_immutable.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-03-19 20:58:16 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-03-19 20:58:27 -0700
commit0edd8d262da4409f1e5566c47bfed9b3f23636b7 (patch)
tree35e7e1680cfe57f8cb36b8c673a4ad419a8947cd /src/string_immutable.zig
parent76622e41d66d8d2bdbb11c9981a4e9506b5a78b6 (diff)
downloadbun-0edd8d262da4409f1e5566c47bfed9b3f23636b7.tar.gz
bun-0edd8d262da4409f1e5566c47bfed9b3f23636b7.tar.zst
bun-0edd8d262da4409f1e5566c47bfed9b3f23636b7.zip
Fix bug with scoped aliased dependencies in bun install on macOS
Diffstat (limited to 'src/string_immutable.zig')
-rw-r--r--src/string_immutable.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index 8f3859a34..d393577fc 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -3187,6 +3187,18 @@ test "indexOfNeedsEscape" {
try std.testing.expectEqual(out.?, 48);
}
+pub fn indexOfCharZ(sliceZ: [:0]const u8, char: u8) ?u63 {
+ const ptr = bun.C.strchr(sliceZ.ptr, char) orelse return null;
+ const pos = @ptrToInt(ptr) - @ptrToInt(sliceZ.ptr);
+
+ if (comptime Environment.allow_assert)
+ std.debug.assert(@ptrToInt(sliceZ.ptr) >= @ptrToInt(ptr) and
+ @ptrToInt(ptr) < @ptrToInt(sliceZ.ptr + sliceZ.len) and
+ pos <= sliceZ.len);
+
+ return @truncate(u63, pos);
+}
+
pub fn indexOfChar(slice: []const u8, char: u8) ?u32 {
var remaining = slice;
if (remaining.len == 0)