Переглянути джерело

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

git-svn-id: trunk@24363 -
reiniero 12 роки тому
батько
коміт
3486661512

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

@@ -2084,9 +2084,9 @@ begin
   end;
   end;
   { this is a hack, we actually need to know per user who's modifying, and who is not }
   { 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" }
   { 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;
   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;
   lBlob.Position := 0;
   Result := lBlob;
   Result := lBlob;
 end;
 end;

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

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