1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-26 05:00:28 +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 558fe0113d
commit 2d82b49cf3
4 changed files with 49 additions and 0 deletions

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"
@ -1256,3 +1258,41 @@ dlerror_w32 ()
snprintf (dlerror_str, DLERROR_LEN, "error %ld: %s", (long) dw, msg_buf);
return dlerror_str;
}
/* 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;
}