diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2009-05-13 15:00:06 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2009-05-13 15:00:06 +0000 |
commit | b6c6ea43f30ee958ca1f0af950af01f683f7b5c9 (patch) | |
tree | 16b5a88b3b3ae4bad7bbe8747a6873b7a9ed2c02 /winsup/cygwin/syscalls.cc | |
parent | 136033a8528352fb63fd25534de9fc10173a2576 (diff) | |
download | cygnal-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/syscalls.cc')
-rw-r--r-- | winsup/cygwin/syscalls.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 64c25348e..ab319225c 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -35,6 +35,7 @@ details. */ #include <utmpx.h> #include <sys/uio.h> #include <ctype.h> +#include <locale.h> #include <unistd.h> #include <sys/wait.h> #include <rpc.h> @@ -3726,7 +3727,11 @@ gen_full_path_at (char *path_ret, int dirfd, const char *pathname, char *p; if (dirfd == AT_FDCWD) - p = stpcpy (path_ret, cygheap->cwd.posix); + { + cwdstuff::cwd_lock.acquire (); + p = stpcpy (path_ret, cygheap->cwd.get_posix ()); + cwdstuff::cwd_lock.release (); + } else { cygheap_fdget cfd (dirfd); @@ -4000,3 +4005,16 @@ unlinkat (int dirfd, const char *pathname, int flags) return -1; return (flags & AT_REMOVEDIR) ? rmdir (path) : unlink (path); } + +extern "C" char * +setlocale (int category, const char *locale) +{ + /* Each setlocale potentially changes the multibyte representation + of the CWD. Therefore we have to rest the CWD's posix path and + reevaluate the next time it's used. */ + /* FIXME: Other buffered paths might be affected as well. */ + char *ret = _setlocale_r (_REENT, category, locale); + if (ret) + cygheap->cwd.reset_posix (); + return ret; +} |