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
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-06-26 09:29:41 +0400
committerChristopher Faylor <me@cgf.cx>2002-06-26 09:29:41 +0400
commitf279e522b05950655c6b4699ecd7a7f115261bc8 (patch)
tree9ef00309bf328db0d891c4078147d830d84375c4 /winsup
parent109e4822783c39090bc4c1d3a0ff670ca56839bb (diff)
* autoload (noload): Avoid clobbering bx register.
* environ.cc (codepage_init): Use case insensitive match. * fhandler_console.cc (cp_get_internal): Delete. (con_to_str): Use get_cp to derive code page. (str_to_con): Ditto. * miscfuncs.cc (get_cp): New function. (sys_wcstombs): New function. Converted from macro. (sys_mbstowcs): Ditto. * winsup.h: Reflect above changes.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog14
-rw-r--r--winsup/cygwin/autoload.cc6
-rw-r--r--winsup/cygwin/environ.cc8
-rw-r--r--winsup/cygwin/fhandler_console.cc16
-rw-r--r--winsup/cygwin/miscfuncs.cc20
-rw-r--r--winsup/cygwin/winsup.h13
6 files changed, 52 insertions, 25 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index cc3ea2890..330ef3aab 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,19 @@
2002-06-26 Christopher Faylor <cgf@redhat.com>
+ * autoload (noload): Avoid clobbering bx register.
+
+ * environ.cc (codepage_init): Use case insensitive match.
+
+ * fhandler_console.cc (cp_get_internal): Delete.
+ (con_to_str): Use get_cp to derive code page.
+ (str_to_con): Ditto.
+ * miscfuncs.cc (get_cp): New function.
+ (sys_wcstombs): New function. Converted from macro.
+ (sys_mbstowcs): Ditto.
+ * winsup.h: Reflect above changes.
+
+2002-06-26 Christopher Faylor <cgf@redhat.com>
+
* winsup.h: Minor cleanup.
* path.h (path_conv::[]): New operator.
* syscalls.cc (_link): Use path_conv operators rather than methods,
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 9bae17deb..d910b43ed 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -122,10 +122,10 @@ noload: \n\
jz 1f # Nope. \n\
decl %eax # Yes. This is the # of bytes + 1 \n\
popl %edx # Caller's caller \n\
- movl %eax,%ebx # For manipulation \n\
- andl $0xffff,%eax # Only want lower word \n\
addl %eax,%esp # Pop off bytes \n\
- pushl %ebx # Save for later \n\
+ andl $0xffff0000,%eax# upper word \n\
+ subl %eax,%esp # adjust for possible return value \n\
+ pushl %eax # Save for later \n\
movl $127,%eax # ERROR_PROC_NOT_FOUND \n\
pushl %eax # First argument \n\
call _SetLastError@4 # Set it \n\
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 9fc4d0ab8..ab280265c 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -448,20 +448,18 @@ codepage_init (const char *buf)
if (!buf || !*buf)
return;
- if (strcmp (buf, "oem")== 0)
+ if (strcasematch (buf, "oem"))
{
current_codepage = oem_cp;
set_file_api_mode (current_codepage);
}
- else if (strcmp (buf, "ansi")== 0)
+ else if (strcasematch (buf, "ansi"))
{
current_codepage = ansi_cp;
set_file_api_mode (current_codepage);
}
else
- {
- debug_printf ("Wrong codepage name: %s", buf);
- }
+ debug_printf ("Wrong codepage name: %s", buf);
}
static void
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index cc948d3d0..458c5a337 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -17,7 +17,7 @@ details. */
#include <wingdi.h>
#include <winuser.h>
#include <wincon.h>
-#include <winnls.h> // MultiByteToWideChar () and friends
+#include <winnls.h>
#include <ctype.h>
#include <sys/cygwin.h>
#include "cygerrno.h"
@@ -32,16 +32,8 @@ details. */
#define CONVERT_LIMIT 4096
-/* The codepages are resolved here instead of using CP_ACP and
- CP_OEMCP, so that they can later be compared for equality. */
-inline UINT
-cp_get_internal ()
-{
- return current_codepage == ansi_cp ? GetACP() : GetOEMCP();
-}
-
static BOOL
-cp_convert (UINT destcp, char * dest, UINT srccp, const char * src, DWORD size)
+cp_convert (UINT destcp, char *dest, UINT srccp, const char *src, DWORD size)
{
if (!size)
/* no action */;
@@ -68,13 +60,13 @@ cp_convert (UINT destcp, char * dest, UINT srccp, const char * src, DWORD size)
inline BOOL
con_to_str (char *d, const char *s, DWORD sz)
{
- return cp_convert (cp_get_internal (), d, GetConsoleCP (), s, sz);
+ return cp_convert (get_cp (), d, GetConsoleCP (), s, sz);
}
inline BOOL
str_to_con (char *d, const char *s, DWORD sz)
{
- return cp_convert (GetConsoleOutputCP (), d, cp_get_internal (), s, sz);
+ return cp_convert (GetConsoleOutputCP (), d, get_cp (), s, sz);
}
/*
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc
index 5d3010470..6fd9ffc91 100644
--- a/winsup/cygwin/miscfuncs.cc
+++ b/winsup/cygwin/miscfuncs.cc
@@ -11,6 +11,8 @@ details. */
#include "winsup.h"
#include "cygerrno.h"
#include <sys/errno.h>
+#include <winbase.h>
+#include <winnls.h>
long tls_ix = -1;
@@ -176,3 +178,21 @@ __check_invalid_read_ptr_errno (const void *s, unsigned sz)
return 0;
return set_errno (EFAULT);
}
+
+UINT
+get_cp ()
+{
+ return current_codepage == ansi_cp ? GetACP() : GetOEMCP();
+}
+
+int __stdcall
+sys_wcstombs (char *tgt, const WCHAR *src, int len)
+{
+ return WideCharToMultiByte (get_cp (), 0, src, -1, tgt, len, NULL, NULL);
+}
+
+int __stdcall
+sys_mbstowcs (WCHAR *tgt, const char *src, int len)
+{
+ return MultiByteToWideChar (get_cp (), 0, src, -1, tgt, len);
+}
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 5735985c7..4cfce5d4c 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -68,15 +68,18 @@ extern "C" DWORD WINAPI GetLastError (void);
enum codepage_type {ansi_cp, oem_cp};
extern codepage_type current_codepage;
-extern int cygserver_running;
+UINT get_cp ();
+
+int __stdcall sys_wcstombs(char *, const WCHAR *, int)
+ __attribute__ ((regparm(3)));
+
+int __stdcall sys_mbstowcs(WCHAR *, const char *, int)
+ __attribute__ ((regparm(3)));
/* Used to check if Cygwin DLL is dynamically loaded. */
extern int dynamically_loaded;
-#define sys_wcstombs(tgt,src,len) \
- WideCharToMultiByte((current_codepage==ansi_cp?CP_ACP:CP_OEMCP),0,(src),-1,(tgt),(len),NULL,NULL)
-#define sys_mbstowcs(tgt,src,len) \
- MultiByteToWideChar((current_codepage==ansi_cp?CP_ACP:CP_OEMCP),0,(src),-1,(tgt),(len))
+extern int cygserver_running;
#define TITLESIZE 1024