Skip to content

zig 0.14 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/zig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
submodules: recursive
- uses: goto-bus-stop/setup-zig@v1
with:
version: 0.13.0
version: 0.14.0
- run: zig build
- run: zig build test
lint:
Expand All @@ -27,5 +27,5 @@ jobs:
submodules: recursive
- uses: goto-bus-stop/setup-zig@v1
with:
version: 0.13.0
version: 0.14.0
- run: zig fmt --check build.zig src/*.zig
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.zig-cache
/zig-cache
/zig-out
8 changes: 4 additions & 4 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ const std = @import("std");
const assert = std.debug.assert;

pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const genent = b.addExecutable(.{
.name = "generate_entities",
.root_source_file = b.path("src/generate_entities.zig"),
.target = b.host,
.target = target,
});
const genent_step = b.addRunArtifact(genent);
const genent_out = genent_step.addOutputFileArg("entities.zig");

const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const mod = b.addModule("htmlentities", .{
.root_source_file = b.path("src/main.zig"),
.optimize = optimize,
Expand Down
6 changes: 3 additions & 3 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.{
.name = "htmlentities.zig",
.name = .htmlentities_zig,
.version = "0.1.0",
.minimum_zig_version = "0.12.0",
.minimum_zig_version = "0.14.0",
.dependencies = .{},

.fingerprint = 0x45088a7324835fcd,
.paths = .{
"entities.json",
"build.zig",
Expand Down
6 changes: 3 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ const entities = @import("entities");
const Entity = entities.Entity;
const Codepoints = entities.Codepoints;

fn order(_: void, lhs: entities.Entity, rhs: Entity) std.math.Order {
fn order(lhs: entities.Entity, rhs: Entity) std.math.Order {
return std.mem.order(u8, lhs.entity, rhs.entity);
}

pub fn lookup(entity: []const u8) ?Entity {
const maybe_index = std.sort.binarySearch(Entity, Entity{
const maybe_index = std.sort.binarySearch(Entity, entities.ENTITIES[0..], Entity{
.entity = entity,
.codepoints = .{ .Single = 0 },
.characters = "",
}, entities.ENTITIES[0..], {}, order);
}, order);

if (maybe_index) |index| {
return entities.ENTITIES[index];
Expand Down