aboutsummaryrefslogtreecommitdiff
path: root/src/install/semver.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/install/semver.zig')
-rw-r--r--src/install/semver.zig48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/install/semver.zig b/src/install/semver.zig
index ce0208a0e..794867f13 100644
--- a/src/install/semver.zig
+++ b/src/install/semver.zig
@@ -1,4 +1,13 @@
-usingnamespace @import("../global.zig");
+const _global = @import("../global.zig");
+const string = _global.string;
+const Output = _global.Output;
+const Global = _global.Global;
+const Environment = _global.Environment;
+const strings = _global.strings;
+const MutableString = _global.MutableString;
+const stringZ = _global.stringZ;
+const default_allocator = _global.default_allocator;
+const C = _global.C;
const std = @import("std");
/// String type that stores either an offset/length into an external buffer or a string inline directly
@@ -26,7 +35,7 @@ pub const String = extern struct {
str: *const String,
buf: string,
- pub fn format(formatter: Formatter, comptime layout: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
+ pub fn format(formatter: Formatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
const str = formatter.str;
try writer.writeAll(str.slice(formatter.buf));
}
@@ -216,7 +225,7 @@ pub const String = extern struct {
else
&[_]u8{};
}
- pub fn allocate(this: *Builder, allocator: *std.mem.Allocator) !void {
+ pub fn allocate(this: *Builder, allocator: std.mem.Allocator) !void {
var ptr_ = try allocator.alloc(u8, this.cap);
this.ptr = ptr_.ptr;
}
@@ -491,7 +500,7 @@ pub const Version = extern struct {
version: Version,
input: string,
- pub fn format(formatter: Formatter, comptime layout: []const u8, opts: std.fmt.FormatOptions, writer: anytype) !void {
+ pub fn format(formatter: Formatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
const self = formatter.version;
try std.fmt.format(writer, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch });
@@ -509,25 +518,16 @@ pub const Version = extern struct {
}
};
- inline fn atPart(i: u8) u32 {
- return switch (i) {
- 0 => self.major,
- 1 => self.minor,
- 2 => self.patch,
- else => unreachable,
- };
- }
-
pub fn eql(lhs: Version, rhs: Version) bool {
return lhs.major == rhs.major and lhs.minor == rhs.minor and lhs.patch == rhs.patch and rhs.tag.eql(lhs.tag);
}
pub const HashContext = struct {
- pub fn hash(this: @This(), lhs: Version) u32 {
+ pub fn hash(_: @This(), lhs: Version) u32 {
return @truncate(u32, lhs.hash());
}
- pub fn eql(this: @This(), lhs: Version, rhs: Version) bool {
+ pub fn eql(_: @This(), lhs: Version, rhs: Version) bool {
return lhs.eql(rhs);
}
};
@@ -628,7 +628,7 @@ pub const Version = extern struct {
var multi_tag_warn = false;
// TODO: support multiple tags
- pub fn parse(allocator: *std.mem.Allocator, sliced_string: SlicedString) TagResult {
+ pub fn parse(_: std.mem.Allocator, sliced_string: SlicedString) TagResult {
var input = sliced_string.slice;
var build_count: u32 = 0;
var pre_count: u32 = 0;
@@ -658,9 +658,6 @@ pub const Version = extern struct {
var state = State.none;
var start: usize = 0;
- var tag_i: usize = 0;
- var had_content = false;
-
var i: usize = 0;
while (i < input.len) : (i += 1) {
@@ -743,7 +740,7 @@ pub const Version = extern struct {
stopped_at: u32 = 0,
};
- pub fn parse(sliced_string: SlicedString, allocator: *std.mem.Allocator) ParseResult {
+ pub fn parse(sliced_string: SlicedString, allocator: std.mem.Allocator) ParseResult {
var input = sliced_string.slice;
var result = ParseResult{};
@@ -918,7 +915,7 @@ pub const Version = extern struct {
std.debug.assert(input[0] != '.');
- for (input) |char, i| {
+ for (input) |char| {
switch (char) {
'X', 'x', '*' => return 0,
'0'...'9' => {
@@ -1132,7 +1129,7 @@ pub const Query = struct {
return lhs_next.eql(rhs_next);
}
- pub fn andRange(self: *List, allocator: *std.mem.Allocator, range: Range) !void {
+ pub fn andRange(self: *List, allocator: std.mem.Allocator, range: Range) !void {
if (!self.head.range.hasLeft() and !self.head.range.hasRight()) {
self.head.range = range;
return;
@@ -1153,7 +1150,7 @@ pub const Query = struct {
pub const Group = struct {
head: List = List{},
tail: ?*List = null,
- allocator: *std.mem.Allocator,
+ allocator: std.mem.Allocator,
input: string = "",
flags: FlagsBitSet = FlagsBitSet.initEmpty(),
@@ -1432,7 +1429,7 @@ pub const Query = struct {
};
pub fn parse(
- allocator: *std.mem.Allocator,
+ allocator: std.mem.Allocator,
input: string,
sliced: SlicedString,
) !Group {
@@ -1448,9 +1445,6 @@ pub const Query = struct {
var count: u8 = 0;
var skip_round = false;
var is_or = false;
- var enable_hyphen = false;
-
- var last_non_whitespace: usize = 0;
while (i < input.len) {
skip_round = false;