diff --git a/components/lazutils/integerlist.pas b/components/lazutils/integerlist.pas index f244bdba39..c1d9c3ef33 100644 --- a/components/lazutils/integerlist.pas +++ b/components/lazutils/integerlist.pas @@ -22,6 +22,16 @@ uses type + TByteList = class(specialize TFPGList) + public + procedure Sort; overload; + end; + + TCardinalList = class(specialize TFPGList) + public + procedure Sort; overload; + end; + TIntegerList = class(specialize TFPGList) public procedure Sort; overload; @@ -35,6 +45,16 @@ type implementation +function CompareByte(const Item1, Item2: Byte): Integer; +begin + Result := Item1 - Item2; +end; + +function CompareCardinal(const Item1, Item2: Cardinal): Integer; +begin + Result := Item1 - Item2; +end; + function CompareInteger(const Item1, Item2: Integer): Integer; begin Result := Item1 - Item2; @@ -45,6 +65,20 @@ begin Result := Item1 - Item2; end; +{ TByteList } + +procedure TByteList.Sort; +begin + inherited Sort(@CompareByte); +end; + +{ TCardinalList } + +procedure TCardinalList.Sort; +begin + inherited Sort(@CompareCardinal); +end; + { TIntegerList } procedure TIntegerList.Sort; diff --git a/components/synedit/synmacrorecorder.pas b/components/synedit/synmacrorecorder.pas index 045dc853ec..7e9ac7e190 100644 --- a/components/synedit/synmacrorecorder.pas +++ b/components/synedit/synmacrorecorder.pas @@ -837,7 +837,7 @@ end; procedure TCustomSynMacroRecorder.SetAsString(const Value: string); var - i, p, Cmd : Integer; + i, p, Cmd : Longint; S : TStrings; cmdStr : string; iEvent: TSynMacroEvent; @@ -853,9 +853,10 @@ begin begin cmdStr := Trim(S[i]); p := Pos(' ', cmdStr); - if p = 0 then p := Length(cmdStr)+1; + if p = 0 then + p := Length(cmdStr)+1; Cmd := ecNone; - if IdentToEditorCommand(Copy(cmdStr, 1, p-1), Longint(Cmd)) then // D2 needs type-cast + if IdentToEditorCommand(Copy(cmdStr, 1, p-1), Cmd) then begin Delete(cmdStr, 1, p); iEvent := CreateMacroEvent(TSynEditorCommand(Cmd)); diff --git a/ide/compiler.pp b/ide/compiler.pp index 6623454d14..2027f69fe8 100644 --- a/ide/compiler.pp +++ b/ide/compiler.pp @@ -1335,7 +1335,7 @@ begin MinOrigLine := MaxInt; for i := 0 to aStrings.Count-1 do begin - OriLine := Integer({%H-}PtrUInt(Pointer(aStrings.Objects[i]))); + OriLine := Integer({%H-}PtrUInt(aStrings.Objects[i])); if (OriLine > -1) and (OriLine < MinOrigLine) then begin MinOrigLine := OriLine; diff --git a/ide/frames/compiler_messages_options.pas b/ide/frames/compiler_messages_options.pas index 3f17095e63..3132dc7945 100644 --- a/ide/frames/compiler_messages_options.pas +++ b/ide/frames/compiler_messages_options.pas @@ -50,7 +50,7 @@ var MsgId: Integer; begin if (Index < 0) or (Index >= chklistCompMsg.Items.Count) then exit; - MsgId:=Integer({%H-}PtrUInt(Pointer(chklistCompMsg.Items.Objects[Index]))); + MsgId:=Integer({%H-}PtrUInt(chklistCompMsg.Items.Objects[Index])); if MsgId<=0 then exit; if chklistCompMsg.Checked[Index] then begin // show message, this is the default diff --git a/ide/mouseactiondialog.pas b/ide/mouseactiondialog.pas index 7bc2b77cdc..3ef17438d6 100644 --- a/ide/mouseactiondialog.pas +++ b/ide/mouseactiondialog.pas @@ -215,7 +215,7 @@ var i: Integer; begin OptBox.Items.Clear; - ACmd := TSynEditorMouseCommand({%H-}PtrUInt(Pointer(ActionBox.items.Objects[ActionBox.ItemIndex]))); + ACmd := TSynEditorMouseCommand({%H-}PtrUInt(ActionBox.items.Objects[ActionBox.ItemIndex])); if ACmd = emcSynEditCommand then begin OptBox.Enabled := True; OptBox.Clear; @@ -331,7 +331,7 @@ begin if OptBox.Enabled then begin if MAct.Command = emcSynEditCommand then begin - MAct.Option := TSynEditorMouseCommandOpt({%H-}PtrUInt(Pointer(OptBox.Items.Objects[OptBox.ItemIndex]))); + MAct.Option := TSynEditorMouseCommandOpt({%H-}PtrUInt(OptBox.Items.Objects[OptBox.ItemIndex])); end else MAct.Option := OptBox.ItemIndex; diff --git a/lcl/include/intfbasewinapi.inc b/lcl/include/intfbasewinapi.inc index 40e32361d9..2a06a1c319 100644 --- a/lcl/include/intfbasewinapi.inc +++ b/lcl/include/intfbasewinapi.inc @@ -423,40 +423,38 @@ var Result := (Flags and DT_NoPrefix) = DT_NoPrefix; end; - function Breakable(Breaks : TList; Index : Integer) : Boolean; + function Breakable(Breaks : TIntegerList; Index : Integer) : Boolean; begin If not Assigned(Breaks) then exit(false); - Result := Breaks.IndexOf(Pointer(PtrInt(Index))) <> -1; + Result := Breaks.IndexOf(Index) <> -1; end; - function NextBreakable(Breaks : TList; Index : Integer) : Integer; + function NextBreakable(Breaks : TIntegerList; Index : Integer) : Integer; begin Result := -1; - If (not Assigned(Breaks)) or - (not Breakable(Breaks,Index)) - then + If (not Assigned(Breaks)) or (not Breakable(Breaks,Index)) then exit; - If Breaks.IndexOf(Pointer(PtrInt(Index))) >= Breaks.Count - 1 then + If Breaks.IndexOf(Index) >= Breaks.Count - 1 then exit; - Result := integer(PtrUInt(Breaks[Breaks.IndexOf(Pointer(PtrInt(Index))) + 1])); + Result := Breaks[Breaks.IndexOf(Index) + 1]; end; - function GetBreakablePoints(const Source : String) : TList; + function GetBreakablePoints(const Source : String) : TIntegerList; var I : Integer; begin - Result := TList.Create; - If Length(Source) < 1 then + Result := TIntegerList.Create; + If Source = '' then exit; For I := 1 to Length(Source) do If Source[I] = ' ' then If not Breakable(Result, I) then - Result.Add(Pointer(PtrInt(I))); + Result.Add(I); If not Breakable(Result, Length(Source)) then - Result.Add(Pointer(PtrInt(Length(Source)))); + Result.Add(Length(Source)); If not Breakable(Result, 0) then - Result.Insert(0,nil); + Result.Insert(0,-1); end; function TextExtent(Handle : hDC; const Source : String) : TSize; @@ -495,7 +493,7 @@ var function BreakString(const Source : String) : TStrings; var I, FromPos, ToPos : Integer; - Breaks : TList; + Breaks : TIntegerList; begin Result := TStringList.Create; Breaks := GetBreakablePoints(Source); diff --git a/lcl/interfacebase.pp b/lcl/interfacebase.pp index 9f7a7a5006..c15f6002ef 100644 --- a/lcl/interfacebase.pp +++ b/lcl/interfacebase.pp @@ -29,7 +29,7 @@ interface uses Types, Classes, SysUtils, Math, FPImage, // LazUtils - LazUTF8, + LazUTF8, IntegerList, // LCL LCLType, LCLProc, LMessages, LCLPlatformDef, GraphType, GraphMath, IntfGraphics, Themes; diff --git a/lcl/interfaces/gtk2/gtk2int.pas b/lcl/interfaces/gtk2/gtk2int.pas index 30e6ab62c9..c33c0ca355 100644 --- a/lcl/interfaces/gtk2/gtk2int.pas +++ b/lcl/interfaces/gtk2/gtk2int.pas @@ -39,7 +39,7 @@ uses {$EndIf} gdk2pixbuf, gtk2, gdk2, glib2, Pango, // LazUtils - LazFileUtils, LazUTF8, DynHashArray, Maps, + LazFileUtils, LazUTF8, DynHashArray, Maps, IntegerList, // LCL Dialogs, Controls, Forms, LCLStrConsts, LMessages, LCLProc, LCLIntf, LCLType, GraphType, GraphMath, diff --git a/lcl/interfaces/gtk2/gtk2widgetset.inc b/lcl/interfaces/gtk2/gtk2widgetset.inc index cd8501c911..f9d7384327 100644 --- a/lcl/interfaces/gtk2/gtk2widgetset.inc +++ b/lcl/interfaces/gtk2/gtk2widgetset.inc @@ -6304,7 +6304,7 @@ var end; var - LinesList: TFPList; + LinesList: TIntegerList; LineStart, LineEnd, LineLen: integer; ArraySize, TotalSize: integer; i: integer; @@ -6317,15 +6317,15 @@ begin exit; end; InitFont; - LinesList:=TFPList.Create; + LinesList:=TIntegerList.Create; LineStart:=0; // find all line starts and line ends repeat - LinesList.Add({%H-}Pointer(PtrInt(LineStart))); + LinesList.Add(LineStart); // find line end LineEnd:=FindLineEnd(LineStart); - LinesList.Add({%H-}Pointer(PtrInt(LineEnd))); + LinesList.Add(LineEnd); // find next line start LineStart:=LineEnd; if AText[LineStart] in [#10,#13] then begin @@ -6348,7 +6348,7 @@ begin i:=0; while i0 then Move(AText[LineStart],CurLineStart^,LineLen); diff --git a/lcl/interfaces/gtk2/gtk2winapi.inc b/lcl/interfaces/gtk2/gtk2winapi.inc index fedd69aecf..7cc3025935 100644 --- a/lcl/interfaces/gtk2/gtk2winapi.inc +++ b/lcl/interfaces/gtk2/gtk2winapi.inc @@ -3324,7 +3324,8 @@ var StylesCount: Integer; StylesList: TStringList; y: Integer; - CharsetList: TFPList; + CharsetList: TByteList; + CS: Byte; function Gtk2GetFontFamiliesDefault(var AList: TStringList): Integer; var @@ -3507,11 +3508,12 @@ begin FontType := TRUETYPE_FONTTYPE; FontList := TStringList.Create; StylesList := TStringList.Create; - CharsetList := TFPList.Create; + CharsetList := TByteList.Create; for i := 0 to CharsetEncodingList.Count - 1 do begin - if CharsetList.IndexOf({%H-}Pointer(PtrUInt(TCharSetEncodingRec(CharsetEncodingList.Items[i]^).CharSet))) = -1 then - CharsetList.Add({%H-}Pointer(PtrUInt(TCharSetEncodingRec(CharsetEncodingList.Items[i]^).CharSet))); + CS := TCharSetEncodingRec(CharsetEncodingList.Items[i]^).CharSet; + if CharsetList.IndexOf(CS) = -1 then + CharsetList.Add(CS); end; try if Gtk2GetFontFamilies(FontList, lpLogFont^.lfPitchAndFamily, @@ -3528,7 +3530,7 @@ begin EnumLogFont.elfStyle := AStyle; if CharSetList.Count > 0 then - EnumLogFont.elfLogFont.lfCharSet := {%H-}PtrUInt(CharsetList.Items[0]); + EnumLogFont.elfLogFont.lfCharSet := CharsetList.Items[0]; Result := Callback(EnumLogFont, Metric, FontType, LParam); for y := 1 to StylesCount - 1 do @@ -3539,7 +3541,7 @@ begin end; for y := 1 to CharSetList.Count - 1 do begin - EnumLogFont.elfLogFont.lfCharSet := {%H-}PtrUInt(CharsetList.Items[y]); + EnumLogFont.elfLogFont.lfCharSet := CharsetList.Items[y]; Result := Callback(EnumLogFont, Metric, FontType, LParam); end; end; diff --git a/lcl/interfaces/gtk3/gtk3int.pas b/lcl/interfaces/gtk3/gtk3int.pas index 2c490e451d..fd911f91a2 100644 --- a/lcl/interfaces/gtk3/gtk3int.pas +++ b/lcl/interfaces/gtk3/gtk3int.pas @@ -26,7 +26,7 @@ uses {$ENDIF} SysUtils, Classes, types, // LazUtils - LazUTF8, Translations, + LazUTF8, Translations, IntegerList, // LCL LCLPlatformDef, InterfaceBase, LCLProc, LCLStrConsts, LCLType, LMessages, Controls, Forms, FPImage, Graphics, GraphUtil, GraphType, IntfGraphics, diff --git a/lcl/interfaces/gtk3/gtk3objects.pas b/lcl/interfaces/gtk3/gtk3objects.pas index 3cdd352548..4ff378179f 100644 --- a/lcl/interfaces/gtk3/gtk3objects.pas +++ b/lcl/interfaces/gtk3/gtk3objects.pas @@ -21,7 +21,7 @@ unit gtk3objects; interface uses - Classes, SysUtils, Graphics, types, LCLType, LCLProc, LazUTF8, + Classes, SysUtils, Graphics, types, LCLType, LCLProc, LazUTF8, IntegerList, LazGtk3, LazGdk3, LazGObject2, LazPango1, LazPangoCairo1, LazGdkPixbuf2, LazGLib2, LazCairo1, FPCanvas; @@ -2057,7 +2057,7 @@ var end; var - LinesList: TFPList; + LinesList: TIntegerList; LineStart, LineEnd, LineLen: integer; ArraySize, TotalSize: integer; i: integer; @@ -2071,15 +2071,15 @@ begin exit; end; InitFont; - LinesList:=TFPList.Create; + LinesList:=TIntegerList.Create; LineStart:=0; // find all line starts and line ends repeat - LinesList.Add({%H-}Pointer(PtrInt(LineStart))); + LinesList.Add(LineStart); // find line end LineEnd:=FindLineEnd(LineStart); - LinesList.Add({%H-}Pointer(PtrInt(LineEnd))); + LinesList.Add(LineEnd); // find next line start LineStart:=LineEnd; if AText[LineStart] in [#10,#13] then @@ -2106,7 +2106,7 @@ begin while i0 then Move(AText[LineStart],CurLineStart^,LineLen); diff --git a/lcl/interfaces/gtk3/gtk3winapi.inc b/lcl/interfaces/gtk3/gtk3winapi.inc index b071b95a8a..80c1958c5b 100644 --- a/lcl/interfaces/gtk3/gtk3winapi.inc +++ b/lcl/interfaces/gtk3/gtk3winapi.inc @@ -1122,7 +1122,8 @@ var StylesCount: Integer; StylesList: TStringList; y: Integer; - CharsetList: TFPList; + CharsetList: TByteList; + CS: Byte; function Gtk3GetFontFamiliesDefault(var AList: TStringList): Integer; var @@ -1305,11 +1306,12 @@ begin FontType := TRUETYPE_FONTTYPE; FontList := TStringList.Create; StylesList := TStringList.Create; - CharsetList := TFPList.Create; + CharsetList := TByteList.Create; for i := 0 to CharsetEncodingList.Count - 1 do begin - if CharsetList.IndexOf({%H-}Pointer(PtrUInt(TCharSetEncodingRec(CharsetEncodingList.Items[i]^).CharSet))) = -1 then - CharsetList.Add({%H-}Pointer(PtrUInt(TCharSetEncodingRec(CharsetEncodingList.Items[i]^).CharSet))); + CS := TCharSetEncodingRec(CharsetEncodingList.Items[i]^).CharSet; + if CharsetList.IndexOf(CS) = -1 then + CharsetList.Add(CS); end; try if Gtk3GetFontFamilies(FontList, lpLogFont^.lfPitchAndFamily, @@ -1321,12 +1323,11 @@ begin EnumLogFont.elfLogFont.lfPitchAndFamily := lpLogFont^.lfPitchAndFamily; EnumLogFont.elfFullName := FontList[i]; - StylesCount := FillLogFontA(i, EnumLogFont.elfLogFont, Metric, FontType, - AStyle); + StylesCount := FillLogFontA(i, EnumLogFont.elfLogFont, Metric, FontType, AStyle); EnumLogFont.elfStyle := AStyle; if CharSetList.Count > 0 then - EnumLogFont.elfLogFont.lfCharSet := {%H-}PtrUInt(CharsetList.Items[0]); + EnumLogFont.elfLogFont.lfCharSet := CharsetList.Items[0]; Result := Callback(EnumLogFont, Metric, FontType, LParam); for y := 1 to StylesCount - 1 do @@ -1337,7 +1338,7 @@ begin end; for y := 1 to CharSetList.Count - 1 do begin - EnumLogFont.elfLogFont.lfCharSet := {%H-}PtrUInt(CharsetList.Items[y]); + EnumLogFont.elfLogFont.lfCharSet := CharsetList.Items[y]; Result := Callback(EnumLogFont, Metric, FontType, LParam); end; end; diff --git a/tools/iconvtable.pas b/tools/iconvtable.pas index a07f0a1b23..b6ed008724 100644 --- a/tools/iconvtable.pas +++ b/tools/iconvtable.pas @@ -108,17 +108,12 @@ begin end; var - i: Integer; - Filename1, Filename2: String; SL: TStringListUTF8; - FromEncoding: String; - ToEncoding: String; + Filename1, Filename2: String; + FromEncoding, ToEncoding: String; s: String; - UniCode: integer; - CharLen: integer; - j: Integer; - TableIndex: LongInt; - k: Integer; + UniCode: Cardinal; + TableIndex, CharLen, i, j, k: Integer; begin // single byte to UTF-8 if ParamCount=0 then @@ -200,7 +195,7 @@ begin ' TableIndex[i]=',TableIndex, ' TableIndex[i+j]=',StrToTableIndex(SortedTable[i+j]), '');} - if integer(UTF8CharacterToUnicode(@SortedTable[i+j][1],CharLen))<>UniCode+j then + if UTF8CharacterToUnicode(@SortedTable[i+j][1],CharLen)<>UniCode+j then break; if StrToTableIndex(SortedTable[i+j])<>TableIndex+j then break;