Browse Source

* small fixes for linux and grep

peter 26 years ago
parent
commit
00ed0b4182
3 changed files with 47 additions and 30 deletions
  1. 4 3
      ide/text/fpcompil.pas
  2. 28 20
      ide/text/fpmtools.inc
  3. 15 7
      ide/text/fpredir.pas

+ 4 - 3
ide/text/fpcompil.pas

@@ -42,9 +42,7 @@ uses
   Dos,Video,
   Objects,Drivers,Views,App,Commands,
   CompHook,
-{$ifdef go32v2}
   FPRedir,
-{$endif def go32v2}
   FPConst,FPVars,FPUtils,FPIntf,FPSwitch;
 
 constructor TCompileStatusDialog.Init;
@@ -274,7 +272,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.13  1999-02-22 11:51:33  peter
+  Revision 1.14  1999-02-22 12:46:56  peter
+    * small fixes for linux and grep
+
+  Revision 1.13  1999/02/22 11:51:33  peter
     * browser updates from gabor
 
   Revision 1.12  1999/02/22 11:29:36  pierre

+ 28 - 20
ide/text/fpmtools.inc

@@ -52,23 +52,21 @@ begin
 end;
 
 procedure TIDEApp.Grep;
-
-  var PGrepDialog : PCenterDialog;
-      R,R2 : TRect;
-      IL1,IL2 : PInputLine;
-      p,lineNb : longint;
-      error : word;
-      searchword,
-      GrepExe,GrepArgs,Line,ModuleName : String;
-      GrepOut : text;
-      Params : Array[0..4] of longint;
-
-  Const GrepOutName = 'grep$$.out';
-{$ifdef linux}
-   GrepExeName = 'grep';
-{$else linux}
-   GrepExeName = 'grep.exe';
-{$endif linux}
+Const
+  GrepOutName = 'grep$$.out';
+  GrepErrName = 'grep$$.err';
+  GrepExeName = 'grep'+ExeExt;
+var
+  PGrepDialog : PCenterDialog;
+  R,R2 : TRect;
+  IL1,IL2 : PInputLine;
+  s : string;
+  p,lineNb : longint;
+  error : word;
+  searchword,
+  GrepExe,GrepArgs,Line,ModuleName : String;
+  GrepOut : text;
+  Params : Array[0..4] of longint;
 begin
 { Find grep.exe }
   GrepExe:=GrepExeName;
@@ -83,9 +81,13 @@ begin
     Searchword:=PSourceWindow(DeskTop^.First)^.Editor^.GetCurrentWord
   else
     Searchword:='';
+  { Don't use the listseparator in the file list else it's seen as 1 file
+    (at least under linux }
+  s:=highlightexts;
+  ReplaceStr(s,';',' ');
   { add "" for args with spaces }
   { WARNING : text must still be entered in usual grep syntax }
-  GrepArgs:='-n -i "$TEXT" '+HighlightExts;
+  GrepArgs:='-n -i "$TEXT" '+s;
 { Dialog }
   R.Assign(0,0,45,8);
   new(PGrepDialog,Init(R,'Grep arguments'));
@@ -120,7 +122,7 @@ begin
          GrepArgs:=IL2^.Data^;
          ReplaceStr(GrepArgs,'$TEXT',SearchWord);
          { Linux ? }
-         if not ExecuteRedir(GrepExe,GrepArgs,GrepOutName,'grep$$.err') then
+         if not ExecuteRedir(GrepExe,GrepArgs,GrepOutName,GrepErrName) then
            Begin
               { 2 as exit code just means that
                 some file vwere not found ! }
@@ -153,6 +155,9 @@ begin
            end;
          Close(GrepOut);
          Erase(GrepOut);
+       { Delete also grep$$.err }
+         Assign(GrepOut,GrepErrName);
+         Erase(GrepOut);
          {$I+}
          EatIO;
        end;
@@ -161,7 +166,10 @@ begin
 end;
 {
   $Log$
-  Revision 1.9  1999-02-22 11:29:37  pierre
+  Revision 1.10  1999-02-22 12:46:57  peter
+    * small fixes for linux and grep
+
+  Revision 1.9  1999/02/22 11:29:37  pierre
     + added col info in MessageItem
     + grep uses HighLightExts and should work for linux
 

+ 15 - 7
ide/text/fpredir.pas

@@ -66,7 +66,7 @@ Uses
   dos;
 
 {*****************************************************************************
-				     Dos
+                                     Dos
 *****************************************************************************}
 
 {$ifdef implemented}
@@ -81,8 +81,8 @@ const
 
 Type
   PtrRec = packed record
-	     Ofs, Seg : Word;
-	   end;
+             Ofs, Seg : Word;
+           end;
 
   PHandles = ^THandles;
   THandles = Array [Byte] of Byte;
@@ -98,7 +98,7 @@ Var
 {$endif TP}
 
 Var
-  F,FE	            : File;
+  F,FE              : File;
   RedirChanged      : Boolean;
   RedirErrorChanged : Boolean;
   TempH, TempErrorH : longint;
@@ -285,7 +285,12 @@ end;
     SmallHeap;
 {$EndIf MsDos}
     SwapVectors;
+    { Must use shell() for linux for the wildcard expansion (PFV) }
+{$ifdef linux}
+    Shell(Progname+' '+Comline);
+{$else}
     Dos.Exec (ProgName, ComLine);
+{$endif}
     IOStatus:=DosError;
     ExecuteResult:=DosExitCode;
     SwapVectors;
@@ -316,7 +321,7 @@ End;
 
 
 {*****************************************************************************
-				 Linux
+                                 Linux
 *****************************************************************************}
 
 
@@ -351,13 +356,16 @@ end;
 
 
 {*****************************************************************************
-				  Initialize
+                                  Initialize
 *****************************************************************************}
 
 End.
 {
   $Log$
-  Revision 1.9  1999-02-22 11:12:33  pierre
+  Revision 1.10  1999-02-22 12:46:58  peter
+    * small fixes for linux and grep
+
+  Revision 1.9  1999/02/22 11:12:33  pierre
     * dup and dup2 work for go32v2
     + also should work for linux (after linux.pp patch)