From 654c8ad4d7080637b3cba81674525caac3b355ff Mon Sep 17 00:00:00 2001 From: anders_k Date: Sat, 22 Aug 2020 16:24:14 +0000 Subject: [PATCH] Added nsExec /MBCS switch git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7221 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/nsExec/nsExec.txt | 8 +++++--- Contrib/nsExec/nsexec.c | 11 ++++++++--- Docs/src/history.but | 4 ++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Contrib/nsExec/nsExec.txt b/Contrib/nsExec/nsExec.txt index 8606986c..c87923d9 100644 --- a/Contrib/nsExec/nsExec.txt +++ b/Contrib/nsExec/nsExec.txt @@ -6,17 +6,17 @@ without opening a dos box. Usage ----- -nsExec::Exec [/OEM] [/TIMEOUT=x] path +nsExec::Exec [/MBCS] [/OEM] [/TIMEOUT=x] path Pop $0 -or- -nsExec::ExecToLog [/OEM] [/TIMEOUT=x] path +nsExec::ExecToLog [/MBCS] [/OEM] [/TIMEOUT=x] path Pop $0 -or- -nsExec::ExecToStack [/OEM] [/TIMEOUT=x] path +nsExec::ExecToStack [/MBCS] [/OEM] [/TIMEOUT=x] path Pop $0 ; Return Pop $1 ; Output @@ -24,6 +24,8 @@ All functions are the same except ExecToLog will print the output to the log window and ExecToStack will push up to ${NSIS_MAX_STRLEN} characters of output onto the stack after the return value. +Use the /MBCS switch to disable Unicode detection and always treat the text as ANSI. + Use the /OEM switch to convert the output text from OEM to ANSI. The timeout value is optional. The timeout is the time in diff --git a/Contrib/nsExec/nsexec.c b/Contrib/nsExec/nsexec.c index 0172b041..04638d95 100644 --- a/Contrib/nsExec/nsexec.c +++ b/Contrib/nsExec/nsexec.c @@ -181,7 +181,7 @@ void ExecScript(int mode) { int ignoreData = mode == MODE_IGNOREOUTPUT; int logMode = mode == MODE_LINES, stackMode = mode == MODE_STACK; unsigned int to, tabExpandLength = logMode ? TAB_REPLACE_CCH : 0, codepage; - BOOL bOEM; + BOOL bOEM, forceNarrowInput = FALSE; *szRet = _T('\0'); @@ -275,7 +275,12 @@ params: goto params; } if (!lstrcmpi(pExec, _T("/OEM"))) { - bOEM = TRUE; + bOEM = forceNarrowInput = TRUE; + *pExec = 0; + goto params; + } + if (!lstrcmpi(pExec, _T("/MBCS"))) { + forceNarrowInput = TRUE; *pExec = 0; goto params; } @@ -300,7 +305,7 @@ params: const BOOL isNT = sizeof(void*) > 4 || (GetVersion() < 0x80000000); HANDLE newstdout = 0, read_stdout = 0; HANDLE newstdin = 0, read_stdin = 0; - int utfSource = sizeof(TCHAR) > 1 ? -1 : FALSE, utfOutput = sizeof(TCHAR) > 1; + int utfSource = sizeof(TCHAR) > 1 && !forceNarrowInput ? -1 : FALSE, utfOutput = sizeof(TCHAR) > 1; DWORD cbRead, dwLastOutput; DWORD dwExit = 0, waitResult = WAIT_TIMEOUT; static BYTE bufSrc[1024]; diff --git a/Docs/src/history.but b/Docs/src/history.but index 46801440..eba90b45 100644 --- a/Docs/src/history.but +++ b/Docs/src/history.but @@ -14,6 +14,10 @@ Unicode is the now default. \b Unicode is the now default +\S2{} Minor Changes + +\b Added nsExec /MBCS switch + \S2{} Translations \b Updated Corsican\#{(forum)} and Japanese (maboroshin PR\#{github.com/maboroshin})