Compare commits

..

No commits in common. "dafc69726ffbe13213cc31891455f046c9a9a430" and "a487d6c2e755e138ac47d334a7852c840d130313" have entirely different histories.

4 changed files with 11 additions and 36 deletions

View file

@ -2,4 +2,4 @@
pre-commit = "latest"
"ubi:DonIsaac/zlint" = "latest"
zig = "0.15.1"
zls = "0.15.0"
zls = "0.14.0"

View file

@ -15,16 +15,19 @@ repos:
- id: zig-build
- repo: local
hooks:
- id: smoke-test
- id: zlint
name: Run zig build smoke-test
entry: zig
args: ["build", "--verbose", "smoke-test"]
language: system
types: [file]
pass_filenames: false
- id: zlint
name: Run zlint
entry: zlint
args: ["--deny-warnings", "--fix"]
language: system
types: [zig]
# - repo: local
# hooks:
# - id: zlint
# name: Run zlint
# entry: zlint
# args: ["--deny-warnings", "--fix"]
# language: system
# types: [zig]

View file

@ -888,8 +888,6 @@ fn parseInt(comptime T: type, val: []const u8) !T {
return rc;
}
/// generalAllocPrint is specific to http headers, which are documented
/// at https://smithy.io/2.0/spec/http-bindings.html#httpheader-trait
fn generalAllocPrint(allocator: std.mem.Allocator, val: anytype) !?[]const u8 {
const T = @TypeOf(val);
switch (@typeInfo(T)) {
@ -900,29 +898,6 @@ fn generalAllocPrint(allocator: std.mem.Allocator, val: anytype) !?[]const u8 {
.one => return try std.fmt.allocPrint(allocator, "{s}", .{val}),
.many => return try std.fmt.allocPrint(allocator, "{s}", .{val}),
.slice => {
if (T == [][]const u8) {
// This would be a list type, which is the described on the first bullet
// of httpHeader trait serialization rules. An example can be found
// in S3 ListObjects API (see the OptionalObjectAttributes property)
// https://smithy.io/2.0/spec/http-bindings.html#serialization-rules
//
// S3 ListObjects REST API: https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjects.html
//
// This also applies to v2, but I don't have usage example here, we're just
// following the spec
//
// tl;dr below, we're putting commas between values
//
// TODO: we need a unit test for this
var vals_len: usize = 0;
for (val, 0..) |v, i| vals_len += v.len + if (i + 1 < v.len) @as(usize, 1) else @as(usize, 0);
var aw = try std.Io.Writer.Allocating.initCapacity(allocator, vals_len);
defer aw.deinit();
const writer = &aw.writer;
for (val, 0..) |v, i|
try writer.print("{s}{s}", .{ v, if (i + 1 < v.len) "," else "" }); // change v to val to trigger compile error (when unit test is written)
return try aw.toOwnedSlice();
}
return try std.fmt.allocPrint(allocator, "{s}", .{val});
},
.c => return try std.fmt.allocPrint(allocator, "{s}", .{val}),

View file

@ -1,3 +0,0 @@
{
"ignore": ["lib/json/src/json.zig"]
}