Zig 0.17.0-dev (Split by item)
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 library itself.
Zig › c/ › string.zig › strtok_r
strtok_r
string.strtok_r
fn strtok_r (noalias maybe_str : ?[*:0 ]c_char , noalias values : [*:0 ]const c_char , noalias state : *?[*:0 ]c_char ) callconv (.c ) ?[*:0 ]c_char
File
Code
fn strtok_r (noalias maybe_str : ?[*:0 ]c_char , noalias values : [*:0 ]const c_char , noalias state : *?[*:0 ]c_char ) callconv (.c ) ?[*:0 ]c_char {
const str = if (maybe_str ) |str |
str
else if (state .*) |state_str |
state_str
else
return null ;
const str_bytes = std .mem .span (@as ([*:0 ]u8 , @ptrCast (str )));
const values_bytes = std .mem .span (@as ([*:0 ]const u8 , @ptrCast (values )));
const tok_start = std .mem .findNone (u8 , str_bytes , values_bytes ) orelse return null ;
if (std .mem .findAnyPos (u8 , str_bytes , tok_start , values_bytes )) |tok_end | {
str [tok_end ] = 0 ;
state .* = str [tok_end + 1 ..];
} else {
state .* = str [str_bytes .len ..];
}
return str [tok_start ..];
}