diff --git a/src/collate.zig b/src/collate.zig index 0a7130b..cb09e70 100644 --- a/src/collate.zig +++ b/src/collate.zig @@ -341,7 +341,7 @@ pub const Collator = struct { fn splitTrackNumber(as_string: []const u8) TrackNumber { var track_number: TrackNumber = undefined; - var split_it = std.mem.split(u8, as_string, "/"); + var split_it = std.mem.splitScalar(u8, as_string, '/'); const number_str = split_it.next(); track_number.number = parseNumberDisallowingZero(u32, number_str); diff --git a/src/fields.zig b/src/fields.zig index e69508c..fb8db8b 100644 --- a/src/fields.zig +++ b/src/fields.zig @@ -8,7 +8,7 @@ const MetadataType = @import("metadata.zig").MetadataType; // causes a compile error. This should not cause any false positives // since it's assumed any MetadataType will at least have an artist field. comptime { - for (@typeInfo(MetadataType).Enum.fields) |enum_field| { + for (@typeInfo(MetadataType).@"enum".fields) |enum_field| { if (artist[enum_field.value] == null) { const msg = std.fmt.comptimePrint("Found null field name for MetadataType '{s}' in artist lookup table. Note: Also double check that all other field lookup tables are populated correctly for this MetadataType, as the artist lookup table is used as a canary in a coal mine.", .{enum_field.name}); @compileError(msg); diff --git a/src/id3v2.zig b/src/id3v2.zig index ecd44f1..bb7e8f5 100644 --- a/src/id3v2.zig +++ b/src/id3v2.zig @@ -366,7 +366,7 @@ pub const EncodedTextIterator = struct { } val_no_bom = bytes_as_utf16[1..]; } - const utf8_end = std.unicode.utf16leToUtf8(self.utf8_buf, val_no_bom) catch return error.InvalidUTF16Data; + const utf8_end = std.unicode.utf16LeToUtf8(self.utf8_buf, val_no_bom) catch return error.InvalidUTF16Data; return self.utf8_buf[0..utf8_end]; } else { if (!std.unicode.utf8ValidateSlice(val_bytes)) return error.InvalidUTF8Data; diff --git a/src/metadata.zig b/src/metadata.zig index f1af689..dc48df6 100644 --- a/src/metadata.zig +++ b/src/metadata.zig @@ -226,7 +226,7 @@ pub const MetadataType = enum { vorbis, mp4, - pub const num_types = @typeInfo(MetadataType).Enum.fields.len; + pub const num_types = @typeInfo(MetadataType).@"enum".fields.len; }; pub const TypedMetadata = union(MetadataType) { @@ -391,7 +391,7 @@ pub const AllMetadata = struct { pub fn countIgnoringDuplicates(self: AllMetadata) usize { var count: usize = 0; - inline for (@typeInfo(MetadataType).Enum.fields) |enum_field| { + inline for (@typeInfo(MetadataType).@"enum".fields) |enum_field| { const tag_type: MetadataType = @enumFromInt(enum_field.value); if (self.getFirstMetadataOfType(tag_type) != null) { count += 1; diff --git a/src/mp4.zig b/src/mp4.zig index d5fc33e..756cc64 100644 --- a/src/mp4.zig +++ b/src/mp4.zig @@ -314,7 +314,7 @@ pub fn readMetadataItem(allocator: Allocator, reader: anytype, seekable_stream: } // convert to UTF-8 - const value_utf8 = std.unicode.utf16leToUtf8Alloc(allocator, value_utf16) catch |err| switch (err) { + const value_utf8 = std.unicode.utf16LeToUtf8Alloc(allocator, value_utf16) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, else => return error.InvalidUTF16Data, }; diff --git a/src/synchsafe.zig b/src/synchsafe.zig index fa20e38..ec8c0a2 100644 --- a/src/synchsafe.zig +++ b/src/synchsafe.zig @@ -2,9 +2,9 @@ const std = @import("std"); const assert = std.debug.assert; pub fn EncodedType(comptime T: type) type { - comptime assert(@typeInfo(T) == .Int); - comptime assert(@typeInfo(T).Int.signedness == .unsigned); - const num_bits = @typeInfo(T).Int.bits; + comptime assert(@typeInfo(T) == .int); + comptime assert(@typeInfo(T).int.signedness == .unsigned); + const num_bits = @typeInfo(T).int.bits; const num_bytes_ceil = try std.math.divCeil(comptime_int, num_bits, 8); const num_zero_bits_available = (num_bytes_ceil * 8) - num_bits; const num_zero_bits_needed = num_bytes_ceil; @@ -16,9 +16,9 @@ pub fn EncodedType(comptime T: type) type { } pub fn DecodedType(comptime T: type) type { - comptime assert(@typeInfo(T) == .Int); - comptime assert(@typeInfo(T).Int.signedness == .unsigned); - const num_bits = @typeInfo(T).Int.bits; + comptime assert(@typeInfo(T) == .int); + comptime assert(@typeInfo(T).int.signedness == .unsigned); + const num_bits = @typeInfo(T).int.bits; comptime assert(num_bits % 8 == 0); const num_bytes = num_bits / 8; // every byte has 1 unavailable bit @@ -28,7 +28,7 @@ pub fn DecodedType(comptime T: type) type { pub fn decode(comptime T: type, x: T) DecodedType(T) { var out: T = 0; - var mask: T = 0x7F << (@typeInfo(T).Int.bits - 8); + var mask: T = 0x7F << (@typeInfo(T).int.bits - 8); while (mask != 0) { out >>= 1; @@ -46,7 +46,7 @@ pub fn encode(comptime T: type, x: T) EncodedType(T) { // compute masks at compile time so that we can handle any // sized integer without any runtime cost - const byte_count = @typeInfo(OutType).Int.bits / 8; + const byte_count = @typeInfo(OutType).int.bits / 8; const byte_masks = comptime blk: { var masks_array: [byte_count]OutType = undefined; masks_array[0] = 0x7F; @@ -83,9 +83,9 @@ pub fn isSliceSynchsafe(bytes: []const u8) bool { /// Returns true if the given integer has no non-synchsafe /// bytes within it. pub fn areIntBytesSynchsafe(comptime T: type, x: T) bool { - comptime assert(@typeInfo(T) == .Int); - comptime assert(@typeInfo(T).Int.signedness == .unsigned); - const num_bits = @typeInfo(T).Int.bits; + comptime assert(@typeInfo(T) == .int); + comptime assert(@typeInfo(T).int.signedness == .unsigned); + const num_bits = @typeInfo(T).int.bits; if (num_bits < 8) return true; const mask: T = comptime mask: { @@ -110,8 +110,8 @@ pub fn areIntBytesSynchsafe(comptime T: type, x: T) bool { /// has the opposite guarantee--the encoded and decoded values /// will always differ. pub fn isBelowSynchsafeThreshold(comptime T: type, x: T) bool { - comptime assert(@typeInfo(T) == .Int); - comptime assert(@typeInfo(T).Int.signedness == .unsigned); + comptime assert(@typeInfo(T) == .int); + comptime assert(@typeInfo(T).int.signedness == .unsigned); return std.math.maxInt(T) < 128 or x < 128; } diff --git a/src/vorbis.zig b/src/vorbis.zig index 5135042..32502d1 100644 --- a/src/vorbis.zig +++ b/src/vorbis.zig @@ -45,7 +45,7 @@ pub fn readComment(allocator: Allocator, reader: anytype, seekable_stream: anyty continue; } - var split_it = std.mem.split(u8, comment, "="); + var split_it = std.mem.splitScalar(u8, comment, '='); const field = split_it.next() orelse return error.InvalidCommentField; const value = split_it.rest(); diff --git a/test/test_against_ffprobe.zig b/test/test_against_ffprobe.zig index 6b8e488..1ff7863 100644 --- a/test/test_against_ffprobe.zig +++ b/test/test_against_ffprobe.zig @@ -386,11 +386,11 @@ fn getFFProbeMetadata(allocator: Allocator, cwd: ?std.fs.Dir, filepath: []const defer allocator.free(indentation); std.mem.set(u8, indentation, ' '); - var line_it = std.mem.split(u8, metadata_text, "\n"); + var line_it = std.mem.splitScalar(u8, metadata_text, '\n'); while (line_it.next()) |line| { if (!std.mem.startsWith(u8, line, indentation)) break; - var field_it = std.mem.split(u8, line, ":"); + var field_it = std.mem.splitScalar(u8, line, ':'); const name = std.mem.trim(u8, field_it.next().?, " "); if (name.len == 0) continue; // TODO multiline values