Adding Unicode support to System plugin

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6050 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
wizou 2010-04-13 15:25:33 +00:00
parent 9852de80be
commit 57d296e159
5 changed files with 1348 additions and 1252 deletions

View file

@ -1,3 +1,5 @@
// Unicode support by Jim Park -- 08/23/2007
#include "stdafx.h"
#include "Plugin.h"
#include "System.h"
@ -23,6 +25,18 @@ PLUGINFUNCTIONSHORT(Alloc)
}
PLUGINFUNCTIONEND
PLUGINFUNCTIONSHORT(StrAlloc)
{
int size;
if ((size = popint64()) == 0)
{
system_pushint(0);
return;
}
system_pushint((int) GlobalAlloc(GPTR, size * sizeof(TCHAR)));
}
PLUGINFUNCTIONEND
PLUGINFUNCTIONSHORT(Copy)
{
int size = 0;

View file

@ -14,7 +14,7 @@ TCHAR *AllocString()
TCHAR *AllocStr(TCHAR *str)
{
return lstrcpy(AllocString(), str);
return lstrcpyn(AllocString(), str, g_stringsize);
}
TCHAR* system_popstring()

File diff suppressed because it is too large Load diff

View file

@ -47,6 +47,11 @@
#define PAT_WSTRING 4
#define PAT_GUID 5
#define PAT_CALLBACK 6
#ifdef _UNICODE
#define PAT_TSTRING PAT_WSTRING
#else
#define PAT_TSTRING PAT_STRING
#endif
// Input/Output Source/Destination
#define IOT_NONE 0

View file

@ -64,7 +64,19 @@ System::Free $0
</pre></blockquote>
</blockquote>
</li>
<li>
<b>StrAlloc</b> <i>SIZE</i>
<blockquote>
<p>Allocates a string buffer for <i>SIZE</i> <b>TCHARs</b> and returns a memory address on the stack. This is extremely useful if you want to write an NSI script that will work for both ANSI and Unicode NSIS.</p>
<h4>Usage Example</h4>
<blockquote><pre>
System::<b>StrAlloc</b> 64 ; String buffer for 63 characters and \0 termination.
Pop $0
DetailPrint "A string buffer for 64 characters allocated at $0"
System::Free $0
</pre></blockquote>
</blockquote>
</li>
<li>
<b>Copy</b> [/<i>SIZE</i>] <i>DESTINATION</i> <i>SOURCE</i>
<blockquote>
@ -283,11 +295,15 @@ DetailPrint $4
</tr>
<tr>
<th>&amp;t<i>N</i></th>
<td><i>N</i> bytes of text (structures only)</td>
<td>array of <i>N</i> text characters TCHAR (structures only)</td>
</tr>
<tr>
<th>&amp;m<i>N</i></th>
<td>array of <i>N</i> ANSI characters CHAR (structures only)</td>
</tr>
<tr>
<th>&amp;w<i>N</i></th>
<td><i>N</i> bytes of Unicode text (structures only)</td>
<td>array of <i>N</i> Unicode characters WCHAR (structures only)</td>
</tr>
<tr>
<th>&amp;g<i>N</i></th>