From d5d5f7f06397d73f497d352f2f38b1a53d932b0d Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Mon, 19 Feb 2024 23:38:33 +0200 Subject: Big update to modern zig --- src/Syntax.zig | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/Syntax.zig') diff --git a/src/Syntax.zig b/src/Syntax.zig index 6858027..18ed477 100644 --- a/src/Syntax.zig +++ b/src/Syntax.zig @@ -10,8 +10,7 @@ const Syntax = @This(); pub const chooseSyntax = ComptimeStringMap( Syntax, - pairWith(&makefile.filematch, makefile.syntax) - ++ pairWith(&zig.filematch, zig.syntax), + pairWith(&makefile.filematch, makefile.syntax) ++ pairWith(&zig.filematch, zig.syntax), ).get; pub const Flags = struct { @@ -20,7 +19,7 @@ pub const Flags = struct { }; name: []const u8, -keyword_classifier: fn([]const u8) ?Highlight, +keyword_classifier: *const fn ([]const u8) ?Highlight, singleline_comment_start: ?[]const u8, multiline_comment_start: ?[]const u8, multiline_comment_end: ?[]const u8, @@ -28,7 +27,7 @@ separators: []const u8, flags: Flags, pub fn isSeparator(self: Syntax, char: u8) bool { - return std.ascii.isSpace(char) or std.mem.indexOfScalar(u8, self.separators, char) != null; + return std.ascii.isWhitespace(char) or std.mem.indexOfScalar(u8, self.separators, char) != null; } pub fn pairWith( @@ -37,8 +36,8 @@ pub fn pairWith( ) [keys.len]KeyValue(@TypeOf(value)) { @setEvalBranchQuota(20000); - var pairs = [_]KeyValue(@TypeOf(value)) {undefined} ** keys.len; - for (keys) |key, i| { + var pairs = [_]KeyValue(@TypeOf(value)){undefined} ** keys.len; + for (keys, 0..) |key, i| { pairs[i] = .{ .@"0" = key, .@"1" = value }; } @@ -51,4 +50,3 @@ fn KeyValue(comptime V: type) type { @"1": V, }; } - -- cgit v1.2.3