libzigc: basename #32084
chrboesch/zig:libzigc_basename into master
switched to llvm22
Hi! I have some comments if you don't mind
@ -0,0 +6,4 @@
comptime{
if(builtin.target.isMuslLibC()orbuiltin.target.isWasiLibC()){
symbol(&basename,"basename");
symbol(&basename,"xpg_basename");
The symbol is __xpg_basename but you're exporting xpg_basename
ok
@ -0,0 +11,4 @@
}
fnbasename(s:?[*:0]c_char)callconv(.c)[*:0]c_char{
constdot:[*c]c_char=@ptrCast(@constCast("."));
[*c] pointers should be avoided if possible as their main use is for automatically generated code. langref
ok
@ -0,0 +15,4 @@
if(s==null)returndot;
constptr=s.?;
the standard library already has std.fs.path.NativeComponentIterator, is there a reason for handrolling it?
converted 1:1 from musl, but will take a look
cannot see any improvement when using the function, rather the code becomes more complex
@ -0,0 +13,4 @@
}
test"basename"{
if(builtin.target.os.tag==.windows)return;// no basename
mingw has basename
char*
basename(char* path)
ok
@GasInfinity Thank you!
8e39a993e8
7c17694366
Is there reason this is not using std.fs.path.basenamePosix and returning "." if it returns "".
EDIT: hmm guess there's other differences https://codeberg.org/ziglang/zig/src/branch/master/lib/std/fs/path.zig#L1444
@Cloudef yes, because of: If path is a null pointer or points to an empty string, basename() shall return a pointer to the string ".".
closed for agit, see #36111
closed for agit, see #36111
Pull request closed
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?