MakeNSIS can now generate Unicode or Ansi installers based on a script attribute. SCons generates both Ansi and Unicode stubs and plugins.
The official plugins are now stored in architecture specific subdirectories under NSIS\Plugins. !AddPluginDir also gained a new (optional) architecture flag because MakeNSIS now stores separate plugin information for each target architecture. Storing plugins in the root of the Plugins directory is no longer supported. MinGW does not implement the unicode CRT startup functions so the entry point functions and linker parameters had to be changed. The unicode tools use the ansi entry point and a small helper function that calls into the real code: _tmain has full argc+argv emulation while wWinMain does not pass the command line parameters. The stubs do not use any CRT functions and have no CRT or unicode helper code, they call our entry point directly. git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6269 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
8f330bbbdf
commit
7cc150c464
73 changed files with 936 additions and 713 deletions
|
@ -18,12 +18,13 @@
|
|||
#include "validateunicode.h"
|
||||
#include "util.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
|
||||
FILE* FileOpenUnicodeText(const TCHAR* file, const TCHAR* mode, BOOL* unicode)
|
||||
{
|
||||
extern FILE *g_output;
|
||||
CValidateUnicode::FILE_TYPE ftype = CValidateUnicode::UTF_8; // default file format is UTF-8
|
||||
if (unicode) *unicode = TRUE;
|
||||
if (unicode) *unicode = TRUE;
|
||||
|
||||
// If we are reading an existing file, check to see what type of file it
|
||||
// is first.
|
||||
|
@ -34,50 +35,50 @@ FILE* FileOpenUnicodeText(const TCHAR* file, const TCHAR* mode, BOOL* unicode)
|
|||
|
||||
if (fp)
|
||||
{
|
||||
MANAGE_WITH(fp, fclose);
|
||||
MANAGE_WITH(fp, fclose);
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size_t fileSize = ftell(fp);
|
||||
if (fileSize == 0)
|
||||
{
|
||||
// Empty files are treated as UTF-8.
|
||||
ftype = CValidateUnicode::UTF_8;
|
||||
// Empty files are treated as UTF-8.
|
||||
ftype = CValidateUnicode::UTF_8;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<unsigned char> buffer(fileSize);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
fread(&buffer[0], sizeof(unsigned char), fileSize, fp);
|
||||
std::vector<unsigned char> buffer(fileSize);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
fread(&buffer[0], sizeof(unsigned char), fileSize, fp);
|
||||
|
||||
ftype = CValidateUnicode::CheckBOM(&buffer[0], buffer.size());
|
||||
ftype = CValidateUnicode::CheckBOM(&buffer[0], buffer.size());
|
||||
|
||||
switch (ftype)
|
||||
{
|
||||
case CValidateUnicode::UTF_8:
|
||||
case CValidateUnicode::UTF_16LE:
|
||||
case CValidateUnicode::UTF_16BE:
|
||||
break;
|
||||
case CValidateUnicode::UTF_32LE:
|
||||
case CValidateUnicode::UTF_32BE:
|
||||
PrintColorFmtMsg_ERR(_T("File '%s' has a BOM marked as %s which is not supported at this time.\n"),
|
||||
file, CValidateUnicode::TypeToName(ftype));
|
||||
exit(-1);
|
||||
break;
|
||||
case CValidateUnicode::UNKNOWN:
|
||||
// If unknown, let's see if it's not just UTF_8 without a BOM.
|
||||
if (CValidateUnicode::ValidateUTF8(&buffer[0], buffer.size()) == 2)
|
||||
{
|
||||
// contains UTF-8 characters sequences
|
||||
_ftprintf(g_output, _T("File '%s' has no BOM but seems to be UTF-8.\n"), file);
|
||||
ftype = CValidateUnicode::UTF_8;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PrintColorFmtMsg_ERR(_T("CValidateUnicode::CheckBOM() for file '%s' returned an unknown return value: %d\n"),
|
||||
file, ftype);
|
||||
exit(-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (ftype)
|
||||
{
|
||||
case CValidateUnicode::UTF_8:
|
||||
case CValidateUnicode::UTF_16LE:
|
||||
case CValidateUnicode::UTF_16BE:
|
||||
break;
|
||||
case CValidateUnicode::UTF_32LE:
|
||||
case CValidateUnicode::UTF_32BE:
|
||||
PrintColorFmtMsg_ERR(_T("File '%s' has a BOM marked as %s which is not supported at this time.\n"),
|
||||
file, CValidateUnicode::TypeToName(ftype));
|
||||
exit(-1);
|
||||
break;
|
||||
case CValidateUnicode::UNKNOWN:
|
||||
// If unknown, let's see if it's not just UTF_8 without a BOM.
|
||||
if (CValidateUnicode::ValidateUTF8(&buffer[0], buffer.size()) == 2)
|
||||
{
|
||||
// contains UTF-8 characters sequences
|
||||
_ftprintf(g_output, _T("File '%s' has no BOM but seems to be UTF-8.\n"), file);
|
||||
ftype = CValidateUnicode::UTF_8;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PrintColorFmtMsg_ERR(_T("CValidateUnicode::CheckBOM() for file '%s' returned an unknown return value: %d\n"),
|
||||
file, ftype);
|
||||
exit(-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +94,7 @@ FILE* FileOpenUnicodeText(const TCHAR* file, const TCHAR* mode, BOOL* unicode)
|
|||
break;
|
||||
default:
|
||||
// Looks like fopen() doesn't support other encodings of Unicode.
|
||||
if (unicode) *unicode = FALSE;
|
||||
if (unicode) *unicode = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue