Skip to content

Commit

Permalink
Update for 0.14.0-dev.2244+e5d9d3f8a
Browse files Browse the repository at this point in the history
  • Loading branch information
squeek502 committed Jan 11, 2025
1 parent a4ec6b5 commit 0e5e6ee
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/collate.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/fields.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/id3v2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/metadata.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/mp4.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
26 changes: 13 additions & 13 deletions src/synchsafe.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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: {
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/vorbis.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions test/test_against_ffprobe.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0e5e6ee

Please sign in to comment.