(initial_env): Use small_printf's %P specifier.
* dll_init.cc (dll_list::alloc): Use PATH_MAX instead of CYG_MAX_PATH
for path name buffer size.
* dll_init.h (struct dll): Ditto.
* environ.cc: Include string.h.
(win_env::add_cache): Use temporary local buffer for path conversion.
(posify): Ditto.
* exceptions.cc (try_to_debug): Use CreateProcessW to allow long path
names.
* miscfuncs.cc: Drop unused implementations of strcasematch and
strncasematch.
(ch_case_eq): Drop.
(strcasestr): Drop.
(cygwin_wcscasecmp): New function.
(cygwin_wcsncasecmp): New function.
(cygwin_strcasecmp): New function.
(cygwin_strncasecmp): New function.
(cygwin_wcslwr): New function.
(cygwin_wcsupr): New function.
(cygwin_strlwr): New function.
(cygwin_strupr): New function.
* ntdll.h (RtlDowncaseUnicodeString): Declare.
(RtlUpcaseUnicodeString): Declare.
(RtlInt64ToHexUnicodeString): Fix typo in comment.
* string.h: Disable not NLS aware implementations of strcasematch
and strncasematch.
(cygwin_strcasecmp): Declare.
(strcasecmp): Define as cygwin_strcasecmp.
(cygwin_strncasecmp): Declare.
(strncasecmp): Define as cygwin_strncasecmp.
(strcasematch):Define using cygwin_strcasecmp.
(strncasematch):Define using cygwin_strncasecmp.
(cygwin_strlwr): Declare.
(strlwr): Define as cygwin_strlwr.
(cygwin_strupr): Declare.
(strupr): Define as cygwin_strupr.
* wchar.h: New file.
* wincap.cc (wincapc::init): Use "NT" as fix OS string.
* winsup.h (strcasematch): Drop declaration.
(strncasematch): Ditto.
(strcasestr): Ditto.
+2007-12-12 Corinna Vinschen <corinna@vinschen.de>
+
+ * dcrt0.cc: Include string.h.
+ (initial_env): Use small_printf's %P specifier.
+ * dll_init.cc (dll_list::alloc): Use PATH_MAX instead of CYG_MAX_PATH
+ for path name buffer size.
+ * dll_init.h (struct dll): Ditto.
+ * environ.cc: Include string.h.
+ (win_env::add_cache): Use temporary local buffer for path conversion.
+ (posify): Ditto.
+ * exceptions.cc (try_to_debug): Use CreateProcessW to allow long path
+ names.
+ * miscfuncs.cc: Drop unused implementations of strcasematch and
+ strncasematch.
+ (ch_case_eq): Drop.
+ (strcasestr): Drop.
+ (cygwin_wcscasecmp): New function.
+ (cygwin_wcsncasecmp): New function.
+ (cygwin_strcasecmp): New function.
+ (cygwin_strncasecmp): New function.
+ (cygwin_wcslwr): New function.
+ (cygwin_wcsupr): New function.
+ (cygwin_strlwr): New function.
+ (cygwin_strupr): New function.
+ * ntdll.h (RtlDowncaseUnicodeString): Declare.
+ (RtlUpcaseUnicodeString): Declare.
+ (RtlInt64ToHexUnicodeString): Fix typo in comment.
+ * string.h: Disable not NLS aware implementations of strcasematch
+ and strncasematch.
+ (cygwin_strcasecmp): Declare.
+ (strcasecmp): Define as cygwin_strcasecmp.
+ (cygwin_strncasecmp): Declare.
+ (strncasecmp): Define as cygwin_strncasecmp.
+ (strcasematch):Define using cygwin_strcasecmp.
+ (strncasematch):Define using cygwin_strncasecmp.
+ (cygwin_strlwr): Declare.
+ (strlwr): Define as cygwin_strlwr.
+ (cygwin_strupr): Declare.
+ (strupr): Define as cygwin_strupr.
+ * wchar.h: New file.
+ * wincap.cc (wincapc::init): Use "NT" as fix OS string.
+ * winsup.h (strcasematch): Drop declaration.
+ (strncasematch): Ditto.
+ (strcasestr): Ditto.
+
2007-12-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix R/O bit
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "glob.h"
#include "exceptions.h"
#include <ctype.h>
if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf) - 1))
{
DWORD ms = atoi (buf);
- buf[0] = '\0';
- len = GetModuleFileName (NULL, buf, PATH_MAX);
- console_printf ("Sleeping %d, pid %u %s\n", ms, GetCurrentProcessId (), buf);
+ console_printf ("Sleeping %d, pid %u %P\n", ms, GetCurrentProcessId ());
Sleep (ms);
if (!strace.active () && !dynamically_loaded)
strace.hello ();
dll *
dll_list::alloc (HINSTANCE h, per_process *p, dll_type type)
{
- char name[CYG_MAX_PATH];
+ char name[PATH_MAX];
DWORD namelen = GetModuleFileName (h, name, sizeof (name));
/* Already loaded? */
int count;
dll_type type;
int namelen;
- char name[CYG_MAX_PATH];
+ char name[PATH_MAX];
void detach ();
int init ();
};
#include "winsup.h"
#include <stdlib.h>
#include <stddef.h>
+#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <sys/cygwin.h>
}
else
{
- native = (char *) realloc (native, namelen + 1 + win32_len (in_posix));
+ char buf[PATH_MAX];
+ strcpy (buf, name + namelen);
+ towin32 (in_posix, buf);
+ native = (char *) realloc (native, namelen + 1 + strlen (buf));
strcpy (native, name);
- towin32 (in_posix, native + namelen);
+ strcpy (native + namelen, buf);
}
MALLOC_CHECK;
if (immediate && cygwin_finished_initializing)
/* Turn all the items from c:<foo>;<bar> into their
mounted equivalents - if there is one. */
- char *outenv = (char *) malloc (1 + len + conv->posix_len (value));
+ char outenv[1 + len + PATH_MAX];
memcpy (outenv, src, len);
char *newvalue = outenv + len;
if (!conv->toposix (value, newvalue) || _impure_ptr->_errno != EIDRM)
}
debug_printf ("env var converted to %s", outenv);
- *here = outenv;
+ *here = strdup (outenv);
free (src);
MALLOC_CHECK;
}
extern "C" int
try_to_debug (bool waitloop)
{
+ WCHAR dbg_cmd[sizeof debugger_command];
+
debug_printf ("debugger_command '%s'", debugger_command);
if (*debugger_command == '\0')
return 0;
SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST);
PROCESS_INFORMATION pi = {NULL, 0, 0, 0};
- STARTUPINFO si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL};
+ STARTUPINFOW si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL};
si.lpReserved = NULL;
si.lpDesktop = NULL;
si.dwFlags = 0;
console_printf ("*** starting debugger for pid %u, tid %u\n",
cygwin_pid (GetCurrentProcessId ()), GetCurrentThreadId ());
BOOL dbg;
- dbg = CreateProcess (NULL,
- debugger_command,
- NULL,
- NULL,
- FALSE,
- CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP,
- NULL,
- NULL,
- &si,
- &pi);
+ sys_mbstowcs (dbg_cmd, debugger_command, sizeof debugger_command);
+ dbg = CreateProcessW (NULL,
+ dbg_cmd,
+ NULL,
+ NULL,
+ FALSE,
+ CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP,
+ NULL,
+ NULL,
+ &si,
+ &pi);
if (!dbg)
system_printf ("Failed to start debugger, %E");
#include <sys/errno.h>
#include <sys/uio.h>
#include <assert.h>
+#include <alloca.h>
#include <limits.h>
+#include <wchar.h>
#include "cygthread.h"
#include "cygtls.h"
+#include "ntdll.h"
long tls_ix = -1;
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-#define ch_case_eq(ch1, ch2) (cyg_tolower(ch1) == cyg_tolower(ch2))
+extern "C" int __stdcall
+cygwin_wcscasecmp (const wchar_t *ws, const wchar_t *wt)
+{
+ UNICODE_STRING us, ut;
-#if 0
+ RtlInitUnicodeString (&us, ws);
+ RtlInitUnicodeString (&ut, wt);
+ return RtlCompareUnicodeString (&us, &ut, TRUE);
+}
-/* Return TRUE if two strings match up to length n */
extern "C" int __stdcall
-strncasematch (const char *s1, const char *s2, size_t n)
+cygwin_wcsncasecmp (const wchar_t *ws, const wchar_t *wt, size_t n)
{
- if (s1 == s2)
- return 1;
+ UNICODE_STRING us, ut;
+
+ n *= sizeof (WCHAR);
+ RtlInitUnicodeString (&us, ws);
+ if (us.Length > n)
+ us.Length = n;
+ RtlInitUnicodeString (&ut, wt);
+ if (ut.Length > n)
+ ut.Length = n;
+ return RtlCompareUnicodeString (&us, &ut, TRUE);
+}
- n++;
- while (--n && *s1)
- {
- if (!ch_case_eq (*s1, *s2))
- return 0;
- s1++; s2++;
- }
- return !n || *s2 == '\0';
+extern "C" int __stdcall
+cygwin_strcasecmp (const char *cs, const char *ct)
+{
+ UNICODE_STRING us, ut;
+ ULONG len;
+
+ len = (strlen (cs) + 1) * sizeof (WCHAR);
+ RtlInitEmptyUnicodeString (&us, (PWCHAR) alloca (len), len);
+ us.Length = sys_mbstowcs (us.Buffer, cs, us.MaximumLength) * sizeof (WCHAR);
+ len = (strlen (ct) + 1) * sizeof (WCHAR);
+ RtlInitEmptyUnicodeString (&ut, (PWCHAR) alloca (len), len);
+ ut.Length = sys_mbstowcs (ut.Buffer, ct, ut.MaximumLength) * sizeof (WCHAR);
+ return RtlCompareUnicodeString (&us, &ut, TRUE);
}
-/* Return TRUE if two strings match */
extern "C" int __stdcall
-strcasematch (const char *s1, const char *s2)
+cygwin_strncasecmp (const char *cs, const char *ct, size_t n)
{
- if (s1 == s2)
- return 1;
+ UNICODE_STRING us, ut;
+ ULONG len;
+
+ n *= sizeof (WCHAR);
+ len = (strlen (cs) + 1) * sizeof (WCHAR);
+ RtlInitEmptyUnicodeString (&us, (PWCHAR) alloca (len), len);
+ us.Length = sys_mbstowcs (us.Buffer, cs, us.MaximumLength) * sizeof (WCHAR);
+ if (us.Length > n)
+ us.Length = n;
+ len = (strlen (ct) + 1) * sizeof (WCHAR);
+ RtlInitEmptyUnicodeString (&ut, (PWCHAR) alloca (len), len);
+ ut.Length = sys_mbstowcs (ut.Buffer, ct, ut.MaximumLength) * sizeof (WCHAR);
+ if (ut.Length > n)
+ ut.Length = n;
+ return RtlCompareUnicodeString (&us, &ut, TRUE);
+}
- while (*s1)
- {
- if (!ch_case_eq (*s1, *s2))
- return 0;
- s1++; s2++;
- }
- return *s2 == '\0';
+extern "C" wchar_t * __stdcall
+cygwin_wcslwr (wchar_t *string)
+{
+ UNICODE_STRING us;
+
+ RtlInitUnicodeString (&us, string);
+ RtlDowncaseUnicodeString (&us, &us, FALSE);
+ return string;
}
-#endif
-extern "C" char * __stdcall
-strcasestr (const char *searchee, const char *lookfor)
+extern "C" wchar_t * __stdcall
+cygwin_wcsupr (wchar_t *string)
{
- if (*searchee == 0)
- {
- if (*lookfor)
- return NULL;
- return (char *) searchee;
- }
+ UNICODE_STRING us;
- while (*searchee)
- {
- int i = 0;
- while (1)
- {
- if (lookfor[i] == 0)
- return (char *) searchee;
+ RtlInitUnicodeString (&us, string);
+ RtlUpcaseUnicodeString (&us, &us, FALSE);
+ return string;
+}
- if (!ch_case_eq (lookfor[i], searchee[i]))
- break;
- lookfor++;
- }
- searchee++;
- }
+extern "C" char * __stdcall
+cygwin_strlwr (char *string)
+{
+ UNICODE_STRING us;
+ size_t len = (strlen (string) + 1) * sizeof (WCHAR);
+
+ us.MaximumLength = len; us.Buffer = (PWCHAR) alloca (len);
+ us.Length = sys_mbstowcs (us.Buffer, string, len) * sizeof (WCHAR)
+ - sizeof (WCHAR);
+ RtlDowncaseUnicodeString (&us, &us, FALSE);
+ sys_wcstombs (string, len / sizeof (WCHAR), us.Buffer);
+ return string;
+}
- return NULL;
+extern "C" char * __stdcall
+cygwin_strupr (char *string)
+{
+ UNICODE_STRING us;
+ size_t len = (strlen (string) + 1) * sizeof (WCHAR);
+
+ us.MaximumLength = len; us.Buffer = (PWCHAR) alloca (len);
+ us.Length = sys_mbstowcs (us.Buffer, string, len) * sizeof (WCHAR)
+ - sizeof (WCHAR);
+ RtlUpcaseUnicodeString (&us, &us, FALSE);
+ sys_wcstombs (string, len / sizeof (WCHAR), us.Buffer);
+ return string;
}
int __stdcall
NTSTATUS NTAPI RtlConvertSidToUnicodeString (PUNICODE_STRING, PSID, BOOLEAN);
VOID NTAPI RtlCopyUnicodeString (PUNICODE_STRING, PUNICODE_STRING);
BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz (PUNICODE_STRING, PCSTR);
+ NTSTATUS NTAPI RtlDowncaseUnicodeString (PUNICODE_STRING, PUNICODE_STRING,
+ BOOLEAN);
BOOLEAN NTAPI RtlEqualUnicodeString (PUNICODE_STRING, PUNICODE_STRING,
BOOLEAN);
VOID NTAPI RtlFreeAnsiString (PANSI_STRING);
NTSTATUS NTAPI RtlUnicodeStringToOemString (PANSI_STRING, PUNICODE_STRING,
BOOLEAN);
WCHAR NTAPI RtlUpcaseUnicodeChar (WCHAR);
+ NTSTATUS NTAPI RtlUpcaseUnicodeString (PUNICODE_STRING, PUNICODE_STRING,
+ BOOLEAN);
/* A few Rtl functions are either actually macros, or they just don't
exist even though they would be a big help. We implement them here,
}
/* Implemented in strfuncs.cc. Create a Hex UNICODE_STRING from a given
64 bit integer value. If append is TRUE, append the hex string,
- otherwise overwrite dest. Returns either STAUTUS_SUCCESS, or
+ otherwise overwrite dest. Returns either STATUS_SUCCESS, or
STATUS_BUFFER_OVERFLOW, if the unicode buffer is too small (hasn't
room for 16 WCHARs). */
NTSTATUS NTAPI RtlInt64ToHexUnicodeString (ULONGLONG value,
/* string.h: Extra string defs
- Copyright 2001 Red Hat, Inc.
+ Copyright 2001, 2007 Red Hat, Inc.
This file is part of Cygwin.
return res;
}
+/* Don't use. Not NLS aware. */
+#if 0 // Not NLS aware
extern const char isalpha_array[];
#undef strcasematch
return __res;
}
+#else
+#undef strcasecmp
+#define strcasecmp cygwin_strcasecmp
+int __stdcall cygwin_strcasecmp (const char *, const char *);
+
+#undef strncasecmp
+#define strncasecmp cygwin_strncasecmp
+int __stdcall cygwin_strncasecmp (const char *, const char *, size_t);
+
+#define strcasematch(s1,s2) (!cygwin_strcasecmp ((s1),(s2)))
+#define strncasematch(s1,s2,n) (!cygwin_strncasecmp ((s1),(s2),(n)))
+#endif
+
+#undef strlwr
+#define strlwr cygwin_strlwr
+char * __stdcall cygwin_strlwr (char *);
+
+#undef strupr
+#define strupr cygwin_strupr
+char * __stdcall cygwin_strupr (char *);
#ifdef __cplusplus
}
--- /dev/null
+/* wchar.h: Extra wchar defs
+
+ Copyright 2007 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifndef _CYGWIN_WCHAR_H
+#define _CYGWIN_WCHAR_H
+
+#include_next <wchar.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#undef wcscasecmp
+#define wcscasecmp cygwin_wcscasecmp
+int __stdcall cygwin_wcscasecmp (const wchar_t *, const wchar_t *);
+
+#undef wcsncasecmp
+#define wcsncasecmp cygwin_wcsncasecmp
+int __stdcall cygwin_wcsncasecmp (const wchar_t *, const wchar_t *, size_t);
+
+#undef wcslwr
+#define wcslwr cygwin_wcslwr
+wchar_t * __stdcall cygwin_wcslwr (wchar_t *);
+
+#undef wcsupr
+#define wcsupr cygwin_wcsupr
+wchar_t * __stdcall cygwin_wcsupr (wchar_t *);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _CYGWIN_WCHAR_H */
void
wincapc::init ()
{
- const char *os;
bool has_osversioninfoex = true;
if (caps)
switch (version.dwMajorVersion)
{
case 4:
- os = "NT";
if (!has_osversioninfoex
&& strcmp (version.szCSDVersion, "Service Pack 4") < 0)
caps = &wincap_nt4;
caps = &wincap_nt4sp4;
break;
case 5:
- os = "NT";
switch (version.dwMinorVersion)
{
case 0:
}
break;
case 6:
- os = "NT";
caps = &wincap_vista;
break;
default:
- os = "??";
caps = &wincap_unknown;
break;
}
api_fatal ("Windows 95/98/Me are not supported.");
break;
default:
- os = "??";
caps = &wincap_unknown;
break;
}
else
((wincaps *)this->caps)->needs_count_in_si_lpres2 = false;
- __small_sprintf (osnam, "%s-%d.%d", os, version.dwMajorVersion,
+ __small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion,
version.dwMinorVersion);
}
/* String manipulation */
extern "C" char *__stdcall strccpy (char *s1, const char **s2, char c);
-extern "C" int __stdcall strcasematch (const char *s1, const char *s2) __attribute__ ((regparm(2)));
-extern "C" int __stdcall strncasematch (const char *s1, const char *s2, size_t n) __attribute__ ((regparm(3)));
-extern "C" char *__stdcall strcasestr (const char *searchee, const char *lookfor) __attribute__ ((regparm(2)));
void *hook_or_detect_cygwin (const char *, const void *, WORD&) __attribute__ ((regparm (3)));