Jim Park's Unicode NSIS merging - Step 2 : merge TCHARs changes into trunk
Compiler output is identical before & after this step git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6037 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
commit
cdf7735a77
206 changed files with 8437 additions and 6403 deletions
|
@ -8,6 +8,7 @@ lib_files = Split("""
|
|||
|
||||
api_files = Split("""
|
||||
pluginapi.h
|
||||
nsis_tchar.h
|
||||
#Source/exehead/api.h
|
||||
""")
|
||||
|
||||
|
@ -18,7 +19,7 @@ example = Split("""
|
|||
exdll.dsw
|
||||
exdll_with_unit.dpr
|
||||
exdll-vs2008.sln
|
||||
exdll-vs2008.vcproj
|
||||
exdll-vs2008.vcproj
|
||||
nsis.pas
|
||||
extdll.inc
|
||||
""")
|
||||
|
|
|
@ -5,8 +5,11 @@ HINSTANCE g_hInstance;
|
|||
|
||||
HWND g_hwndParent;
|
||||
|
||||
// To work with Unicode version of NSIS, please use TCHAR-type
|
||||
// functions for accessing the variables and the stack.
|
||||
|
||||
void __declspec(dllexport) myFunction(HWND hwndParent, int string_size,
|
||||
char *variables, stack_t **stacktop,
|
||||
TCHAR *variables, stack_t **stacktop,
|
||||
extra_parameters *extra)
|
||||
{
|
||||
g_hwndParent=hwndParent;
|
||||
|
@ -23,8 +26,8 @@ void __declspec(dllexport) myFunction(HWND hwndParent, int string_size,
|
|||
|
||||
// do your stuff here
|
||||
{
|
||||
char buf[1024];
|
||||
wsprintf(buf,"$0=%s\n",getuservariable(INST_0));
|
||||
TCHAR buf[1024];
|
||||
wsprintf(buf,_T("$0=%s\n"),getuservariable(INST_0));
|
||||
MessageBox(g_hwndParent,buf,0,MB_OK);
|
||||
}
|
||||
}
|
||||
|
|
214
Contrib/ExDLL/nsis_tchar.h
Normal file
214
Contrib/ExDLL/nsis_tchar.h
Normal file
|
@ -0,0 +1,214 @@
|
|||
/*
|
||||
* nsis_tchar.h
|
||||
*
|
||||
* This file is a part of NSIS.
|
||||
*
|
||||
* Copyright (C) 1999-2007 Nullsoft and Contributors
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty.
|
||||
*
|
||||
* For Unicode support by Jim Park -- 08/30/2007
|
||||
*/
|
||||
|
||||
// Jim Park: Only those we use are listed here.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _UNICODE
|
||||
|
||||
#ifndef _T
|
||||
#define __T(x) L ## x
|
||||
#define _T(x) __T(x)
|
||||
#define _TEXT(x) __T(x)
|
||||
#endif
|
||||
typedef wchar_t TCHAR;
|
||||
typedef wchar_t _TUCHAR;
|
||||
|
||||
// program
|
||||
#define _tmain wmain
|
||||
#define _tWinMain wWinMain
|
||||
#define _tenviron _wenviron
|
||||
#define __targv __wargv
|
||||
|
||||
// printfs
|
||||
#define _ftprintf fwprintf
|
||||
#define _sntprintf _snwprintf
|
||||
#define _stprintf _swprintf
|
||||
#define _tprintf wprintf
|
||||
#define _vftprintf vfwprintf
|
||||
#define _vsntprintf _vsnwprintf
|
||||
#define _vstprintf _vswprintf
|
||||
|
||||
// scanfs
|
||||
#define _tscanf wscanf
|
||||
#define _stscanf swscanf
|
||||
|
||||
// string manipulations
|
||||
#define _tcscat wcscat
|
||||
#define _tcschr wcschr
|
||||
#define _tcsclen wcslen
|
||||
#define _tcscpy wcscpy
|
||||
#define _tcsdup _wcsdup
|
||||
#define _tcslen wcslen
|
||||
#define _tcsnccpy wcsncpy
|
||||
#define _tcsncpy wcsncpy
|
||||
#define _tcsrchr wcsrchr
|
||||
#define _tcsstr wcsstr
|
||||
#define _tcstok wcstok
|
||||
|
||||
// string comparisons
|
||||
#define _tcscmp wcscmp
|
||||
#define _tcsicmp _wcsicmp
|
||||
#define _tcsncicmp _wcsnicmp
|
||||
#define _tcsncmp wcsncmp
|
||||
#define _tcsnicmp _wcsnicmp
|
||||
|
||||
// upper / lower
|
||||
#define _tcslwr _wcslwr
|
||||
#define _tcsupr _wcsupr
|
||||
#define _totlower towlower
|
||||
#define _totupper towupper
|
||||
|
||||
// conversions to numbers
|
||||
#define _tcstoi64 _wcstoi64
|
||||
#define _tcstol wcstol
|
||||
#define _tcstoul wcstoul
|
||||
#define _tstof _wtof
|
||||
#define _tstoi _wtoi
|
||||
#define _tstoi64 _wtoi64
|
||||
#define _ttoi _wtoi
|
||||
#define _ttoi64 _wtoi64
|
||||
#define _ttol _wtol
|
||||
|
||||
// conversion from numbers to strings
|
||||
#define _itot _itow
|
||||
#define _ltot _ltow
|
||||
#define _i64tot _i64tow
|
||||
#define _ui64tot _ui64tow
|
||||
|
||||
// file manipulations
|
||||
#define _tfopen _wfopen
|
||||
#define _topen _wopen
|
||||
#define _tremove _wremove
|
||||
#define _tunlink _wunlink
|
||||
|
||||
// reading and writing to i/o
|
||||
#define _fgettc fgetwc
|
||||
#define _fgetts fgetws
|
||||
#define _fputts fputws
|
||||
#define _gettchar getwchar
|
||||
|
||||
// directory
|
||||
#define _tchdir _wchdir
|
||||
|
||||
// environment
|
||||
#define _tgetenv _wgetenv
|
||||
#define _tsystem _wsystem
|
||||
|
||||
// time
|
||||
#define _tcsftime wcsftime
|
||||
|
||||
#else // ANSI
|
||||
|
||||
#ifndef _T
|
||||
#define _T(x) x
|
||||
#define _TEXT(x) x
|
||||
#endif
|
||||
typedef char TCHAR;
|
||||
typedef unsigned char _TUCHAR;
|
||||
|
||||
// program
|
||||
#define _tmain main
|
||||
#define _tWinMain WinMain
|
||||
#define _tenviron environ
|
||||
#define __targv __argv
|
||||
|
||||
// printfs
|
||||
#define _ftprintf fprintf
|
||||
#define _sntprintf _snprintf
|
||||
#define _stprintf sprintf
|
||||
#define _tprintf printf
|
||||
#define _vftprintf vfprintf
|
||||
#define _vsntprintf _vsnprintf
|
||||
#define _vstprintf vsprintf
|
||||
|
||||
// scanfs
|
||||
#define _tscanf scanf
|
||||
#define _stscanf sscanf
|
||||
|
||||
// string manipulations
|
||||
#define _tcscat strcat
|
||||
#define _tcschr strchr
|
||||
#define _tcsclen strlen
|
||||
#define _tcscnlen strnlen
|
||||
#define _tcscpy strcpy
|
||||
#define _tcsdup _strdup
|
||||
#define _tcslen strlen
|
||||
#define _tcsnccpy strncpy
|
||||
#define _tcsrchr strrchr
|
||||
#define _tcsstr strstr
|
||||
#define _tcstok strtok
|
||||
|
||||
// string comparisons
|
||||
#define _tcscmp strcmp
|
||||
#define _tcsicmp _stricmp
|
||||
#define _tcsncmp strncmp
|
||||
#define _tcsncicmp _strnicmp
|
||||
#define _tcsnicmp _strnicmp
|
||||
|
||||
// upper / lower
|
||||
#define _tcslwr _strlwr
|
||||
#define _tcsupr _strupr
|
||||
|
||||
#define _totupper toupper
|
||||
#define _totlower tolower
|
||||
|
||||
// conversions to numbers
|
||||
#define _tcstol strtol
|
||||
#define _tcstoul strtoul
|
||||
#define _tstof atof
|
||||
#define _tstoi atoi
|
||||
#define _tstoi64 _atoi64
|
||||
#define _tstoi64 _atoi64
|
||||
#define _ttoi atoi
|
||||
#define _ttoi64 _atoi64
|
||||
#define _ttol atol
|
||||
|
||||
// conversion from numbers to strings
|
||||
#define _i64tot _i64toa
|
||||
#define _itot _itoa
|
||||
#define _ltot _ltoa
|
||||
#define _ui64tot _ui64toa
|
||||
|
||||
// file manipulations
|
||||
#define _tfopen fopen
|
||||
#define _topen _open
|
||||
#define _tremove remove
|
||||
#define _tunlink _unlink
|
||||
|
||||
// reading and writing to i/o
|
||||
#define _fgettc fgetc
|
||||
#define _fgetts fgets
|
||||
#define _fputts fputs
|
||||
#define _gettchar getchar
|
||||
|
||||
// directory
|
||||
#define _tchdir _chdir
|
||||
|
||||
// environment
|
||||
#define _tgetenv getenv
|
||||
#define _tsystem system
|
||||
|
||||
// time
|
||||
#define _tcsftime strftime
|
||||
|
||||
#endif
|
||||
|
||||
// is functions (the same in Unicode / ANSI)
|
||||
#define _istgraph isgraph
|
||||
#define _istascii __isascii
|
||||
|
||||
#define __TFILE__ _T(__FILE__)
|
||||
#define __TDATE__ _T(__DATE__)
|
||||
#define __TTIME__ _T(__TIME__)
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
unsigned int g_stringsize;
|
||||
stack_t **g_stacktop;
|
||||
char *g_variables;
|
||||
TCHAR *g_variables;
|
||||
|
||||
// utility functions (not required but often useful)
|
||||
|
||||
int NSISCALL popstring(char *str)
|
||||
int NSISCALL popstring(TCHAR *str)
|
||||
{
|
||||
stack_t *th;
|
||||
if (!g_stacktop || !*g_stacktop) return 1;
|
||||
|
@ -19,7 +19,7 @@ int NSISCALL popstring(char *str)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int NSISCALL popstringn(char *str, int maxlen)
|
||||
int NSISCALL popstringn(TCHAR *str, int maxlen)
|
||||
{
|
||||
stack_t *th;
|
||||
if (!g_stacktop || !*g_stacktop) return 1;
|
||||
|
@ -30,7 +30,7 @@ int NSISCALL popstringn(char *str, int maxlen)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void NSISCALL pushstring(const char *str)
|
||||
void NSISCALL pushstring(const TCHAR *str)
|
||||
{
|
||||
stack_t *th;
|
||||
if (!g_stacktop) return;
|
||||
|
@ -40,13 +40,13 @@ void NSISCALL pushstring(const char *str)
|
|||
*g_stacktop=th;
|
||||
}
|
||||
|
||||
char * NSISCALL getuservariable(const int varnum)
|
||||
TCHAR * NSISCALL getuservariable(const int varnum)
|
||||
{
|
||||
if (varnum < 0 || varnum >= __INST_LAST) return NULL;
|
||||
return g_variables+varnum*g_stringsize;
|
||||
}
|
||||
|
||||
void NSISCALL setuservariable(const int varnum, const char *var)
|
||||
void NSISCALL setuservariable(const int varnum, const TCHAR *var)
|
||||
{
|
||||
if (var != NULL && varnum >= 0 && varnum < __INST_LAST)
|
||||
lstrcpyA(g_variables + varnum*g_stringsize, var);
|
||||
|
@ -54,29 +54,29 @@ void NSISCALL setuservariable(const int varnum, const char *var)
|
|||
|
||||
// playing with integers
|
||||
|
||||
int NSISCALL myatoi(const char *s)
|
||||
int NSISCALL myatoi(const TCHAR *s)
|
||||
{
|
||||
int v=0;
|
||||
if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
|
||||
if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X')))
|
||||
{
|
||||
s++;
|
||||
for (;;)
|
||||
{
|
||||
int c=*(++s);
|
||||
if (c >= '0' && c <= '9') c-='0';
|
||||
else if (c >= 'a' && c <= 'f') c-='a'-10;
|
||||
else if (c >= 'A' && c <= 'F') c-='A'-10;
|
||||
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
|
||||
else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10;
|
||||
else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10;
|
||||
else break;
|
||||
v<<=4;
|
||||
v+=c;
|
||||
}
|
||||
}
|
||||
else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
|
||||
else if (*s == _T('0') && s[1] <= _T('7') && s[1] >= _T('0'))
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
int c=*(++s);
|
||||
if (c >= '0' && c <= '7') c-='0';
|
||||
if (c >= _T('0') && c <= _T('7')) c-=_T('0');
|
||||
else break;
|
||||
v<<=3;
|
||||
v+=c;
|
||||
|
@ -85,10 +85,10 @@ int NSISCALL myatoi(const char *s)
|
|||
else
|
||||
{
|
||||
int sign=0;
|
||||
if (*s == '-') sign++; else s--;
|
||||
if (*s == _T('-')) sign++; else s--;
|
||||
for (;;)
|
||||
{
|
||||
int c=*(++s) - '0';
|
||||
int c=*(++s) - _T('0');
|
||||
if (c < 0 || c > 9) break;
|
||||
v*=10;
|
||||
v+=c;
|
||||
|
@ -99,14 +99,14 @@ int NSISCALL myatoi(const char *s)
|
|||
return v;
|
||||
}
|
||||
|
||||
unsigned NSISCALL myatou(const char *s)
|
||||
unsigned NSISCALL myatou(const TCHAR *s)
|
||||
{
|
||||
unsigned int v=0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
unsigned int c=*s++;
|
||||
if (c >= '0' && c <= '9') c-='0';
|
||||
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
|
||||
else break;
|
||||
v*=10;
|
||||
v+=c;
|
||||
|
@ -114,29 +114,29 @@ unsigned NSISCALL myatou(const char *s)
|
|||
return v;
|
||||
}
|
||||
|
||||
int NSISCALL myatoi_or(const char *s)
|
||||
int NSISCALL myatoi_or(const TCHAR *s)
|
||||
{
|
||||
int v=0;
|
||||
if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
|
||||
if (*s == _T('0') && (s[1] == _T('x') || s[1] == _T('X')))
|
||||
{
|
||||
s++;
|
||||
for (;;)
|
||||
{
|
||||
int c=*(++s);
|
||||
if (c >= '0' && c <= '9') c-='0';
|
||||
else if (c >= 'a' && c <= 'f') c-='a'-10;
|
||||
else if (c >= 'A' && c <= 'F') c-='A'-10;
|
||||
if (c >= _T('0') && c <= _T('9')) c-=_T('0');
|
||||
else if (c >= _T('a') && c <= _T('f')) c-=_T('a')-10;
|
||||
else if (c >= _T('A') && c <= _T('F')) c-=_T('A')-10;
|
||||
else break;
|
||||
v<<=4;
|
||||
v+=c;
|
||||
}
|
||||
}
|
||||
else if (*s == '0' && s[1] <= '7' && s[1] >= '0')
|
||||
else if (*s == _T('0') && s[1] <= _T('7') && s[1] >= _T('0'))
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
int c=*(++s);
|
||||
if (c >= '0' && c <= '7') c-='0';
|
||||
if (c >= _T('0') && c <= _T('7')) c-=_T('0');
|
||||
else break;
|
||||
v<<=3;
|
||||
v+=c;
|
||||
|
@ -145,10 +145,10 @@ int NSISCALL myatoi_or(const char *s)
|
|||
else
|
||||
{
|
||||
int sign=0;
|
||||
if (*s == '-') sign++; else s--;
|
||||
if (*s == _T('-')) sign++; else s--;
|
||||
for (;;)
|
||||
{
|
||||
int c=*(++s) - '0';
|
||||
int c=*(++s) - _T('0');
|
||||
if (c < 0 || c > 9) break;
|
||||
v*=10;
|
||||
v+=c;
|
||||
|
@ -157,7 +157,7 @@ int NSISCALL myatoi_or(const char *s)
|
|||
}
|
||||
|
||||
// Support for simple ORed expressions
|
||||
if (*s == '|')
|
||||
if (*s == _T('|'))
|
||||
{
|
||||
v |= myatoi_or(s+1);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ int NSISCALL myatoi_or(const char *s)
|
|||
|
||||
int NSISCALL popint()
|
||||
{
|
||||
char buf[128];
|
||||
TCHAR buf[128];
|
||||
if (popstringn(buf,sizeof(buf)))
|
||||
return 0;
|
||||
|
||||
|
@ -176,7 +176,7 @@ int NSISCALL popint()
|
|||
|
||||
int NSISCALL popint_or()
|
||||
{
|
||||
char buf[128];
|
||||
TCHAR buf[128];
|
||||
if (popstringn(buf,sizeof(buf)))
|
||||
return 0;
|
||||
|
||||
|
@ -185,7 +185,7 @@ int NSISCALL popint_or()
|
|||
|
||||
void NSISCALL pushint(int value)
|
||||
{
|
||||
char buffer[1024];
|
||||
wsprintf(buffer, "%d", value);
|
||||
TCHAR buffer[1024];
|
||||
wsprintf(buffer, _T("%d"), value);
|
||||
pushstring(buffer);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#include "api.h"
|
||||
#include "nsis_tchar.h"
|
||||
|
||||
#ifndef NSISCALL
|
||||
# define NSISCALL __stdcall
|
||||
|
@ -18,7 +19,7 @@ extern "C" {
|
|||
|
||||
typedef struct _stack_t {
|
||||
struct _stack_t *next;
|
||||
char text[1]; // this should be the length of string_size
|
||||
TCHAR text[1]; // this should be the length of string_size
|
||||
} stack_t;
|
||||
|
||||
enum
|
||||
|
@ -53,19 +54,25 @@ __INST_LAST
|
|||
|
||||
extern unsigned int g_stringsize;
|
||||
extern stack_t **g_stacktop;
|
||||
extern char *g_variables;
|
||||
extern TCHAR *g_variables;
|
||||
|
||||
int NSISCALL popstring(char *str); // 0 on success, 1 on empty stack
|
||||
int NSISCALL popstringn(char *str, int maxlen); // with length limit, pass 0 for g_stringsize
|
||||
int NSISCALL popstring(TCHAR *str); // 0 on success, 1 on empty stack
|
||||
int NSISCALL popstringn(TCHAR *str, int maxlen); // with length limit, pass 0 for g_stringsize
|
||||
int NSISCALL popint(); // pops an integer
|
||||
int NSISCALL popint_or(); // with support for or'ing (2|4|8)
|
||||
int NSISCALL myatoi(const char *s); // converts a string to an integer
|
||||
unsigned NSISCALL myatou(const char *s); // converts a string to an unsigned integer, decimal only
|
||||
int NSISCALL myatoi_or(const char *s); // with support for or'ing (2|4|8)
|
||||
void NSISCALL pushstring(const char *str);
|
||||
int NSISCALL myatoi(const TCHAR *s); // converts a string to an integer
|
||||
unsigned NSISCALL myatou(const TCHAR *s); // converts a string to an unsigned integer, decimal only
|
||||
int NSISCALL myatoi_or(const TCHAR *s); // with support for or'ing (2|4|8)
|
||||
void NSISCALL pushstring(const TCHAR *str);
|
||||
void NSISCALL pushint(int value);
|
||||
char * NSISCALL getuservariable(const int varnum);
|
||||
void NSISCALL setuservariable(const int varnum, const char *var);
|
||||
TCHAR * NSISCALL getuservariable(const int varnum);
|
||||
void NSISCALL setuservariable(const int varnum, const TCHAR *var);
|
||||
|
||||
// ANSI defs
|
||||
|
||||
#define PopStringA(x) popstring(x)
|
||||
#define PushStringA(x) pushstring(x)
|
||||
#define SetUserVariableA(x,y) setuservariable(x,y)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue