diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-05-09 15:08:16 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-05-09 15:08:16 +0000 |
commit | a22af4a956ce1926fb69c8f522ecf3111ee372f4 (patch) | |
tree | 2ab604fafcd3083ced396995225dd1bbf9b150eb /winsup/cygwin/path.cc | |
parent | 4dff3fed7d1e258f8a16e54c7c3e3410450fc64f (diff) | |
download | cygnal-a22af4a956ce1926fb69c8f522ecf3111ee372f4.tar.gz cygnal-a22af4a956ce1926fb69c8f522ecf3111ee372f4.tar.bz2 cygnal-a22af4a956ce1926fb69c8f522ecf3111ee372f4.zip |
* sec_auth.cc (str2uni_cat): Move from here...
* path.cc (str2uni_cat): ...to here. Simplify. Make static inline.
(get_nt_native_path): Use RtlAppendUnicodeToString rather than
str2uni_cat for constant strings for speed.
* security.h (str2uni_cat): Drop declaration.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index e39a4b2fb..ec5c40b5c 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -428,6 +428,16 @@ transform_chars (PUNICODE_STRING upath, USHORT start_idx) upath->Buffer + upath->Length / sizeof (WCHAR) - 1); } +static inline void +str2uni_cat (UNICODE_STRING &tgt, const char *srcstr) +{ + int len = sys_mbstowcs (tgt.Buffer + tgt.Length / sizeof (WCHAR), + (tgt.MaximumLength - tgt.Length) / sizeof (WCHAR), + srcstr); + if (len) + tgt.Length += (len - 1) * sizeof (WCHAR); +} + PUNICODE_STRING get_nt_native_path (const char *path, UNICODE_STRING& upath) { @@ -438,7 +448,7 @@ get_nt_native_path (const char *path, UNICODE_STRING& upath) { if (path[1] == ':') /* X:\... */ { - str2uni_cat (upath, "\\??\\"); + RtlAppendUnicodeToString (&upath, L"\\??\\"); str2uni_cat (upath, path); /* The drive letter must be upper case. */ upath.Buffer[4] = towupper (upath.Buffer[4]); @@ -452,13 +462,13 @@ get_nt_native_path (const char *path, UNICODE_STRING& upath) else if ((path[2] != '.' && path[2] != '?') || path[3] != '\\') /* \\server\share\... */ { - str2uni_cat (upath, "\\??\\UNC\\"); + RtlAppendUnicodeToString (&upath, L"\\??\\UNC\\"); str2uni_cat (upath, path + 2); transform_chars (&upath, 8); } else /* \\.\device or \\?\foo */ { - str2uni_cat (upath, "\\??\\"); + RtlAppendUnicodeToString (&upath, L"\\??\\"); str2uni_cat (upath, path + 4); } return &upath; |