1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-30 06:50:31 +02:00

mingw: canonicalize-path: Also canonicalize drive letter and '/'.

* libguile/posix-w32.c (canonicalize_device_name,
slashify_file_name): New static functions.
(canonicalize_file_name_mingw): Use them in new function.
* libguile/posix-w32.h (canonicalize_file_name_mingw): Declare it.
(canonicalize_file_name): New define.
* libguile/filesys.c[__MINGW32__]: Include posix-w32.h to use it.
* libguile/fports.c[__MINGW32__]: Likewise.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2021-12-12 15:48:18 +01:00 committed by Michael Gran
parent 79ea1082d0
commit a3018d6d0e
3 changed files with 46 additions and 0 deletions

View file

@ -90,6 +90,9 @@
#include "ports-internal.h"
#include "ports.h"
#include "posix.h"
#if __MINGW32__
#include "posix-w32.h"
#endif
#include "smob.h"
#include "srfi-13.h"
#include "strings.h"

View file

@ -24,6 +24,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <c-strcase.h>
#include <ctype.h>
#include <process.h>
#include <stdio.h>
#include <stdlib.h>
@ -34,6 +35,7 @@
#include <fcntl.h>
#include "gc.h" /* for scm_*alloc, scm_strdup */
#include "filename.h"
#include "threads.h" /* for scm_i_scm_pthread_mutex_lock */
#include "posix-w32.h"
@ -342,3 +344,41 @@ getpagesize_w32 (void)
{
return 4 * 1024;
}
/* Use upcase drive letter in NAME. */
static char *
canonicalize_device_name (char *name)
{
if (name == NULL)
return name;
if (HAS_DEVICE (name))
name[0] = toupper (name[0]);
return name;
}
/* Replace any use of '\\' by '/' in NAME. */
static char *
slashify_file_name (char *name)
{
if (name == NULL)
return name;
for (char *p = name; *p; p++)
if (ISSLASH (*p))
*p = '/';
return name;
}
#undef canonicalize_file_name
/* Also canonicalize use of drive letter and '/' for NAME. */
char *
canonicalize_file_name_mingw (const char *name)
{
char *canon = canonicalize_file_name (name);
canonicalize_device_name (canon);
slashify_file_name (canon);
return canon;
}

View file

@ -85,4 +85,7 @@ SCM_INTERNAL int getpagesize_w32 (void);
#define RTLD_GLOBAL 4
#define RTLD_LOCAL 8
#define canonicalize_file_name canonicalize_file_name_mingw
char *canonicalize_file_name_mingw (const char *name);
#endif /* SCM_POSIX_W32_H */