Explorar el Código

Bit of UNICODE cleanup.

Martijn Laan hace 1 año
padre
commit
775b61f2a1
Se han modificado 4 ficheros con 25 adiciones y 67 borrados
  1. 2 30
      Components/ScintEdit.pas
  2. 4 5
      Projects/CompForm.pas
  3. 17 28
      Projects/Compile.pas
  4. 2 4
      Projects/DebugStruct.pas

+ 2 - 30
Components/ScintEdit.pas

@@ -25,7 +25,7 @@ type
   TScintEditCharAddedEvent = procedure(Sender: TObject; Ch: AnsiChar) of object;
   TScintEditDropFilesEvent = procedure(Sender: TObject; X, Y: Integer;
     AFiles: TStrings) of object;
-  TScintHintInfo = {$IFDEF UNICODE} Controls. {$ENDIF} THintInfo;
+  TScintHintInfo = Controls.THintInfo;
   TScintEditHintShowEvent = procedure(Sender: TObject;
     var Info: TScintHintInfo) of object;
   TScintEditMarginClickEvent = procedure(Sender: TObject; MarginNumber: Integer;
@@ -43,7 +43,7 @@ type
     StartPos, EndPos: Integer;
   end;
   TScintRawCharSet = set of AnsiChar;
-  TScintRawString = type {$IFDEF UNICODE} RawByteString {$ELSE} AnsiString {$ENDIF};
+  TScintRawString = type RawByteString;
   TScintRectangle = record
     Left, Top, Right, Bottom: Integer;
   end;
@@ -327,9 +327,6 @@ type
   protected
     procedure CheckIndexRange(const Index: Integer);
     procedure CheckIndexRangePlusOne(const Index: Integer);
-{$IFNDEF UNICODE}
-    class procedure Error(Msg: PResStringRec; Data: Integer);
-{$ENDIF}
     function Get(Index: Integer): String; override;
     function GetCount: Integer; override;
     function GetTextStr: String; override;
@@ -552,7 +549,6 @@ begin
 end;
 
 function TScintEdit.ConvertRawStringToString(const S: TScintRawString): String;
-{$IFDEF UNICODE}
 var
   SrcLen, DestLen: Integer;
   DestStr: UnicodeString;
@@ -569,22 +565,14 @@ begin
   end;
   Result := DestStr;
 end;
-{$ELSE}
-begin
-  Result := S;
-end;
-{$ENDIF}
 
 function TScintEdit.ConvertPCharToRawString(const Text: PChar;
   const TextLen: Integer): TScintRawString;
 var
-{$IFDEF UNICODE}
   DestLen: Integer;
-{$ENDIF}
   DestStr: TScintRawString;
 begin
   if TextLen > 0 then begin
-{$IFDEF UNICODE}
     DestLen := WideCharToMultiByte(FCodePage, 0, Text, TextLen, nil, 0, nil, nil);
     if DestLen <= 0 then
       Error('WideCharToMultiByte failed');
@@ -592,20 +580,13 @@ begin
     if WideCharToMultiByte(FCodePage, 0, Text, TextLen, @DestStr[1], Length(DestStr),
        nil, nil) <> DestLen then
       Error('Unexpected result from WideCharToMultiByte');
-{$ELSE}
-    SetString(DestStr, Text, TextLen);
-{$ENDIF}
   end;
   Result := DestStr;
 end;
 
 function TScintEdit.ConvertStringToRawString(const S: String): TScintRawString;
 begin
-{$IFDEF UNICODE}
   Result := ConvertPCharToRawString(PChar(S), Length(S));
-{$ELSE}
-  Result := S;
-{$ENDIF}
 end;
 
 procedure TScintEdit.CopyToClipboard;
@@ -1015,11 +996,9 @@ end;
 procedure TScintEdit.InitRawString(var S: TScintRawString; const Len: Integer);
 begin
   SetString(S, nil, Len);
-{$IFDEF UNICODE}
   //experimental, dont need this ATM:
   if FCodePage <> 0 then
     System.SetCodePage(RawByteString(S), FCodePage, False);
-{$ENDIF}
 end;
 
 function TScintEdit.IsPositionInViewVertically(const Pos: Integer): Boolean;
@@ -1863,13 +1842,6 @@ begin
   FEdit.ReplaceRawTextRange(StartPos, EndPos, '');
 end;
 
-{$IFNDEF UNICODE}
-class procedure TScintEditStrings.Error(Msg: PResStringRec; Data: Integer);
-begin
-  TList.Error(LoadResString(Msg), Data);
-end;
-{$ENDIF}
-
 function TScintEditStrings.Get(Index: Integer): String;
 begin
   Result := FEdit.ConvertRawStringToString(GetRawLine(Index));

+ 4 - 5
Projects/CompForm.pas

@@ -3874,11 +3874,10 @@ procedure TCompileForm.MemoHintShow(Sender: TObject; var Info: TScintHintInfo);
     S: TScintRawString;
     U: String;
   begin
-    { On the Unicode build, [Code] lines get converted from the editor's
-      UTF-8 to UTF-16 Strings when passed to the compiler. This can lead to
-      column number discrepancies between Scintilla and ROPS. This code
-      simulates the conversion to try to find out where ROPS thinks a Pos
-      resides. }
+    { [Code] lines get converted from the editor's UTF-8 to UTF-16 Strings when
+      passed to the compiler. This can lead to column number discrepancies
+      between Scintilla and ROPS. This code simulates the conversion to try to
+      find out where ROPS thinks a Pos resides. }
     LinePos := FActiveMemo.GetPositionFromLine(FActiveMemo.GetLineFromPosition(Pos));
     S := FActiveMemo.GetRawTextRange(LinePos, Pos);
     U := FActiveMemo.ConvertRawStringToString(S);

+ 17 - 28
Projects/Compile.pas

@@ -8589,7 +8589,22 @@ begin
 
     { Read languages:
 
-      Non Unicode:
+      0. Determine final code pages:
+      Unicode Setup uses Unicode text and does not depend on the system code page. To
+      provide Setup with Unicode text without requiring Unicode .isl files (but still
+      supporting Unicode .iss, license and info files), the compiler converts the .isl
+      files to Unicode during compilation. It also does this if it finds ANSI plain text
+      license and info files. To be able to do this it needs to know the language's code
+      page but as seen above it can't simply take this from the current .isl. And license
+      and info files do not even have a language code page setting.
+
+      This means the Unicode compiler has to do an extra phase: following the logic above
+      it first determines the final language code page for each language, storing these
+      into an extra list called PreDataList, and then it continues as normal while using
+      the final language code page for any conversions needed.
+
+      Note: it must avoid caching the .isl files while determining the code pages, since
+      the conversion is done *before* the caching.
 
       1. Read Default.isl messages:
 
@@ -8645,33 +8660,7 @@ begin
       4. Check 'language completeness' of custom message constants:
       CheckCustomMessageDefinitions is used to check for missing custom messages and
       where necessary it 'promotes' a custom message by resetting its LangIndex property
-      to -1.
-
-      5. Display the language at run time:
-      Setup checks if the system code page matches the language code page, and only shows
-      the language if it does. The system code page is then used to display all text, this
-      does not only include messages and custom messages, but also any readme and info files.
-
-      Unicode:
-
-      Unicode works exactly like above with one exception:
-
-      0. Determine final code pages:
-      Unicode Setup uses Unicode text and does not depend on the system code page. To
-      provide Setup with Unicode text without requiring Unicode .isl files (but still
-      supporting Unicode .iss, license and info files), the compiler converts the .isl
-      files to Unicode during compilation. It also does this if it finds ANSI plain text
-      license and info files. To be able to do this it needs to know the language's code
-      page but as seen above it can't simply take this from the current .isl. And license
-      and info files do not even have a language code page setting.
-
-      This means the Unicode compiler has to do an extra phase: following the logic above
-      it first determines the final language code page for each language, storing these
-      into an extra list called PreDataList, and then it continues as normal while using
-      the final language code page for any conversions needed.
-
-      Note: it must avoid caching the .isl files while determining the code pages, since
-      the conversion is done *before* the caching. }
+      to -1. }
 
     { 0. Determine final language code pages }
     AddStatus(SCompilerStatusDeterminingCodePages);

+ 2 - 4
Projects/DebugStruct.pas

@@ -2,7 +2,7 @@ unit DebugStruct;
 
 {
   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.
 
@@ -101,11 +101,9 @@ function GetThreadTopWindow: HWND;
 function SendCopyDataMessage(DestWnd, SourceWnd: HWND; CopyDataMsg: DWORD;
   Data: Pointer; Size: Cardinal): LRESULT;
 function SendCopyDataMessageStr(DestWnd, SourceWnd: HWND; CopyDataMsg: DWORD;
-  Data: AnsiString): LRESULT;{$IFDEF UNICODE} overload;{$ENDIF}
-{$IFDEF UNICODE}
+  Data: AnsiString): LRESULT; overload;
 function SendCopyDataMessageStr(DestWnd, SourceWnd: HWND; CopyDataMsg: DWORD;
   Data: UnicodeString): LRESULT; overload;
-{$ENDIF}
 
 implementation