From c0dd2841362b67fdb5ede262b19688004a4eb9a4 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 28 Dec 2022 00:51:22 -0800 Subject: Upgrade to latest Zig (#1610) * @min and @max * builtins and some trivial ones * Most of them * more * more! * More Progress * wip * Update tagged_pointer.zig * Update http_client_async.zig * Most of the iterable dir changes * alright * Remove usages of deprecated formatters * :camera: * fmt * Update shimmer.zig * wip * wip * wip * progress * more * Latest * stuck on error * latest * workaround stage2 * wip * Update string_immutable.zig * wip * Migrate `Dirent` and `require("fs')` to use JSC<>Zig bindings * Fix build errors * Fixup most of the test failures * Fix `make headers` * Fix "outside package path" error * Fixup aligned alloc * Add missing file * linux * More linux fixes * use latest peechy * Fix transpiler test failure * Forgot about these * Fixup test failure * Update node-timers.test.ts * [node:htt] Fix `undefined is not an object` error Fixes https://github.com/oven-sh/bun/issues/1618 * Update http.exports.js * Make this test less flaky * fix hashes * Fix hex formatting and zls issues * Download zig version * Update Dockerfile * Update Dockerfile * Update uws * Update Dockerfile * Set llvm version * Update README.md * Update uws * Update Dockerfile * Update io_linux.zig * Update bun.zig * Log output * workaround strange @cInclude error * Make ffi tests better * Don't use cImport * Update c.zig * Update c-bindings.cpp * call setOutputDir * Update Dockerfile * Use a longer name * latest * Update serve.test.ts Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Veikka Tuominen --- src/resolver/resolve_path.zig | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/resolver/resolve_path.zig') diff --git a/src/resolver/resolve_path.zig b/src/resolver/resolve_path.zig index a6ccfb0c7..605c16e6a 100644 --- a/src/resolver/resolve_path.zig +++ b/src/resolver/resolve_path.zig @@ -40,7 +40,7 @@ inline fn @"is ../"(slice: []const u8) bool { pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u8, comptime isPathSeparator: IsSeparatorFunc) []const u8 { var min_length: usize = std.math.maxInt(usize); for (input) |str| { - min_length = @minimum(str.len, min_length); + min_length = @min(str.len, min_length); } var index: usize = 0; @@ -59,7 +59,7 @@ pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u if (input[0][index] != input[1][index]) { break; } - if (@call(.{ .modifier = .always_inline }, isPathSeparator, .{input[0][index]})) { + if (@call(.always_inline, isPathSeparator, .{input[0][index]})) { last_common_separator = index; } } @@ -69,7 +69,7 @@ pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u if (nqlAtIndex(3, index, input)) { break; } - if (@call(.{ .modifier = .always_inline }, isPathSeparator, .{input[0][index]})) { + if (@call(.always_inline, isPathSeparator, .{input[0][index]})) { last_common_separator = index; } } @@ -79,7 +79,7 @@ pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u if (nqlAtIndex(4, index, input)) { break; } - if (@call(.{ .modifier = .always_inline }, isPathSeparator, .{input[0][index]})) { + if (@call(.always_inline, isPathSeparator, .{input[0][index]})) { last_common_separator = index; } } @@ -89,7 +89,7 @@ pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u if (nqlAtIndex(5, index, input)) { break; } - if (@call(.{ .modifier = .always_inline }, isPathSeparator, .{input[0][index]})) { + if (@call(.always_inline, isPathSeparator, .{input[0][index]})) { last_common_separator = index; } } @@ -99,7 +99,7 @@ pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u if (nqlAtIndex(6, index, input)) { break; } - if (@call(.{ .modifier = .always_inline }, isPathSeparator, .{input[0][index]})) { + if (@call(.always_inline, isPathSeparator, .{input[0][index]})) { last_common_separator = index; } } @@ -109,7 +109,7 @@ pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u if (nqlAtIndex(7, index, input)) { break; } - if (@call(.{ .modifier = .always_inline }, isPathSeparator, .{input[0][index]})) { + if (@call(.always_inline, isPathSeparator, .{input[0][index]})) { last_common_separator = index; } } @@ -119,7 +119,7 @@ pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u if (nqlAtIndex(8, index, input)) { break; } - if (@call(.{ .modifier = .always_inline }, isPathSeparator, .{input[0][index]})) { + if (@call(.always_inline, isPathSeparator, .{input[0][index]})) { last_common_separator = index; } } @@ -132,7 +132,7 @@ pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u break; } } - if (@call(.{ .modifier = .always_inline }, isPathSeparator, .{input[0][index]})) { + if (@call(.always_inline, isPathSeparator, .{input[0][index]})) { last_common_separator = index; } } @@ -154,7 +154,7 @@ pub fn longestCommonPathGeneric(input: []const []const u8, comptime separator: u // and say, "do one of you have a path separator after what we thought was the end?" for (input) |str| { if (str.len > index + 1) { - if (@call(.{ .modifier = .always_inline }, isPathSeparator, .{str[index]})) { + if (@call(.always_inline, isPathSeparator, .{str[index]})) { return str[0 .. index + 2]; } } @@ -192,7 +192,7 @@ pub fn relativeToCommonPath( const common_path = if (has_leading_separator) _common_path[1..] else _common_path; - const shortest = @minimum(normalized_from.len, normalized_to.len); + const shortest = @min(normalized_from.len, normalized_to.len); var last_common_separator = strings.lastIndexOfChar(_common_path, separator) orelse 0; @@ -804,7 +804,7 @@ pub fn isSepWin32(char: u8) bool { } pub fn isSepAny(char: u8) bool { - return @call(.{ .modifier = .always_inline }, isSepPosix, .{char}) or @call(.{ .modifier = .always_inline }, isSepWin32, .{char}); + return @call(.always_inline, isSepPosix, .{char}) or @call(.always_inline, isSepWin32, .{char}); } pub fn lastIndexOfSeparatorWindows(slice: []const u8) ?usize { @@ -1256,7 +1256,3 @@ test "longestCommonPath" { _ = t.expect("/app/", longestCommonPath(&more), @src()); _ = t.expect("/app/public/", longestCommonPath(more[0..2]), @src()); } - -test "" { - @import("std").testing.refAllDecls(@This()); -} -- cgit v1.2.3