Просмотр исходного кода

* do not automatically register the RC reader, because it captures any file, instead handle that in fpcres itself if the output format calls for it

git-svn-id: trunk@46395 -
svenbarth 5 лет назад
Родитель
Сommit
bd6d1e0b6a
3 измененных файлов с 15 добавлено и 6 удалено
  1. 2 1
      packages/fcl-res/src/rcreader.pp
  2. 1 0
      utils/fpcres/fpcres.pas
  3. 12 5
      utils/fpcres/sourcehandler.pas

+ 2 - 1
packages/fcl-res/src/rcreader.pp

@@ -127,6 +127,7 @@ begin
 end;
 
 initialization
-  TResources.RegisterReader('.rc',TRCResourceReader);
+  { don't register automatically, as this is essentially a "catch all" }
+  //TResources.RegisterReader('.rc',TRCResourceReader);
 
 end.

+ 1 - 0
utils/fpcres/fpcres.pas

@@ -218,6 +218,7 @@ begin
   sourcefiles.FileList.AddStrings(params.InputFiles);
   sourcefiles.RCDefines.AddStrings(params.RCDefines);
   sourcefiles.RCIncludeDirs.AddStrings(params.RCIncludeDirs);
+  sourcefiles.RCMode:=CurrentTarget.objformat=ofRes;
   try
     sourcefiles.Load(resources);
   except

+ 12 - 5
utils/fpcres/sourcehandler.pas

@@ -39,6 +39,7 @@ type
     fRCIncludeDirs: TStringList;
     fRCDefines: TStringList;
     fStreamList : TFPList;
+    fRCMode: Boolean;
   public
     constructor Create;
     destructor Destroy; override;
@@ -46,6 +47,7 @@ type
     property FileList : TStringList read fFileList;
     property RCIncludeDirs: TStringList read fRCIncludeDirs;
     property RCDefines: TStringList read fRCDefines;
+    property RCMode: Boolean read fRCMode write fRCMode;
   end;
   
 implementation
@@ -61,6 +63,7 @@ begin
   fStreamList:=TFPList.Create;
   fRCDefines:= TStringList.Create;
   fRCIncludeDirs:= TStringList.Create;
+  fRCMode:=False;
 end;
 
 destructor TSourceFiles.Destroy;
@@ -92,11 +95,15 @@ begin
         raise ECantOpenFileException.Create(fFileList[i]);
       end;
       fStreamList.Add(aStream);
-      try
-        aReader:=TResources.FindReader(aStream);
-      except
-        raise EUnknownInputFormatException.Create(fFileList[i]);
-      end;
+      { the RC reader reads anything, so handle that separately }
+      if fRCMode then
+        aReader:=TRCResourceReader.Create
+      else
+        try
+          aReader:=TResources.FindReader(aStream);
+        except
+          raise EUnknownInputFormatException.Create(fFileList[i]);
+        end;
       Messages.DoVerbose(Format('Chosen reader: %s',[aReader.Description]));
       try
         Messages.DoVerbose('Reading resource information...');