Skip to content

Commit 7c5d3ef

Browse files
authored
Update renamed builtins (#15)
* Update renamed builtins See: ziglang/zig#16046 * Update builtins to infer target type See: ziglang/zig#16163
1 parent 0f3f47e commit 7c5d3ef

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/c.zig

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const LinenoiseCompletions = extern struct {
1919

2020
pub fn free(self: *LinenoiseCompletions) void {
2121
if (self.cvec) |raw_completions| {
22-
const len = @intCast(usize, self.len);
22+
const len: usize = @intCast(self.len);
2323
for (raw_completions[0..len]) |x| global_allocator.free(mem.span(x));
2424
global_allocator.free(raw_completions[0..len]);
2525
}
@@ -129,7 +129,7 @@ export fn linenoise(prompt: [*:0]const u8) ?[*:0]u8 {
129129
}
130130

131131
export fn linenoiseFree(ptr: *anyopaque) void {
132-
global_allocator.free(mem.span(@ptrCast([*:0]const u8, ptr)));
132+
global_allocator.free(mem.span(@as([*:0]const u8, @ptrCast(ptr))));
133133
}
134134

135135
export fn linenoiseHistoryAdd(line: [*:0]const u8) c_int {
@@ -140,7 +140,7 @@ export fn linenoiseHistoryAdd(line: [*:0]const u8) c_int {
140140

141141
export fn linenoiseHistorySetMaxLen(len: c_int) c_int {
142142
if (global_linenoise == null) global_linenoise = Linenoise.init(global_allocator);
143-
global_linenoise.?.history.setMaxLen(@intCast(usize, len)) catch return -1;
143+
global_linenoise.?.history.setMaxLen(@intCast(len)) catch return -1;
144144
return 0;
145145
}
146146

src/state.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn calculateStartOrEnd(
9393

9494
var utf8 = (try std.unicode.Utf8View.init(buf)).iterator();
9595
while (utf8.nextCodepointSlice()) |codepoint| {
96-
map.appendAssumeCapacity(@ptrToInt(codepoint.ptr) - @ptrToInt(buf.ptr));
96+
map.appendAssumeCapacity(@intFromPtr(codepoint.ptr) - @intFromPtr(buf.ptr));
9797
}
9898

9999
const codepoint_start = binarySearchBestEffort(

src/term.zig

+13-13
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,20 @@ pub fn enableRawMode(in: File, out: File) !termios {
5959
var raw = orig;
6060

6161
// TODO fix hardcoding of linux
62-
raw.iflag &= ~(@intCast(tcflag_t, std.os.linux.BRKINT) |
63-
@intCast(tcflag_t, std.os.linux.ICRNL) |
64-
@intCast(tcflag_t, std.os.linux.INPCK) |
65-
@intCast(tcflag_t, std.os.linux.ISTRIP) |
66-
@intCast(tcflag_t, std.os.linux.IXON));
62+
raw.iflag &= ~(@as(tcflag_t, @intCast(std.os.linux.BRKINT)) |
63+
@as(tcflag_t, @intCast(std.os.linux.ICRNL)) |
64+
@as(tcflag_t, @intCast(std.os.linux.INPCK)) |
65+
@as(tcflag_t, @intCast(std.os.linux.ISTRIP)) |
66+
@as(tcflag_t, @intCast(std.os.linux.IXON)));
6767

68-
raw.oflag &= ~(@intCast(tcflag_t, std.os.linux.OPOST));
68+
raw.oflag &= ~(@as(tcflag_t, @intCast(std.os.linux.OPOST)));
6969

70-
raw.cflag |= (@intCast(tcflag_t, std.os.linux.CS8));
70+
raw.cflag |= (@as(tcflag_t, @intCast(std.os.linux.CS8)));
7171

72-
raw.lflag &= ~(@intCast(tcflag_t, std.os.linux.ECHO) |
73-
@intCast(tcflag_t, std.os.linux.ICANON) |
74-
@intCast(tcflag_t, std.os.linux.IEXTEN) |
75-
@intCast(tcflag_t, std.os.linux.ISIG));
72+
raw.lflag &= ~(@as(tcflag_t, @intCast(std.os.linux.ECHO)) |
73+
@as(tcflag_t, @intCast(std.os.linux.ICANON)) |
74+
@as(tcflag_t, @intCast(std.os.linux.IEXTEN)) |
75+
@as(tcflag_t, @intCast(std.os.linux.ISIG)));
7676

7777
// FIXME
7878
// raw.cc[std.os.VMIN] = 1;
@@ -131,7 +131,7 @@ pub fn getColumns(in: File, out: File) !usize {
131131
switch (builtin.os.tag) {
132132
.linux => {
133133
var wsz: std.os.linux.winsize = undefined;
134-
if (std.os.linux.ioctl(in.handle, std.os.linux.T.IOCGWINSZ, @ptrToInt(&wsz)) == 0) {
134+
if (std.os.linux.ioctl(in.handle, std.os.linux.T.IOCGWINSZ, @intFromPtr(&wsz)) == 0) {
135135
return wsz.ws_col;
136136
} else {
137137
return try getColumnsFallback(in, out);
@@ -140,7 +140,7 @@ pub fn getColumns(in: File, out: File) !usize {
140140
.windows => {
141141
var csbi: w.CONSOLE_SCREEN_BUFFER_INFO = undefined;
142142
_ = k32.GetConsoleScreenBufferInfo(out.handle, &csbi);
143-
return @intCast(usize, csbi.dwSize.X);
143+
return @intCast(csbi.dwSize.X);
144144
},
145145
else => return try getColumnsFallback(in, out),
146146
}

src/unicode.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn width(s: []const u8) usize {
2121
} else {
2222
const wcw = wcwidth(codepoint);
2323
if (wcw < 0) return 0;
24-
result += @intCast(usize, wcw);
24+
result += @intCast(wcw);
2525
}
2626
}
2727
}

0 commit comments

Comments
 (0)