* 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.
This commit is contained in:
Christopher Faylor 2002-06-26 05:29:41 +00:00
parent 109e482278
commit f279e522b0
6 changed files with 52 additions and 25 deletions

View File

@ -1,3 +1,17 @@
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.

View File

@ -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\

View File

@ -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

View File

@ -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);
}
/*

View File

@ -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);
}

View File

@ -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