diff options
author | Christopher Faylor <me@cgf.cx> | 2010-05-18 18:30:51 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2010-05-18 18:30:51 +0400 |
commit | d3258e063cb0a4fc77a76df3c91ba9841ca4971c (patch) | |
tree | 2921ded7329f12667d439c207fa81f15575dba14 /winsup/cygwin | |
parent | c8bd391c328c8650a93388f5cb3409c3740ee963 (diff) |
* environ.cc (regopt): Change the first argument to wide char string.
(environ_init): Accommodate change to the first argument of regopt.
* exception.cc (open_stackdumpfile): Accommodate change to the type of progname
in _pinfo.
* external.cc (fillout_pinfo): Ditto.
* fhandler_process.cc (format_process_winexename): Ditto.
(format_process_stat): Ditto.
* fork.cc (fork::parent): Ditto.
* pinfo.cc (pinfo_basic::pinfo_basic): Call GetModuleFileNameW instead of
GetModuleFileName.
(pinfo::thisproc): Accommodate change to the type of progname in _pinfo.
(pinfo_init): Ditto.
* pinfo.h (_pinfo): Change the type of progname to a wide char array.
* registry.h (reg_key::get_int): Change the first argument from constant point
to pointer to constant.
(reg_key::get_string): Ditto. Change the last argument likewise.
* registry.cc (reg_key::get_int): Accommodate change to the declaration.
(reg_key::get_string): Ditto.
* strace.cc (strace::hello): Accommodate change to the type of progname in
_pinfo.
(strace::vsprntf): Ditto.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 26 | ||||
-rw-r--r-- | winsup/cygwin/environ.cc | 17 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 15 | ||||
-rw-r--r-- | winsup/cygwin/external.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_process.cc | 18 | ||||
-rw-r--r-- | winsup/cygwin/fork.cc | 13 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.cc | 8 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.h | 2 | ||||
-rw-r--r-- | winsup/cygwin/registry.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/registry.h | 4 | ||||
-rw-r--r-- | winsup/cygwin/spawn.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/strace.cc | 32 |
12 files changed, 89 insertions, 60 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a2d40a9f6..cbf2a0e45 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,29 @@ +2010-05-18 Kazuhiro Fujida <fujieda@acm.org> + + * environ.cc (regopt): Change the first argument to wide char string. + (environ_init): Accommodate change to the first argument of regopt. + * exception.cc (open_stackdumpfile): Accommodate change to the type of + progname in _pinfo. + * external.cc (fillout_pinfo): Ditto. + * fhandler_process.cc (format_process_winexename): Ditto. + (format_process_stat): Ditto. + * fork.cc (fork::parent): Ditto. + * pinfo.cc (pinfo_basic::pinfo_basic): Call GetModuleFileNameW instead + of GetModuleFileName. + (pinfo::thisproc): Accommodate change to the type of progname in + _pinfo. + (pinfo_init): Ditto. + * pinfo.h (_pinfo): Change the type of progname to a wide char array. + * registry.h (reg_key::get_int): Change the first argument from + constant point to pointer to constant. + (reg_key::get_string): Ditto. Change the last argument likewise. + * registry.cc (reg_key::get_int): Accommodate change to the + declaration. + (reg_key::get_string): Ditto. + * strace.cc (strace::hello): Accommodate change to the type of progname + in _pinfo. + (strace::vsprntf): Ditto. + 2010-05-07 Christopher Faylor <me+cygwin@cgf.cx> * Makefile.in (DLL_OFILES): Add pseudo-reloc.o. diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc index 4935bc815..9d1544429 100644 --- a/winsup/cygwin/environ.cc +++ b/winsup/cygwin/environ.cc @@ -29,6 +29,7 @@ details. */ #include "registry.h" #include "environ.h" #include "child_info.h" +#include "ntdll.h" extern bool dos_file_warning; extern bool ignore_case_with_glob; @@ -698,18 +699,24 @@ parse_options (char *buf) /* Set options from the registry. */ static bool __stdcall -regopt (const char *name, char *buf) +regopt (const WCHAR *name, char *buf) { bool parsed_something = false; - char lname[strlen (name) + 1]; - strlwr (strcpy (lname, name)); + UNICODE_STRING lname; + size_t len = (wcslen(name) + 1) * sizeof (WCHAR); + RtlInitEmptyUnicodeString(&lname, (PWCHAR) alloca (len), len); + wcscpy(lname.Buffer, name); + RtlDowncaseUnicodeString(&lname, &lname, FALSE); for (int i = 0; i < 2; i++) { reg_key r (i, KEY_READ, CYGWIN_INFO_PROGRAM_OPTIONS_NAME, NULL); - if (r.get_string (lname, buf, NT_MAX_PATH, "") == ERROR_SUCCESS) + if (r.get_string (lname.Buffer, (PWCHAR) buf, NT_MAX_PATH, L"") == ERROR_SUCCESS) { + char *newp; + sys_wcstombs_alloc(&newp, HEAP_NOTHEAP, (PWCHAR) buf); + strcpy(buf, newp); parse_options (buf); parsed_something = true; break; @@ -747,7 +754,7 @@ environ_init (char **envp, int envc) } char *tmpbuf = tp.t_get (); - got_something_from_registry = regopt ("default", tmpbuf); + got_something_from_registry = regopt (L"default", tmpbuf); if (myself->progname[0]) got_something_from_registry = regopt (myself->progname, tmpbuf) || got_something_from_registry; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index ed72f7967..16a4e190f 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -130,24 +130,21 @@ open_stackdumpfile () { if (myself->progname[0]) { - const char *p; + const WCHAR *p; /* write to progname.stackdump if possible */ if (!myself->progname[0]) - p = "unknown"; - else if ((p = strrchr (myself->progname, '\\'))) + p = L"unknown"; + else if ((p = wcsrchr (myself->progname, L'\\'))) p++; else p = myself->progname; - WCHAR corefile[strlen (p) + sizeof (".stackdump")]; + WCHAR corefile[wcslen (p) + sizeof (".stackdump")]; + wcscpy(corefile, p); UNICODE_STRING ucore; OBJECT_ATTRIBUTES attr; /* Create the UNICODE variation of <progname>.stackdump. */ - RtlInitEmptyUnicodeString (&ucore, corefile, - sizeof corefile - sizeof (WCHAR)); - ucore.Length = sys_mbstowcs (ucore.Buffer, - ucore.MaximumLength / sizeof (WCHAR), - p, strlen (p)) * sizeof (WCHAR); + RtlInitUnicodeString (&ucore, corefile); RtlAppendUnicodeToString (&ucore, L".stackdump"); /* Create an object attribute which refers to <progname>.stackdump in Cygwin's cwd. Stick to caseinsensitivity. */ diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index c8cbd9370..d76000916 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -89,7 +89,7 @@ fillout_pinfo (pid_t pid, int winpid) ep.rusage_self = p->rusage_self; ep.rusage_children = p->rusage_children; ep.progname[0] = '\0'; - strncat (ep.progname, p->progname, MAX_PATH - 1); + sys_wcstombs(ep.progname, MAX_PATH, p->progname); ep.strace_mask = 0; ep.version = EXTERNAL_PINFO_VERSION; @@ -99,7 +99,7 @@ fillout_pinfo (pid_t pid, int winpid) ep.gid32 = p->gid; ep.progname_long = ep_progname_long_buf; - strcpy (ep.progname_long, p->progname); + sys_wcstombs(ep.progname_long, NT_MAX_PATH, p->progname); break; } } diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index 10610541f..83b69b84a 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -537,9 +537,9 @@ static _off64_t format_process_winexename (void *data, char *&destbuf) { _pinfo *p = (_pinfo *) data; - int len = strlen (p->progname); - destbuf = (char *) crealloc_abort (destbuf, len + 2); - strcpy (destbuf, p->progname); + size_t len = sys_wcstombs (NULL, 0, p->progname); + destbuf = (char *) crealloc_abort (destbuf, len + 1); + sys_wcstombs (destbuf, len, p->progname); destbuf[len] = '\n'; return len + 1; } @@ -649,6 +649,7 @@ format_process_stat (void *data, char *&destbuf) { _pinfo *p = (_pinfo *) data; char cmd[NAME_MAX + 1]; + WCHAR wcmd[NAME_MAX + 1]; int state = 'R'; unsigned long fault_count = 0UL, utime = 0UL, stime = 0UL, @@ -659,8 +660,9 @@ format_process_stat (void *data, char *&destbuf) strcpy (cmd, "<defunct>"); else { - char *last_slash = strrchr (p->progname, '\\'); - strcpy (cmd, last_slash ? last_slash + 1 : p->progname); + PWCHAR last_slash = wcsrchr (p->progname, L'\\'); + wcscpy (wcmd, last_slash ? last_slash + 1 : p->progname); + sys_wcstombs (cmd, NAME_MAX + 1, wcmd); int len = strlen (cmd); if (len > 4) { @@ -779,6 +781,7 @@ format_process_status (void *data, char *&destbuf) { _pinfo *p = (_pinfo *) data; char cmd[NAME_MAX + 1]; + WCHAR wcmd[NAME_MAX + 1]; int state = 'R'; const char *state_str = "unknown"; unsigned long vmsize = 0UL, vmrss = 0UL, vmdata = 0UL, vmlib = 0UL, vmtext = 0UL, @@ -787,8 +790,9 @@ format_process_status (void *data, char *&destbuf) strcpy (cmd, "<defunct>"); else { - char *last_slash = strrchr (p->progname, '\\'); - strcpy (cmd, last_slash ? last_slash + 1 : p->progname); + PWCHAR last_slash = wcsrchr (p->progname, L'\\'); + wcscpy (wcmd, last_slash ? last_slash + 1 : p->progname); + sys_wcstombs (cmd, NAME_MAX + 1, wcmd); int len = strlen (cmd); if (len > 4) { diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index f0a427a63..97440ae0f 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -342,13 +342,8 @@ frok::parent (volatile char * volatile stack_here) si.lpReserved2 = (LPBYTE) &ch; si.cbReserved2 = sizeof (ch); - /* FIXME: myself->progname should be converted to WCHAR. */ - tmp_pathbuf tp; - PWCHAR progname = tp.w_get (); - sys_mbstowcs (progname, NT_MAX_PATH, myself->progname); - syscall_printf ("CreateProcess (%W, %W, 0, 0, 1, %p, 0, 0, %p, %p)", - progname, progname, c_flags, &si, &pi); + myself->progname, myself->progname, c_flags, &si, &pi); bool locked = __malloc_lock (); time_t start_time = time (NULL); @@ -358,8 +353,8 @@ frok::parent (volatile char * volatile stack_here) while (1) { - rc = CreateProcessW (progname, /* image to run */ - progname, /* what we send in arg0 */ + rc = CreateProcessW (myself->progname, /* image to run */ + myself->progname, /* what we send in arg0 */ &sec_none_nih, &sec_none_nih, TRUE, /* inherit handles from parent */ @@ -430,7 +425,7 @@ frok::parent (volatile char * volatile stack_here) /* Initialize things that are done later in dll_crt0_1 that aren't done for the forkee. */ - strcpy (child->progname, myself->progname); + wcscpy (child->progname, myself->progname); /* Fill in fields in the child's process table entry. */ child->dwProcessId = pi.dwProcessId; diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index cdc801d56..e0b1e1f02 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -39,7 +39,7 @@ public: pinfo_basic::pinfo_basic() { pid = dwProcessId = GetCurrentProcessId (); - GetModuleFileName (NULL, progname, sizeof (progname)); + GetModuleFileNameW (NULL, progname, sizeof (progname)); } pinfo_basic myself_initial NO_COPY; @@ -62,7 +62,7 @@ pinfo::thisproc (HANDLE h) init (cygheap->pid, PID_IN_USE, h ?: INVALID_HANDLE_VALUE); procinfo->process_state |= PID_IN_USE; procinfo->dwProcessId = myself_initial.pid; - strcpy (procinfo->progname, myself_initial.progname); + wcscpy (procinfo->progname, myself_initial.progname); strace.hello (); debug_printf ("myself->dwProcessId %u", procinfo->dwProcessId); if (h) @@ -121,7 +121,9 @@ status_exit (DWORD x) case STATUS_DLL_NOT_FOUND: { char posix_prog[NT_MAX_PATH]; - path_conv pc (myself->progname, PC_NOWARN); + UNICODE_STRING uc; + RtlInitUnicodeString(&uc, myself->progname); + path_conv pc (&uc, PC_NOWARN); mount_table->conv_to_posix_path (pc.get_win32 (), posix_prog, 1); small_printf ("%s: error while loading shared libraries: %s: cannot open shared object file: No such file or directory\n", posix_prog, find_first_notloaded_dll (pc)); diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h index 8a30b8dcf..3e7e547df 100644 --- a/winsup/cygwin/pinfo.h +++ b/winsup/cygwin/pinfo.h @@ -64,7 +64,7 @@ public: DWORD dwProcessId; /* Used to spawn a child for fork(), among other things. */ - char progname[NT_MAX_PATH]; + WCHAR progname[NT_MAX_PATH]; /* User information. The information is derived from the GetUserName system call, diff --git a/winsup/cygwin/registry.cc b/winsup/cygwin/registry.cc index c71ff7902..5f65603d8 100644 --- a/winsup/cygwin/registry.cc +++ b/winsup/cygwin/registry.cc @@ -123,7 +123,7 @@ reg_key::get_int (const char *name, int def) } int -reg_key::get_int (const PWCHAR name, int def) +reg_key::get_int (const WCHAR *name, int def) { DWORD type; DWORD dst; @@ -185,7 +185,7 @@ reg_key::get_string (const char *name, char *dst, size_t max, const char *def) } int -reg_key::get_string (const PWCHAR name, PWCHAR dst, size_t max, const PWCHAR def) +reg_key::get_string (const WCHAR *name, PWCHAR dst, size_t max, const WCHAR *def) { DWORD size = max; DWORD type; diff --git a/winsup/cygwin/registry.h b/winsup/cygwin/registry.h index b14c3afb5..2b0f4657a 100644 --- a/winsup/cygwin/registry.h +++ b/winsup/cygwin/registry.h @@ -32,9 +32,9 @@ public: HKEY get_key (); int get_int (const char *, int); - int get_int (const PWCHAR, int); + int get_int (const WCHAR *, int); int get_string (const char *, char *, size_t, const char *); - int get_string (const PWCHAR, PWCHAR, size_t, const PWCHAR); + int get_string (const WCHAR *, PWCHAR, size_t, const WCHAR *); int set_int (const char *, int); int set_int (const PWCHAR, int); diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index e583f8fea..7f6738976 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -692,8 +692,8 @@ loop: myself->dwProcessId = pi.dwProcessId; strace.execing = 1; myself.hProcess = hExeced = pi.hProcess; - strcpy (myself->progname, real_path.get_win32 ()); // FIXME: race? - sigproc_printf ("new process name %s", myself->progname); + wcscpy (myself->progname, real_path.get_nt_native_path ()->Buffer); // FIXME: race? + sigproc_printf ("new process name %S", myself->progname); /* If wr_proc_pipe doesn't exist then this process was not started by a cygwin process. So, we need to wait around until the process we've just "execed" dies. Use our own wait facility to wait for our own pid to exit (there @@ -733,7 +733,7 @@ loop: child->dwProcessId = pi.dwProcessId; child.hProcess = pi.hProcess; - strcpy (child->progname, real_path.get_win32 ()); + wcscpy (child->progname, real_path.get_nt_native_path ()->Buffer); /* FIXME: This introduces an unreferenced, open handle into the child. The purpose is to keep the pid shared memory open so that all of the fields filled out by child.remember do not disappear and so there diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc index beba5b335..4670f8a9a 100644 --- a/winsup/cygwin/strace.cc +++ b/winsup/cygwin/strace.cc @@ -52,11 +52,11 @@ strace::hello () __small_sprintf (pidbuf, "(pid %d, ppid %d)", myself->pid, myself->ppid ?: 1); else { - GetModuleFileName (NULL, myself->progname, sizeof (myself->progname)); + GetModuleFileNameW (NULL, myself->progname, sizeof (myself->progname)); __small_sprintf (pidbuf, "(windows pid %d)", GetCurrentProcessId ()); } prntf (1, NULL, "**********************************************"); - prntf (1, NULL, "Program name: %s %s", myself->progname, pidbuf); + prntf (1, NULL, "Program name: %W %s", myself->progname, pidbuf); prntf (1, NULL, "App version: %d.%d, api: %d.%d", user_data->dll_major, user_data->dll_minor, user_data->api_major, user_data->api_minor); @@ -135,7 +135,7 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap) int microsec = microseconds (); lmicrosec = microsec; - __small_sprintf (fmt, "%7d [%s] %s ", microsec, tn, "%s %s%s"); + __small_sprintf (fmt, "%7d [%s] %s ", microsec, tn, "%W %s%s"); SetLastError (err); @@ -143,34 +143,32 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap) count = 0; else { - char *pn; + PWCHAR pn = NULL; + WCHAR progname[NT_MAX_PATH]; if (!cygwin_finished_initializing) - pn = myself ? myself->progname : NULL; + pn = (myself) ? myself->progname : NULL; else if (__progname) - pn = __progname; - else - pn = NULL; + sys_mbstowcs(pn = progname, NT_MAX_PATH, __progname); - char *p; - char progname[NT_MAX_PATH]; + PWCHAR p; if (!pn) - GetModuleFileName (NULL, pn = progname, sizeof (progname)); + GetModuleFileNameW (NULL, pn = progname, sizeof (progname)); if (!pn) /* hmm */; - else if ((p = strrchr (pn, '\\')) != NULL) + else if ((p = wcsrchr (pn, L'\\')) != NULL) p++; - else if ((p = strrchr (pn, '/')) != NULL) + else if ((p = wcsrchr (pn, L'/')) != NULL) p++; else p = pn; if (p != progname) - strcpy (progname, p); - if ((p = strrchr (progname, '.')) != NULL - && ascii_strcasematch (p, ".exe")) + wcscpy (progname, p); + if ((p = wcsrchr (progname, '.')) != NULL + && !wcscasecmp (p, L".exe")) *p = '\000'; p = progname; char tmpbuf[20]; - count = __small_sprintf (buf, fmt, p && *p ? p : "?", mypid (tmpbuf), + count = __small_sprintf (buf, fmt, *p ? p : L"?", mypid (tmpbuf), execing ? "!" : ""); if (func) count += getfunc (buf + count, func); |