mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
just kernel32 things (#4354)
* just kernel32 things * more * Update linux_c.zig * Update windows_c.zig * Add workaround Workaround https://github.com/ziglang/zig/issues/16980 * Rename http.zig to bun_dev_http_server.zig * Rename usages * more * more * more * thanks tigerbeetle * Rename `JSC.Node.Syscall` -> `bun.sys` * more * woops * more! * hmm * it says there are only 37 errors, but that's not true * populate argv * it says 32 errors! * 24 errors * fix regular build * 12 left! * Still 12 left! * more * 2 errors left... * 1 more error * Add link to Tigerbeetle * Fix the remainign error * Fix test timeout * Update syscall.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -23,6 +23,20 @@ pub inline fn contains(self: string, str: string) bool {
|
||||
return indexOf(self, str) != null;
|
||||
}
|
||||
|
||||
pub fn w(comptime str: []const u8) [:0]const u16 {
|
||||
comptime var output: [str.len + 1]u16 = undefined;
|
||||
|
||||
for (str, 0..) |c, i| {
|
||||
output[i] = c;
|
||||
}
|
||||
output[str.len] = 0;
|
||||
|
||||
const Static = struct {
|
||||
pub const literal: [:0]const u16 = output[0 .. output.len - 1 :0];
|
||||
};
|
||||
return Static.literal;
|
||||
}
|
||||
|
||||
pub fn toUTF16Literal(comptime str: []const u8) []const u16 {
|
||||
return comptime brk: {
|
||||
comptime var output: [str.len]u16 = undefined;
|
||||
@@ -1462,6 +1476,27 @@ pub fn utf16Codepoint(comptime Type: type, input: Type) UTF16Replacement {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fromWPath(buf: []u8, utf16: []const u16) [:0]const u8 {
|
||||
std.debug.assert(buf.len > 0);
|
||||
const encode_into_result = copyUTF16IntoUTF8(buf[0 .. buf.len - 1], []const u16, utf16, false);
|
||||
std.debug.assert(encode_into_result.written < buf.len);
|
||||
buf[encode_into_result.written] = 0;
|
||||
return buf[0..encode_into_result.written :0];
|
||||
}
|
||||
|
||||
pub fn toWPath(wbuf: []u16, utf8: []const u8) [:0]const u16 {
|
||||
std.debug.assert(wbuf.len > 0);
|
||||
var result = bun.simdutf.convert.utf8.to.utf16.with_errors.le(
|
||||
utf8,
|
||||
wbuf[0..wbuf.len -| 1],
|
||||
);
|
||||
|
||||
// TODO: error handling
|
||||
// if (result.status == .surrogate) {
|
||||
// }
|
||||
return wbuf[0..result.count :0];
|
||||
}
|
||||
|
||||
pub fn convertUTF16ToUTF8(list_: std.ArrayList(u8), comptime Type: type, utf16: Type) !std.ArrayList(u8) {
|
||||
var list = list_;
|
||||
var result = bun.simdutf.convert.utf16.to.utf8.with_errors.le(
|
||||
@@ -4525,6 +4560,10 @@ pub fn isIPAddress(input: []const u8) bool {
|
||||
if (containsChar(input, ':'))
|
||||
return true;
|
||||
|
||||
if (comptime Environment.isWindows) {
|
||||
return bun.todo(@src(), false);
|
||||
}
|
||||
|
||||
if (std.net.Address.resolveIp(input, 0)) |_| {
|
||||
return true;
|
||||
} else |_| {
|
||||
@@ -4533,6 +4572,10 @@ pub fn isIPAddress(input: []const u8) bool {
|
||||
}
|
||||
|
||||
pub fn isIPV6Address(input: []const u8) bool {
|
||||
if (comptime Environment.isWindows) {
|
||||
return bun.todo(@src(), false);
|
||||
}
|
||||
|
||||
if (std.net.Address.parseIp6(input, 0)) |_| {
|
||||
return true;
|
||||
} else |_| {
|
||||
|
||||
Reference in New Issue
Block a user