Unicode port: fixing special NSIS escape characters in strings. No change in exehead size.
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6055 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
408a5d5169
commit
637db8940c
7 changed files with 30 additions and 29 deletions
|
@ -159,7 +159,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPTSTR lpszCmdPara
|
|||
|
||||
if (CMP4CHAR(cmdline-2, _T(" /D=")))
|
||||
{
|
||||
*(LPDWORD)(cmdline-2)=0; // keep this from being passed to uninstaller if necessary
|
||||
*(cmdline-2)=_T('\0'); // keep this from being passed to uninstaller if necessary
|
||||
mystrcpy(state_install_directory,cmdline+2);
|
||||
break; // /D= must always be last
|
||||
}
|
||||
|
|
|
@ -475,21 +475,26 @@ typedef struct {
|
|||
#define DEL_REBOOT 4
|
||||
#define DEL_SIMPLE 8
|
||||
|
||||
// $0..$9, $INSTDIR, etc are encoded as ASCII bytes starting from this value.
|
||||
// Added by ramon 3 jun 2003
|
||||
#define NS_SKIP_CODE 252
|
||||
#define NS_VAR_CODE 253
|
||||
#define NS_SHELL_CODE 254
|
||||
#define NS_LANG_CODE 255
|
||||
#define NS_CODES_START NS_SKIP_CODE
|
||||
#define NS_IS_CODE(x) ((x) >= NS_SKIP_CODE)
|
||||
// special escape characters used in strings: (we use control codes in order to minimize conflicts with normal characters)
|
||||
#define NS_LANG_CODE _T('\x01') // for a langstring
|
||||
#define NS_SHELL_CODE _T('\x02') // for a shell folder path
|
||||
#define NS_VAR_CODE _T('\x03') // for a variable
|
||||
#define NS_SKIP_CODE _T('\x04') // to consider next character as a normal character
|
||||
#define NS_IS_CODE(x) ((x) <= NS_SKIP_CODE) // NS_SKIP_CODE must always be the higher code
|
||||
|
||||
// We are doing this to store an integer value into a char string and we
|
||||
// don't want false end of string values so we shift then OR with 0x8080
|
||||
// don't want false end of string values
|
||||
#if _UNICODE
|
||||
#define CODE_SHORT(x) ((WORD)x + 1)
|
||||
#define MAX_CODED 0xFFFE
|
||||
// This macro takes a pointer to WCHAR
|
||||
#define DECODE_SHORT(c) (c[0]-1)
|
||||
#else
|
||||
#define CODE_SHORT(x) (WORD)((((WORD)(x) & 0x7F) | (((WORD)(x) & 0x3F80) << 1) | 0x8080))
|
||||
#define MAX_CODED 16383 // 0x3FFF
|
||||
// This macro takes a pointer to char
|
||||
#define MAX_CODED 0x3FFF
|
||||
// This macro takes a pointer to CHAR
|
||||
#define DECODE_SHORT(c) (((c[1] & 0x7F) << 7) | (c[0] & 0x7F))
|
||||
#endif
|
||||
|
||||
#define NSIS_INSTDIR_INVALID 1
|
||||
#define NSIS_INSTDIR_NOT_ENOUGH_SPACE 2
|
||||
|
|
|
@ -662,14 +662,21 @@ TCHAR * NSISCALL GetNSISString(TCHAR *outbuf, int strtab)
|
|||
_TUCHAR nVarIdx = (_TUCHAR)*in++;
|
||||
int nData;
|
||||
int fldrs[4];
|
||||
if (nVarIdx > NS_CODES_START)
|
||||
if (nVarIdx < NS_SKIP_CODE)
|
||||
{
|
||||
// the next 2 BYTEs in the string might be coding either a value 0..MAX_CODED (nData), or 2 CSIDL of Special folders (for NS_SHELL_CODE)
|
||||
nData = DECODE_SHORT(in);
|
||||
#ifdef _UNICODE
|
||||
fldrs[1] = LOBYTE(*in); // current user
|
||||
fldrs[0] = fldrs[1] | CSIDL_FLAG_CREATE;
|
||||
fldrs[3] = HIBYTE(*in); // all users
|
||||
fldrs[2] = fldrs[3] | CSIDL_FLAG_CREATE;
|
||||
#else
|
||||
fldrs[0] = in[0] | CSIDL_FLAG_CREATE; // current user
|
||||
fldrs[1] = in[0];
|
||||
fldrs[2] = in[1] | CSIDL_FLAG_CREATE; // all users
|
||||
fldrs[3] = in[1];
|
||||
#endif
|
||||
//TODO: are fldrs[1] and fldrs[3] really useful? why not force folder creation directly?
|
||||
in += sizeof(SHORT)/sizeof(TCHAR);
|
||||
|
||||
|
@ -828,6 +835,7 @@ void NSISCALL validate_filename(TCHAR *in) {
|
|||
in = CharNext(in);
|
||||
}
|
||||
*out = 0;
|
||||
// now trim rightmost backslashes & spaces
|
||||
do
|
||||
{
|
||||
out = CharPrev(out_save, out);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue