{ $Id$ This program is part of the Free Pascal run time library. Copyright (c) 1998 by Peter Vreman Show the differences between two .msg files See the file COPYING.FPC, included in this distribution, for details about the copyright. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} Program messagedif; Type TEnum = String; TText = String; PMsg = ^TMsg; TMsg = Record Line : Longint; enum : TEnum; text : TText; Next,Prev : PMsg; FileNext, Equivalent : PMsg; end; Var OrgFileName,DiffFileName : String; OrgRoot,DiffRoot : PMsg; OrgFirst,DiffFirst : PMsg; Last : PMsg; Function NewMsg (Var RM : PMsg; L : Longint; Const E : TEnum;Const T : TText) : PMsg; Var P,R : PMsg; begin New(P); with P^ do begin Line:=L; Text:=T; enum:=E; next:=Nil; prev:=Nil; filenext:=nil; equivalent:=nil; if assigned(last) then last^.FileNext:=P; last:=P; end; R:=RM; While (R<>Nil) and (R^.enum
Nil then
R^.Prev:=P;
If P^.Prev<>Nil then
P^.Prev^.Next:=P
else
RM:=P;
NewMsg:=P;
end;
Procedure Usage;
begin
Writeln ('Usage : msgdif orgfile diffile');
halt(1)
end;
Procedure ProcessOptions;
begin
If ParamCount<>2 then
Usage;
OrgfileName:=Paramstr(1);
DiffFileName:=Paramstr(2);
end;
Procedure ProcessFile (FileName : String; Var Root,First : PMsg);
Var F : Text;
S : String;
J,LineNo,Count : Longint;
begin
Assign(F,FileName);
Reset(F);
Write ('Processing: ',Filename,'...');
LineNo:=0;
Count:=0;
Root:=Nil;
First:=nil;
Last:=nil;
While not eof(f) do
begin
Readln(F,S);
Inc(LineNo);
If (length(S)>0) and Not (S[1] in ['%','#']) Then
begin
J:=Pos('=',S);
If j<1 then
writeln (Filename,'(',LineNo,') : Invalid entry')
else
begin
NewMsg(Root,LineNo,Copy(S,1,J-1),Copy(S,j+1,255));
if First=nil then
First:=Root;
Inc(Count);
end;
end;
end;
Writeln (' Done. Read ',LineNo,' lines, got ',Count,' constants.');
Close(f);
end;
Procedure ShowDiff (POrg,PDiff : PMsg);
Procedure NotFound (Org : Boolean; P : PMsg);
begin
With P^ do
If Org Then
Writeln ('Not found in ',DiffFileName,' : ',Enum,' ',OrgFileName,'(',Line,')')
else
Writeln ('Extra in ',DiffFileName,'(',line,') : ',enum)
end;
Var P : PMsg;
count : longint;
begin
count:=0;
While (Porg<>Nil) and (PDiff<>Nil) do
begin
// Writeln (POrg^.enum,'<=>',PDiff^.Enum);
If Porg^.Enum