diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 2233ebb4..e6d2793d 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -1419,14 +1419,14 @@ static int NSISCALL ExecuteEntry(entry *entry_) { TCHAR c; #ifdef _UNICODE - c=0; // Make sure high byte is 0 for FileReadByte - if (which==EW_FGETS && !parm3) + if (which==EW_FGETS) { char tmpc[2]; 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; - 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. if (MultiByteToWideChar(CP_ACP,mbtwcflags,tmpc,cbio,&c,1)) break; @@ -1438,9 +1438,8 @@ static int NSISCALL ExecuteEntry(entry *entry_) else #endif { - // Read 1 TCHAR (FileReadUTF16LE and (Ansi)FileRead) or - // parm3 bytes (FileReadByte and (Unicode)FileReadWord) - if (!myReadFile(h,&c,!parm3 ? sizeof(TCHAR) : sizeof(TCHAR) > 1 ? parm3 : 1)) break; + // Read 1 TCHAR (FileReadUTF16LE, (Ansi)FileRead, FileReadWord) + if (!myReadFile(h,&c,sizeof(TCHAR))) break; } if (parm3) { diff --git a/Source/script.cpp b/Source/script.cpp index 57725b4b..d153f2cb 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -5872,7 +5872,7 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) ent.offsets[0]=GetUserVarIndex(line, 1); // file handle ent.offsets[1]=GetUserVarIndex(line, 2); // output string 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() SCRIPT_MSG(_T("FileReadWord: %s->%s\n"),line.gettoken_str(1),line.gettoken_str(2)); return add_entry(&ent);