mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
windows.eqlIgnoreCaseWTF16 -> eqlIgnoreCaseWtf16
Consistent with naming of other, similar functions
This commit is contained in:
parent
aa4332fb0e
commit
adf74ba4fb
@ -2088,7 +2088,7 @@ pub fn nanoSecondsToFileTime(ns: Io.Timestamp) FILETIME {
|
|||||||
/// Compares two WTF16 strings using the equivalent functionality of
|
/// Compares two WTF16 strings using the equivalent functionality of
|
||||||
/// `RtlEqualUnicodeString` (with case insensitive comparison enabled).
|
/// `RtlEqualUnicodeString` (with case insensitive comparison enabled).
|
||||||
/// This function can be called on any target.
|
/// This function can be called on any target.
|
||||||
pub fn eqlIgnoreCaseWTF16(a: []const u16, b: []const u16) bool {
|
pub fn eqlIgnoreCaseWtf16(a: []const u16, b: []const u16) bool {
|
||||||
if (@inComptime() or builtin.os.tag != .windows) {
|
if (@inComptime() or builtin.os.tag != .windows) {
|
||||||
// This function compares the strings code unit by code unit (aka u16-to-u16),
|
// This function compares the strings code unit by code unit (aka u16-to-u16),
|
||||||
// so any length difference implies inequality. In other words, there's no possible
|
// so any length difference implies inequality. In other words, there's no possible
|
||||||
@ -2165,19 +2165,19 @@ pub fn eqlIgnoreCaseWtf8(a: []const u8, b: []const u8) bool {
|
|||||||
|
|
||||||
fn testEqlIgnoreCase(comptime expect_eql: bool, comptime a: []const u8, comptime b: []const u8) !void {
|
fn testEqlIgnoreCase(comptime expect_eql: bool, comptime a: []const u8, comptime b: []const u8) !void {
|
||||||
try std.testing.expectEqual(expect_eql, eqlIgnoreCaseWtf8(a, b));
|
try std.testing.expectEqual(expect_eql, eqlIgnoreCaseWtf8(a, b));
|
||||||
try std.testing.expectEqual(expect_eql, eqlIgnoreCaseWTF16(
|
try std.testing.expectEqual(expect_eql, eqlIgnoreCaseWtf16(
|
||||||
std.unicode.utf8ToUtf16LeStringLiteral(a),
|
std.unicode.utf8ToUtf16LeStringLiteral(a),
|
||||||
std.unicode.utf8ToUtf16LeStringLiteral(b),
|
std.unicode.utf8ToUtf16LeStringLiteral(b),
|
||||||
));
|
));
|
||||||
|
|
||||||
try comptime std.testing.expect(expect_eql == eqlIgnoreCaseWtf8(a, b));
|
try comptime std.testing.expect(expect_eql == eqlIgnoreCaseWtf8(a, b));
|
||||||
try comptime std.testing.expect(expect_eql == eqlIgnoreCaseWTF16(
|
try comptime std.testing.expect(expect_eql == eqlIgnoreCaseWtf16(
|
||||||
std.unicode.utf8ToUtf16LeStringLiteral(a),
|
std.unicode.utf8ToUtf16LeStringLiteral(a),
|
||||||
std.unicode.utf8ToUtf16LeStringLiteral(b),
|
std.unicode.utf8ToUtf16LeStringLiteral(b),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "eqlIgnoreCaseWTF16/Wtf8" {
|
test "eqlIgnoreCaseWtf16/Wtf8" {
|
||||||
try testEqlIgnoreCase(true, "\x01 a B Λ ɐ", "\x01 A b λ Ɐ");
|
try testEqlIgnoreCase(true, "\x01 a B Λ ɐ", "\x01 A b λ Ɐ");
|
||||||
// does not do case-insensitive comparison for codepoints >= U+10000
|
// does not do case-insensitive comparison for codepoints >= U+10000
|
||||||
try testEqlIgnoreCase(false, "𐓏", "𐓷");
|
try testEqlIgnoreCase(false, "𐓏", "𐓷");
|
||||||
|
|||||||
@ -564,7 +564,7 @@ pub fn getenvW(key: [*:0]const u16) ?[:0]const u16 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const this_key = key_value[0..equal_index];
|
const this_key = key_value[0..equal_index];
|
||||||
if (windows.eqlIgnoreCaseWTF16(key_slice, this_key)) {
|
if (windows.eqlIgnoreCaseWtf16(key_slice, this_key)) {
|
||||||
return key_value[equal_index + 1 ..];
|
return key_value[equal_index + 1 ..];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1227,7 +1227,7 @@ fn windowsCreateProcessPathExt(
|
|||||||
const app_name = app_buf.items[0..app_name_len];
|
const app_name = app_buf.items[0..app_name_len];
|
||||||
const ext_start = std.mem.lastIndexOfScalar(u16, app_name, '.') orelse break :unappended err;
|
const ext_start = std.mem.lastIndexOfScalar(u16, app_name, '.') orelse break :unappended err;
|
||||||
const ext = app_name[ext_start..];
|
const ext = app_name[ext_start..];
|
||||||
if (windows.eqlIgnoreCaseWTF16(ext, unicode.utf8ToUtf16LeStringLiteral(".EXE"))) {
|
if (windows.eqlIgnoreCaseWtf16(ext, unicode.utf8ToUtf16LeStringLiteral(".EXE"))) {
|
||||||
return error.UnrecoverableInvalidExe;
|
return error.UnrecoverableInvalidExe;
|
||||||
}
|
}
|
||||||
break :unappended err;
|
break :unappended err;
|
||||||
@ -1278,7 +1278,7 @@ fn windowsCreateProcessPathExt(
|
|||||||
// On InvalidExe, if the extension of the app name is .exe then
|
// On InvalidExe, if the extension of the app name is .exe then
|
||||||
// it's treated as an unrecoverable error. Otherwise, it'll be
|
// it's treated as an unrecoverable error. Otherwise, it'll be
|
||||||
// skipped as normal.
|
// skipped as normal.
|
||||||
if (windows.eqlIgnoreCaseWTF16(ext, unicode.utf8ToUtf16LeStringLiteral(".EXE"))) {
|
if (windows.eqlIgnoreCaseWtf16(ext, unicode.utf8ToUtf16LeStringLiteral(".EXE"))) {
|
||||||
return error.UnrecoverableInvalidExe;
|
return error.UnrecoverableInvalidExe;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user