Skip to content

Commit

Permalink
upgrade to zig 0.12
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro authored and truemedian committed May 25, 2024
1 parent 31563ce commit a7f03a1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ deps.zig

# zigmod
.zigmod/
zigmod.lock

# gyro
.gyro/
Expand Down
13 changes: 10 additions & 3 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
const std = @import("std");

var filters: [1][]const u8 = undefined;
var filters_len: usize = 0;

pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const test_filter = b.option([]const u8, "test-filter", "Filter the executed library tests");
const emit_docs = b.option(bool, "emit-docs", "Build library documentation") orelse false;

const module = b.addModule("hzzp", .{
.source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
});

const test_compile_step = b.addTest(.{
.root_source_file = module.source_file,
.root_source_file = module.root_source_file.?,
.target = target,
.optimize = optimize,
});
test_compile_step.filter = test_filter;
if (test_filter) |_| {
filters[0] = test_filter.?;
filters_len += 1;
}
test_compile_step.filters = filters[0..filters_len];

const test_run_step = b.addRunArtifact(test_compile_step);

Expand Down
3 changes: 3 additions & 0 deletions licenses.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MIT:
= https://spdx.org/licenses/MIT
- This
10 changes: 5 additions & 5 deletions src/base/client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@ pub fn BaseClient(comptime Reader: type, comptime Writer: type) type {
}

// This makes interacting with URI parsers like Vexu/zuri much nicer, because you don't need to reconstruct the path.
pub fn writeStatusLineParts(self: *Self, method: []const u8, path: []const u8, query: ?[]const u8, fragment: ?[]const u8) Writer.Error!void {
pub fn writeStatusLineParts(self: *Self, method: []const u8, path: std.Uri.Component, query: ?std.Uri.Component, fragment: ?std.Uri.Component) (Writer.Error || std.mem.Allocator.Error)!void {
assert(!self.head_finished);

try self.writer.writeAll(method);
try self.writer.writeAll(" ");
try self.writer.writeAll(path);
try self.writer.writeAll(try path.toRawMaybeAlloc(std.testing.failing_allocator));

if (query) |qs| {
try self.writer.writeAll("?");
try self.writer.writeAll(qs);
try self.writer.writeAll(try qs.toRawMaybeAlloc(std.testing.failing_allocator));
}

if (fragment) |frag| {
try self.writer.writeAll("#");
try self.writer.writeAll(frag);
try self.writer.writeAll(try frag.toRawMaybeAlloc(std.testing.failing_allocator));
}

try self.writer.writeAll(" HTTP/1.1\r\n");
Expand Down Expand Up @@ -241,7 +241,7 @@ pub fn BaseClient(comptime Reader: type, comptime Writer: type) type {
const size = @min(buffer.len, self.payload_size - start);
const end = start + size;

mem.copy(u8, buffer[0..size], self.read_buffer[start..end]);
@memcpy(buffer[0..size], self.read_buffer[start..end]);
self.payload_index = end;

return size;
Expand Down

0 comments on commit a7f03a1

Please sign in to comment.