mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50: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:
parent
558fe0113d
commit
2d82b49cf3
4 changed files with 49 additions and 0 deletions
|
@ -83,6 +83,9 @@
|
||||||
#include "ports-internal.h"
|
#include "ports-internal.h"
|
||||||
#include "ports.h"
|
#include "ports.h"
|
||||||
#include "posix.h"
|
#include "posix.h"
|
||||||
|
#if __MINGW32__
|
||||||
|
#include "posix-w32.h"
|
||||||
|
#endif
|
||||||
#include "smob.h"
|
#include "smob.h"
|
||||||
#include "srfi-13.h"
|
#include "srfi-13.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
|
|
|
@ -59,6 +59,9 @@
|
||||||
#include "pairs.h"
|
#include "pairs.h"
|
||||||
#include "ports-internal.h"
|
#include "ports-internal.h"
|
||||||
#include "posix.h"
|
#include "posix.h"
|
||||||
|
#if __MINGW32__
|
||||||
|
#include "posix-w32.h"
|
||||||
|
#endif
|
||||||
#include "read.h"
|
#include "read.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <c-strcase.h>
|
#include <c-strcase.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -34,6 +35,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "gc.h" /* for scm_*alloc, scm_strdup */
|
#include "gc.h" /* for scm_*alloc, scm_strdup */
|
||||||
|
#include "filename.h"
|
||||||
#include "threads.h" /* for scm_i_scm_pthread_mutex_lock */
|
#include "threads.h" /* for scm_i_scm_pthread_mutex_lock */
|
||||||
|
|
||||||
#include "posix-w32.h"
|
#include "posix-w32.h"
|
||||||
|
@ -1256,3 +1258,41 @@ dlerror_w32 ()
|
||||||
snprintf (dlerror_str, DLERROR_LEN, "error %ld: %s", (long) dw, msg_buf);
|
snprintf (dlerror_str, DLERROR_LEN, "error %ld: %s", (long) dw, msg_buf);
|
||||||
return dlerror_str;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -110,4 +110,7 @@ SCM_INTERNAL char *dlerror_w32 (void);
|
||||||
#define RTLD_GLOBAL 4
|
#define RTLD_GLOBAL 4
|
||||||
#define RTLD_LOCAL 8
|
#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 */
|
#endif /* SCM_POSIX_W32_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue