From: Victor Wagner <vitus@wagner.pp.ru>
Date: Wed, 3 Aug 2016 14:42:58 +0000 (+0300)
Subject: Removed code page operation. Fix GLOB macros for 64-bit win32. Fixed debug flags... 
X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=oss%2Fless.git

Removed code page operation. Fix GLOB macros for 64-bit win32. Fixed debug flags for 2012 compiler
---

diff --git a/Makefile.wnm b/Makefile.wnm
index cd84a3b..8a6ddb4 100644
--- a/Makefile.wnm
+++ b/Makefile.wnm
@@ -16,7 +16,7 @@ CFLAGS = /nologo /MD /W3 /EHsc /O2 /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /
 LDFLAGS = /nologo /subsystem:console /incremental:no /machine:$(ARCH)
 
 # Debugging flags
-#CFLAGS = /nologo /MDd /W3 /GX /Od /Gm /Zi /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /c
+#CFLAGS = /nologo /MDd /W3 /EHsc /Od /Gm /Zi /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /c
 #LDFLAGS = /nologo /subsystem:console /incremental:yes /debug /machine:$(ARCH)
 
 LD = link
diff --git a/charset.c b/charset.c
index 69b035f..b427c49 100644
--- a/charset.c
+++ b/charset.c
@@ -323,11 +323,6 @@ set_charset()
 		return;
 	}
 #ifdef WIN32
-	SetConsoleOutputCP(65001);
-    _setmode(_fileno(stdout),_O_U8TEXT);
-    _setmode(_fileno(stderr),_O_U8TEXT);
-	if (isatty(fileno(stdin))) 
-		_setmode(_fileno(stdin),_O_U8TEXT);
 	icharset("UTF-8",0);
 	
 #else 
diff --git a/lglob.h b/lglob.h
index 87b5fb4..6d68bc7 100644
--- a/lglob.h
+++ b/lglob.h
@@ -69,7 +69,7 @@
 					char dir[_MAX_DIR];	\
 					char fname[_MAX_FNAME];	\
 					char ext[_MAX_EXT];	\
-					long handle;
+					intptr_t handle;
 
 #else
 #if MSDOS_COMPILER==WIN32C && !defined(_MSC_VER) /* Borland C for Windows */
diff --git a/main.c b/main.c
index e4f35b9..149999c 100644
--- a/main.c
+++ b/main.c
@@ -51,7 +51,6 @@ extern int	jump_sline;
 
 #ifdef WIN32
 static char consoleTitle[256];
-static int  savedConsoleCodePage;
 #endif
 
 extern int	less_is_more;
@@ -104,7 +103,6 @@ main(argc, argv)
 		}
 	}
 	GetConsoleTitle(consoleTitle, sizeof(consoleTitle)/sizeof(char));
-	savedConsoleCodePage = GetConsoleOutputCP();	
 #endif /* WIN32 */
 
 	/*
@@ -406,7 +404,6 @@ quit(status)
 #endif
 #ifdef WIN32
 	SetConsoleTitle(consoleTitle);
-	SetConsoleOutputCP(savedConsoleCodePage);
 #endif
 	close_getchr();
 	exit(status);
diff --git a/screen.c b/screen.c
index 8f8a433..6cd4cb9 100644
--- a/screen.c
+++ b/screen.c
@@ -2490,7 +2490,13 @@ WIN32textout(text, len)
 {
 #if MSDOS_COMPILER==WIN32C
 	DWORD written;
-	WriteConsole(con_out, text, len, &written, NULL);
+	wchar_t widebuf[1024];
+	wchar_t *wb=widebuf;
+	if (len >= 1024) 
+		wb = (wchar_t *) malloc(len*sizeof(wchar_t));
+	written=MultiByteToWideChar(CP_UTF8,0,text,len,wb,len>1024?len:1024);
+	WriteConsoleW(con_out, wb, written, &written, NULL);
+	if (wb != widebuf) free(wb);
 #else
 	char c = text[len];
 	text[len] = '\0';