Skip to content

Commit 6841133

Browse files
authored
Merge pull request #13 from McSinyx/cmt
Update examples in README to match example/
2 parents ac5822f + 5a96394 commit 6841133

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This 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+
```

0 commit comments

Comments
 (0)