From ea34cb18fa3b80aad2813fc39b57888dab8b5c37 Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 23 Jul 1999 23:13:54 +0000 Subject: [PATCH] * array[cardinal] is buggy, use array[word] * small fix in getresourcestring --- rtl/objpas/objpas.pp | 62 +++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/rtl/objpas/objpas.pp b/rtl/objpas/objpas.pp index 5617af5ce5..94d53122f5 100644 --- a/rtl/objpas/objpas.pp +++ b/rtl/objpas/objpas.pp @@ -25,7 +25,7 @@ unit objpas; smallint = system.integer; integer = system.longint; - { the compiler searches in the objpas unit for the tvarrec symbol } + { the compiler searches in the objpas unit for the tvarrec symbol } TVarRec = System.TVarRec; PVarRec = ^TVarRec; {**************************************************************************** @@ -60,9 +60,9 @@ unit objpas; Function GetResourceString(Hash : Longint) : AnsiString; Procedure ResetResourceTables; Function SetResourceString(Hash : longint; Const Value : AnsiString) : Boolean; -{$endif} - - +{$endif} + + implementation {**************************************************************************** @@ -149,10 +149,10 @@ begin if (Param>=0) and (Param#0 do + While Argv[Param][Len]<>#0 do Inc(len); SetLength(Result,Len); - If Len>0 then + If Len>0 then Move(Argv[Param][0],Result[1],Len); end else @@ -160,7 +160,7 @@ begin end; {$IFDEF HasResourceStrings} - + { --------------------------------------------------------------------- ResourceString support ---------------------------------------------------------------------} @@ -170,32 +170,33 @@ Type DefaultValue, CurrentValue : AnsiString; HashValue : longint; - end; - - TResourceStringTable = Packed Record + end; + + TResourceStringTable = Packed Record Count : longint; - Resrec : Array[Cardinal] of TResourceStringRecord; - end; - -Var + Resrec : Array[Word] of TResourceStringRecord; + end; + +Var ResourceStringTable : TResourceStringTable; External Name 'RESOURCESTRINGLIST'; Function FindHashIndex (Value : Longint) : Longint; -VAr I : longint; - +Var + I : longint; begin // Linear search, later we can implement binary search. - With ResourceStringTable do + With ResourceStringTable do For I:=0 to Count-1 do - If Value=Resrec[result].HashValue then + If Value=Resrec[I].HashValue then begin Result:=I; exit; end; - Result:=-1; + Result:=-1; end; - + + Function GetResourceString(Hash : Longint) : AnsiString;[Public,Alias : 'FPC_GETRESOURCESTRING']; begin @@ -203,9 +204,10 @@ begin If Hash<>-1 then Result:=ResourceStringTable.ResRec[Hash].CurrentValue else - Result:=''; + Result:=''; end; + Function SetResourceString(Hash : longint; Const Value : AnsiString) : Boolean; begin @@ -215,25 +217,31 @@ begin ResourceStringTable.ResRec[Hash].CurrentValue:=Value; end; + Procedure ResetResourceTables; Var I : longint; begin - For I:=0 to ResourceStringTable.Count-1 do - ResourceStringTable.ResRec[i].CurrentValue:= - ResourceStringTable.ResRec[i].DefaultValue; + With ResourceStringTable do + For I:=0 to Count-1 do + With ResRec[i] do + CurrentValue:=DefaultValue; end; Initialization ResetResourceTables; -{$endif} - +{$endif} + end. { $Log$ - Revision 1.28 1999-07-23 22:51:11 michael + Revision 1.29 1999-07-23 23:13:54 peter + * array[cardinal] is buggy, use array[word] + * small fix in getresourcestring + + Revision 1.28 1999/07/23 22:51:11 michael * Added HasResourceStrings check Revision 1.27 1999/07/22 20:30:13 michael