lauren n. liberda: 12 zig 0.12: adapt build.zig zig 0.12: convert some vars to consts zig 0.12: roll the version zig 0.12: std.os.SIG -> std.os.linux.SIG zig 0.12: std.os.getenv -> std.posix.getenv zig 0.12: std.os.sigaction -> std.posix.sigaction zig 0.12: std.mem.copy -> std.mem.copyForwards zig 0.12: std.math.absCast -> @abs zig 0.12: std.ChildProcess.exec -> std.ChildProcess.run zig 0.12: std.os.exit -> std.posix.exit zig 0.12: std.os.poll -> std.posix.poll zig 0.12: std.math.absInt -> @abs 20 files changed, 76 insertions(+), 92 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~mil/mepo-devel/patches/51184/mbox | git am -3Learn more about email & git
--- build.zig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index c15e65d..a61082e 100644 --- a/build.zig @@ -1,8 +1,6 @@ const std = @import("std"); -const Builder = std.build.Builder; -const LibExeObjStep = std.build.LibExeObjStep; -fn setDependencies(step: *std.build.LibExeObjStep) void { +fn setDependencies(step: *std.Build.Step.Compile) void { step.linkSystemLibrary("c"); step.linkSystemLibrary("SDL2"); step.linkSystemLibrary("SDL2_gfx"); @@ -11,7 +9,7 @@ fn setDependencies(step: *std.build.LibExeObjStep) void { step.linkSystemLibrary("curl"); } -pub fn build(b: *Builder) void { +pub fn build(b: *std.Build) void { b.installDirectory(.{ .source_dir = .{ .path = "scripts" }, .install_dir = .{ .bin = {} }, -- 2.44.0
--- src/Mepo.zig | 13 ++++++++----- src/TileCache.zig | 13 ++++++------- src/api/shellpipe_async.zig | 4 ++-- src/blit/blit.zig | 36 +++++++++++------------------------- src/util/utilmepolang.zig | 22 +++++++++++----------- src/util/utilsdl.zig | 2 +- 6 files changed, 39 insertions(+), 51 deletions(-) diff --git a/src/Mepo.zig b/src/Mepo.zig index 44b7990..dc49cab 100644 --- a/src/Mepo.zig +++ b/src/Mepo.zig @@ -473,7 +473,7 @@ pub fn init_video_and_sdl_stdin_loop(mepo: *@This(), enable_stdin_mepolang_repl: while (true) { const stdin = &std.io.getStdIn().reader(); - var read_slice: []const u8 = stdin.readUntilDelimiterAlloc(mepo.allocator, '\n', 102400) catch continue; + const read_slice: []const u8 = stdin.readUntilDelimiterAlloc(mepo.allocator, '\n', 102400) catch continue; const slice_z = try mepo.allocator.dupeZ(u8, read_slice); mepo.allocator.free(read_slice); std.debug.print("Read {d} bytes, running input as mepolang\n", .{slice_z.len}); @@ -509,7 +509,7 @@ pub fn sdl_event_loop(mepo: *@This()) !void { // Process SDL events if (sdl.SDL_WaitEventTimeout(&e, config.DragThresholdTicks) > 0) { - var pending_fn = switch (e.type) { + const pending_fn = switch (e.type) { sdl.SDL_FINGERDOWN => &event_fingerdown, sdl.SDL_FINGERUP => &event_fingerup, sdl.SDL_KEYUP => &event_keyup, @@ -734,7 +734,7 @@ pub fn blit(mepo: *@This()) !void { pub fn video_init(mepo: *@This()) !void { mepo.window = try setup_sdl_video_and_window(mepo.allocator); mepo.renderer = renderer: { - var r = try utilsdl.errorcheck_ptr(sdl.SDL_Renderer, sdl.SDL_CreateRenderer( + const r = try utilsdl.errorcheck_ptr(sdl.SDL_Renderer, sdl.SDL_CreateRenderer( mepo.window, -1, switch (mepo.renderer_type) { @@ -747,7 +747,7 @@ pub fn video_init(mepo: *@This()) !void { }; var sdl_renderer_info: sdl.SDL_RendererInfo = undefined; try utilsdl.errorcheck(sdl.SDL_GetRendererInfo(mepo.renderer, &sdl_renderer_info)); - utildbg.log("Requested renderer driver {}, using renderer: {s}\n", .{mepo.renderer_type, sdl_renderer_info.name}); + utildbg.log("Requested renderer driver {}, using renderer: {s}\n", .{ mepo.renderer_type, sdl_renderer_info.name }); mepo.tile_cache.renderer = mepo.renderer; } @@ -774,7 +774,10 @@ pub fn init(allocator: std.mem.Allocator, tile_cache: *TileCache, use_config: [] return @as(@This(), .{ .allocator = allocator, .blit_pinlayer_cache = datastructure.EvictionHashMap( - types.XYZ, *sdl.SDL_Texture, evict_texture, &config.MaxTextures, + types.XYZ, + *sdl.SDL_Texture, + evict_texture, + &config.MaxTextures, ).init(allocator), .async_shellpipe_threads = datastructure.QueueHashMap(i8, sdl.SDL_threadID).init(allocator), .config = use_config, diff --git a/src/TileCache.zig b/src/TileCache.zig index 9014589..0b1fa63 100644 --- a/src/TileCache.zig +++ b/src/TileCache.zig @@ -82,13 +82,13 @@ pub fn download_loop(tile_cache: *@This(), graphical_mode: bool) !void { // 2. Transfer from UI LIFO into transfers while (tile_cache.queue_lifo_ui.count() > 0 and tile_cache.transfer_map.count() < p.get(p.pref.tile_cache_max_n_transfers).u) { - var coords = tile_cache.queue_lifo_ui.pop(); + const coords = tile_cache.queue_lifo_ui.pop(); try tile_cache.curl_add_to_multi_and_register_transfer(coords.key, true); } // 3. Transfer from BG LIFO into transfers while (tile_cache.queue_lifo_bg.count() > 0 and tile_cache.transfer_map.count() < p.get(p.pref.tile_cache_max_n_transfers).u) { - var coords = tile_cache.queue_lifo_bg.pop(); + const coords = tile_cache.queue_lifo_bg.pop(); try tile_cache.curl_add_to_multi_and_register_transfer(coords.key, false); } @@ -259,7 +259,7 @@ pub fn tile_ui_retreive_or_queue(tile_cache: *@This(), coords: types.XYZ) !TileD if (file_cached_png_opt) |file_cached_png| { defer tile_cache.allocator.free(file_cached_png); const surface = tile_cache.load_data_to_surface(file_cached_png) catch |err| { - utildbg.log("Errored when loading data for tile {} from FS (file: {s}) to SDL Surface: {}\n", .{coords, png_fs_path, err}); + utildbg.log("Errored when loading data for tile {} from FS (file: {s}) to SDL Surface: {}\n", .{ coords, png_fs_path, err }); break :load_from_fs; }; defer sdl.SDL_FreeSurface(surface); @@ -285,7 +285,7 @@ pub fn tile_ui_retreive_or_queue(tile_cache: *@This(), coords: types.XYZ) !TileD fn curl_add_to_multi_and_register_transfer(tile_cache: *@This(), coords: types.XYZ, load_to_texture: bool) !void { if (tile_cache.transfer_map.get(coords)) |_| return; - var transfer_datum: *TransferDatum = datum: { + const transfer_datum: *TransferDatum = datum: { var dat = try tile_cache.allocator.create(TransferDatum); dat.client = curl.curl_easy_init().?; dat.coords = coords; @@ -297,7 +297,7 @@ fn curl_add_to_multi_and_register_transfer(tile_cache: *@This(), coords: types.X }; try tile_cache.transfer_map.put(coords, transfer_datum); - var tile_url = url: { + const tile_url = url: { var url = try tile_cache.allocator.alloc(u8, p.get(p.pref.tile_cache_url).t.?.len + (3 * 10)); if (cstdio.sprintf( &url[0], @@ -387,8 +387,7 @@ fn download_loop_progress_indicator(tile_cache: *@This(), initial_queue_size: us \\ , .{ - 100.0 * @as(f32, @floatFromInt(initial_queue_size - tile_cache.queue_lifo_bg.count())) - / @as(f32, @floatFromInt(initial_queue_size)), + 100.0 * @as(f32, @floatFromInt(initial_queue_size - tile_cache.queue_lifo_bg.count())) / @as(f32, @floatFromInt(initial_queue_size)), initial_queue_size - tile_cache.queue_lifo_bg.count(), initial_queue_size, tile_cache.byte_counter / 1024 / 1024, diff --git a/src/api/shellpipe_async.zig b/src/api/shellpipe_async.zig index 02d60c7..f45b3e4 100644 --- a/src/api/shellpipe_async.zig +++ b/src/api/shellpipe_async.zig @@ -38,7 +38,7 @@ fn async_shellpipe(mepo: *Mepo, unique_handle_id: i8, cmd: []const u8) !void { } fn async_shellpipe_run(userdata: ?*anyopaque) callconv(.C) c_int { - var shellpipe_request: *AsyncShellpipeRequest = @alignCast(@ptrCast(userdata.?)); + const shellpipe_request: *AsyncShellpipeRequest = @alignCast(@ptrCast(userdata.?)); async_shellpipe_run_catch_errors(shellpipe_request.mepo, shellpipe_request.unique_handle_id, shellpipe_request.cmd) catch |err| { utildbg.log("Error running async shellpipe: {}\n", .{err}); }; @@ -89,7 +89,7 @@ fn async_shellpipe_run_catch_errors(mepo: *Mepo, unique_handle_id: i8, cmd: []co if (std.mem.lastIndexOf(u8, stdout.items, ";")) |mepolang_statement_end_index| { const statement = stdout.items[0 .. mepolang_statement_end_index + 1]; utildbg.log("Running mepolang statement from async shellpipe: {s}\n", .{statement}); - var heap_statement = try mepo.allocator.dupeZ(u8, statement); + const heap_statement = try mepo.allocator.dupeZ(u8, statement); utilsdl.sdl_push_event_mepolang_execution(heap_statement); try stdout.replaceRange(0, mepolang_statement_end_index + 1, &[_]u8{}); } diff --git a/src/blit/blit.zig b/src/blit/blit.zig index 55f74dc..5abba0c 100644 --- a/src/blit/blit.zig +++ b/src/blit/blit.zig @@ -187,7 +187,7 @@ fn blit_tile_pinlayer(mepo: *Mepo, tile_x: u32, tile_y: u32, zoom: u8, x_off: i3 { const pingroup_order = order: { // E.g. place active pingroup last so its always ontop in rendering order - var groups = [10]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const groups = [10]u8{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var target_order: [10]u8 = undefined; var index: u8 = 0; for (groups) |i| { @@ -201,7 +201,7 @@ fn blit_tile_pinlayer(mepo: *Mepo, tile_x: u32, tile_y: u32, zoom: u8, x_off: i3 for (pingroup_order) |pin_group_i| { const pin_group = mepo.pin_groups[pin_group_i]; - var is_active_path_track= false; + var is_active_path_track = false; var prev_pin: ?*types.Pin = null; for (pin_group.items, 0..) |*pin, pin_i| { defer prev_pin = pin; @@ -227,26 +227,12 @@ fn blit_tile_pinlayer(mepo: *Mepo, tile_x: u32, tile_y: u32, zoom: u8, x_off: i3 } }; - try blit_pin( - mepo, - pin, - if (prev_pin != null) prev_pin else null, - @intCast(pin_group_i), - is_active_path, - .{ .x = tile_x, .y = tile_y, .z = zoom } - ); + try blit_pin(mepo, pin, if (prev_pin != null) prev_pin else null, @intCast(pin_group_i), is_active_path, .{ .x = tile_x, .y = tile_y, .z = zoom }); } } if (mepo.pin_group_active_item) |active_pin_i| { - try blit_pin( - mepo, - &mepo.pin_groups[mepo.pin_group_active].items[active_pin_i], - null, - mepo.pin_group_active, - true, - .{ .x = tile_x, .y = tile_y, .z = zoom } - ); + try blit_pin(mepo, &mepo.pin_groups[mepo.pin_group_active].items[active_pin_i], null, mepo.pin_group_active, true, .{ .x = tile_x, .y = tile_y, .z = zoom }); } } @@ -362,14 +348,14 @@ fn blit_pin(mepo: *Mepo, pin: *types.Pin, prev_pin: ?*types.Pin, pin_group: u8, const font_height: i8 = @intCast(config.ZoomLevelToPinFontSize[p.get(p.pref.zoom).u]); const n_tiles_font_overlap = 2; const pin_in_view = r: { - const a = pin_target_x > (-config.Tsize * n_tiles_font_overlap) and pin_target_x < (config.Tsize * n_tiles_font_overlap); + const a = pin_target_x > (-config.Tsize * n_tiles_font_overlap) and pin_target_x < (config.Tsize * n_tiles_font_overlap); const b = pin_target_y > -font_height and pin_target_y - (pin_rect_size / 2) < config.Tsize; break :r a and b; }; const prevpin_in_view = r: { if (prev_pin == null) break :r false; const a = prevpin_target_x.? > (-config.Tsize * n_tiles_font_overlap) and prevpin_target_x.? < config.Tsize * n_tiles_font_overlap; - const b = prevpin_target_y.? > -font_height and prevpin_target_y.? - (pin_rect_size / 2) < config.Tsize; + const b = prevpin_target_y.? > -font_height and prevpin_target_y.? - (pin_rect_size / 2) < config.Tsize; break :r a and b; }; const connecting_line_in_view = r: { @@ -430,9 +416,9 @@ fn blit_pin(mepo: *Mepo, pin: *types.Pin, prev_pin: ?*types.Pin, pin_group: u8, if (pin.category != .Instructive or mepo.pin_group_active != pin_group) break :render_pin_label; - const pin_label_bg_value : u24 = if (is_active) 0xe8e8e8 else 0xffffff; + const pin_label_bg_value: u24 = if (is_active) 0xe8e8e8 else 0xffffff; const pin_label_bg: types.Color = .{ .value = pin_label_bg_value, .opacity = 255 }; - const pin_label_border_value : u24 = if (is_active) 0x000000 else 0xe8e8e8; + const pin_label_border_value: u24 = if (is_active) 0x000000 else 0xe8e8e8; const pin_label_border = .{ .value = pin_label_border_value, .opacity = 255 }; const label_color: u24 = 0x000000; @@ -525,7 +511,7 @@ fn blit_overlay_debugbar(mepo: *Mepo) !void { fn blit_help(mepo: *Mepo) !void { if (!p.get(p.pref.help).b) return; - var msg = msg: { + const msg = msg: { var acc = std.ArrayList([]const u8).init(mepo.allocator); defer acc.deinit(); defer for (acc.items) |item| mepo.allocator.free(item); @@ -658,7 +644,7 @@ fn blit_multiline_text( comptime fmt_string: [:0]const u8, args: anytype, ) !void { - var msg = try std.fmt.allocPrintZ(mepo.allocator, fmt_string, args); + const msg = try std.fmt.allocPrintZ(mepo.allocator, fmt_string, args); defer mepo.allocator.free(msg); const font_size = font_size: { @@ -673,7 +659,7 @@ fn blit_multiline_text( var textures_height: c_int = 0; // Accumulate lines rendered into slice of textures - var textures: []*sdl.SDL_Texture = textures: { + const textures: []*sdl.SDL_Texture = textures: { var textures_array: [50]*sdl.SDL_Texture = undefined; var textures_array_size: usize = 0; diff --git a/src/util/utilmepolang.zig b/src/util/utilmepolang.zig index 4b859b3..40cc8a5 100644 --- a/src/util/utilmepolang.zig +++ b/src/util/utilmepolang.zig @@ -128,7 +128,7 @@ test "statementize" { { const input = &[_][]const u8{ "foo", "bar", "baz" }; const expect_0 = [_][]const u8{ "foo", "bar", "baz" }; - var result = try statementize(std.heap.c_allocator, input[0..]); + const result = try statementize(std.heap.c_allocator, input[0..]); try std.testing.expectEqual(@as(usize, @intCast(1)), result.len); for (result[0], 0..) |_, idx| { try std.testing.expect(std.mem.eql(u8, expect_0[idx], result[0][idx])); @@ -140,7 +140,7 @@ test "statementize" { const input = &[_][]const u8{ "foo", "bar", "baz", ";", "bil", "nil", ";" }; const expect_0 = [_][]const u8{ "foo", "bar", "baz" }; const expect_1 = [_][]const u8{ "bil", "nil" }; - var result = try statementize(std.heap.c_allocator, input[0..]); + const result = try statementize(std.heap.c_allocator, input[0..]); try std.testing.expectEqual(@as(usize, @intCast(2)), result.len); for (result[0], 0..) |_, idx| { try std.testing.expect(std.mem.eql(u8, expect_0[idx], result[0][idx])); @@ -155,7 +155,7 @@ test "statementize" { const input = &[_][]const u8{ "foo", "[", "bar", "[", "gill", "]", "]", "baz", ";", "bil", "nil", ";" }; const expect_0 = [_][]const u8{ "foo", "[", "bar", "[", "gill", "]", "]", "baz" }; const expect_1 = [_][]const u8{ "bil", "nil" }; - var result = try statementize(std.heap.c_allocator, input[0..]); + const result = try statementize(std.heap.c_allocator, input[0..]); try std.testing.expectEqual(@as(usize, @intCast(2)), result.len); for (result[0], 0..) |_, idx| { try std.testing.expect(std.mem.eql(u8, expect_0[idx], result[0][idx])); @@ -168,7 +168,7 @@ test "statementize" { // Returns error for unmatched [] inputs { const input = &[_][]const u8{ "foo", "]", ";" }; - var result = statementize(std.heap.c_allocator, input[0..]); + const result = statementize(std.heap.c_allocator, input[0..]); try std.testing.expectEqual(result, error.UnbalancedBrackets); } } @@ -177,8 +177,8 @@ test "tokenize" { { // basic tokenization test based on whitespace const input = "foo bar baz"; - var expect = [_][]const u8{ "foo", "bar", "baz" }; - var result = try tokenize(std.heap.c_allocator, input); + const expect = [_][]const u8{ "foo", "bar", "baz" }; + const result = try tokenize(std.heap.c_allocator, input); try std.testing.expectEqual(@as(usize, @intCast(3)), result.len); for (result, 0..) |_, idx| { try std.testing.expect(std.mem.eql(u8, expect[idx], result[idx])); @@ -188,8 +188,8 @@ test "tokenize" { { // e.g. treats [] brackets as individual tokens irregardless of whitespace (test [foo]) const input = "foo bar [baz]"; - var expect = [_][]const u8{ "foo", "bar", "[", "baz", "]" }; - var result = try tokenize(std.heap.c_allocator, input); + const expect = [_][]const u8{ "foo", "bar", "[", "baz", "]" }; + const result = try tokenize(std.heap.c_allocator, input); try std.testing.expectEqual(@as(usize, @intCast(5)), result.len); for (result, 0..) |_, idx| { try std.testing.expect(std.mem.eql(u8, expect[idx], result[idx])); @@ -199,8 +199,8 @@ test "tokenize" { { // e.g. treats [] brackets as individual tokens irregardless of whitespace (test [ foo]) const input = "foo bar [ baz]"; - var expect = [_][]const u8{ "foo", "bar", "[", "baz", "]" }; - var result = try tokenize(std.heap.c_allocator, input); + const expect = [_][]const u8{ "foo", "bar", "[", "baz", "]" }; + const result = try tokenize(std.heap.c_allocator, input); try std.testing.expectEqual(@as(usize, @intCast(5)), result.len); for (result, 0..) |_, idx| { try std.testing.expect(std.mem.eql(u8, expect[idx], result[idx])); @@ -217,7 +217,7 @@ test "argize" { expect: []const types.MepoArg, }; - var specs = [_]spec{ + const specs = [_]spec{ .{ // Standard check to make sure text / numbers argized properly .input = &[_][]const u8{ "arga", "22.2" }, diff --git a/src/util/utilsdl.zig b/src/util/utilsdl.zig index 0ff0501..ec2f4f9 100644 --- a/src/util/utilsdl.zig +++ b/src/util/utilsdl.zig @@ -52,7 +52,7 @@ pub fn sdl_push_event_signal(signal: c_int) callconv(.C) void { } pub fn sdl_renderer_set_draw_color(renderer: *sdl.SDL_Renderer, color: types.Color) errors.SDLError!void { - var sdl_color = color.to_sdl(); + const sdl_color = color.to_sdl(); const blend_mode = if (sdl_color.a != sdl.SDL_ALPHA_OPAQUE) sdl.SDL_BLENDMODE_ADD else sdl.SDL_BLENDMODE_NONE; try errorcheck(sdl.SDL_SetRenderDrawBlendMode(renderer, @intCast(blend_mode))); try errorcheck(sdl.SDL_SetRenderDrawColor(renderer, sdl_color.r, sdl_color.g, sdl_color.b, color.opacity)); -- 2.44.0
--- src/main.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.zig b/src/main.zig index 77b0eb4..b477ad7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -12,8 +12,8 @@ const utildbg = @import("./util/utildbg.zig"); pub fn main() !void { comptime { const v = builtin.zig_version; - if (v.major != 0 or v.minor != 11) - @panic("Must be built against Zig 0.11.x"); + if (v.major != 0 or v.minor != 12) + @panic("Must be built against Zig 0.12.x"); } const allocator = std.heap.c_allocator; -- 2.44.0
--- src/api/bind_signal.zig | 11 +++++------ src/api/filedump.zig | 8 ++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/api/bind_signal.zig b/src/api/bind_signal.zig index 235dde2..05d8a0c 100644 --- a/src/api/bind_signal.zig +++ b/src/api/bind_signal.zig @@ -27,13 +27,13 @@ fn bind_signal(mepo: *Mepo, signo_str: [:0]const u8, expression: []const u8) !vo // Signal var signal_name: u6 = 0; if (std.mem.orderZ(u8, signo_str, "USR1") == .eq) { - signal_name = std.os.SIG.USR1; + signal_name = std.os.linux.SIG.USR1; } else if (std.mem.orderZ(u8, signo_str, "USR2") == .eq) { - signal_name = std.os.SIG.USR2; + signal_name = std.os.linux.SIG.USR2; } else if (std.mem.orderZ(u8, signo_str, "TERM") == .eq) { - signal_name = std.os.SIG.TERM; + signal_name = std.os.linux.SIG.TERM; } else if (std.mem.orderZ(u8, signo_str, "INT") == .eq) { - signal_name = std.os.SIG.INT; + signal_name = std.os.linux.SIG.INT; } else { return error.InvalidSignalName; } @@ -45,8 +45,7 @@ fn bind_signal(mepo: *Mepo, signo_str: [:0]const u8, expression: []const u8) !vo .flags = 0, }; - std.os.sigaction(signal_name, &signal_action, null) - catch return error.FailedToSetupSighandler; + std.os.sigaction(signal_name, &signal_action, null) catch return error.FailedToSetupSighandler; if (mepo.table_signals.get(signal_name)) |heap_str| { mepo.allocator.free(heap_str); diff --git a/src/api/filedump.zig b/src/api/filedump.zig index bbc892e..38adbb0 100644 --- a/src/api/filedump.zig +++ b/src/api/filedump.zig @@ -105,10 +105,10 @@ fn filedump(mepo: *Mepo, save_types: []const u8, filepath: []const u8) !void { var it_sigs = mepo.table_signals.iterator(); while (it_sigs.next()) |sig| { const signame = switch (sig.key_ptr.*) { - std.os.SIG.USR1 => "USR1", - std.os.SIG.USR2 => "USR2", - std.os.SIG.INT => "INT", - std.os.SIG.TERM => "TERM", + std.os.linux.SIG.USR1 => "USR1", + std.os.linux.SIG.USR2 => "USR2", + std.os.linux.SIG.INT => "INT", + std.os.linux.SIG.TERM => "TERM", else => continue, }; -- 2.44.0
--- src/Mepo.zig | 2 +- src/util/utilfile.zig | 4 ++-- src/util/utilplatform.zig | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mepo.zig b/src/Mepo.zig index dc49cab..eb7f8cf 100644 --- a/src/Mepo.zig +++ b/src/Mepo.zig @@ -710,7 +710,7 @@ fn setup_sdl_video_and_window(allocator: std.mem.Allocator) !*sdl.SDL_Window { config.InitWindowH, sdl.SDL_WINDOW_SHOWN | sdl.SDL_WINDOW_RESIZABLE | sdl.SDL_WINDOW_ALLOW_HIGHDPI, )); - if (std.os.getenv("MEPO_WINDOW_REPOSITION")) |reposition| { + if (std.posix.getenv("MEPO_WINDOW_REPOSITION")) |reposition| { if (reposition.len == 1 and reposition[0] == '1') { sdl.SDL_SetWindowPosition(w, 0, 0); } diff --git a/src/util/utilfile.zig b/src/util/utilfile.zig index 950964e..d0656e9 100644 --- a/src/util/utilfile.zig +++ b/src/util/utilfile.zig @@ -29,8 +29,8 @@ pub fn wordexp_filepath(allocator: std.mem.Allocator, path: []const u8) ![:0]con .default_home_path = ".cache", }, }) |default_mapping| { - if (std.os.getenv(default_mapping.env_var) != null) continue; - if (std.os.getenv("HOME")) |home_dir| { + if (std.posix.getenv(default_mapping.env_var) != null) continue; + if (std.posix.getenv("HOME")) |home_dir| { const value = try std.fmt.allocPrintZ(allocator, "{s}/{s}", .{ home_dir, default_mapping.default_home_path }); defer allocator.free(value); _ = cstdlib.setenv(&default_mapping.env_var[0], &value[0], 1); diff --git a/src/util/utilplatform.zig b/src/util/utilplatform.zig index 204a802..65d0dcc 100644 --- a/src/util/utilplatform.zig +++ b/src/util/utilplatform.zig @@ -9,7 +9,7 @@ pub fn supports_osk() bool { pub fn xdg_session_desktop() enum { Phosh, Plamo, Unknown } { var env_session_desktop: []const u8 = "unknown"; - if (std.os.getenv("XDG_SESSION_DESKTOP")) |v| { + if (std.posix.getenv("XDG_SESSION_DESKTOP")) |v| { env_session_desktop = v; } -- 2.44.0
--- src/api/bind_signal.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/bind_signal.zig b/src/api/bind_signal.zig index 05d8a0c..a80033b 100644 --- a/src/api/bind_signal.zig +++ b/src/api/bind_signal.zig @@ -39,13 +39,13 @@ fn bind_signal(mepo: *Mepo, signo_str: [:0]const u8, expression: []const u8) !vo } // Register generic signal handler - const signal_action = std.os.Sigaction{ + const signal_action = std.posix.Sigaction{ .handler = .{ .handler = utilsdl.sdl_push_event_signal }, - .mask = std.os.empty_sigset, + .mask = std.posix.empty_sigset, .flags = 0, }; - std.os.sigaction(signal_name, &signal_action, null) catch return error.FailedToSetupSighandler; + std.posix.sigaction(signal_name, &signal_action, null) catch return error.FailedToSetupSighandler; if (mepo.table_signals.get(signal_name)) |heap_str| { mepo.allocator.free(heap_str); -- 2.44.0
--- src/Mepo.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mepo.zig b/src/Mepo.zig index eb7f8cf..9541a2b 100644 --- a/src/Mepo.zig +++ b/src/Mepo.zig @@ -362,7 +362,7 @@ pub fn mepolang_execute(mepo: *@This(), mepolang_text: []const u8) !void { if (FnTable.get(statement[0])) |fn_spec| { const args: []types.MepoArg = try utilmepolang.argize(arena.allocator(), statement[1..statement.len]); var caller_args: [types.MepoFnNargs]types.MepoArg = undefined; - std.mem.copy(types.MepoArg, caller_args[0..], args); + std.mem.copyForwards(types.MepoArg, caller_args[0..], args); utildbg.log("Running API function for: {s} requested by mepolang input statement: {s}\n", .{ statement[0], statement }); _ = mepolang_execute_validate_args(fn_spec, args) catch |e| { -- 2.44.0
--- src/api/pin_cycle.zig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/api/pin_cycle.zig b/src/api/pin_cycle.zig index cc1a73f..fdd33cf 100644 --- a/src/api/pin_cycle.zig +++ b/src/api/pin_cycle.zig @@ -14,8 +14,7 @@ pub const spec = .{ }; fn execute(mepo: *Mepo, args: [types.MepoFnNargs]types.MepoArg) !void { - try pin_cycle(mepo, @as(i32, @intFromFloat(args[0].Number)) == 1, - @intFromFloat(args[1].Number)); + try pin_cycle(mepo, @as(i32, @intFromFloat(args[0].Number)) == 1, @intFromFloat(args[1].Number)); } pub fn pin_cycle(mepo: *Mepo, viewport_only: bool, delta: i32) !void { @@ -25,7 +24,7 @@ pub fn pin_cycle(mepo: *Mepo, viewport_only: bool, delta: i32) !void { var target_i = if (mepo.pin_group_active_item) |active_item| @as(i32, @intCast(active_item)) else 0; const group_unordered = !p.get(p.pingroup_prop(mepo.pin_group_active, .Ordered)).b; const add: i32 = if (delta > 0) 1 else -1; - for (0..std.math.absCast(delta)) |_| { + for (0..@abs(delta)) |_| { var pin_i = target_i + add; // E.g. two conditions to skip and continually increase pin_i: // 1. Within an ordered group, structural pins should be skipped -- 2.44.0
--- src/api/shellpipe_sync.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/shellpipe_sync.zig b/src/api/shellpipe_sync.zig index a96ad1a..71051fd 100644 --- a/src/api/shellpipe_sync.zig +++ b/src/api/shellpipe_sync.zig @@ -32,7 +32,7 @@ fn shellpipe_sync(mepo: *Mepo, cmd: []const u8) !void { try mepo.blit(); const env_vars = try get_env_vars(mepo, arena.allocator()); const args = [_][]const u8{ "sh", "-c", cmd }; - const process_result = try std.ChildProcess.exec(.{ + const process_result = try std.ChildProcess.run(.{ .allocator = arena.allocator(), .argv = args[0..], .env_map = &env_vars, -- 2.44.0
--- src/Mepo.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mepo.zig b/src/Mepo.zig index 9541a2b..998f7d9 100644 --- a/src/Mepo.zig +++ b/src/Mepo.zig @@ -618,7 +618,7 @@ pub fn graceful_terminate_sdl() void { sdl.IMG_Quit(); sdl.SDL_VideoQuit(); sdl.SDL_Quit(); - std.os.exit(0); + std.posix.exit(0); } pub fn sighandle_terminate(arg: c_int) callconv(.C) void { -- 2.44.0
--- src/api/shellpipe_async.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/shellpipe_async.zig b/src/api/shellpipe_async.zig index f45b3e4..63c919a 100644 --- a/src/api/shellpipe_async.zig +++ b/src/api/shellpipe_async.zig @@ -68,19 +68,19 @@ fn async_shellpipe_run_catch_errors(mepo: *Mepo, unique_handle_id: i8, cmd: []co var stdout = std.ArrayList(u8).init(mepo.allocator); errdefer stdout.deinit(); - var poll_fds = [_]std.os.pollfd{ - .{ .fd = child.stdout.?.handle, .events = std.os.POLL.IN, .revents = undefined }, + var poll_fds = [_]std.posix.pollfd{ + .{ .fd = child.stdout.?.handle, .events = std.posix.POLL.IN, .revents = undefined }, }; const bump_amt = 512; var continue_reading = true; while (continue_reading) { - const events = try std.os.poll(&poll_fds, std.math.maxInt(i32)); + const events = try std.posix.poll(&poll_fds, std.math.maxInt(i32)); if (events == 0) continue; - if (poll_fds[0].revents & std.os.POLL.IN != 0) { + if (poll_fds[0].revents & std.posix.POLL.IN != 0) { try stdout.ensureTotalCapacity(@min(stdout.items.len + bump_amt, max_output_bytes)); if (stdout.unusedCapacitySlice().len == 0) return error.StdoutStreamTooLong; - const nread = try std.os.read(poll_fds[0].fd, stdout.unusedCapacitySlice()); + const nread = try std.posix.read(poll_fds[0].fd, stdout.unusedCapacitySlice()); if (nread == 0) { continue_reading = false; continue; @@ -93,7 +93,7 @@ fn async_shellpipe_run_catch_errors(mepo: *Mepo, unique_handle_id: i8, cmd: []co utilsdl.sdl_push_event_mepolang_execution(heap_statement); try stdout.replaceRange(0, mepolang_statement_end_index + 1, &[_]u8{}); } - } else if (poll_fds[0].revents & (std.os.POLL.ERR | std.os.POLL.NVAL | std.os.POLL.HUP) != 0) { + } else if (poll_fds[0].revents & (std.posix.POLL.ERR | std.posix.POLL.NVAL | std.posix.POLL.HUP) != 0) { continue_reading = false; continue; } -- 2.44.0
--- src/Mepo.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Mepo.zig b/src/Mepo.zig index 998f7d9..b8f9fe3 100644 --- a/src/Mepo.zig +++ b/src/Mepo.zig @@ -23,8 +23,8 @@ debug_message: ?[]const u8 = null, drag: ?struct { begin_ticks: u32, point: sdl.SDL_Point, - delta_x: i32 = 0, - delta_y: i32 = 0, + delta_x: u32 = 0, + delta_y: u32 = 0, } = null, fingers: std.ArrayList(sdl.SDL_FingerID), fingers_gesture_delta: isize = 0, @@ -169,14 +169,14 @@ fn event_mousebuttonup(mepo: *@This(), e: sdl.SDL_Event) types.Pending { var closest_match_pin: ?struct { pin_group_i: u8, pin_i: u32, - delta_dist: i32, + delta_dist: u32, } = null; for (mepo.pin_groups, 0..) |pin_group, pin_group_i| { for (pin_group.items, 0..) |*item, pin_i| { if (item.category == .Structural) continue; const pin_x = mepo.convert_latlon_to_xy(.LonToX, item.lon); const pin_y = mepo.convert_latlon_to_xy(.LatToY, item.lat); - const delta = (std.math.absInt(pin_x - cursor.x) catch continue) + (std.math.absInt(pin_y - cursor.y) catch continue); + const delta = @abs(pin_x - cursor.x) + @abs(pin_y - cursor.y); if (delta < config.ClickPinMaxDelta and (closest_match_pin == null or closest_match_pin.?.delta_dist > delta)) { closest_match_pin = .{ .pin_group_i = @intCast(pin_group_i), @@ -212,8 +212,8 @@ fn event_mousemotion(mepo: *@This(), e: sdl.SDL_Event) types.Pending { if (mepo.drag != null and mepo.within_touch_bounds(cursor.x, cursor.y)) { mepo.drag.?.point.x = cursor.x; mepo.drag.?.point.y = cursor.y; - mepo.drag.?.delta_x += std.math.absInt(e.motion.xrel) catch unreachable; - mepo.drag.?.delta_y += std.math.absInt(e.motion.yrel) catch unreachable; + mepo.drag.?.delta_x += @abs(e.motion.xrel); + mepo.drag.?.delta_y += @abs(e.motion.yrel); mepo.set_x(mepo.get_x() - (e.motion.xrel * p.get(p.pref.drag_scale).u)); mepo.set_y(mepo.get_y() - (e.motion.yrel * p.get(p.pref.drag_scale).u)); return .Drag; -- 2.44.0