diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-09-21 19:29:16 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-09-21 19:29:16 +0000 |
commit | ee42ccd3a2c71ddf73a7b58cdf7ce8afdd0da5dd (patch) | |
tree | ae7ba1374266f5e3060a65a0c66a6766de54319a /winsup/cygwin/path.cc | |
parent | 92763ad9ba0498994c6d466c7e58ba755560183a (diff) | |
download | cygnal-ee42ccd3a2c71ddf73a7b58cdf7ce8afdd0da5dd.tar.gz cygnal-ee42ccd3a2c71ddf73a7b58cdf7ce8afdd0da5dd.tar.bz2 cygnal-ee42ccd3a2c71ddf73a7b58cdf7ce8afdd0da5dd.zip |
* cygheap.h (cwdstuff::get_posix): Convert to const inline method just
returning pointer to posix path.
(cwdstuff::reset_posix): Convert to non-inline method taking a wchar_t
pointer.
* path.cc (cwdstuff::set): Revert change from 2009-05-13. Set posix
to valid incoming path again.
(cwdstuff::reset_posix): New implementation setting posix path from
incoming wchar_t path. Explain usage.
(cwdstuff::get_posix): Drop implementation.
(cwdstuff::get): Drop special case to handle empty posix path.
* syscalls.cc (internal_setlocale): Store old posix cwd as wide char
path. Restore posix cwd using new charset. Explain why.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index db514d325..223cc2331 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3306,8 +3306,8 @@ cwdstuff::set (PUNICODE_STRING nat_cwd, const char *posix_cwd, bool doit) posix_cwd = (const char *) tp.c_get (); mount_table->conv_to_posix_path (win32.Buffer, (char *) posix_cwd, 0); } - if (posix) - posix[0] = '\0'; + posix = (char *) crealloc_abort (posix, strlen (posix_cwd) + 1); + stpcpy (posix, posix_cwd); } out: @@ -3315,20 +3315,14 @@ out: return res; } -/* Copy the value for either the posix or the win32 cwd into a buffer. */ -char * -cwdstuff::get_posix () +/* Store incoming wchar_t path as current posix cwd. This is called from + setlocale so that the cwd is always stored in the right charset. */ +void +cwdstuff::reset_posix (wchar_t *w_cwd) { - if (!posix || !*posix) - { - tmp_pathbuf tp; - - char *tocopy = tp.c_get (); - mount_table->conv_to_posix_path (win32.Buffer, tocopy, 0); - posix = (char *) crealloc_abort (posix, strlen (tocopy) + 1); - stpcpy (posix, tocopy); - } - return posix; + size_t len = sys_wcstombs (NULL, (size_t) -1, w_cwd); + posix = (char *) crealloc_abort (posix, len + 1); + sys_wcstombs (posix, len + 1, w_cwd); } char * @@ -3356,13 +3350,6 @@ cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen) sys_wcstombs (tocopy, NT_MAX_PATH, win32.Buffer, win32.Length / sizeof (WCHAR)); } - else if (!posix || !*posix) - { - tocopy = tp.c_get (); - mount_table->conv_to_posix_path (win32.Buffer, tocopy, 0); - posix = (char *) crealloc_abort (posix, strlen (tocopy) + 1); - stpcpy (posix, tocopy); - } else tocopy = posix; |