curlx: dedupe basename copies into curlx_basename()

Also stop redefining system `basename()` symbol. Call `curlx_basename()`
instead, and map that to `basename()` if available.

Closes #20424
This commit is contained in:
Viktor Szakats 2026-01-25 05:35:00 +01:00
parent 0e2507a3c6
commit 6974bd7cc8
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
7 changed files with 54 additions and 79 deletions

View file

@ -25,10 +25,6 @@
#if defined(_WIN32) || defined(MSDOS)
#if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME)
# include <libgen.h>
#endif
#ifdef _WIN32
# include <tlhelp32.h>
# undef PATH_MAX
@ -41,7 +37,6 @@
#endif
#include "tool_cfgable.h"
#include "tool_bname.h"
#include "tool_doswin.h"
#include "tool_msgs.h"
@ -327,7 +322,7 @@ static SANITIZEcode rename_if_reserved_dos(char ** const sanitized,
memcpy(buffer, file_name, len + 1);
base = basename(buffer);
base = curlx_basename(buffer);
/* Rename reserved device names that are known to be accessible without \\.\
Examples: CON => _CON, CON.EXT => CON_EXT, CON:ADS => CON_ADS
@ -378,7 +373,7 @@ static SANITIZEcode rename_if_reserved_dos(char ** const sanitized,
/* the basename pointer must be updated since the path has expanded */
if(p == buffer)
base = basename(buffer);
base = curlx_basename(buffer);
}
/* This is the legacy portion from rename_if_dos_device_name that checks for