It is necessary to re-implement these two functions because

1. They used to change the global locale and were subject to races
   with almost all stdio functions.
2. The previous `basename()` had a VLA and might effect stack overflows if
   the argument path was too long.
3. They used to produce erroneous results if the argument path was not in
   the default ANSI code page.  (I don't think this is a bug though, just
   a design flaw.)


--
Best regards,
LIU Hao
From 5ef71a3214b71032b442575a761436fbb9327040 Mon Sep 17 00:00:00 2001
From: LIU Hao <[email protected]>
Date: Sat, 25 Mar 2023 18:35:15 +0800
Subject: [PATCH 1/3] crt/{base,dir}name: Remove old implementations for
 refactoring

Signed-off-by: LIU Hao <[email protected]>
---
 mingw-w64-crt/Makefile.am     |   2 +-
 mingw-w64-crt/misc/basename.c | 135 -------------------------
 mingw-w64-crt/misc/dirname.c  | 183 ----------------------------------
 3 files changed, 1 insertion(+), 319 deletions(-)
 delete mode 100644 mingw-w64-crt/misc/basename.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 3cf7203e9..0f1d241f4 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -584,7 +584,7 @@ src_libmingwex=\
   misc/mingw_longjmp.S \
   misc/mingw_getsp.S \
   misc/alarm.c \
-  misc/basename.c        misc/btowc.c               misc/delay-f.c          
misc/delay-n.c         \
+  misc/btowc.c               misc/delay-f.c          misc/delay-n.c         \
   misc/delayimp.c        misc/dirent.c          \
   misc/dirname.c \
   misc/feclearexcept.c   misc/fegetenv.c            misc/fegetexceptflag.c  
misc/fegetround.c            misc/feholdexcept.c    \
diff --git a/mingw-w64-crt/misc/basename.c b/mingw-w64-crt/misc/basename.c
deleted file mode 100644
index c45dbbb36..000000000
--- a/mingw-w64-crt/misc/basename.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* basename.c
- *
- * $Id: basename.c,v 1.2 2007/03/08 23:15:58 keithmarshall Exp $
- *
- * Provides an implementation of the "basename" function, conforming
- * to SUSv3, with extensions to accommodate Win32 drive designators,
- * and suitable for use on native Microsoft(R) Win32 platforms.
- *
- * Written by Keith Marshall <[email protected]>
- *
- * This is free software.  You may redistribute and/or modify it as you
- * see fit, without restriction of copyright.
- *
- * This software is provided "as is", in the hope that it may be useful,
- * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of
- * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE.  At no
- * time will the author accept any form of liability for any damages,
- * however caused, resulting from the use of this software.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libgen.h>
-#include <locale.h>
-
-#ifndef __cdecl
-#define __cdecl
-#endif
-
-char * __cdecl
-basename (char *path)
-{
-  static char *retfail = NULL;
-  size_t len;
-  /* to handle path names for files in multibyte character locales,
-   * we need to set up LC_CTYPE to match the host file system locale
-   */
-  char *locale = setlocale (LC_CTYPE, NULL);
-
-  if (locale != NULL)
-    locale = strdup (locale);
-  setlocale (LC_CTYPE, "");
-
-  if (path && *path)
-    {
-      /* allocate sufficient local storage space,
-       * in which to create a wide character reference copy of path
-       */
-      wchar_t refcopy[1 + (len = mbstowcs (NULL, path, 0))];
-      /* create the wide character reference copy of path,
-       * and step over the drive designator, if present ...
-       */
-      wchar_t *refpath = refcopy;
-
-      if ((len = mbstowcs( refpath, path, len)) > 1 && refpath[1] == L':')
-        {
-         /* FIXME: maybe should confirm *refpath is a valid drive designator */
-         refpath += 2;
-        }
-      /* ensure that our wide character reference path is NUL terminated */
-      refcopy[len] = L'\0';
-      /* check again, just to ensure we still have a non-empty path name ... */
-      if (*refpath)
-        {
-         /* and, when we do, process it in the wide character domain ...
-          * scanning from left to right, to the char after the final dir 
separator.  */
-         wchar_t *refname;
-
-         for (refname = refpath; *refpath; ++refpath)
-           {
-             if (*refpath == L'/' || *refpath == L'\\')
-               {
-                 /* we found a dir separator ...
-                  * step over it, and any others which immediately follow it.  
*/
-                 while (*refpath == L'/' || *refpath == L'\\')
-                   ++refpath;
-                 /* if we didn't reach the end of the path string ... */
-                 if (*refpath)
-                   /* then we have a new candidate for the base name.  */
-                   refname = refpath;
-                 /* otherwise ...
-                  * strip off any trailing dir separators which we found.  */
-                 else
-                   while (refpath > refname
-                     && (*--refpath == L'/' || *refpath == L'\\')   )
-                     *refpath = L'\0';
-               }
-           }
-         /* in the wide character domain ...
-          * refname now points at the resolved base name ...  */
-         if (*refname)
-           {
-             /* if it's not empty,
-              * then we transform the full normalised path back into 
-              * the multibyte character domain, and skip over the dirname,
-              * to return the resolved basename.  */
-             if ((len = wcstombs( path, refcopy, len)) != (size_t)(-1))
-               path[len] = '\0';
-             *refname = L'\0';
-             if ((len = wcstombs( NULL, refcopy, 0 )) != (size_t)(-1))
-               path += len;
-           }
-         else
-           {
-             /* the basename is empty, so return the default value of "/",
-              * transforming from wide char to multibyte char domain, and
-              * returning it in our own buffer.  */
-             retfail = realloc (retfail, len = 1 + wcstombs (NULL, L"/", 0));
-             wcstombs (path = retfail, L"/", len);
-           }
-         /* restore the caller's locale, clean up, and return the result */
-         setlocale (LC_CTYPE, locale);
-         free (locale);
-         return path;
-        }
-      /* or we had an empty residual path name, after the drive designator,
-       * in which case we simply fall through ...  */
-    }
-  /* and, if we get to here ...
-   * the path name is either NULL, or it decomposes to an empty string;
-   * in either case, we return the default value of "." in our own buffer,
-   * reloading it with the correct value, transformed from the wide char
-   * to the multibyte char domain, just in case the caller trashed it
-   * after a previous call.
-   */
-  retfail = realloc (retfail, len = 1 + wcstombs( NULL, L".", 0));
-  wcstombs (retfail, L".", len);
-
-  /* restore the caller's locale, clean up, and return the result.  */
-  setlocale (LC_CTYPE, locale);
-  free (locale);
-  return retfail;
-}
diff --git a/mingw-w64-crt/misc/dirname.c b/mingw-w64-crt/misc/dirname.c
index 9c5cf87db..e69de29bb 100644
--- a/mingw-w64-crt/misc/dirname.c
+++ b/mingw-w64-crt/misc/dirname.c
@@ -1,183 +0,0 @@
-/* dirname.c
- *
- * $Id: dirname.c,v 1.2 2007/03/08 23:15:58 keithmarshall Exp $
- *
- * Provides an implementation of the "dirname" function, conforming
- * to SUSv3, with extensions to accommodate Win32 drive designators,
- * and suitable for use on native Microsoft(R) Win32 platforms.
- *
- * Written by Keith Marshall <[email protected]>
- *
- * This is free software.  You may redistribute and/or modify it as you
- * see fit, without restriction of copyright.
- *
- * This software is provided "as is", in the hope that it may be useful,
- * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of
- * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE.  At no
- * time will the author accept any form of liability for any damages,
- * however caused, resulting from the use of this software.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libgen.h>
-#include <locale.h>
-
-#ifndef __cdecl  /* If compiling on any non-Win32 platform ... */
-#define __cdecl  /* this may not be defined.                   */
-#endif
-
-char * __cdecl
-dirname(char *path)
-{
-  static char *retfail = NULL;
-  size_t len;
-  /* to handle path names for files in multibyte character locales,
-   * we need to set up LC_CTYPE to match the host file system locale.  */
-  char *locale = setlocale (LC_CTYPE, NULL);
-
-  if (locale != NULL)
-    locale = strdup (locale);
-  setlocale (LC_CTYPE, "");
-
-  if (path && *path)
-    {
-      /* allocate sufficient local storage space,
-       * in which to create a wide character reference copy of path.  */
-      wchar_t refcopy[1 + (len = mbstowcs (NULL, path, 0))];
-      /* create the wide character reference copy of path */
-      wchar_t *refpath = refcopy;
-
-      len = mbstowcs (refpath, path, len);
-      refcopy[len] = L'\0';
-      /* SUSv3 identifies a special case, where path is exactly equal to "//";
-       * (we will also accept "\\" in the Win32 context, but not "/\" or "\/",
-       *  and neither will we consider paths with an initial drive designator).
-       * For this special case, SUSv3 allows the implementation to choose to
-       * return "/" or "//", (or "\" or "\\", since this is Win32); we will
-       * simply return the path unchanged, (i.e. "//" or "\\").  */
-      if (len > 1 && (refpath[0] == L'/' || refpath[0] == L'\\'))
-        {
-         if (refpath[1] == refpath[0] && refpath[2] == L'\0')
-           {
-             setlocale (LC_CTYPE, locale);
-             free (locale);
-             return path;
-           }
-        }
-      /* For all other cases ...
-       * step over the drive designator, if present ...  */
-      else if (len > 1 && refpath[1] == L':')
-        {
-         /* FIXME: maybe should confirm *refpath is a valid drive designator.  
*/
-         refpath += 2;
-        }
-      /* check again, just to ensure we still have a non-empty path name ... */
-      if (*refpath)
-        {
-#      undef  basename
-#      define basename __the_basename          /* avoid shadowing. */
-         /* reproduce the scanning logic of the "basename" function
-          * to locate the basename component of the current path string,
-          * (but also remember where the dirname component starts).  */
-         wchar_t *refname, *basename;
-         for (refname = basename = refpath; *refpath; ++refpath)
-           {
-             if (*refpath == L'/' || *refpath == L'\\')
-               {
-                 /* we found a dir separator ...
-                  * step over it, and any others which immediately follow it.  
*/
-                 while (*refpath == L'/' || *refpath == L'\\')
-                   ++refpath;
-                 /* if we didn't reach the end of the path string ... */
-                 if (*refpath)
-                   /* then we have a new candidate for the base name.  */
-                   basename = refpath;
-                 else
-                   /* we struck an early termination of the path string,
-                    * with trailing dir separators following the base name,
-                    * so break out of the for loop, to avoid overrun.  */
-                   break;
-               }
-           }
-         /* now check,
-          * to confirm that we have distinct dirname and basename components.  
*/
-         if (basename > refname)
-           {
-             /* and, when we do ...
-              * backtrack over all trailing separators on the dirname 
component,
-              * (but preserve exactly two initial dirname separators, if 
identical),
-              * and add a NUL terminator in their place.  */
-             do --basename;
-             while (basename > refname && (*basename == L'/' || *basename == 
L'\\'));
-             if (basename == refname && (refname[0] == L'/' || refname[0] == 
L'\\')
-                 && refname[1] == refname[0] && refname[2] != L'/' && 
refname[2] != L'\\')
-               ++basename;
-             *++basename = L'\0';
-             /* if the resultant dirname begins with EXACTLY two dir 
separators,
-              * AND both are identical, then we preserve them.  */
-             refpath = refcopy;
-             while ((*refpath == L'/' || *refpath == L'\\'))
-               ++refpath;
-             if ((refpath - refcopy) > 2 || refcopy[1] != refcopy[0])
-               refpath = refcopy;
-             /* and finally ...
-              * we remove any residual, redundantly duplicated separators from 
the dirname,
-              * reterminate, and return it.  */
-             refname = refpath;
-             while (*refpath)
-               {
-                 if ((*refname++ = *refpath) == L'/' || *refpath++ == L'\\')
-                   {
-                     while (*refpath == L'/' || *refpath == L'\\')
-                       ++refpath;
-                   }
-               }
-             *refname = L'\0';
-             /* finally ...
-              * transform the resolved dirname back into the multibyte char 
domain,
-              * restore the caller's locale, and return the resultant dirname. 
 */
-             if ((len = wcstombs( path, refcopy, len )) != (size_t)(-1))
-               path[len] = '\0';
-           }
-         else
-           {
-             /* either there were no dirname separators in the path name,
-              * or there was nothing else ...  */
-             if (*refname == L'/' || *refname == L'\\')
-               {
-                 /* it was all separators, so return one.  */
-                 ++refname;
-               }
-             else
-               {
-                 /* there were no separators, so return '.'.  */
-                 *refname++ = L'.';
-               }
-             /* add a NUL terminator, in either case,
-              * then transform to the multibyte char domain,
-              * using our own buffer.  */
-             *refname = L'\0';
-             retfail = realloc (retfail, len = 1 + wcstombs (NULL, refcopy, 
0));
-             wcstombs (path = retfail, refcopy, len);
-           }
-         /* restore caller's locale, clean up, and return the resolved 
dirname.  */
-         setlocale (LC_CTYPE, locale);
-         free (locale);
-         return path;
-        }
-#      undef  basename
-    }
-  /* path is NULL, or an empty string; default return value is "." ...
-   * return this in our own buffer, regenerated by wide char transform,
-   * in case the caller trashed it after a previous call.
-   */
-  retfail = realloc (retfail, len = 1 + wcstombs (NULL, L".", 0));
-  wcstombs (retfail, L".", len);
-  /* restore caller's locale, clean up, and return the default dirname.  */
-  setlocale (LC_CTYPE, locale);
-  free (locale);
-  return retfail;
-}
-- 
2.40.0

From e176fa69d7001dd9fafd6f9a0f2e488252565daa Mon Sep 17 00:00:00 2001
From: LIU Hao <[email protected]>
Date: Sat, 25 Mar 2023 18:35:54 +0800
Subject: [PATCH 2/3] crt: Regenerate Makefile.in

Signed-off-by: LIU Hao <[email protected]>
---
 mingw-w64-crt/Makefile.in | 104 ++++----------------------------------
 1 file changed, 10 insertions(+), 94 deletions(-)

diff --git a/mingw-w64-crt/Makefile.in b/mingw-w64-crt/Makefile.in
index 436d80bbc..6106a77c3 100644
--- a/mingw-w64-crt/Makefile.in
+++ b/mingw-w64-crt/Makefile.in
@@ -846,8 +846,8 @@ am__lib32_libmingwex_a_SOURCES_DIST = 
cfguard/mingw_cfguard_support.c \
        math/tgammaf.c math/tgammal.c math/truncl.c math/powi.def.h \
        math/sqrt.def.h math/cephes_mconf.h math/fp_consts.h \
        misc/mb_wc_common.h misc/mingw_longjmp.S misc/mingw_getsp.S \
-       misc/alarm.c misc/basename.c misc/btowc.c misc/delay-f.c \
-       misc/delay-n.c misc/delayimp.c misc/dirent.c misc/dirname.c \
+       misc/alarm.c misc/btowc.c misc/delay-f.c misc/delay-n.c \
+       misc/delayimp.c misc/dirent.c misc/dirname.c \
        misc/feclearexcept.c misc/fegetenv.c misc/fegetexceptflag.c \
        misc/fegetround.c misc/feholdexcept.c misc/feraiseexcept.c \
        misc/fesetenv.c misc/fesetexceptflag.c misc/fesetround.c \
@@ -1107,7 +1107,6 @@ am__objects_23 =  \
        misc/lib32_libmingwex_a-mingw_longjmp.$(OBJEXT) \
        misc/lib32_libmingwex_a-mingw_getsp.$(OBJEXT) \
        misc/lib32_libmingwex_a-alarm.$(OBJEXT) \
-       misc/lib32_libmingwex_a-basename.$(OBJEXT) \
        misc/lib32_libmingwex_a-btowc.$(OBJEXT) \
        misc/lib32_libmingwex_a-delay-f.$(OBJEXT) \
        misc/lib32_libmingwex_a-delay-n.$(OBJEXT) \
@@ -2320,8 +2319,8 @@ am__lib64_libmingwex_a_SOURCES_DIST = 
cfguard/mingw_cfguard_support.c \
        math/tgammaf.c math/tgammal.c math/truncl.c math/powi.def.h \
        math/sqrt.def.h math/cephes_mconf.h math/fp_consts.h \
        misc/mb_wc_common.h misc/mingw_longjmp.S misc/mingw_getsp.S \
-       misc/alarm.c misc/basename.c misc/btowc.c misc/delay-f.c \
-       misc/delay-n.c misc/delayimp.c misc/dirent.c misc/dirname.c \
+       misc/alarm.c misc/btowc.c misc/delay-f.c misc/delay-n.c \
+       misc/delayimp.c misc/dirent.c misc/dirname.c \
        misc/feclearexcept.c misc/fegetenv.c misc/fegetexceptflag.c \
        misc/fegetround.c misc/feholdexcept.c misc/feraiseexcept.c \
        misc/fesetenv.c misc/fesetexceptflag.c misc/fesetround.c \
@@ -2581,7 +2580,6 @@ am__objects_80 =  \
        misc/lib64_libmingwex_a-mingw_longjmp.$(OBJEXT) \
        misc/lib64_libmingwex_a-mingw_getsp.$(OBJEXT) \
        misc/lib64_libmingwex_a-alarm.$(OBJEXT) \
-       misc/lib64_libmingwex_a-basename.$(OBJEXT) \
        misc/lib64_libmingwex_a-btowc.$(OBJEXT) \
        misc/lib64_libmingwex_a-delay-f.$(OBJEXT) \
        misc/lib64_libmingwex_a-delay-n.$(OBJEXT) \
@@ -3629,8 +3627,8 @@ am__libarm32_libmingwex_a_SOURCES_DIST =  \
        math/tgammaf.c math/tgammal.c math/truncl.c math/powi.def.h \
        math/sqrt.def.h math/cephes_mconf.h math/fp_consts.h \
        misc/mb_wc_common.h misc/mingw_longjmp.S misc/mingw_getsp.S \
-       misc/alarm.c misc/basename.c misc/btowc.c misc/delay-f.c \
-       misc/delay-n.c misc/delayimp.c misc/dirent.c misc/dirname.c \
+       misc/alarm.c misc/btowc.c misc/delay-f.c misc/delay-n.c \
+       misc/delayimp.c misc/dirent.c misc/dirname.c \
        misc/feclearexcept.c misc/fegetenv.c misc/fegetexceptflag.c \
        misc/fegetround.c misc/feholdexcept.c misc/feraiseexcept.c \
        misc/fesetenv.c misc/fesetexceptflag.c misc/fesetround.c \
@@ -3895,7 +3893,6 @@ am__objects_130 =  \
        misc/libarm32_libmingwex_a-mingw_longjmp.$(OBJEXT) \
        misc/libarm32_libmingwex_a-mingw_getsp.$(OBJEXT) \
        misc/libarm32_libmingwex_a-alarm.$(OBJEXT) \
-       misc/libarm32_libmingwex_a-basename.$(OBJEXT) \
        misc/libarm32_libmingwex_a-btowc.$(OBJEXT) \
        misc/libarm32_libmingwex_a-delay-f.$(OBJEXT) \
        misc/libarm32_libmingwex_a-delay-n.$(OBJEXT) \
@@ -4977,8 +4974,8 @@ am__libarm64_libmingwex_a_SOURCES_DIST =  \
        math/tgammaf.c math/tgammal.c math/truncl.c math/powi.def.h \
        math/sqrt.def.h math/cephes_mconf.h math/fp_consts.h \
        misc/mb_wc_common.h misc/mingw_longjmp.S misc/mingw_getsp.S \
-       misc/alarm.c misc/basename.c misc/btowc.c misc/delay-f.c \
-       misc/delay-n.c misc/delayimp.c misc/dirent.c misc/dirname.c \
+       misc/alarm.c misc/btowc.c misc/delay-f.c misc/delay-n.c \
+       misc/delayimp.c misc/dirent.c misc/dirname.c \
        misc/feclearexcept.c misc/fegetenv.c misc/fegetexceptflag.c \
        misc/fegetround.c misc/feholdexcept.c misc/feraiseexcept.c \
        misc/fesetenv.c misc/fesetexceptflag.c misc/fesetround.c \
@@ -5209,7 +5206,6 @@ am__objects_178 =  \
        misc/libarm64_libmingwex_a-mingw_longjmp.$(OBJEXT) \
        misc/libarm64_libmingwex_a-mingw_getsp.$(OBJEXT) \
        misc/libarm64_libmingwex_a-alarm.$(OBJEXT) \
-       misc/libarm64_libmingwex_a-basename.$(OBJEXT) \
        misc/libarm64_libmingwex_a-btowc.$(OBJEXT) \
        misc/libarm64_libmingwex_a-delay-f.$(OBJEXT) \
        misc/libarm64_libmingwex_a-delay-n.$(OBJEXT) \
@@ -8525,7 +8521,6 @@ am__depfiles_remade = 
./$(DEPDIR)/lib32_libm_a-_libm_dummy.Po \
        misc/$(DEPDIR)/lib32_libcrtdll_extra_a-strtoumax.Po \
        misc/$(DEPDIR)/lib32_libdloadhelper_a-delay-f.Po \
        misc/$(DEPDIR)/lib32_libmingwex_a-alarm.Po \
-       misc/$(DEPDIR)/lib32_libmingwex_a-basename.Po \
        misc/$(DEPDIR)/lib32_libmingwex_a-btowc.Po \
        misc/$(DEPDIR)/lib32_libmingwex_a-delay-f.Po \
        misc/$(DEPDIR)/lib32_libmingwex_a-delay-n.Po \
@@ -8662,7 +8657,6 @@ am__depfiles_remade = 
./$(DEPDIR)/lib32_libm_a-_libm_dummy.Po \
        misc/$(DEPDIR)/lib32_libucrtapp_extra_a-setjmp.Po \
        misc/$(DEPDIR)/lib64_libdloadhelper_a-delay-f.Po \
        misc/$(DEPDIR)/lib64_libmingwex_a-alarm.Po \
-       misc/$(DEPDIR)/lib64_libmingwex_a-basename.Po \
        misc/$(DEPDIR)/lib64_libmingwex_a-btowc.Po \
        misc/$(DEPDIR)/lib64_libmingwex_a-delay-f.Po \
        misc/$(DEPDIR)/lib64_libmingwex_a-delay-n.Po \
@@ -8765,7 +8759,6 @@ am__depfiles_remade = 
./$(DEPDIR)/lib32_libm_a-_libm_dummy.Po \
        misc/$(DEPDIR)/lib64_libucrtapp_extra_a-setjmp.Po \
        misc/$(DEPDIR)/libarm32_libdloadhelper_a-delay-f.Po \
        misc/$(DEPDIR)/libarm32_libmingwex_a-alarm.Po \
-       misc/$(DEPDIR)/libarm32_libmingwex_a-basename.Po \
        misc/$(DEPDIR)/libarm32_libmingwex_a-btowc.Po \
        misc/$(DEPDIR)/libarm32_libmingwex_a-delay-f.Po \
        misc/$(DEPDIR)/libarm32_libmingwex_a-delay-n.Po \
@@ -8859,7 +8852,6 @@ am__depfiles_remade = 
./$(DEPDIR)/lib32_libm_a-_libm_dummy.Po \
        misc/$(DEPDIR)/libarm32_libucrtapp_extra_a-setjmp.Po \
        misc/$(DEPDIR)/libarm64_libdloadhelper_a-delay-f.Po \
        misc/$(DEPDIR)/libarm64_libmingwex_a-alarm.Po \
-       misc/$(DEPDIR)/libarm64_libmingwex_a-basename.Po \
        misc/$(DEPDIR)/libarm64_libmingwex_a-btowc.Po \
        misc/$(DEPDIR)/libarm64_libmingwex_a-delay-f.Po \
        misc/$(DEPDIR)/libarm64_libmingwex_a-delay-n.Po \
@@ -11214,8 +11206,8 @@ src_libmingwex = cfguard/mingw_cfguard_support.c 
crt/dllentry.c \
        math/tgammaf.c math/tgammal.c math/truncl.c math/powi.def.h \
        math/sqrt.def.h math/cephes_mconf.h math/fp_consts.h \
        misc/mb_wc_common.h misc/mingw_longjmp.S misc/mingw_getsp.S \
-       misc/alarm.c misc/basename.c misc/btowc.c misc/delay-f.c \
-       misc/delay-n.c misc/delayimp.c misc/dirent.c misc/dirname.c \
+       misc/alarm.c misc/btowc.c misc/delay-f.c misc/delay-n.c \
+       misc/delayimp.c misc/dirent.c misc/dirname.c \
        misc/feclearexcept.c misc/fegetenv.c misc/fegetexceptflag.c \
        misc/fegetround.c misc/feholdexcept.c misc/feraiseexcept.c \
        misc/fesetenv.c misc/fesetexceptflag.c misc/fesetround.c \
@@ -14690,8 +14682,6 @@ misc/lib32_libmingwex_a-mingw_getsp.$(OBJEXT): 
misc/$(am__dirstamp) \
        misc/$(DEPDIR)/$(am__dirstamp)
 misc/lib32_libmingwex_a-alarm.$(OBJEXT): misc/$(am__dirstamp) \
        misc/$(DEPDIR)/$(am__dirstamp)
-misc/lib32_libmingwex_a-basename.$(OBJEXT): misc/$(am__dirstamp) \
-       misc/$(DEPDIR)/$(am__dirstamp)
 misc/lib32_libmingwex_a-btowc.$(OBJEXT): misc/$(am__dirstamp) \
        misc/$(DEPDIR)/$(am__dirstamp)
 misc/lib32_libmingwex_a-delay-f.$(OBJEXT): misc/$(am__dirstamp) \
@@ -16731,8 +16721,6 @@ misc/lib64_libmingwex_a-mingw_getsp.$(OBJEXT): 
misc/$(am__dirstamp) \
        misc/$(DEPDIR)/$(am__dirstamp)
 misc/lib64_libmingwex_a-alarm.$(OBJEXT): misc/$(am__dirstamp) \
        misc/$(DEPDIR)/$(am__dirstamp)
-misc/lib64_libmingwex_a-basename.$(OBJEXT): misc/$(am__dirstamp) \
-       misc/$(DEPDIR)/$(am__dirstamp)
 misc/lib64_libmingwex_a-btowc.$(OBJEXT): misc/$(am__dirstamp) \
        misc/$(DEPDIR)/$(am__dirstamp)
 misc/lib64_libmingwex_a-delay-f.$(OBJEXT): misc/$(am__dirstamp) \
@@ -18517,8 +18505,6 @@ misc/libarm32_libmingwex_a-mingw_getsp.$(OBJEXT):  \
        misc/$(am__dirstamp) misc/$(DEPDIR)/$(am__dirstamp)
 misc/libarm32_libmingwex_a-alarm.$(OBJEXT): misc/$(am__dirstamp) \
        misc/$(DEPDIR)/$(am__dirstamp)
-misc/libarm32_libmingwex_a-basename.$(OBJEXT): misc/$(am__dirstamp) \
-       misc/$(DEPDIR)/$(am__dirstamp)
 misc/libarm32_libmingwex_a-btowc.$(OBJEXT): misc/$(am__dirstamp) \
        misc/$(DEPDIR)/$(am__dirstamp)
 misc/libarm32_libmingwex_a-delay-f.$(OBJEXT): misc/$(am__dirstamp) \
@@ -20462,8 +20448,6 @@ misc/libarm64_libmingwex_a-mingw_getsp.$(OBJEXT):  \
        misc/$(am__dirstamp) misc/$(DEPDIR)/$(am__dirstamp)
 misc/libarm64_libmingwex_a-alarm.$(OBJEXT): misc/$(am__dirstamp) \
        misc/$(DEPDIR)/$(am__dirstamp)
-misc/libarm64_libmingwex_a-basename.$(OBJEXT): misc/$(am__dirstamp) \
-       misc/$(DEPDIR)/$(am__dirstamp)
 misc/libarm64_libmingwex_a-btowc.$(OBJEXT): misc/$(am__dirstamp) \
        misc/$(DEPDIR)/$(am__dirstamp)
 misc/libarm64_libmingwex_a-delay-f.$(OBJEXT): misc/$(am__dirstamp) \
@@ -24422,7 +24406,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib32_libcrtdll_extra_a-strtoumax.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib32_libdloadhelper_a-delay-f.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib32_libmingwex_a-alarm.Po@am__quote@ # 
am--include-marker
-@AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib32_libmingwex_a-basename.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib32_libmingwex_a-btowc.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib32_libmingwex_a-delay-f.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib32_libmingwex_a-delay-n.Po@am__quote@ # 
am--include-marker
@@ -24559,7 +24542,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib32_libucrtapp_extra_a-setjmp.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib64_libdloadhelper_a-delay-f.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib64_libmingwex_a-alarm.Po@am__quote@ # 
am--include-marker
-@AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib64_libmingwex_a-basename.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib64_libmingwex_a-btowc.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib64_libmingwex_a-delay-f.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib64_libmingwex_a-delay-n.Po@am__quote@ # 
am--include-marker
@@ -24662,7 +24644,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/lib64_libucrtapp_extra_a-setjmp.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm32_libdloadhelper_a-delay-f.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm32_libmingwex_a-alarm.Po@am__quote@ # 
am--include-marker
-@AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm32_libmingwex_a-basename.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm32_libmingwex_a-btowc.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm32_libmingwex_a-delay-f.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm32_libmingwex_a-delay-n.Po@am__quote@ # 
am--include-marker
@@ -24756,7 +24737,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm32_libucrtapp_extra_a-setjmp.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm64_libdloadhelper_a-delay-f.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm64_libmingwex_a-alarm.Po@am__quote@ # 
am--include-marker
-@AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm64_libmingwex_a-basename.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm64_libmingwex_a-btowc.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm64_libmingwex_a-delay-f.Po@am__quote@ # 
am--include-marker
 @AMDEP_TRUE@@am__include@ 
@am__quote@misc/$(DEPDIR)/libarm64_libmingwex_a-delay-n.Po@am__quote@ # 
am--include-marker
@@ -32336,20 +32316,6 @@ misc/lib32_libmingwex_a-alarm.obj: misc/alarm.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(lib32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 
-c -o misc/lib32_libmingwex_a-alarm.obj `if test -f 'misc/alarm.c'; then 
$(CYGPATH_W) 'misc/alarm.c'; else $(CYGPATH_W) '$(srcdir)/misc/alarm.c'; fi`
 
-misc/lib32_libmingwex_a-basename.o: misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(lib32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/lib32_libmingwex_a-basename.o -MD -MP -MF 
misc/$(DEPDIR)/lib32_libmingwex_a-basename.Tpo -c -o 
misc/lib32_libmingwex_a-basename.o `test -f 'misc/basename.c' || echo 
'$(srcdir)/'`misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/lib32_libmingwex_a-basename.Tpo 
misc/$(DEPDIR)/lib32_libmingwex_a-basename.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='misc/basename.c' 
object='misc/lib32_libmingwex_a-basename.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(lib32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 
-c -o misc/lib32_libmingwex_a-basename.o `test -f 'misc/basename.c' || echo 
'$(srcdir)/'`misc/basename.c
-
-misc/lib32_libmingwex_a-basename.obj: misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(lib32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/lib32_libmingwex_a-basename.obj -MD -MP -MF 
misc/$(DEPDIR)/lib32_libmingwex_a-basename.Tpo -c -o 
misc/lib32_libmingwex_a-basename.obj `if test -f 'misc/basename.c'; then 
$(CYGPATH_W) 'misc/basename.c'; else $(CYGPATH_W) '$(srcdir)/misc/basename.c'; 
fi`
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/lib32_libmingwex_a-basename.Tpo 
misc/$(DEPDIR)/lib32_libmingwex_a-basename.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='misc/basename.c' 
object='misc/lib32_libmingwex_a-basename.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(lib32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 
-c -o misc/lib32_libmingwex_a-basename.obj `if test -f 'misc/basename.c'; then 
$(CYGPATH_W) 'misc/basename.c'; else $(CYGPATH_W) '$(srcdir)/misc/basename.c'; 
fi`
-
 misc/lib32_libmingwex_a-btowc.o: misc/btowc.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(lib32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/lib32_libmingwex_a-btowc.o -MD -MP -MF 
misc/$(DEPDIR)/lib32_libmingwex_a-btowc.Tpo -c -o 
misc/lib32_libmingwex_a-btowc.o `test -f 'misc/btowc.c' || echo 
'$(srcdir)/'`misc/btowc.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/lib32_libmingwex_a-btowc.Tpo 
misc/$(DEPDIR)/lib32_libmingwex_a-btowc.Po
@@ -43550,20 +43516,6 @@ misc/lib64_libmingwex_a-alarm.obj: misc/alarm.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(lib64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 
-c -o misc/lib64_libmingwex_a-alarm.obj `if test -f 'misc/alarm.c'; then 
$(CYGPATH_W) 'misc/alarm.c'; else $(CYGPATH_W) '$(srcdir)/misc/alarm.c'; fi`
 
-misc/lib64_libmingwex_a-basename.o: misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(lib64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/lib64_libmingwex_a-basename.o -MD -MP -MF 
misc/$(DEPDIR)/lib64_libmingwex_a-basename.Tpo -c -o 
misc/lib64_libmingwex_a-basename.o `test -f 'misc/basename.c' || echo 
'$(srcdir)/'`misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/lib64_libmingwex_a-basename.Tpo 
misc/$(DEPDIR)/lib64_libmingwex_a-basename.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='misc/basename.c' 
object='misc/lib64_libmingwex_a-basename.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(lib64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 
-c -o misc/lib64_libmingwex_a-basename.o `test -f 'misc/basename.c' || echo 
'$(srcdir)/'`misc/basename.c
-
-misc/lib64_libmingwex_a-basename.obj: misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(lib64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/lib64_libmingwex_a-basename.obj -MD -MP -MF 
misc/$(DEPDIR)/lib64_libmingwex_a-basename.Tpo -c -o 
misc/lib64_libmingwex_a-basename.obj `if test -f 'misc/basename.c'; then 
$(CYGPATH_W) 'misc/basename.c'; else $(CYGPATH_W) '$(srcdir)/misc/basename.c'; 
fi`
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/lib64_libmingwex_a-basename.Tpo 
misc/$(DEPDIR)/lib64_libmingwex_a-basename.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='misc/basename.c' 
object='misc/lib64_libmingwex_a-basename.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(lib64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 
-c -o misc/lib64_libmingwex_a-basename.obj `if test -f 'misc/basename.c'; then 
$(CYGPATH_W) 'misc/basename.c'; else $(CYGPATH_W) '$(srcdir)/misc/basename.c'; 
fi`
-
 misc/lib64_libmingwex_a-btowc.o: misc/btowc.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(lib64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/lib64_libmingwex_a-btowc.o -MD -MP -MF 
misc/$(DEPDIR)/lib64_libmingwex_a-btowc.Tpo -c -o 
misc/lib64_libmingwex_a-btowc.o `test -f 'misc/btowc.c' || echo 
'$(srcdir)/'`misc/btowc.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/lib64_libmingwex_a-btowc.Tpo 
misc/$(DEPDIR)/lib64_libmingwex_a-btowc.Po
@@ -53532,20 +53484,6 @@ misc/libarm32_libmingwex_a-alarm.obj: misc/alarm.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(libarm32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) 
$(CFLAGS) -c -o misc/libarm32_libmingwex_a-alarm.obj `if test -f 
'misc/alarm.c'; then $(CYGPATH_W) 'misc/alarm.c'; else $(CYGPATH_W) 
'$(srcdir)/misc/alarm.c'; fi`
 
-misc/libarm32_libmingwex_a-basename.o: misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(libarm32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/libarm32_libmingwex_a-basename.o -MD -MP -MF 
misc/$(DEPDIR)/libarm32_libmingwex_a-basename.Tpo -c -o 
misc/libarm32_libmingwex_a-basename.o `test -f 'misc/basename.c' || echo 
'$(srcdir)/'`misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/libarm32_libmingwex_a-basename.Tpo 
misc/$(DEPDIR)/libarm32_libmingwex_a-basename.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='misc/basename.c' 
object='misc/libarm32_libmingwex_a-basename.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(libarm32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) 
$(CFLAGS) -c -o misc/libarm32_libmingwex_a-basename.o `test -f 
'misc/basename.c' || echo '$(srcdir)/'`misc/basename.c
-
-misc/libarm32_libmingwex_a-basename.obj: misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(libarm32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/libarm32_libmingwex_a-basename.obj -MD -MP -MF 
misc/$(DEPDIR)/libarm32_libmingwex_a-basename.Tpo -c -o 
misc/libarm32_libmingwex_a-basename.obj `if test -f 'misc/basename.c'; then 
$(CYGPATH_W) 'misc/basename.c'; else $(CYGPATH_W) '$(srcdir)/misc/basename.c'; 
fi`
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/libarm32_libmingwex_a-basename.Tpo 
misc/$(DEPDIR)/libarm32_libmingwex_a-basename.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='misc/basename.c' 
object='misc/libarm32_libmingwex_a-basename.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(libarm32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) 
$(CFLAGS) -c -o misc/libarm32_libmingwex_a-basename.obj `if test -f 
'misc/basename.c'; then $(CYGPATH_W) 'misc/basename.c'; else $(CYGPATH_W) 
'$(srcdir)/misc/basename.c'; fi`
-
 misc/libarm32_libmingwex_a-btowc.o: misc/btowc.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(libarm32_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/libarm32_libmingwex_a-btowc.o -MD -MP -MF 
misc/$(DEPDIR)/libarm32_libmingwex_a-btowc.Tpo -c -o 
misc/libarm32_libmingwex_a-btowc.o `test -f 'misc/btowc.c' || echo 
'$(srcdir)/'`misc/btowc.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/libarm32_libmingwex_a-btowc.Tpo 
misc/$(DEPDIR)/libarm32_libmingwex_a-btowc.Po
@@ -64298,20 +64236,6 @@ misc/libarm64_libmingwex_a-alarm.obj: misc/alarm.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(libarm64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) 
$(CFLAGS) -c -o misc/libarm64_libmingwex_a-alarm.obj `if test -f 
'misc/alarm.c'; then $(CYGPATH_W) 'misc/alarm.c'; else $(CYGPATH_W) 
'$(srcdir)/misc/alarm.c'; fi`
 
-misc/libarm64_libmingwex_a-basename.o: misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(libarm64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/libarm64_libmingwex_a-basename.o -MD -MP -MF 
misc/$(DEPDIR)/libarm64_libmingwex_a-basename.Tpo -c -o 
misc/libarm64_libmingwex_a-basename.o `test -f 'misc/basename.c' || echo 
'$(srcdir)/'`misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/libarm64_libmingwex_a-basename.Tpo 
misc/$(DEPDIR)/libarm64_libmingwex_a-basename.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='misc/basename.c' 
object='misc/libarm64_libmingwex_a-basename.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(libarm64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) 
$(CFLAGS) -c -o misc/libarm64_libmingwex_a-basename.o `test -f 
'misc/basename.c' || echo '$(srcdir)/'`misc/basename.c
-
-misc/libarm64_libmingwex_a-basename.obj: misc/basename.c
-@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(libarm64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/libarm64_libmingwex_a-basename.obj -MD -MP -MF 
misc/$(DEPDIR)/libarm64_libmingwex_a-basename.Tpo -c -o 
misc/libarm64_libmingwex_a-basename.obj `if test -f 'misc/basename.c'; then 
$(CYGPATH_W) 'misc/basename.c'; else $(CYGPATH_W) '$(srcdir)/misc/basename.c'; 
fi`
-@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/libarm64_libmingwex_a-basename.Tpo 
misc/$(DEPDIR)/libarm64_libmingwex_a-basename.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='misc/basename.c' 
object='misc/libarm64_libmingwex_a-basename.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) 
$(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) 
$(INCLUDES) $(libarm64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) 
$(CFLAGS) -c -o misc/libarm64_libmingwex_a-basename.obj `if test -f 
'misc/basename.c'; then $(CYGPATH_W) 'misc/basename.c'; else $(CYGPATH_W) 
'$(srcdir)/misc/basename.c'; fi`
-
 misc/libarm64_libmingwex_a-btowc.o: misc/btowc.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) 
$(libarm64_libmingwex_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT 
misc/libarm64_libmingwex_a-btowc.o -MD -MP -MF 
misc/$(DEPDIR)/libarm64_libmingwex_a-btowc.Tpo -c -o 
misc/libarm64_libmingwex_a-btowc.o `test -f 'misc/btowc.c' || echo 
'$(srcdir)/'`misc/btowc.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) 
misc/$(DEPDIR)/libarm64_libmingwex_a-btowc.Tpo 
misc/$(DEPDIR)/libarm64_libmingwex_a-btowc.Po
@@ -75648,7 +75572,6 @@ distclean: distclean-am
        -rm -f misc/$(DEPDIR)/lib32_libcrtdll_extra_a-strtoumax.Po
        -rm -f misc/$(DEPDIR)/lib32_libdloadhelper_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/lib32_libmingwex_a-alarm.Po
-       -rm -f misc/$(DEPDIR)/lib32_libmingwex_a-basename.Po
        -rm -f misc/$(DEPDIR)/lib32_libmingwex_a-btowc.Po
        -rm -f misc/$(DEPDIR)/lib32_libmingwex_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/lib32_libmingwex_a-delay-n.Po
@@ -75785,7 +75708,6 @@ distclean: distclean-am
        -rm -f misc/$(DEPDIR)/lib32_libucrtapp_extra_a-setjmp.Po
        -rm -f misc/$(DEPDIR)/lib64_libdloadhelper_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/lib64_libmingwex_a-alarm.Po
-       -rm -f misc/$(DEPDIR)/lib64_libmingwex_a-basename.Po
        -rm -f misc/$(DEPDIR)/lib64_libmingwex_a-btowc.Po
        -rm -f misc/$(DEPDIR)/lib64_libmingwex_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/lib64_libmingwex_a-delay-n.Po
@@ -75888,7 +75810,6 @@ distclean: distclean-am
        -rm -f misc/$(DEPDIR)/lib64_libucrtapp_extra_a-setjmp.Po
        -rm -f misc/$(DEPDIR)/libarm32_libdloadhelper_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/libarm32_libmingwex_a-alarm.Po
-       -rm -f misc/$(DEPDIR)/libarm32_libmingwex_a-basename.Po
        -rm -f misc/$(DEPDIR)/libarm32_libmingwex_a-btowc.Po
        -rm -f misc/$(DEPDIR)/libarm32_libmingwex_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/libarm32_libmingwex_a-delay-n.Po
@@ -75982,7 +75903,6 @@ distclean: distclean-am
        -rm -f misc/$(DEPDIR)/libarm32_libucrtapp_extra_a-setjmp.Po
        -rm -f misc/$(DEPDIR)/libarm64_libdloadhelper_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/libarm64_libmingwex_a-alarm.Po
-       -rm -f misc/$(DEPDIR)/libarm64_libmingwex_a-basename.Po
        -rm -f misc/$(DEPDIR)/libarm64_libmingwex_a-btowc.Po
        -rm -f misc/$(DEPDIR)/libarm64_libmingwex_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/libarm64_libmingwex_a-delay-n.Po
@@ -79054,7 +78974,6 @@ maintainer-clean: maintainer-clean-am
        -rm -f misc/$(DEPDIR)/lib32_libcrtdll_extra_a-strtoumax.Po
        -rm -f misc/$(DEPDIR)/lib32_libdloadhelper_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/lib32_libmingwex_a-alarm.Po
-       -rm -f misc/$(DEPDIR)/lib32_libmingwex_a-basename.Po
        -rm -f misc/$(DEPDIR)/lib32_libmingwex_a-btowc.Po
        -rm -f misc/$(DEPDIR)/lib32_libmingwex_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/lib32_libmingwex_a-delay-n.Po
@@ -79191,7 +79110,6 @@ maintainer-clean: maintainer-clean-am
        -rm -f misc/$(DEPDIR)/lib32_libucrtapp_extra_a-setjmp.Po
        -rm -f misc/$(DEPDIR)/lib64_libdloadhelper_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/lib64_libmingwex_a-alarm.Po
-       -rm -f misc/$(DEPDIR)/lib64_libmingwex_a-basename.Po
        -rm -f misc/$(DEPDIR)/lib64_libmingwex_a-btowc.Po
        -rm -f misc/$(DEPDIR)/lib64_libmingwex_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/lib64_libmingwex_a-delay-n.Po
@@ -79294,7 +79212,6 @@ maintainer-clean: maintainer-clean-am
        -rm -f misc/$(DEPDIR)/lib64_libucrtapp_extra_a-setjmp.Po
        -rm -f misc/$(DEPDIR)/libarm32_libdloadhelper_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/libarm32_libmingwex_a-alarm.Po
-       -rm -f misc/$(DEPDIR)/libarm32_libmingwex_a-basename.Po
        -rm -f misc/$(DEPDIR)/libarm32_libmingwex_a-btowc.Po
        -rm -f misc/$(DEPDIR)/libarm32_libmingwex_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/libarm32_libmingwex_a-delay-n.Po
@@ -79388,7 +79305,6 @@ maintainer-clean: maintainer-clean-am
        -rm -f misc/$(DEPDIR)/libarm32_libucrtapp_extra_a-setjmp.Po
        -rm -f misc/$(DEPDIR)/libarm64_libdloadhelper_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/libarm64_libmingwex_a-alarm.Po
-       -rm -f misc/$(DEPDIR)/libarm64_libmingwex_a-basename.Po
        -rm -f misc/$(DEPDIR)/libarm64_libmingwex_a-btowc.Po
        -rm -f misc/$(DEPDIR)/libarm64_libmingwex_a-delay-f.Po
        -rm -f misc/$(DEPDIR)/libarm64_libmingwex_a-delay-n.Po
-- 
2.40.0

From 4d4794b0d095885f0e88772c3d07c5eaa925b3ff Mon Sep 17 00:00:00 2001
From: LIU Hao <[email protected]>
Date: Sun, 26 Mar 2023 02:02:52 +0800
Subject: [PATCH 3/3] crt: Reimplement `dirname()` and `basename()`

Signed-off-by: LIU Hao <[email protected]>
---
 mingw-w64-crt/misc/dirname.c | 259 +++++++++++++++++++++++++++++++++++
 1 file changed, 259 insertions(+)

diff --git a/mingw-w64-crt/misc/dirname.c b/mingw-w64-crt/misc/dirname.c
index e69de29bb..e546caaf3 100644
--- a/mingw-w64-crt/misc/dirname.c
+++ b/mingw-w64-crt/misc/dirname.c
@@ -0,0 +1,259 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include "mb_wc_common.h"
+#include <stdlib.h>
+#include <libgen.h>
+#include <windows.h>
+
+/* A 'directory separator' is a byte that equals 0x2F ('solidus' or more
+ * commonly 'forward slash') or 0x5C ('reverse solidus' or more commonly
+ * 'backward slash'). The byte 0x5C may look different from a backward slash
+ * in some locales; for example, it looks the same as a Yen sign in Japanese
+ * locales and a Won sign in Korean locales. Despite its appearance, it still
+ * functions as a directory separator.
+ *
+ * A 'path' comprises an optional DOS drive letter with a colon, and then an
+ * arbitrary number of possibily empty components, separated by non-empty
+ * sequences of directory separators (in other words, consecutive directory
+ * separators are treated as a single one). A path that comprises an empty
+ * component denotes the current working directory.
+ *
+ * An 'absolute path' comprises at least two components, the first of which
+ * is empty.
+ *
+ * A 'relative path' is a path that is not an absolute path. In other words,
+ * it either comprises an empty component, or begins with a non-empty
+ * component.
+ *
+ * POSIX doesn't have a concept about DOS drives. A path that does not have a
+ * drive letter starts from the same drive as the current working directory.
+ *
+ * For example:
+ * (Examples without drive letters match POSIX.)
+ *
+ *   Argument                 dirname() returns        basename() returns
+ *   --------                 -----------------        ------------------
+ *   `` or NULL               `.`                      `.`
+ *   `usr`                    `.`                      `usr`
+ *   `usr\`                   `.`                      `usr`
+ *   `\`                      `\`                      `\`
+ *   `\usr`                   `\`                      `usr`
+ *   `\usr\lib`               `\usr`                   `lib`
+ *   `\home\\dwc\\test`       `\home\\dwc`             `test`
+ *   `\\host\usr`             `\\host\.`               `usr`
+ *   `\\host\usr\lib`         `\\host\usr`             `lib`
+ *   `\\host\\usr`            `\\host\\`               `usr`
+ *   `\\host\\usr\lib`        `\\host\\usr`            `lib`
+ *   `C:`                     `C:.`                    `.`
+ *   `C:usr`                  `C:.`                    `usr`
+ *   `C:usr\`                 `C:.`                    `usr`
+ *   `C:\`                    `C:\`                    `\`
+ *   `C:\\`                   `C:\`                    `\`
+ *   `C:\\\`                  `C:\`                    `\`
+ *   `C:\usr`                 `C:\`                    `usr`
+ *   `C:\usr\lib`             `C:\usr`                 `lib`
+ *   `C:\\usr\\lib\\`         `C:\\usr`                `lib`
+ *   `C:\home\\dwc\\test`     `C:\home\\dwc`           `test`
+ */
+
+struct path_info
+  {
+    /* This points to end of the UNC prefix and drive letter, if any.  */
+    char* prefix_end;
+
+    /* These point to the directory separator in front of the last non-empty
+     * component.  */
+    char* base_sep_begin;
+    char* base_sep_end;
+
+    /* This points to the last directory separator sequence if no other
+     * non-separator characters follow it.  */
+    char* term_sep_begin;
+
+    /* This points to the end of the string.  */
+    char* path_end;
+  };
+
+#define IS_DIR_SEP(c)  ((c) == '/' || (c) == '\\')
+
+static
+void
+do_get_path_info(struct path_info* info, char* path)
+  {
+    unsigned int cp = ___lc_codepage_func();
+    char* pos = path;
+    int dbcs_tb, dir_sep;
+
+    /* Set the structure to 'no data'.  */
+    info->prefix_end = NULL;
+    info->base_sep_begin = NULL;
+    info->base_sep_end = NULL;
+    info->term_sep_begin = NULL;
+
+    /* Check for a UNC prefix.  */
+    if(IS_DIR_SEP(pos[0]) && IS_DIR_SEP(pos[1])) {
+      pos += 2;
+      info->prefix_end = pos;
+
+      /* Seek to the end of the host name.  */
+      dbcs_tb = 0;
+      while(*pos != 0) {
+        dir_sep = 0;
+
+        if(dbcs_tb)
+          dbcs_tb = 0;
+        else if(IsDBCSLeadByteEx(cp, *pos))
+          dbcs_tb = 1;
+        else
+          dir_sep = IS_DIR_SEP(*pos);
+
+        if(dir_sep)
+          break;
+
+        pos ++;
+      }
+
+      /* Host name terminates here. The terminating directory separator is
+       * part of the prefix.  */
+      pos ++;
+      info->prefix_end = pos;
+    }
+
+    /* Check for a DOS drive letter.  */
+    if((pos[0] >= 'A' && pos[0] <= 'Z' && pos[1] == ':')
+       || (pos[0] >= 'a' && pos[0] <= 'z' && pos[1] == ':')) {
+      pos += 2;
+      info->prefix_end = pos;
+    }
+
+    /* The remaining part of the path is almost the same as POSIX.  */
+    dbcs_tb = 0;
+    while(*pos != 0) {
+      dir_sep = 0;
+
+      if(dbcs_tb)
+        dbcs_tb = 0;
+      else if(IsDBCSLeadByteEx(cp, *pos))
+        dbcs_tb = 1;
+      else
+        dir_sep = IS_DIR_SEP(*pos);
+
+      /* If a separator has been encountered and the previous character
+       * was not, mark this as the beginning of the terminating separator
+       * sequence.  */
+      if(dir_sep && !info->term_sep_begin)
+        info->term_sep_begin = pos;
+
+      /* If a non-separator character has been encountered and a previous
+       * terminating separator sequence exists, start a new component.  */
+      if(!dir_sep && info->term_sep_begin) {
+        info->base_sep_begin = info->term_sep_begin;
+        info->base_sep_end = pos;
+        info->term_sep_begin = NULL;
+      }
+
+      pos ++;
+    }
+
+    /* Stores the end of the path for convenience.  */
+    info->path_end = pos;
+  }
+
+char*
+dirname(char* path)
+  {
+    struct path_info info;
+    char* upath;
+    const char* top;
+    static char* static_path_copy;
+
+    if(path == NULL|| path[0] == 0)
+      return (char*) ".";
+
+    do_get_path_info(&info, path);
+    upath = info.prefix_end ? info.prefix_end : path;
+    top = IS_DIR_SEP(upath[0]) ? "\\" : ".";
+
+    /* If a non-terminating directory separator exists, it terminates the
+     * dirname. Truncate the path there.  */
+    if(info.base_sep_begin) {
+      info.base_sep_begin[0] = 0;
+
+      /* If the unprefixed path has not been truncated to empty, it is now
+       * the dirname, so return it.  */
+      if(upath[0])
+        return path;
+    }
+
+    /* The dirname is empty. In principle we return `<prefix>.` if the
+     * path is relative and `<prefix>\` if it is absolute. This can be
+     * optimized if there is no prefix.  */
+    if(upath == path)
+      return (char*) top;
+
+    /* When there is a prefix, we must append a character to the prefix.
+     * If there is enough room in the original path, we just reuse its
+     * storage.  */
+    if(info.prefix_end != info.path_end) {
+      info.prefix_end[0] = *top;
+      info.prefix_end[1] = 0;
+      return path;
+    }
+
+    /* This is only the last resort. If there is no room, we have to copy
+     * the prefix elsewhere.  */
+    upath = realloc(static_path_copy, info.prefix_end - path + 2);
+    if(!upath)
+      return (char*) top;
+
+    memcpy(upath, path, info.prefix_end - path);
+    static_path_copy = upath;
+
+    upath = static_path_copy + (info.prefix_end - path);
+    upath[0] = *top;
+    upath[1] = 0;
+    return static_path_copy;
+  }
+
+char*
+basename(char* path)
+  {
+    struct path_info info;
+    char* upath;
+
+    if(path == NULL)
+      return (char*) ".";
+
+    do_get_path_info(&info, path);
+    upath = info.prefix_end ? info.prefix_end : path;
+
+    /* If the unprefixed path is empty, POSIX says '.' shall be returned.  */
+    if(upath[0] == 0)
+      return (char*) ".";
+
+    /* If a terminating separator sequence exists, it is not part of the
+     * name and shall be truncated.  */
+    if(info.term_sep_begin)
+      info.term_sep_begin[0] = 0;
+
+    /* If some other separator sequence has been found, the basename
+     * immediately follows it.  */
+    if(info.base_sep_end)
+      return info.base_sep_end;
+
+    /* If removal of the terminating separator sequence has caused the
+     * unprefixed path to become empty, it must have comprised only
+     * separators. POSIX says `/` shall be returned, but on Windows, we
+     * return `\` instead.  */
+    if(upath[0] == 0)
+      return (char*) "\\";
+
+    /* Return the unprefixed path.  */
+    return upath;
+  }
-- 
2.40.0

#include <stdio.h>
#include <string.h>
#include <libgen.h>

struct
  {
    char path[32], dir[32], base[32];
  }
const tests[] =
  {
    { "", ".", "." },
    { "usr", ".", "usr" },
    { "usr\\", ".", "usr" },
    { "\\", "\\", "\\" },
    { "\\usr", "\\", "usr" },
    { "\\usr\\lib", "\\usr", "lib" },
    { "\\home\\\\dwc\\\\test", "\\home\\\\dwc", "test" },
    { "\\\\host\\usr", "\\\\host\\.", "usr" },
    { "\\\\host\\usr\\lib", "\\\\host\\usr", "lib" },
    { "\\\\host\\\\usr", "\\\\host\\\\", "usr" },
    { "\\\\host\\\\usr\\lib", "\\\\host\\\\usr", "lib" },
    { "C:", "C:.", "." },
    { "C:usr", "C:.", "usr" },
    { "C:usr\\", "C:.", "usr" },
    { "C:\\", "C:\\", "\\" },
    { "C:\\\\", "C:\\", "\\" },
    { "C:\\\\\\", "C:\\", "\\" },
    { "C:\\usr", "C:\\", "usr" },
    { "C:\\usr\\lib", "C:\\usr", "lib" },
    { "C:\\\\usr\\\\lib\\\\", "C:\\\\usr", "lib" },
    { "C:\\home\\\\dwc\\\\test", "C:\\home\\\\dwc", "test" },
  };

int
main(void)
  {
    char temp[40];
    char* r;
    size_t i;

    for(i = 0;  i != sizeof(tests) / sizeof(*tests);  ++i) {
      //printf("`%s`     `%s`     `%s`\n", tests[i].path, tests[i].dir, 
tests[i].base);

      strcpy(temp, tests[i].path);
      r = dirname(temp);
      if(strcmp(r, tests[i].dir) != 0)
        printf("-- error: dirname('%s'): '%s' != '%s'\n", tests[i].path, r, 
tests[i].dir);

      strcpy(temp, tests[i].path);
      r = basename(temp);
      if(strcmp(r, tests[i].base) != 0)
        printf("-- error: basename('%s'): '%s' != '%s'\n", tests[i].path, r, 
tests[i].base);
    }

    printf("done\n");
  }

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to