File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 33This is a very simple ini-parser library that provides:
44- Raw record reading
55- Leading/trailing whitespace removal
6- - comments based on ` ; ` and ` # `
6+ - Comments
77- Zig API
88- C API
99
@@ -19,7 +19,9 @@ pub fn main() !void {
1919 const file = try std.fs.cwd().openFile("example.ini", .{});
2020 defer file.close();
2121
22- var parser = ini.parse(std.testing.allocator, file.reader());
22+ var gpa = std.heap.GeneralPurposeAllocator(.{}){};
23+ defer if (gpa.deinit() != .ok) @panic("memory leaked");
24+ var parser = ini.parse(gpa.allocator(), file.reader(), ";#");
2325 defer parser.deinit();
2426
2527 var writer = std.io.getStdOut().writer();
@@ -46,17 +48,17 @@ int main() {
4648 FILE * f = fopen("example.ini", "rb");
4749 if(!f)
4850 return 1;
49-
51+
5052 struct ini_Parser parser;
51- ini_create_file (&parser, f);
53+ ini_create_file (&parser, f, ";#", 2 );
5254
5355 struct ini_Record record;
5456 while(true)
5557 {
5658 enum ini_Error error = ini_next(&parser, &record);
5759 if(error != INI_SUCCESS)
5860 goto cleanup;
59-
61+
6062 switch(record.type) {
6163 case INI_RECORD_NUL: goto done;
6264 case INI_RECORD_SECTION:
@@ -78,4 +80,4 @@ cleanup:
7880 fclose (f);
7981 return 0;
8082}
81- ```
83+ ```
You can’t perform that action at this time.
0 commit comments