summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/path.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2009-05-13 15:00:06 +0000
committerCorinna Vinschen <corinna@vinschen.de>2009-05-13 15:00:06 +0000
commitb6c6ea43f30ee958ca1f0af950af01f683f7b5c9 (patch)
tree16b5a88b3b3ae4bad7bbe8747a6873b7a9ed2c02 /winsup/cygwin/path.cc
parent136033a8528352fb63fd25534de9fc10173a2576 (diff)
downloadcygnal-b6c6ea43f30ee958ca1f0af950af01f683f7b5c9.tar.gz
cygnal-b6c6ea43f30ee958ca1f0af950af01f683f7b5c9.tar.bz2
cygnal-b6c6ea43f30ee958ca1f0af950af01f683f7b5c9.zip
* cygheap.h (cwdstuff): Convert to class. Make posix and dir private.
(cwdstuff::get_posix): New method. (cwdstuff::reset_posix): New method. * dcrt0.cc (dll_crt0_1): Call setlocale rather than _setlocale_r. * environ.cc (environ_init): Ditto. Prefer "C" locale over current codepage default locale. * path.cc (chdir): Use cwdstuff::get_posix method instead of accessing cwdstuff::posix directly. (cwdstuff::set): Defer creating posix path to first usage. (cwdstuff::get_posix): Create posix path if it's empty, and return it. (cwdstuff::get): Create posix path if it's empty. * strfuncs.cc (sys_cp_wcstombs): Use UTF-8 conversion in the "C" locale. (sys_cp_mbstowcs): Ditto. * syscalls.cc (gen_full_path_at): Fetch CWD posix path locked. (setlocale): Implement here. Reset CWD posix path.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc28
1 files changed, 25 insertions, 3 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index ec5c40b5c..ca2df5872 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2599,7 +2599,7 @@ chdir (const char *in_dir)
/* Note that we're accessing cwd.posix without a lock here. I didn't think
it was worth locking just for strace. */
syscall_printf ("%d = chdir() cygheap->cwd.posix '%s' native '%S'", res,
- cygheap->cwd.posix, path.get_nt_native_path ());
+ cygheap->cwd.get_posix (), path.get_nt_native_path ());
MALLOC_CHECK;
return res;
}
@@ -3230,8 +3230,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);
}
- posix = (char *) crealloc_abort (posix, strlen (posix_cwd) + 1);
- stpcpy (posix, posix_cwd);
+ if (posix)
+ posix[0] = '\0';
}
out:
@@ -3241,6 +3241,21 @@ out:
/* Copy the value for either the posix or the win32 cwd into a buffer. */
char *
+cwdstuff::get_posix ()
+{
+ 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;
+}
+
+char *
cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen)
{
MALLOC_CHECK;
@@ -3265,6 +3280,13 @@ 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;