View Issue Details

IDProjectCategoryView StatusLast Update
0035345FPCRTLpublic2020-06-24 13:36
ReporterSerge Anvarov Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Platformx64 
Target Version3.2.0Fixed in Version3.3.1 
Summary0035345: Support for "TStrings" strings larger than 2GB on x64 systems. Patch.
DescriptionPeriodically on the forum the question arises why the TStrings and its descendants are not able to save/load big data on x64 systems.
This patch offers such a solution. Only to put/get the whole value. Item indexes remain within "Integer".
Additional InformationIt is not very complicated, just in a few places there is a replacement of "Integer" to "SizeInt".
Since the functions GetNextLine and GetNextLineBreak have already been defined with "var P: Integer", to avoid errors in old code when compiling on x64, duplicates of functions with Integer are made.
TagsNo tags attached.
Fixed in Revision41852
FPCOldBugId
FPCTarget
Attached Files

Activities

Serge Anvarov

2019-04-08 18:12

reporter  

Strings.x64.diff (3,314 bytes)   
Index: rtl/objpas/classes/classesh.inc
===================================================================
--- rtl/objpas/classes/classesh.inc	(revision 41850)
+++ rtl/objpas/classes/classesh.inc	(working copy)
@@ -663,8 +663,12 @@
     Function GetValueFromIndex(Index: Integer): string;
     Procedure SetValueFromIndex(Index: Integer; const Value: string);
     Procedure CheckSpecialChars;
-    Class Function GetNextLine (Const Value : String; Var S : String; Var P : Integer) : Boolean;
-    Function GetNextLinebreak (Const Value : String; Var S : String; Var P : Integer) : Boolean;
+    Class Function GetNextLine (Const Value : String; Var S : String; Var P : SizeInt) : Boolean;
+    Function GetNextLinebreak (Const Value : String; Var S : String; Var P : SizeInt) : Boolean;
+    {$IF (SizeOf(Integer) < SizeOf(SizeInt)) }
+    class function GetNextLine(const Value: string; var S: string; var P: Integer) : Boolean; deprecated;
+    function GetNextLineBreak(const Value: string; var S: string; var P: Integer) : Boolean; deprecated;
+    {$IFEND}
   public
     constructor Create;
     destructor Destroy; override;
Index: rtl/objpas/classes/stringl.inc
===================================================================
--- rtl/objpas/classes/stringl.inc	(revision 41850)
+++ rtl/objpas/classes/stringl.inc	(working copy)
@@ -325,7 +325,7 @@
 
 
 Procedure TStrings.SetDelimitedText(const AValue: string);
-var i,j:integer;
+var i,j: SizeInt;
     aNotFirst:boolean;
 begin
  CheckSpecialChars;
@@ -542,7 +542,7 @@
 Function TStrings.GetTextStr: string;
 
 Var P : Pchar;
-    I,L,NLS : Longint;
+    I,L,NLS : SizeInt;
     S,NL : String;
 
 begin
@@ -608,11 +608,11 @@
   // Empty.
 end;
 
-Class Function TStrings.GetNextLine (Const Value : String; Var S : String; Var P : Integer) : Boolean;
+Class Function TStrings.GetNextLine (Const Value : String; Var S : String; Var P : SizeInt) : Boolean;
 
 Var 
   PS : PChar;
-  IP,L : Integer;
+  IP,L : SizeInt;
   
 begin
   L:=Length(Value);
@@ -642,7 +642,7 @@
   Result:=True;
 end;
 
-Function TStrings.GetNextLineBreak (Const Value : String; Var S : String; Var P : Integer) : Boolean;
+Function TStrings.GetNextLineBreak (Const Value : String; Var S : String; Var P : SizeInt) : Boolean;
 
 Var
   PS,PC,PP : PChar;
@@ -663,11 +663,31 @@
   Result:=True;
 end;
 
+{$IF (SizeOf(Integer) < SizeOf(SizeInt)) }
+class function TStrings.GetNextLine(const Value: string; var S: string; var P: Integer) : Boolean;
+var
+  LP: SizeInt;
+begin
+  LP := P;
+  Result := GetNextLine(Value, S, LP);
+  P := LP;
+end;
+
+function TStrings.GetNextLineBreak(const Value: string; var S: string; var P: Integer) : Boolean;
+var
+  LP: SizeInt;
+begin
+  LP := P;
+  Result := GetNextLineBreak(Value, S, LP);
+  P := LP;
+end;
+{$IFEND}
+
 Procedure TStrings.DoSetTextStr(const Value: string; DoClear : Boolean);
 
 Var
   S : String;
-  P : Integer;
+  P : SizeInt;
 
 begin
   Try
@@ -1037,7 +1057,7 @@
   Buffer     : AnsiString;
   BytesRead,
   BufLen,
-  I,BufDelta     : Longint;
+  I,BufDelta     : SizeInt;
 begin
   if not IgnoreEncoding then
     begin
@@ -1082,7 +1102,7 @@
   T              : string;
   BytesRead,
   BufLen,
-  I,BufDelta,
+  I,BufDelta: SizeInt;
   PreambleLength : Longint;
 begin
   // reread into a buffer
Strings.x64.diff (3,314 bytes)   

Michael Van Canneyt

2019-04-09 11:17

administrator   ~0115344

Checked and applied, thank you!

Serge Anvarov

2020-06-24 13:36

reporter   ~0123569

In 3.2.0

Issue History

Date Modified Username Field Change
2019-04-08 18:12 Serge Anvarov New Issue
2019-04-08 18:12 Serge Anvarov File Added: Strings.x64.diff
2019-04-08 19:26 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-04-08 19:26 Michael Van Canneyt Status new => assigned
2019-04-09 11:17 Michael Van Canneyt Fixed in Revision => 41852
2019-04-09 11:17 Michael Van Canneyt Note Added: 0115344
2019-04-09 11:17 Michael Van Canneyt Status assigned => resolved
2019-04-09 11:17 Michael Van Canneyt Fixed in Version => 3.3.1
2019-04-09 11:17 Michael Van Canneyt Resolution open => fixed
2019-04-09 11:17 Michael Van Canneyt Target Version => 3.2.0
2020-06-24 13:36 Serge Anvarov Status resolved => closed
2020-06-24 13:36 Serge Anvarov Note Added: 0123569