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 standard library.
std › Uri › remove_dot_segments Private Function remove_dot_segments Doc Source Private Function std.Uri.remove_dot_segments
fn remove_dot_segments (path : []u8 ) Component Params File Uri.zig: 424
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464 fn remove_dot_segments (path : []u8 ) Component {
var in_i : usize = 0 ;
var out_i : usize = 0 ;
while (in_i < path .len ) {
if (std .mem .startsWith (u8 , path [in_i ..], "./" )) {
in_i += 2 ;
} else if (std .mem .startsWith (u8 , path [in_i ..], "../" )) {
in_i += 3 ;
} else if (std .mem .startsWith (u8 , path [in_i ..], "/./" )) {
in_i += 2 ;
} else if (std .mem .eql (u8 , path [in_i ..], "/." )) {
in_i += 1 ;
path [in_i ] = '/' ;
} else if (std .mem .startsWith (u8 , path [in_i ..], "/../" )) {
in_i += 3 ;
while (out_i > 0 ) {
out_i -= 1 ;
if (path [out_i ] == '/' ) break ;
}
} else if (std .mem .eql (u8 , path [in_i ..], "/.." )) {
in_i += 2 ;
path [in_i ] = '/' ;
while (out_i > 0 ) {
out_i -= 1 ;
if (path [out_i ] == '/' ) break ;
}
} else if (std .mem .eql (u8 , path [in_i ..], "." )) {
in_i += 1 ;
} else if (std .mem .eql (u8 , path [in_i ..], ".." )) {
in_i += 2 ;
} else {
while (true ) {
path [out_i ] = path [in_i ];
out_i += 1 ;
in_i += 1 ;
if (in_i >= path .len or path [in_i ] == '/' ) break ;
}
}
}
return .{ .percent_encoded = path [0 ..out_i ] };
}
In-place implementation of RFC 3986, Section 5.2.4.