Martijn Laan hai 1 ano
pai
achega
8af1e33489

+ 11 - 41
Components/PathFunc.pas

@@ -2,17 +2,11 @@ unit PathFunc;
 
 {
   Inno Setup
-  Copyright (C) 1997-2010 Jordan Russell
+  Copyright (C) 1997-2024 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
 
-  This unit provides some path-related, MBCS-aware functions.
-
-  These functions should always be used in lieu of their SysUtils counterparts
-  since they aren't MBCS-aware on Delphi 2, and sometimes not MBCS-aware on
-  Delphi 6 and 7 either (see QC#5096).
-
-  $jrsoftware: issrc/Components/PathFunc.pas,v 1.43 2010/04/19 21:43:01 jr Exp $
+  This unit provides some path-related functions.
 }
 
 interface
@@ -66,20 +60,9 @@ begin
 end;
 
 function PathCharLength(const S: String; const Index: Integer): Integer;
-{ Returns the length in bytes of the character at Index in S.
-  Notes:
-  1. If Index specifies the last character in S, 1 will always be returned,
-     even if the last character is a lead byte.
-  2. If a lead byte is followed by a null character (e.g. #131#0), 2 will be
-     returned. This mimics the behavior of MultiByteToWideChar and CharPrev,
-     but not CharNext(P)-P, which would stop on the null. }
+{ Returns the length in characters of the character at Index in S. }
 begin
-  {$IFNDEF UNICODE}
-  if IsDBCSLeadByte(Ord(S[Index])) and (Index < Length(S)) then
-    Result := 2
-  else
-  {$ENDIF}
-    Result := 1;
+  Result := 1;
 end;
 
 function PathCharIsSlash(const C: Char): Boolean;
@@ -188,8 +171,7 @@ function PathDrivePartLengthEx(const Filename: String;
     'x:\file'             -> 3  ('x:\')
     '\\server\share\file' -> 14 ('\\server\share')
     '\file'               -> 1  ('\')
-  Note: This is MBCS-safe, unlike the Delphi's ExtractFileDrive function.
-  (Computer and share names can include multi-byte characters!) }
+}
 var
   Len, I, C: Integer;
 begin
@@ -392,8 +374,8 @@ begin
 end;
 
 function PathLastChar(const S: String): PChar;
-{ Returns pointer to last character in the string. Is MBCS-aware. Returns nil
-  if the string is empty. }
+{ Returns pointer to last character in the string. Returns nil if the string is
+  empty. }
 begin
   if S = '' then
     Result := nil
@@ -431,7 +413,6 @@ begin
 end;
 
 function PathPos(Ch: Char; const S: String): Integer;
-{ This is an MBCS-aware Pos function. }
 var
   Len, I: Integer;
 begin
@@ -474,7 +455,7 @@ end;
 
 function PathStartsWith(const S, AStartsWith: String): Boolean;
 { Returns True if S starts with (or is equal to) AStartsWith. Uses path casing
-  rules, and is MBCS-aware. }
+  rules. }
 var
   AStartsWithLen: Integer;
 begin
@@ -488,35 +469,24 @@ begin
 end;
 
 function PathStrNextChar(const S: PChar): PChar;
-{ Returns pointer to the character after S, unless S points to a null (#0).
-  Is MBCS-aware. }
+{ Returns pointer to the character after S, unless S points to a null (#0). }
 begin
-  {$IFNDEF UNICODE}
-  Result := CharNext(S);
-  {$ELSE}
   Result := S;
   if Result^ <> #0 then
     Inc(Result);
-  {$ENDIF}
 end;
 
 function PathStrPrevChar(const Start, Current: PChar): PChar;
-{ Returns pointer to the character before Current, unless Current = Start.
-  Is MBCS-aware. }
+{ Returns pointer to the character before Current, unless Current = Start. }
 begin
-  {$IFNDEF UNICODE}
-  Result := CharPrev(Start, Current);
-  {$ELSE}
   Result := Current;
   if Result > Start then
     Dec(Result);
-  {$ENDIF}
 end;
 
 function PathStrScan(const S: PChar; const C: Char): PChar;
 { Returns pointer to first occurrence of C in S, or nil if there are no
-  occurrences. Like StrScan, but MBCS-aware.
-  Note: As with StrScan, specifying #0 for the search character is legal. }
+  occurrences. As with StrScan, specifying #0 for the search character is legal. }
 begin
   Result := S;
   while Result^ <> C do begin

+ 1 - 1
Projects/CompExeUpdate.pas

@@ -29,7 +29,7 @@ procedure PreventCOMCTL32Sideloading(const F: TCustomFile);
 implementation
 
 uses
-  ResUpdate{$IFDEF UNICODE}, Math{$ENDIF}, Int64Em;
+  ResUpdate, Math, Int64Em;
 
 procedure UpdateSetupPEHeaderFields(const F: TCustomFile;
   const IsTSAware, IsDEPCompatible, IsASLRCompatible: Boolean);

+ 5 - 35
Projects/FileClass.pas

@@ -96,18 +96,14 @@ type
     FBufferOffset, FBufferSize: Cardinal;
     FEof: Boolean;
     FBuffer: array[0..4095] of AnsiChar;
-{$IFDEF UNICODE}
     FSawFirstLine: Boolean;
     FCodePage: Cardinal;
-{$ENDIF}
-    function DoReadLine{$IFDEF UNICODE}(const UTF8: Boolean){$ENDIF}: AnsiString;
+    function DoReadLine(const UTF8: Boolean): AnsiString;
     function GetEof: Boolean;
     procedure FillBuffer;
   public
     function ReadLine: String;
-{$IFDEF UNICODE}
     function ReadAnsiLine: AnsiString;
-{$ENDIF}
     property CodePage: Cardinal write FCodePage;
     property Eof: Boolean read GetEof;
   end;
@@ -116,7 +112,7 @@ type
   private
     FSeekedToEnd: Boolean;
     FUTF8NoPreamble: Boolean;
-    procedure DoWrite(const S: AnsiString{$IFDEF UNICODE}; const UTF8: Boolean{$ENDIF});
+    procedure DoWrite(const S: AnsiString; const UTF8: Boolean);
   protected
     function CreateHandle(const AFilename: String;
       ACreateDisposition: TFileCreateDisposition; AAccess: TFileAccess;
@@ -125,10 +121,8 @@ type
     property UTF8NoPreamble: Boolean read FUTF8NoPreamble write FUTF8NoPreamble;
     procedure Write(const S: String);
     procedure WriteLine(const S: String);
-{$IFDEF UNICODE}
     procedure WriteAnsi(const S: AnsiString);
     procedure WriteAnsiLine(const S: AnsiString);
-{$ENDIF}
   end;
 
   TFileMapping = class
@@ -438,29 +432,21 @@ begin
 end;
 
 function TTextFileReader.ReadLine: String;
-{$IFDEF UNICODE}
 var
  S: RawByteString;
-{$ENDIF}
 begin
-{$IFDEF UNICODE}
  S := DoReadLine(True);
  if FCodePage <> 0 then
    SetCodePage(S, FCodePage, False);
  Result := String(S);
-{$ELSE}
- Result := DoReadLine;
-{$ENDIF}
 end; 
 
-{$IFDEF UNICODE}
 function TTextFileReader.ReadAnsiLine: AnsiString;
 begin
   Result := DoReadLine(False);
 end;
-{$ENDIF}
 
-function TTextFileReader.DoReadLine{$IFDEF UNICODE}(const UTF8: Boolean){$ENDIF}: AnsiString;
+function TTextFileReader.DoReadLine(const UTF8: Boolean): AnsiString;
 var
   I, L: Cardinal;
   S: AnsiString;
@@ -502,7 +488,7 @@ begin
       Break;
     end;
   end;
-  {$IFDEF UNICODE}
+
   if not FSawFirstLine then begin
     if UTF8 then begin
       { Handle UTF8 as requested: check for a BOM at the start and if not found then check entire file }
@@ -526,7 +512,7 @@ begin
     end;
     FSawFirstLine := True;
   end;
-  {$ENDIF}
+
   Result := S;
 end;
 
@@ -545,17 +531,11 @@ begin
     ASharing);
 end;
 
-{$IFDEF UNICODE}
 procedure TTextFileWriter.DoWrite(const S: AnsiString; const UTF8: Boolean);
-{$ELSE}
-procedure TTextFileWriter.DoWrite(const S: String);
-{$ENDIF}
 { Writes a string to the file, seeking to the end first if necessary }
 const
   CRLF: array[0..1] of AnsiChar = (#13, #10);
-{$IFDEF UNICODE}
   UTF8Preamble: array[0..2] of AnsiChar = (#$EF, #$BB, #$BF);
-{$ENDIF}
 var
   I: Integer64;
   C: AnsiChar;
@@ -578,12 +558,8 @@ begin
         { Otherwise, append CRLF }
         WriteBuffer(CRLF, SizeOf(CRLF));
       end;
-{$IFDEF UNICODE}
     end else if UTF8 and not FUTF8NoPreamble then
       WriteBuffer(UTF8Preamble, SizeOf(UTF8Preamble));
-{$ELSE}
-    end;
-{$ENDIF}
     FSeekedToEnd := True;
   end;
   WriteBuffer(Pointer(S)^, Length(S));
@@ -591,11 +567,7 @@ end;
 
 procedure TTextFileWriter.Write(const S: String);
 begin
-{$IFDEF UNICODE}
   DoWrite(UTF8Encode(S), True);
-{$ELSE}
-  DoWrite(S);
-{$ENDIF}
 end;
 
 procedure TTextFileWriter.WriteLine(const S: String);
@@ -603,7 +575,6 @@ begin
   Write(S + #13#10);
 end;
 
-{$IFDEF UNICODE}
 procedure TTextFileWriter.WriteAnsi(const S: AnsiString);
 begin
   DoWrite(S, False);
@@ -613,7 +584,6 @@ procedure TTextFileWriter.WriteAnsiLine(const S: AnsiString);
 begin
   WriteAnsi(S + #13#10);
 end;
-{$ENDIF}
 
 { TFileMapping }
 

+ 0 - 14
Projects/ISPP/IsppFuncs.pas

@@ -1620,7 +1620,6 @@ end;
 
 function GetMD5OfUnicodeString(Ext: Longint; const Params: IIsppFuncParams;
   const FuncResult: IIsppFuncResult): TIsppFuncResult; stdcall;
-{$IFDEF UNICODE}
 var
   S: UnicodeString;
 begin
@@ -1639,12 +1638,6 @@ begin
     end;
   end;
 end;
-{$ELSE}
-begin
-  FuncResult.Error('Cannot call "GetMD5OfUnicodeString" function during non Unicode compilation');
-  Result.Error := ISPPFUNC_FAIL
-end;
-{$ENDIF}
 
 function GetSHA1OfFile(Ext: Longint; const Params: IIsppFuncParams;
   const FuncResult: IIsppFuncResult): TIsppFuncResult; stdcall;
@@ -1703,7 +1696,6 @@ end;
 
 function GetSHA1OfUnicodeString(Ext: Longint; const Params: IIsppFuncParams;
   const FuncResult: IIsppFuncResult): TIsppFuncResult; stdcall;
-{$IFDEF UNICODE}
 var
   S: UnicodeString;
 begin
@@ -1722,12 +1714,6 @@ begin
     end;
   end;
 end;
-{$ELSE}
-begin
-  FuncResult.Error('Cannot call "GetSHA1OfUnicodeString" function during non Unicode compilation');
-  Result.Error := ISPPFUNC_FAIL
-end;
-{$ENDIF}
 
 function TrimFunc(Ext: Longint; const Params: IIsppFuncParams;
   const FuncResult: IIsppFuncResult): TIsppFuncResult; stdcall;

+ 0 - 11
Projects/ISPP/IsppPreprocessor.pas

@@ -1075,20 +1075,14 @@ begin
 end;
 
 procedure TPreprocessor.SaveToFile(const FileName: string);
-{$IFDEF UNICODE}
 var
   S: String;
-{$ENDIF}
 begin
-{$IFDEF UNICODE}
   S := FOutput.Text;
   if SameText(S, String(AnsiString(S))) then
     FOutput.SaveToFile(FileName)
   else
     FOutput.SaveToFile(FileName, TEncoding.UTF8);
-{$ELSE}
-  FOutput.SaveToFile(FileName)
-{$ENDIF}
 end;
 
 function TPreprocessor.CheckFile(const FileName: string): Boolean;
@@ -1404,13 +1398,8 @@ end;
 
 function LookupAlwaysDefined(const Name: string): Boolean;
 const
-{$IFDEF UNICODE}
   AlwaysDefined: array[0..3] of string =
     ('ISPP_INVOKED', 'WINDOWS', '__WIN32__', 'UNICODE');
-{$ELSE}
-  AlwaysDefined: array[0..2] of string =
-    ('ISPP_INVOKED', 'WINDOWS', '__WIN32__');
-{$ENDIF}
 var
   I: Integer;
 begin

+ 1 - 9
Projects/ScriptCompiler.pas

@@ -2,7 +2,7 @@ unit ScriptCompiler;
 
 {
   Inno Setup
-  Copyright (C) 1997-2018 Jordan Russell
+  Copyright (C) 1997-2024 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
 
@@ -363,10 +363,8 @@ begin
     LineLength := FindNewLine(FScriptText, LineStartPosition);
   end;
 
-{$IFDEF UNICODE}
   { Convert Position from the UTF8 encoded ANSI string index to a UTF-16 string index }
   Position := Length(UTF8ToString(Copy(FScriptText, LineStartPosition, Position - 1))) + 1;
-{$ENDIF}
   Col := Position;
 end;
 
@@ -465,11 +463,7 @@ var
 begin
   Result := False;
 
-{$IFDEF UNICODE}
   FScriptText := UTF8Encode(ScriptText);
-{$ELSE}
-  FScriptText := ScriptText;
-{$ENDIF}
 
   for I := 0 to FExports.Count-1 do
     TScriptExport(FExports[I]).Exported := False;
@@ -482,10 +476,8 @@ begin
     PSPascalCompiler.AllowNoBegin := True;
     PSPascalCompiler.AllowNoEnd := True;
     PSPascalCompiler.BooleanShortCircuit := True;
-{$IFDEF UNICODE}
     PSPascalCompiler.AllowDuplicateRegister := False;
     PSPascalCompiler.UTF8Decode := True;
-{$ENDIF}
     PSPascalCompiler.AttributesOpenTokenID := CSTI_Less;
     PSPascalCompiler.AttributesCloseTokenID := CSTI_Greater;
 

+ 5 - 12
Projects/Struct.pas

@@ -2,7 +2,7 @@ unit Struct;
 
 {
   Inno Setup
-  Copyright (C) 1997-2020 Jordan Russell
+  Copyright (C) 1997-2024 Jordan Russell
   Portions by Martijn Laan
   For conditions of distribution and use, see LICENSE.TXT.
 
@@ -33,10 +33,10 @@ const
     this file it's recommended you change SetupID. Any change will do (like
     changing the letters or numbers), as long as your format is
     unrecognizable by the standard Inno Setup. }
-  SetupID: TSetupID = 'Inno Setup Setup Data (6.3.0)'{$IFDEF UNICODE}+' (u)'{$ENDIF};
+  SetupID: TSetupID = 'Inno Setup Setup Data (6.3.0)';
   UninstallLogID: array[Boolean] of TUninstallLogID =
     ('Inno Setup Uninstall Log (b)', 'Inno Setup Uninstall Log (b) 64-bit');
-  MessagesHdrID: TMessagesHdrID = 'Inno Setup Messages (6.0.0)'{$IFDEF UNICODE}+' (u)'{$ENDIF};
+  MessagesHdrID: TMessagesHdrID = 'Inno Setup Messages (6.0.0) (u)';
   MessagesLangOptionsID: TMessagesLangOptionsID = '!mlo!001';
   ZLIBID: TCompID = 'zlb'#26;
   DiskSliceID: TDiskSliceID = 'idska32'#26;
@@ -61,8 +61,7 @@ type
     shAllowUNCPath, shUserInfoPage, shUsePreviousUserInfo,
     shUninstallRestartComputer, shRestartIfNeededByRun, shShowTasksTreeLines,
     shAllowCancelDuringInstall, shWizardImageStretch, shAppendDefaultDirName,
-    shAppendDefaultGroupName, shEncryptionUsed,
-    {$IFNDEF UNICODE}shShowUndisplayableLanguages, {$ENDIF}shSetupLogging,
+    shAppendDefaultGroupName, shEncryptionUsed, shSetupLogging,
     shSignedUninstaller, shUsePreviousLanguage, shDisableWelcomePage,
     shCloseApplications, shRestartApplications, shAllowNetworkDrive,
     shForceCloseApplications, shAppNameHasConsts, shUsePreviousPrivileges,
@@ -94,9 +93,6 @@ type
       AppModifyPath, CreateUninstallRegKey, Uninstallable, CloseApplicationsFilter,
       SetupMutex, ChangesEnvironment, ChangesAssociations: String;
     LicenseText, InfoBeforeText, InfoAfterText, CompiledCodeText: AnsiString;
-{$IFNDEF UNICODE}
-    LeadBytes: set of AnsiChar;
-{$ENDIF}
     NumLanguageEntries, NumCustomMessageEntries, NumPermissionEntries,
       NumTypeEntries, NumComponentEntries, NumTaskEntries, NumDirEntries,
       NumFileEntries, NumFileLocationEntries, NumIconEntries, NumIniEntries,
@@ -137,13 +133,10 @@ const
 type
   PSetupLanguageEntry = ^TSetupLanguageEntry;
   TSetupLanguageEntry = packed record
-{$IFNDEF UNICODE}
-    { Note: LanguageName is Unicode }
-{$ENDIF}
     Name, LanguageName, DialogFontName, TitleFontName, WelcomeFontName,
       CopyrightFontName: String;
     Data, LicenseText, InfoBeforeText, InfoAfterText: AnsiString;
-    LanguageID{$IFNDEF UNICODE}, LanguageCodePage{$ENDIF}: Cardinal;
+    LanguageID: Cardinal;
     DialogFontSize: Integer;
     TitleFontSize: Integer;
     WelcomeFontSize: Integer;