Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog45
-rw-r--r--winsup/cygwin/dcrt0.cc5
-rw-r--r--winsup/cygwin/dll_init.cc2
-rw-r--r--winsup/cygwin/dll_init.h2
-rw-r--r--winsup/cygwin/environ.cc12
-rw-r--r--winsup/cygwin/exceptions.cc25
-rw-r--r--winsup/cygwin/miscfuncs.cc141
-rw-r--r--winsup/cygwin/ntdll.h6
-rw-r--r--winsup/cygwin/string.h24
-rw-r--r--winsup/cygwin/wchar.h39
-rw-r--r--winsup/cygwin/wincap.cc8
-rw-r--r--winsup/cygwin/winsup.h3
12 files changed, 232 insertions, 80 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 7c3ddabd1..6000c25c8 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,48 @@
+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
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index ca4331cf8..a022c8305 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -13,6 +13,7 @@ details. */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "glob.h"
#include "exceptions.h"
#include <ctype.h>
@@ -552,9 +553,7 @@ initial_env ()
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 ();
diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index 189d9b188..d76771216 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -106,7 +106,7 @@ dll_list::operator[] (const char *name)
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? */
diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h
index 2c4fb49c3..cd88c564a 100644
--- a/winsup/cygwin/dll_init.h
+++ b/winsup/cygwin/dll_init.h
@@ -51,7 +51,7 @@ struct dll
int count;
dll_type type;
int namelen;
- char name[CYG_MAX_PATH];
+ char name[PATH_MAX];
void detach ();
int init ();
};
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index e91cc5ad2..9c68dcaaf 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -11,6 +11,7 @@ details. */
#include "winsup.h"
#include <stdlib.h>
#include <stddef.h>
+#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <sys/cygwin.h>
@@ -114,9 +115,12 @@ win_env::add_cache (const char *in_posix, const char *in_native)
}
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)
@@ -180,7 +184,7 @@ posify (char **here, const char *value)
/* 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)
@@ -195,7 +199,7 @@ posify (char **here, const char *value)
}
debug_printf ("env var converted to %s", outenv);
- *here = outenv;
+ *here = strdup (outenv);
free (src);
MALLOC_CHECK;
}
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index d030f130d..06a9b5409 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -331,6 +331,8 @@ cygwin_stackdump ()
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;
@@ -347,7 +349,7 @@ try_to_debug (bool waitloop)
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;
@@ -382,16 +384,17 @@ try_to_debug (bool waitloop)
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");
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index bbbcd59e9..c6328cb18 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -14,9 +14,12 @@ details. */
#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;
@@ -77,70 +80,112 @@ const char isalpha_array[] NO_COPY = {
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
diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h
index 60651e82c..fa1beee8d 100644
--- a/winsup/cygwin/ntdll.h
+++ b/winsup/cygwin/ntdll.h
@@ -857,6 +857,8 @@ extern "C"
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);
@@ -878,6 +880,8 @@ extern "C"
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,
@@ -958,7 +962,7 @@ extern "C"
}
/* 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,
diff --git a/winsup/cygwin/string.h b/winsup/cygwin/string.h
index 1ad902134..ee831191e 100644
--- a/winsup/cygwin/string.h
+++ b/winsup/cygwin/string.h
@@ -1,6 +1,6 @@
/* string.h: Extra string defs
- Copyright 2001 Red Hat, Inc.
+ Copyright 2001, 2007 Red Hat, Inc.
This file is part of Cygwin.
@@ -59,6 +59,8 @@ strechr (const char *s, int c)
return res;
}
+/* Don't use. Not NLS aware. */
+#if 0 // Not NLS aware
extern const char isalpha_array[];
#undef strcasematch
@@ -122,6 +124,26 @@ cygwin_strncasematch (const char *cs, const char *ct, size_t n)
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
}
diff --git a/winsup/cygwin/wchar.h b/winsup/cygwin/wchar.h
new file mode 100644
index 000000000..b03d5110f
--- /dev/null
+++ b/winsup/cygwin/wchar.h
@@ -0,0 +1,39 @@
+/* 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 */
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index b970aa8c3..e8b44c0e6 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -308,7 +308,6 @@ wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
void
wincapc::init ()
{
- const char *os;
bool has_osversioninfoex = true;
if (caps)
@@ -331,7 +330,6 @@ wincapc::init ()
switch (version.dwMajorVersion)
{
case 4:
- os = "NT";
if (!has_osversioninfoex
&& strcmp (version.szCSDVersion, "Service Pack 4") < 0)
caps = &wincap_nt4;
@@ -339,7 +337,6 @@ wincapc::init ()
caps = &wincap_nt4sp4;
break;
case 5:
- os = "NT";
switch (version.dwMinorVersion)
{
case 0:
@@ -367,11 +364,9 @@ wincapc::init ()
}
break;
case 6:
- os = "NT";
caps = &wincap_vista;
break;
default:
- os = "??";
caps = &wincap_unknown;
break;
}
@@ -382,7 +377,6 @@ wincapc::init ()
api_fatal ("Windows 95/98/Me are not supported.");
break;
default:
- os = "??";
caps = &wincap_unknown;
break;
}
@@ -396,7 +390,7 @@ wincapc::init ()
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);
}
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 034fba161..5b4b573f5 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -264,9 +264,6 @@ void __stdcall nofinalslash (const char *src, char *dst) __attribute__ ((regparm
/* 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)));