diff options
| author | 2025-08-09 18:57:19 +0800 | |
|---|---|---|
| committer | 2025-08-09 18:57:19 +0800 | |
| commit | e011e342420fe1f1f5d2fee932447b194f989032 (patch) | |
| tree | 01c19ac7f5b7ce540cc3fd98581e29d8f7b782bd /build/Preprocessor.zig | |
| parent | Merge pull request #188 from gracen-writes-code/master (diff) | |
| download | zig-sqlite-e011e342420fe1f1f5d2fee932447b194f989032.tar.gz zig-sqlite-e011e342420fe1f1f5d2fee932447b194f989032.tar.xz zig-sqlite-e011e342420fe1f1f5d2fee932447b194f989032.zip | |
chore: update to zig 0.15
Everything other than loadextension works. zig 0.15 remove
usingnamespac, so tha whole mechanism has to be reworked, and idk how
Diffstat (limited to 'build/Preprocessor.zig')
| -rw-r--r-- | build/Preprocessor.zig | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/build/Preprocessor.zig b/build/Preprocessor.zig index a069523..f3d0dc6 100644 --- a/build/Preprocessor.zig +++ b/build/Preprocessor.zig | |||
| @@ -27,10 +27,10 @@ const mem = std.mem; | |||
| 27 | fn readOriginalData(allocator: mem.Allocator, path: []const u8) ![]const u8 { | 27 | fn readOriginalData(allocator: mem.Allocator, path: []const u8) ![]const u8 { |
| 28 | var file = try std.fs.cwd().openFile(path, .{}); | 28 | var file = try std.fs.cwd().openFile(path, .{}); |
| 29 | defer file.close(); | 29 | defer file.close(); |
| 30 | var buf: [1024]u8 = undefined; | ||
| 31 | var reader = file.reader(&buf); | ||
| 30 | 32 | ||
| 31 | var reader = file.reader(); | 33 | const data = reader.interface.readAlloc(allocator, 1024 * 1024); |
| 32 | |||
| 33 | const data = reader.readAllAlloc(allocator, 1024 * 1024); | ||
| 34 | return data; | 34 | return data; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| @@ -127,13 +127,13 @@ const Processor = struct { | |||
| 127 | switch (range) { | 127 | switch (range) { |
| 128 | .delete => |dr| { | 128 | .delete => |dr| { |
| 129 | const to_write = self.data[pos..dr.start]; | 129 | const to_write = self.data[pos..dr.start]; |
| 130 | try writer.writeAll(to_write); | 130 | try writer.interface.writeAll(to_write); |
| 131 | pos = dr.end; | 131 | pos = dr.end; |
| 132 | }, | 132 | }, |
| 133 | .replace => |rr| { | 133 | .replace => |rr| { |
| 134 | const to_write = self.data[pos..rr.start]; | 134 | const to_write = self.data[pos..rr.start]; |
| 135 | try writer.writeAll(to_write); | 135 | try writer.interface.writeAll(to_write); |
| 136 | try writer.writeAll(rr.replacement); | 136 | try writer.interface.writeAll(rr.replacement); |
| 137 | pos = rr.end; | 137 | pos = rr.end; |
| 138 | }, | 138 | }, |
| 139 | } | 139 | } |
| @@ -148,7 +148,7 @@ const Processor = struct { | |||
| 148 | // Finally append the remaining data in the buffer (the last range will probably not be the end of the file) | 148 | // Finally append the remaining data in the buffer (the last range will probably not be the end of the file) |
| 149 | if (pos < self.data.len) { | 149 | if (pos < self.data.len) { |
| 150 | const remaining_data = self.data[pos..]; | 150 | const remaining_data = self.data[pos..]; |
| 151 | try writer.writeAll(remaining_data); | 151 | try writer.interface.writeAll(remaining_data); |
| 152 | } | 152 | } |
| 153 | } | 153 | } |
| 154 | }; | 154 | }; |
| @@ -196,7 +196,9 @@ pub fn sqlite3(allocator: mem.Allocator, input_path: []const u8, output_path: [] | |||
| 196 | defer output_file.close(); | 196 | defer output_file.close(); |
| 197 | 197 | ||
| 198 | try output_file.writeAll("/* sqlite3.h edited by the zig-sqlite build script */\n"); | 198 | try output_file.writeAll("/* sqlite3.h edited by the zig-sqlite build script */\n"); |
| 199 | try processor.dump(output_file.writer()); | 199 | var buf: [1024]u8 = undefined; |
| 200 | var out_writer = output_file.writer(&buf); | ||
| 201 | try processor.dump(&out_writer); | ||
| 200 | } | 202 | } |
| 201 | 203 | ||
| 202 | pub fn sqlite3ext(allocator: mem.Allocator, input_path: []const u8, output_path: []const u8) !void { | 204 | pub fn sqlite3ext(allocator: mem.Allocator, input_path: []const u8, output_path: []const u8) !void { |
| @@ -232,5 +234,7 @@ pub fn sqlite3ext(allocator: mem.Allocator, input_path: []const u8, output_path: | |||
| 232 | defer output_file.close(); | 234 | defer output_file.close(); |
| 233 | 235 | ||
| 234 | try output_file.writeAll("/* sqlite3ext.h edited by the zig-sqlite build script */\n"); | 236 | try output_file.writeAll("/* sqlite3ext.h edited by the zig-sqlite build script */\n"); |
| 235 | try processor.dump(output_file.writer()); | 237 | var buf: [1024]u8 = undefined; |
| 238 | var out_writer = output_file.writer(&buf); | ||
| 239 | try processor.dump(&out_writer); | ||
| 236 | } | 240 | } |