⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Merged
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
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This is a very simple ini-parser library that provides:
- Raw record reading
- Leading/trailing whitespace removal
- comments based on `;` and `#`
- Comments
- Zig API
- C API

Expand All @@ -19,7 +19,9 @@ pub fn main() !void {
const file = try std.fs.cwd().openFile("example.ini", .{});
defer file.close();

var parser = ini.parse(std.testing.allocator, file.reader());
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer if (gpa.deinit() != .ok) @panic("memory leaked");
var parser = ini.parse(gpa.allocator(), file.reader(), ";#");
defer parser.deinit();

var writer = std.io.getStdOut().writer();
Expand All @@ -46,17 +48,17 @@ int main() {
FILE * f = fopen("example.ini", "rb");
if(!f)
return 1;

struct ini_Parser parser;
ini_create_file(&parser, f);
ini_create_file(&parser, f, ";#", 2);

struct ini_Record record;
while(true)
{
enum ini_Error error = ini_next(&parser, &record);
if(error != INI_SUCCESS)
goto cleanup;

switch(record.type) {
case INI_RECORD_NUL: goto done;
case INI_RECORD_SECTION:
Expand All @@ -78,4 +80,4 @@ cleanup:
fclose(f);
return 0;
}
```
```