Index: winsup/cygwin/autoload.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/autoload.cc,v retrieving revision 1.3 diff -c -2 -r1.3 autoload.cc *** winsup/cygwin/autoload.cc 2000/11/07 20:01:09 1.3 --- winsup/cygwin/autoload.cc 2000/11/29 14:34:58 *************** *** 248,251 **** --- 248,252 ---- LoadDLLinit (user32) + LoadDLLfunc (CharToOemA, 8, user32) LoadDLLfunc (CharToOemBuffA, 12, user32) LoadDLLfunc (CloseClipboard, 0, user32) Index: winsup/cygwin/dcrt0.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/dcrt0.cc,v retrieving revision 1.81 diff -c -2 -r1.81 dcrt0.cc *** winsup/cygwin/dcrt0.cc 2000/11/15 06:27:48 1.81 --- winsup/cygwin/dcrt0.cc 2000/11/29 14:34:59 *************** *** 16,19 **** --- 16,21 ---- #include #include + #include + #include #include "sync.h" #include "sigproc.h" *************** *** 56,59 **** --- 58,62 ---- BOOL strip_title_path = FALSE; BOOL allow_glob = TRUE; + codepage_type current_codepage = ansi_cp; int cygwin_finished_initializing = 0; *************** *** 789,792 **** --- 792,798 ---- char *line = GetCommandLineA (); line = strcpy ((char *) alloca (strlen (line) + 1), line); + + if (current_codepage == oem_cp) + CharToOemA ( line, line ); /* Scan the command line and build argv. Expand wildcards if not Index: winsup/cygwin/environ.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/environ.cc,v retrieving revision 1.37 diff -c -2 -r1.37 environ.cc *** winsup/cygwin/environ.cc 2000/11/15 06:27:48 1.37 --- winsup/cygwin/environ.cc 2000/11/29 14:34:59 *************** *** 432,435 **** --- 432,436 ---- { {"binmode", {x: &binmode}, justset, NULL, {{O_TEXT}, {O_BINARY}}}, + {"codepage", {func: &codepage_init}, isfunc, NULL, {{0}, {0}}}, {"envcache", {&envcache}, justset, NULL, {{TRUE}, {FALSE}}}, {"error_start", {func: &error_start_init}, isfunc, NULL, {{0}, {0}}}, Index: winsup/cygwin/fhandler_clipboard.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler_clipboard.cc,v retrieving revision 1.2 diff -c -2 -r1.2 fhandler_clipboard.cc *** winsup/cygwin/fhandler_clipboard.cc 2000/10/28 05:41:43 1.2 --- winsup/cygwin/fhandler_clipboard.cc 2000/11/29 14:34:59 *************** *** 53,57 **** { OpenClipboard(0); ! hglb = GetClipboardData(CF_TEXT); lpstr = (LPSTR) GlobalLock(hglb); if (len < sizeof (lpstr)) --- 53,57 ---- { OpenClipboard(0); ! hglb = GetClipboardData((current_codepage==ansi_cp ? CF_TEXT : CF_OEMTEXT)); lpstr = (LPSTR) GlobalLock(hglb); if (len < sizeof (lpstr)) Index: winsup/cygwin/fhandler_console.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler_console.cc,v retrieving revision 1.28 diff -c -2 -r1.28 fhandler_console.cc *** winsup/cygwin/fhandler_console.cc 2000/11/17 03:01:14 1.28 --- winsup/cygwin/fhandler_console.cc 2000/11/29 14:35:02 *************** *** 222,226 **** /* Need this check since US code page seems to have a bug when converting a CTRL-U. */ ! if ((unsigned char)ich > 0x7f) OemToCharBuff (tmp + 1, tmp + 1, 1); if (!(input_rec.Event.KeyEvent.dwControlKeyState & LEFT_ALT_PRESSED)) --- 222,226 ---- /* Need this check since US code page seems to have a bug when converting a CTRL-U. */ ! if ((unsigned char)ich > 0x7f && current_codepage == ansi_cp) OemToCharBuff (tmp + 1, tmp + 1, 1); if (!(input_rec.Event.KeyEvent.dwControlKeyState & LEFT_ALT_PRESSED)) *************** *** 1075,1079 **** do { size_t l2 = min (sizeof (buf), len); ! CharToOemBuff ((LPCSTR)src, buf, l2); if (! WriteFile (get_output_handle (), buf, l2, &done, 0)) { --- 1075,1082 ---- do { size_t l2 = min (sizeof (buf), len); ! if (current_codepage == ansi_cp) ! CharToOemBuff ((LPCSTR)src, buf, l2); ! else ! strncpy (buf, (LPCSTR)src, l2); if (! WriteFile (get_output_handle (), buf, l2, &done, 0)) { Index: winsup/cygwin/pinfo.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/pinfo.cc,v retrieving revision 1.38 diff -c -2 -r1.38 pinfo.cc *** winsup/cygwin/pinfo.cc 2000/11/05 06:42:23 1.38 --- winsup/cygwin/pinfo.cc 2000/11/29 14:35:03 *************** *** 88,91 **** --- 88,116 ---- } + extern "C" void + codepage_init (const char *buf) + { + if (!buf || !*buf) + return; + + if ( strcmp ( buf, "oem" ) == 0 ) + { + current_codepage = oem_cp; + SetFileApisToOEM (); + debug_printf ( "File APIs set to OEM" ); + } + else if ( strcmp ( buf, "ansi" ) == 0 ) + { + current_codepage = ansi_cp; + SetFileApisToANSI (); + debug_printf ( "File APIs set to ANSI" ); + } + else + { + debug_printf ( "Wrong codepage name: %s", buf ); + } + } + + /* Initialize the process table entry for the current task. This is not called for fork'd tasks, only exec'd ones. */ Index: winsup/cygwin/security.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/security.cc,v retrieving revision 1.29 diff -c -2 -r1.29 security.cc *** winsup/cygwin/security.cc 2000/11/15 21:04:02 1.29 --- winsup/cygwin/security.cc 2000/11/29 14:35:03 *************** *** 23,26 **** --- 23,28 ---- #include #include + #include + #include #include "cygerrno.h" #include "fhandler.h" *************** *** 514,519 **** DWORD len = 0; ! if (! GetFileSecurity (file, ! OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, --- 516,531 ---- DWORD len = 0; ! const char *pfile = file; ! char fbuf [PATH_MAX]; ! if (current_codepage == oem_cp) ! { ! DWORD fname_len = min (sizeof (fbuf) - 1, strlen (file)); ! bzero (fbuf, sizeof (fbuf)); ! OemToCharBuff(file, fbuf, fname_len); ! pfile = fbuf; ! } ! ! if (! GetFileSecurity (pfile, ! OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, Index: winsup/cygwin/winsup.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/winsup.h,v retrieving revision 1.44 diff -c -2 -r1.44 winsup.h *** winsup/cygwin/winsup.h 2000/10/27 09:50:33 1.44 --- winsup/cygwin/winsup.h 2000/11/29 14:35:03 *************** *** 84,94 **** extern os_type os_being_run; /* Used to check if Cygwin DLL is dynamically loaded. */ extern int dynamically_loaded; #define sys_wcstombs(tgt,src,len) \ ! WideCharToMultiByte(CP_ACP,0,(src),-1,(tgt),(len),NULL,NULL) #define sys_mbstowcs(tgt,src,len) \ ! MultiByteToWideChar(CP_ACP,0,(src),-1,(tgt),(len)) #define TITLESIZE 1024 --- 84,97 ---- extern os_type os_being_run; + enum codepage_type {ansi_cp, oem_cp}; + extern codepage_type current_codepage; + /* 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)) #define TITLESIZE 1024 *************** *** 182,185 **** --- 185,190 ---- extern "C" void error_start_init (const char*); extern "C" int try_to_debug (); + + extern "C" void codepage_init (const char*); extern int cygwin_finished_initializing;