Browse Source

* fcl-db/dbase: fix Dbase3,4,7 zero content memo fields

git-svn-id: trunk@24363 -
reiniero 12 năm trước cách đây
mục cha
commit
3486661512
2 tập tin đã thay đổi với 10 bổ sung2 xóa
  1. 2 2
      packages/fcl-db/src/dbase/dbf.pas
  2. 8 0
      packages/fcl-db/src/dbase/dbf_memo.pas

+ 2 - 2
packages/fcl-db/src/dbase/dbf.pas

@@ -2084,9 +2084,9 @@ begin
   end;
   { this is a hack, we actually need to know per user who's modifying, and who is not }
   { Mode is more like: the mode of the last "creation" }
-  { if create/free is nested, then everything will be alright, i think ;-) }
+  { if create/free is nested, then everything will be alright, I think ;-) }
   lBlob.Mode := Mode;
-  { this is a hack: we actually need to know per user what it's position is }
+  { this is a hack: we actually need to know per user what its position is }
   lBlob.Position := 0;
   Result := lBlob;
 end;

+ 8 - 0
packages/fcl-db/src/dbase/dbf_memo.pas

@@ -218,6 +218,7 @@ begin
 
     RecordSize := GetBlockLen;
     // checking for right blocksize not needed for foxpro?
+    // todo: why exactly are we testing for 0x7F?
     // mod 128 <> 0 <-> and 0x7F <> 0
     if (RecordSize = 0) and
       ((FDbfVersion in [xFoxPro,xVisualFoxPro]) or ((RecordSize and $7F) <> 0)) then
@@ -226,6 +227,12 @@ begin
       //http://technet.microsoft.com/en-us/subscriptions/d6e1ah7y%28v=vs.90%29.aspx
       RecordSize := 64;
       WriteHeader;
+    end
+    else if (RecordSize = 0) then
+    begin
+      SetBlockLen(512); //dbase default
+      RecordSize := 512;
+      WriteHeader;
     end;
 
     // get memory for temporary buffer
@@ -470,6 +477,7 @@ function  TDbaseMemoFile.GetMemoSize: Integer;
 begin
   // dBase4 memofiles contain a small 'header'
   if (FDbfVersion<>xBaseIII) and (PInteger(@FBuffer[0])^ = Integer(SwapIntLE($0008FFFF))) then
+    // Subtract size of the block header itself:
     Result := SwapIntLE(PBlockHdr(FBuffer)^.MemoSize)-8
   else
     Result := -1;