Optimize FileReadByte/FileReadWord
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6400 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
d387a32658
commit
55738e1385
2 changed files with 7 additions and 8 deletions
|
@ -1419,14 +1419,14 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
{
|
{
|
||||||
TCHAR c;
|
TCHAR c;
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
c=0; // Make sure high byte is 0 for FileReadByte
|
if (which==EW_FGETS)
|
||||||
if (which==EW_FGETS && !parm3)
|
|
||||||
{
|
{
|
||||||
char tmpc[2];
|
char tmpc[2];
|
||||||
DWORD mbtwcflags=MB_ERR_INVALID_CHARS, cbio;
|
DWORD mbtwcflags=MB_ERR_INVALID_CHARS, cbio;
|
||||||
if (!ReadFile(h,tmpc,2,&cbio,NULL) || !cbio) break;
|
if (!ReadFile(h,tmpc,2-parm3,&cbio,NULL) || !cbio) break;
|
||||||
ungetseek=cbio;
|
ungetseek=cbio;
|
||||||
for(;;) // Try to parse as DBCS first, if that fails try again as a single byte
|
c = (unsigned char) tmpc[0]; // FileReadByte
|
||||||
|
if (!parm3) for(;;) // Try to parse as DBCS first, if that fails try again as a single byte
|
||||||
{
|
{
|
||||||
// BUGBUG: Limited to UCS-2/BMP, surrogate pairs are not supported.
|
// BUGBUG: Limited to UCS-2/BMP, surrogate pairs are not supported.
|
||||||
if (MultiByteToWideChar(CP_ACP,mbtwcflags,tmpc,cbio,&c,1)) break;
|
if (MultiByteToWideChar(CP_ACP,mbtwcflags,tmpc,cbio,&c,1)) break;
|
||||||
|
@ -1438,9 +1438,8 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// Read 1 TCHAR (FileReadUTF16LE and (Ansi)FileRead) or
|
// Read 1 TCHAR (FileReadUTF16LE, (Ansi)FileRead, FileReadWord)
|
||||||
// parm3 bytes (FileReadByte and (Unicode)FileReadWord)
|
if (!myReadFile(h,&c,sizeof(TCHAR))) break;
|
||||||
if (!myReadFile(h,&c,!parm3 ? sizeof(TCHAR) : sizeof(TCHAR) > 1 ? parm3 : 1)) break;
|
|
||||||
}
|
}
|
||||||
if (parm3)
|
if (parm3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5872,7 +5872,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
|
||||||
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle
|
ent.offsets[0]=GetUserVarIndex(line, 1); // file handle
|
||||||
ent.offsets[1]=GetUserVarIndex(line, 2); // output string
|
ent.offsets[1]=GetUserVarIndex(line, 2); // output string
|
||||||
ent.offsets[2]=add_asciistring(_T("1"));
|
ent.offsets[2]=add_asciistring(_T("1"));
|
||||||
ent.offsets[3]=2;
|
ent.offsets[3]=1;
|
||||||
if (ent.offsets[0]<0 || ent.offsets[1]<0) PRINTHELP()
|
if (ent.offsets[0]<0 || ent.offsets[1]<0) PRINTHELP()
|
||||||
SCRIPT_MSG(_T("FileReadWord: %s->%s\n"),line.gettoken_str(1),line.gettoken_str(2));
|
SCRIPT_MSG(_T("FileReadWord: %s->%s\n"),line.gettoken_str(1),line.gettoken_str(2));
|
||||||
return add_entry(&ent);
|
return add_entry(&ent);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue