Browse Source

+ TExternalLinker.CatFileContent method and tf_no_backquote_support tsystemflags enum value

git-svn-id: trunk@19648 -
pierre 13 years ago
parent
commit
5d6a7dc03d
2 changed files with 36 additions and 1 deletions
  1. 34 0
      compiler/link.pas
  2. 2 1
      compiler/systems.pas

+ 34 - 0
compiler/link.pas

@@ -79,6 +79,7 @@ interface
          Constructor Create;override;
          Destructor Destroy;override;
          Function  FindUtil(const s:TCmdStr):TCmdStr;
+         Function  CatFileContent(para:TCmdStr):TCmdStr;
          Function  DoExec(const command:TCmdStr; para:TCmdStr;showinfo,useshell:boolean):boolean;
          procedure SetDefaultInfo;virtual;
          Function  MakeStaticLibrary:boolean;override;
@@ -671,6 +672,39 @@ Implementation
       end;
 
 
+    Function TExternalLinker.CatFileContent(para : TCmdStr) : TCmdStr;
+      var
+        filecontent : TCmdStr;
+        f : text;
+        st : string;
+      begin
+        if not (tf_no_backquote_support in source_info.flags) then
+           begin
+             CatFileContent:='`cat '+MaybeQuoted(para)+'`';
+             Exit;
+           end;
+        assign(f,para);
+        filecontent:='';
+        {$push}{$I-}
+        reset(f);
+        {$pop}
+        if IOResult<>0 then
+          begin
+            Message1(exec_n_backquote_cat_file_not_found,para);
+          end
+        else
+          begin
+            while not eof(f) do
+              begin
+                readln(f,st);
+                if st<>'' then
+                  filecontent:=filecontent+' '+st;
+              end;
+            close(f);
+          end;
+        CatFileContent:=filecontent;
+      end;
+
     Function TExternalLinker.DoExec(const command:TCmdStr; para:TCmdStr;showinfo,useshell:boolean):boolean;
       var
         exitcode: longint;

+ 2 - 1
compiler/systems.pas

@@ -148,8 +148,9 @@ interface
             tf_no_generic_stackcheck,
             tf_has_winlike_resources,
             tf_safecall_clearstack,             // With this flag set, after safecall calls the caller cleans up the stack
-            tf_safecall_exceptions              // Exceptions in safecall calls are not raised, but passed to the caller as an ordinal (hresult) in the function result.
+            tf_safecall_exceptions,             // Exceptions in safecall calls are not raised, but passed to the caller as an ordinal (hresult) in the function result.
                                                 // The original result (if it exists) is passed as an extra parameter
+            tf_no_backquote_support
        );
 
        psysteminfo = ^tsysteminfo;