Browse Source

* remove phistrec usage

peter 20 years ago
parent
commit
a1a644cbb5
1 changed files with 33 additions and 40 deletions
  1. 33 40
      fv/histlist.pas

+ 33 - 40
fv/histlist.pas

@@ -156,8 +156,8 @@ PROCEDURE StoreHistory (Var S: TStream);
 {                 INITIALIZED DOS/DPMI/WIN/NT/OS2 VARIABLES                 }
 {                 INITIALIZED DOS/DPMI/WIN/NT/OS2 VARIABLES                 }
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
 CONST
 CONST
-   HistorySize: Word = 64*1024;                       { Maximum history size }
-   HistoryUsed: LongInt = 0;                          { History used }
+   HistorySize: sw_integer = 64*1024;                    { Maximum history size }
+   HistoryUsed: sw_integer = 0;                          { History used }
    HistoryBlock: Pointer = Nil;                       { Storage block }
    HistoryBlock: Pointer = Nil;                       { Storage block }
 
 
 {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
 {<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>}
@@ -169,19 +169,12 @@ CONST
 {***************************************************************************}
 {***************************************************************************}
 
 
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
-{                       THistRec RECORD DEFINITION                          }
-{---------------------------------------------------------------------------}
-TYPE
-   THistRec =
-{$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
-   PACKED
-{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
-   RECORD
-     Zero: byte;                                      { Start marker }
-     Id  : byte;                                      { History id }
-     Str : String;                                    { History string }
-   END;
-   PHistRec = ^THistRec;                              { History record ptr }
+{                       THistRec RECORD DEFINITION
+
+   Zero  1 byte, start marker
+   Id    1 byte, History id
+   <shortstring>   1 byte length+string data, Contents
+}
 
 
 {***************************************************************************}
 {***************************************************************************}
 {                      UNINITIALIZED PRIVATE VARIABLES                      }
 {                      UNINITIALIZED PRIVATE VARIABLES                      }
@@ -218,7 +211,7 @@ BEGIN
    Dec(P, 2);                                         { Correct position }
    Dec(P, 2);                                         { Correct position }
    Inc(P2, PByte(P2)^+1);                             { Next hist record }
    Inc(P2, PByte(P2)^+1);                             { Next hist record }
    { Shuffle history }
    { Shuffle history }
-   Move(P2^, P^, cardinal(HistoryBlock) + HistoryUsed - cardinal(P2) );
+   Move(P2^, P^, Pointer(HistoryBlock) + HistoryUsed - Pointer(P2) );
    Dec(HistoryUsed, Len);                             { Adjust history used }
    Dec(HistoryUsed, Len);                             { Adjust history used }
 END;
 END;
 
 
@@ -226,23 +219,24 @@ END;
 {  AdvanceStringPtr -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB  }
 {  AdvanceStringPtr -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB  }
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
 PROCEDURE AdvanceStringPtr;
 PROCEDURE AdvanceStringPtr;
-VAR P: PHistRec;
+VAR P: PChar;
 BEGIN
 BEGIN
    While (CurString <> Nil) Do Begin
    While (CurString <> Nil) Do Begin
-     If (cardinal(CurString) >= cardinal(HistoryBlock) + HistoryUsed) Then Begin{ Last string check }
+     If (Pointer(CurString) >= Pointer(HistoryBlock) + HistoryUsed) Then Begin{ Last string check }
        CurString := Nil;                              { Clear current string }
        CurString := Nil;                              { Clear current string }
        Exit;                                          { Now exit }
        Exit;                                          { Now exit }
      End;
      End;
      Inc(PChar(CurString), PByte(CurString)^+1);      { Move to next string }
      Inc(PChar(CurString), PByte(CurString)^+1);      { Move to next string }
-     If (cardinal(CurString) >= cardinal(HistoryBlock) + HistoryUsed) Then Begin{ Last string check }
+     If (Pointer(CurString) >= Pointer(HistoryBlock) + HistoryUsed) Then Begin{ Last string check }
        CurString := Nil;                              { Clear current string }
        CurString := Nil;                              { Clear current string }
        Exit;                                          { Now exit }
        Exit;                                          { Now exit }
      End;
      End;
-     P := PHistRec(CurString);                        { Transfer record ptr }
+     P := PChar(CurString);                        { Transfer record ptr }
      Inc(PChar(CurString), 2);                        { Move to string }
      Inc(PChar(CurString), 2);                        { Move to string }
-     if (P^.Zero<>0) then
+     if (P^<>#0) then
        RunError(215);
        RunError(215);
-     If (P^.Id = CurId) Then Exit;                    { Found the string }
+     Inc(P);  
+     If (P^ = Chr(CurId)) Then Exit;                    { Found the string }
    End;
    End;
 END;
 END;
 
 
@@ -250,35 +244,31 @@ END;
 {  InsertString -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB      }
 {  InsertString -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB      }
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
 PROCEDURE InsertString (Id: Byte; Const Str: String);
 PROCEDURE InsertString (Id: Byte; Const Str: String);
-VAR P1, P2: PChar;
-    P : PHistRec;
+VAR P, P1, P2: PChar;
 BEGIN
 BEGIN
   while (HistoryUsed+Length(Str)+3>HistorySize) do
   while (HistoryUsed+Length(Str)+3>HistorySize) do
    begin
    begin
-       P:=PHistRec(HistoryBlock);
+       P:=PChar(HistoryBlock);
        while Pointer(P)<Pointer(HistoryBlock)+HistorySize do
        while Pointer(P)<Pointer(HistoryBlock)+HistorySize do
          begin
          begin
-           if Pointer(P)+Length(P^.Str)+6+Length(Str) >
+           if Pointer(P)+Length(PShortString(P+2)^)+6+Length(Str) >
               Pointer(HistoryBlock)+HistorySize then
               Pointer(HistoryBlock)+HistorySize then
              begin
              begin
-               HistoryUsed:=HistoryUsed-(Length(P^.Str)+3);
+               Dec(HistoryUsed,Length(PShortString(P+2)^)+3);
                FillChar(P^,Pointer(HistoryBlock)+HistorySize-Pointer(P),#0);
                FillChar(P^,Pointer(HistoryBlock)+HistorySize-Pointer(P),#0);
                break;
                break;
              end;
              end;
-           P:=PHistRec(Pointer(P)+Length(P^.Str)+3);
+           Inc(P,Length(PShortString(P+2)^)+3);
          end;
          end;
    end;
    end;
    P1 := PChar(HistoryBlock)+1;                     { First history record }
    P1 := PChar(HistoryBlock)+1;                     { First history record }
    P2 := P1+Length(Str)+3;                          { History record after }
    P2 := P1+Length(Str)+3;                          { History record after }
    Move(P1^, P2^, HistoryUsed - 1);                 { Shuffle history data }
    Move(P1^, P2^, HistoryUsed - 1);                 { Shuffle history data }
-   PHistRec(P1)^.Zero := 0;                         { Set marker byte }
-   PHistRec(P1)^.Id := Id;                          { Set history id }
-   {$IFDEF PPC_DELPHI3}                             { DELPHI3+ COMPILER }
-   Move(Str[1], PHistRec(P1)^.Str[1], Length(Str)); { Set history string }
-   SetLength(PHistRec(P1)^.Str, Length(Str));       { Set string length }
-   {$ELSE}                                          { OTHER COMPILERS }
-   Move(Str[0], PHistRec(P1)^.Str, Length(Str)+1);  { Set history string }
-   {$ENDIF}
+   P1^:=#0;                         { Set marker byte }
+   Inc(P1);
+   P1^:=Chr(Id);                          { Set history id }
+   Inc(P1);
+   Move(Str[0], P1^, Length(Str)+1);  { Set history string }
    Inc(HistoryUsed, Length(Str)+3);                 { Inc history used }
    Inc(HistoryUsed, Length(Str)+3);                 { Inc history used }
 END;
 END;
 
 
@@ -309,7 +299,7 @@ BEGIN
      begin
      begin
        FreeMem(HistoryBlock);              { Release history block }
        FreeMem(HistoryBlock);              { Release history block }
        HistoryBlock:=nil;
        HistoryBlock:=nil;
-     end;  
+     end;
 END;
 END;
 
 
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
 {+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
@@ -401,7 +391,7 @@ end;
 {  LoadHistory -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB       }
 {  LoadHistory -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB       }
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
 PROCEDURE LoadHistory (Var S: TStream);
 PROCEDURE LoadHistory (Var S: TStream);
-VAR Size: sw_Word;
+VAR Size: sw_integer;
 BEGIN
 BEGIN
    S.Read(Size, sizeof(Size));                        { Read history size }
    S.Read(Size, sizeof(Size));                        { Read history size }
    If (HistoryBlock <> Nil) Then Begin                { History initialized }
    If (HistoryBlock <> Nil) Then Begin                { History initialized }
@@ -416,7 +406,7 @@ END;
 {  StoreHistory -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB      }
 {  StoreHistory -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 30Sep99 LdB      }
 {---------------------------------------------------------------------------}
 {---------------------------------------------------------------------------}
 PROCEDURE StoreHistory (Var S: TStream);
 PROCEDURE StoreHistory (Var S: TStream);
-VAR Size: sw_Word;
+VAR Size: sw_integer;
 BEGIN
 BEGIN
    If (HistoryBlock = Nil) Then Size := 0 Else        { No history data }
    If (HistoryBlock = Nil) Then Size := 0 Else        { No history data }
      Size := HistoryUsed;                             { Size of history data }
      Size := HistoryUsed;                             { Size of history data }
@@ -428,7 +418,10 @@ END.
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.13  2004-12-22 15:45:34  peter
+ Revision 1.14  2004-12-26 13:26:52  peter
+   * remove phistrec usage
+
+ Revision 1.13  2004/12/22 15:45:34  peter
    * fixed overflow when histsize=0
    * fixed overflow when histsize=0
 
 
  Revision 1.12  2004/11/06 17:08:48  peter
  Revision 1.12  2004/11/06 17:08:48  peter