authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 23:46:08 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 23:46:08 -07:00
log8f09305b8088596d37e78fe053b9494ec89a1f31
treec7f827cb68d2e0f131c02b6053d2290b6cb40a03
parente1aad7a592e568a9471213ef9fe885608ad52941
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

update to zig 0.15.2


2 files changed, 21 insertions(+), 21 deletions(-)

README.md+1-1
......@@ -3,7 +3,7 @@
33![loc](https://sloc.xyz/github/nektro/zig-qrcode)
44[![license](https://img.shields.io/github/license/nektro/zig-qrcode.svg)](https://github.com/nektro/zig-qrcode/blob/master/LICENSE)
55[![nektro @ github sponsors](https://img.shields.io/badge/sponsors-nektro-purple?logo=github)](https://github.com/sponsors/nektro)
6[![Zig](https://img.shields.io/badge/Zig-0.14-f7a41d)](https://ziglang.org/)
6[![Zig](https://img.shields.io/badge/Zig-0.15-f7a41d)](https://ziglang.org/)
77[![Zigmod](https://img.shields.io/badge/Zigmod-latest-f7a41d)](https://github.com/nektro/zigmod)
88
99Zig library for quick-response (QR) codes
qrcode.zig+20-20
......@@ -486,7 +486,7 @@ fn BitGrid(comptime size: usize) type {
486486 }
487487
488488 pub fn asBlockString(grid: *const @This(), allocator: std.mem.Allocator) ![]u8 {
489 var content: std.ArrayList(u8) = .init(allocator);
489 var content: std.Io.Writer.Allocating = .init(allocator);
490490 errdefer content.deinit();
491491 for (0..grid.size / 2 + 1) |y| {
492492 for (0..grid.size / 2 + 1) |x| {
......@@ -503,16 +503,16 @@ fn BitGrid(comptime size: usize) type {
503503 }
504504 }
505505 const characters = [_][]const u8{ " ", "▘", "▖", "▌", "▝", "▀", "▞", "▛", "▗", "▚", "▄", "▙", "▐", "▜", "▟", "█" };
506 try content.appendSlice(characters[(idx.mask)]);
506 try content.writer.writeAll(characters[(idx.mask)]);
507507 }
508 if (builtin.is_test) try content.appendSlice("|");
509 try content.appendSlice("\n");
508 if (builtin.is_test) try content.writer.writeAll("|");
509 try content.writer.writeAll("\n");
510510 }
511511 return content.toOwnedSlice();
512512 }
513513
514514 pub fn asBlockString2(grid: *const @This(), allocator: std.mem.Allocator) ![]u8 {
515 var content: std.ArrayList(u8) = .init(allocator);
515 var content: std.Io.Writer.Allocating = .init(allocator);
516516 errdefer content.deinit();
517517 for (0..grid.size / 2 + 1) |y| {
518518 for (0..grid.size) |x| {
......@@ -527,17 +527,17 @@ fn BitGrid(comptime size: usize) type {
527527 idx.set(y2);
528528 }
529529 const characters = [_][]const u8{ " ", "▀", "▄", "█" };
530 try content.appendSlice(characters[(idx.mask)]);
530 try content.writer.writeAll(characters[(idx.mask)]);
531531 }
532 if (builtin.is_test) try content.appendSlice("|");
533 try content.appendSlice("\n");
532 if (builtin.is_test) try content.writer.writeAll("|");
533 try content.writer.writeAll("\n");
534534 }
535535 return content.toOwnedSlice();
536536 }
537537
538538 pub fn asBrailleString(grid: *const @This(), allocator: std.mem.Allocator) ![]u8 {
539539 const B = packed struct(u8) { @"0": bool, @"1": bool, @"2": bool, @"3": bool, @"4": bool, @"5": bool, @"6": bool, @"7": bool };
540 var content: std.ArrayList(u8) = .init(allocator);
540 var content: std.Io.Writer.Allocating = .init(allocator);
541541 errdefer content.deinit();
542542 for (0..grid.size / 4 + 1) |y| {
543543 for (0..grid.size / 2 + 1) |x| {
......@@ -557,23 +557,23 @@ fn BitGrid(comptime size: usize) type {
557557 cp += @as(u8, @bitCast(b));
558558 var buf: [3]u8 = undefined;
559559 _ = std.unicode.utf8Encode(cp, &buf) catch unreachable;
560 try content.appendSlice(&buf);
560 try content.writer.writeAll(&buf);
561561 }
562 if (builtin.is_test) try content.appendSlice("|");
563 try content.appendSlice("\n");
562 if (builtin.is_test) try content.writer.writeAll("|");
563 try content.writer.writeAll("\n");
564564 }
565565 return content.toOwnedSlice();
566566 }
567567
568568 pub fn asSvg(grid: *const @This(), allocator: std.mem.Allocator) ![]u8 {
569 var content: std.ArrayList(u8) = .init(allocator);
569 var content: std.Io.Writer.Allocating = .init(allocator);
570570 errdefer content.deinit();
571 try content.writer().print("<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{d}0\" height=\"{d}0\" viewBox=\"-1 -1 {d} {d}\" shape-rendering=\"crispEdges\" stroke=\"#000\">\n", .{ size + 2, size + 1, size + 2, size + 1 });
572 try content.writer().print("<rect x=\"-1\" y=\"-1\" width=\"{d}\" height=\"{d}\" fill=\"#fff\" stroke=\"none\" />\n", .{ size + 2, size + 1 });
571 try content.writer.print("<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{d}0\" height=\"{d}0\" viewBox=\"-1 -1 {d} {d}\" shape-rendering=\"crispEdges\" stroke=\"#000\">\n", .{ size + 2, size + 1, size + 2, size + 1 });
572 try content.writer.print("<rect x=\"-1\" y=\"-1\" width=\"{d}\" height=\"{d}\" fill=\"#fff\" stroke=\"none\" />\n", .{ size + 2, size + 1 });
573573 var prev = false;
574574 var run: u16 = 0;
575575 for (0..size) |y| {
576 try content.appendSlice("<path d=\"");
576 try content.writer.writeAll("<path d=\"");
577577 for (0..size) |x| {
578578 if (x == 0) {
579579 run = 0;
......@@ -584,7 +584,7 @@ fn BitGrid(comptime size: usize) type {
584584 run += 1;
585585 } else {
586586 if (prev) {
587 try content.writer().print("M{d},{d} h{d} ", .{ x - run, y, run });
587 try content.writer.print("M{d},{d} h{d} ", .{ x - run, y, run });
588588 }
589589 run = 1;
590590 }
......@@ -592,11 +592,11 @@ fn BitGrid(comptime size: usize) type {
592592 }
593593 if (grid.isSet(size - 1, y)) {
594594 const x = size;
595 try content.writer().print("M{d},{d} h{d}", .{ x - run, y, run });
595 try content.writer.print("M{d},{d} h{d}", .{ x - run, y, run });
596596 }
597 try content.appendSlice("\" />\n");
597 try content.writer.writeAll("\" />\n");
598598 }
599 try content.appendSlice("</svg>\n");
599 try content.writer.writeAll("</svg>\n");
600600 return content.toOwnedSlice();
601601 }
602602 };