* ntdll.h (RtlCreateUnicodeStringFromAsciiz): Fix declaration.
(RtlUpcaseUnicodeChar): Declare. * path.cc (hash_path_name): Split into three functions, taking the path as char *, PWCSTR, or PUNICODE_STRING. Move implementation into PUNICODE_STRING-based function. Drop old drive-relative path consideration. * winsup.h (iswdirsep): Like isdirsep but for WCHARs. (isabspath_u): Like isabspath, for PUNICODE_STRINGs. (iswabspath): Like isabspath, for PWCHARs. (hash_path_name): Add new declarations.
This commit is contained in:
parent
c4bd837700
commit
855e63eb4b
@ -1,3 +1,16 @@
|
|||||||
|
2007-08-16 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* ntdll.h (RtlCreateUnicodeStringFromAsciiz): Fix declaration.
|
||||||
|
(RtlUpcaseUnicodeChar): Declare.
|
||||||
|
* path.cc (hash_path_name): Split into three functions, taking
|
||||||
|
the path as char *, PWCSTR, or PUNICODE_STRING. Move implementation
|
||||||
|
into PUNICODE_STRING-based function. Drop old drive-relative path
|
||||||
|
consideration.
|
||||||
|
* winsup.h (iswdirsep): Like isdirsep but for WCHARs.
|
||||||
|
(isabspath_u): Like isabspath, for PUNICODE_STRINGs.
|
||||||
|
(iswabspath): Like isabspath, for PWCHARs.
|
||||||
|
(hash_path_name): Add new declarations.
|
||||||
|
|
||||||
2007-08-15 Corinna Vinschen <corinna@vinschen.de>
|
2007-08-15 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* path.cc (get_nt_native_path): Allow to convert special paths which
|
* path.cc (get_nt_native_path): Allow to convert special paths which
|
||||||
|
@ -833,7 +833,7 @@ extern "C"
|
|||||||
BOOLEAN);
|
BOOLEAN);
|
||||||
NTSTATUS NTAPI RtlConvertSidToUnicodeString (PUNICODE_STRING, PSID, BOOLEAN);
|
NTSTATUS NTAPI RtlConvertSidToUnicodeString (PUNICODE_STRING, PSID, BOOLEAN);
|
||||||
VOID NTAPI RtlCopyUnicodeString (PUNICODE_STRING, PUNICODE_STRING);
|
VOID NTAPI RtlCopyUnicodeString (PUNICODE_STRING, PUNICODE_STRING);
|
||||||
ULONG WINAPI RtlCreateUnicodeStringFromAsciiz (PUNICODE_STRING, PCSTR);
|
BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz (PUNICODE_STRING, PCSTR);
|
||||||
BOOLEAN NTAPI RtlEqualUnicodeString (PUNICODE_STRING, PUNICODE_STRING,
|
BOOLEAN NTAPI RtlEqualUnicodeString (PUNICODE_STRING, PUNICODE_STRING,
|
||||||
BOOLEAN);
|
BOOLEAN);
|
||||||
VOID NTAPI RtlFreeAnsiString (PANSI_STRING);
|
VOID NTAPI RtlFreeAnsiString (PANSI_STRING);
|
||||||
@ -853,6 +853,7 @@ extern "C"
|
|||||||
BOOLEAN);
|
BOOLEAN);
|
||||||
NTSTATUS NTAPI RtlUnicodeStringToOemString (PANSI_STRING, PUNICODE_STRING,
|
NTSTATUS NTAPI RtlUnicodeStringToOemString (PANSI_STRING, PUNICODE_STRING,
|
||||||
BOOLEAN);
|
BOOLEAN);
|
||||||
|
WCHAR NTAPI RtlUpcaseUnicodeChar (WCHAR);
|
||||||
|
|
||||||
/* A few Rtl functions are either actually macros, or they just don't
|
/* A few Rtl functions are either actually macros, or they just don't
|
||||||
exist even though they would be a big help. We implement them here,
|
exist even though they would be a big help. We implement them here,
|
||||||
|
@ -80,6 +80,7 @@ details. */
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ntdll.h>
|
#include <ntdll.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <wctype.h>
|
||||||
|
|
||||||
bool dos_file_warning = true;
|
bool dos_file_warning = true;
|
||||||
static int normalize_win32_path (const char *, char *, char *&);
|
static int normalize_win32_path (const char *, char *, char *&);
|
||||||
@ -3740,62 +3741,51 @@ readlink (const char *path, char *buf, int buflen)
|
|||||||
done during the opendir call and the hash or the filename within
|
done during the opendir call and the hash or the filename within
|
||||||
the directory. FIXME: Not bullet-proof. */
|
the directory. FIXME: Not bullet-proof. */
|
||||||
/* Cygwin internal */
|
/* Cygwin internal */
|
||||||
|
|
||||||
__ino64_t __stdcall
|
__ino64_t __stdcall
|
||||||
hash_path_name (__ino64_t hash, const char *name)
|
hash_path_name (__ino64_t hash, PUNICODE_STRING name)
|
||||||
{
|
{
|
||||||
if (!*name)
|
if (name->Length == 0)
|
||||||
return hash;
|
return hash;
|
||||||
|
|
||||||
/* Perform some initial permutations on the pathname if this is
|
/* Fill out the hashed path name with the current working directory if
|
||||||
not "seeded" */
|
this is not an absolute path and there is no pre-specified hash value.
|
||||||
if (!hash)
|
Otherwise the inodes same will differ depending on whether a file is
|
||||||
|
referenced with an absolute value or relatively. */
|
||||||
|
if (!hash && !isabspath_u (name))
|
||||||
{
|
{
|
||||||
/* Simplistic handling of drives. If there is a drive specified,
|
hash = cygheap->cwd.get_hash ();
|
||||||
make sure that the initial letter is upper case. If there is
|
if (name->Length == sizeof (WCHAR) && name->Buffer[0] == L'.')
|
||||||
no \ after the ':' assume access through the root directory
|
return hash;
|
||||||
of that drive.
|
hash = L'\\' + (hash << 6) + (hash << 16) - hash;
|
||||||
FIXME: Should really honor MS-Windows convention of using
|
|
||||||
the environment to track current directory on various drives. */
|
|
||||||
if (name[1] == ':')
|
|
||||||
{
|
|
||||||
char *nn, *newname = (char *) alloca (strlen (name) + 2);
|
|
||||||
nn = newname;
|
|
||||||
*nn = isupper (*name) ? cyg_tolower (*name) : *name;
|
|
||||||
*++nn = ':';
|
|
||||||
name += 2;
|
|
||||||
if (*name != '\\')
|
|
||||||
*++nn = '\\';
|
|
||||||
strcpy (++nn, name);
|
|
||||||
name = newname;
|
|
||||||
goto hashit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill out the hashed path name with the current working directory if
|
|
||||||
this is not an absolute path and there is no pre-specified hash value.
|
|
||||||
Otherwise the inodes same will differ depending on whether a file is
|
|
||||||
referenced with an absolute value or relatively. */
|
|
||||||
|
|
||||||
if (!hash && !isabspath (name))
|
|
||||||
{
|
|
||||||
hash = cygheap->cwd.get_hash ();
|
|
||||||
if (name[0] == '.' && name[1] == '\0')
|
|
||||||
return hash;
|
|
||||||
hash = '\\' + (hash << 6) + (hash << 16) - hash;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hashit:
|
hashit:
|
||||||
/* Build up hash. Name is already normalized */
|
/* Build up hash. Name is already normalized */
|
||||||
do
|
USHORT len = name->Length / sizeof (WCHAR);
|
||||||
{
|
for (USHORT idx = 0; idx < len; ++idx)
|
||||||
int ch = cyg_tolower (*name);
|
hash = RtlUpcaseUnicodeChar (name->Buffer[idx])
|
||||||
hash = ch + (hash << 6) + (hash << 16) - hash;
|
+ (hash << 6) + (hash << 16) - hash;
|
||||||
}
|
|
||||||
while (*++name != '\0');
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__ino64_t __stdcall
|
||||||
|
hash_path_name (__ino64_t hash, PCWSTR name)
|
||||||
|
{
|
||||||
|
UNICODE_STRING uname;
|
||||||
|
RtlInitUnicodeString (&uname, name);
|
||||||
|
return hash_path_name (hash, &uname);
|
||||||
|
}
|
||||||
|
|
||||||
|
__ino64_t __stdcall
|
||||||
|
hash_path_name (__ino64_t hash, const char *name)
|
||||||
|
{
|
||||||
|
UNICODE_STRING uname;
|
||||||
|
RtlCreateUnicodeStringFromAsciiz (&uname, name);
|
||||||
|
__ino64_t ret = hash_path_name (hash, &uname);
|
||||||
|
RtlFreeUnicodeString (&uname);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
getcwd (char *buf, size_t ulen)
|
getcwd (char *buf, size_t ulen)
|
||||||
{
|
{
|
||||||
|
@ -143,6 +143,12 @@ extern HANDLE tty_mutex;
|
|||||||
type flag () const { return (type) status.flag; }
|
type flag () const { return (type) status.flag; }
|
||||||
|
|
||||||
/* Used when treating / and \ as equivalent. */
|
/* Used when treating / and \ as equivalent. */
|
||||||
|
#define iswdirsep(ch) \
|
||||||
|
({ \
|
||||||
|
WCHAR __c = (ch); \
|
||||||
|
((__c) == L'/' || (__c) == L'\\'); \
|
||||||
|
})
|
||||||
|
|
||||||
#define isdirsep(ch) \
|
#define isdirsep(ch) \
|
||||||
({ \
|
({ \
|
||||||
char __c = (ch); \
|
char __c = (ch); \
|
||||||
@ -160,6 +166,18 @@ extern int __api_fatal_exit_val;
|
|||||||
#undef issep
|
#undef issep
|
||||||
#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL)
|
#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL)
|
||||||
|
|
||||||
|
/* Every path beginning with / or \, as well as every path being X:
|
||||||
|
or starting with X:/ or X:\ */
|
||||||
|
#define isabspath_u(p) \
|
||||||
|
((p)->Length && \
|
||||||
|
(iswdirsep ((p)->Buffer[0]) || \
|
||||||
|
((p)->Length > sizeof (WCHAR) && iswalpha ((p)->Buffer[0]) \
|
||||||
|
&& (p)->Buffer[1] == L':' && \
|
||||||
|
((p)->Length == 2 * sizeof (WCHAR) || iswdirsep ((p)->Buffer[2])))))
|
||||||
|
|
||||||
|
#define iswabspath(p) \
|
||||||
|
(iswdirsep (*(p)) || (iswalpha (*(p)) && (p)[1] == L':' && (!(p)[2] || iswdirsep ((p)[2]))))
|
||||||
|
|
||||||
#define isabspath(p) \
|
#define isabspath(p) \
|
||||||
(isdirsep (*(p)) || (isalpha (*(p)) && (p)[1] == ':' && (!(p)[2] || isdirsep ((p)[2]))))
|
(isdirsep (*(p)) || (isalpha (*(p)) && (p)[1] == ':' && (!(p)[2] || isdirsep ((p)[2]))))
|
||||||
|
|
||||||
@ -239,6 +257,8 @@ extern bool cygwin_finished_initializing;
|
|||||||
void __stdcall set_std_handle (int);
|
void __stdcall set_std_handle (int);
|
||||||
int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *);
|
int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *);
|
||||||
|
|
||||||
|
__ino64_t __stdcall hash_path_name (__ino64_t hash, PUNICODE_STRING name) __attribute__ ((regparm(2)));
|
||||||
|
__ino64_t __stdcall hash_path_name (__ino64_t hash, PCWSTR name) __attribute__ ((regparm(2)));
|
||||||
__ino64_t __stdcall hash_path_name (__ino64_t hash, const char *name) __attribute__ ((regparm(2)));
|
__ino64_t __stdcall hash_path_name (__ino64_t hash, const char *name) __attribute__ ((regparm(2)));
|
||||||
void __stdcall nofinalslash (const char *src, char *dst) __attribute__ ((regparm(2)));
|
void __stdcall nofinalslash (const char *src, char *dst) __attribute__ ((regparm(2)));
|
||||||
extern "C" char *__stdcall rootdir (const char *full_path, char *root_path) __attribute__ ((regparm(2)));
|
extern "C" char *__stdcall rootdir (const char *full_path, char *root_path) __attribute__ ((regparm(2)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user