From 51c791fe5b66b4cd5a417bf058c205e3c52d24f9 Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 7 Oct 2015 14:14:46 +0000 Subject: [PATCH] IDE+lazbuild: update po files: check if both exists rst and rsj and use only the newest git-svn-id: trunk@49975 - --- ide/idetranslations.pas | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/ide/idetranslations.pas b/ide/idetranslations.pas index 304a91e701..53f3f49d0d 100644 --- a/ide/idetranslations.pas +++ b/ide/idetranslations.pas @@ -201,7 +201,7 @@ var i: Integer; Item: PItem; j: Integer; - OutputFilename: String; + OutputFilename, OtherRSTFilename, Ext, OtherExt: String; begin Result:=true; if (RSTDirectory='') or (PODirectory='') then exit;// nothing to do @@ -227,11 +227,10 @@ begin Item:=nil; // collect all rst/po files that needs update for i:=0 to Files.Count-1 do begin - if (CompareFileExt(Files[i],'.rst',false)<>0) and - (CompareFileExt(Files[i],'.lrt',false)<>0) and - (CompareFileExt(Files[i],'.rsj',false)<>0) - then continue; RSTFilename:=RSTDirectory+Files[i]; + Ext:=LowerCase(ExtractFileExt(RSTFilename)); + if (Ext<>'.rst') and (Ext<>'.lrt') and (Ext<>'.rsj') then + continue; if POFilename='' then OutputFilename:=PODirectory+ChangeFileExt(Files[i],'.po') else @@ -250,7 +249,32 @@ begin Item^.RSTFileList:=TStringList.Create; Item^.OutputFilename:=OutputFilename; Items.Add(Item); + end else begin + // there is already a source file for this .po file + //debugln(['ConvertRSTFiles found another source: ',RSTFilename]); + if (Ext='.rsj') or (Ext='.rst') then begin + // rsj are created by FPC 2.7.1+, rst by older => use only the newest + for j:=Item^.RSTFileList.Count-1 downto 0 do begin + OtherRSTFilename:=Item^.RSTFileList[j]; + //debugln(['ConvertRSTFiles old: ',OtherRSTFilename]); + OtherExt:=LowerCase(ExtractFileExt(OtherRSTFilename)); + if (OtherExt='.rsj') or (OtherExt='.rst') then begin + if FileAgeCached(RSTFilename)<=FileAgeCached(OtherRSTFilename) then + begin + // this one is older => skip + //debugln(['ConvertRSTFiles ',RSTFilename,' is older => skip']); + RSTFilename:=''; + break; + end else begin + // this one is newer + //debugln(['ConvertRSTFiles ',RSTFilename,' is newer => ignoring old']); + Item^.RSTFileList.Delete(j); + end; + end; + end; + end; end; + if RSTFilename='' then continue; Item^.RSTFileList.Add(RSTFilename); if (not Item^.NeedUpdate) or (not FileExistsCached(OutputFilename))