Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

init

Public Function
std.zig.PkgConfig.init
pub fn init(arena: Allocator, stdout: []const u8, diagnostic: ?*Diagnostic) InitError!PkgConfig

Parses the output of pkg-config --list-all.

Params

File

zig/PkgConfig.zig:24
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pub fn init(arena: Allocator, stdout: []const u8, diagnostic: ?*Diagnostic) InitError!PkgConfig {
    var list: std.ArrayList(Pkg) = .empty;
    var line_it = mem.tokenizeAny(u8, stdout, "\r\n");
    var line_index: usize = 0;
    while (line_it.next()) |line| : (line_index += 1) {
        if (mem.trim(u8, line, " \t").len == 0) continue;
        var tok_it = mem.tokenizeAny(u8, line, " \t");
        try list.append(arena, .{
            .name = tok_it.next() orelse {
                if (diagnostic) |d| d.* = .{
                    .invalid_line_index = line_index,
                    .invalid_line = line,
                };
                return error.InvalidPkgConfigOutput;
            },
            .desc = tok_it.rest(),
        });
    }
    try list.shrinkToLen(arena);
    return .{ .all = list.toOwnedSliceAssert() };
}