Browse Source

* in lexbase and yaccbase units,
use DirectorySeparator instead of '\' in functions
path, root and addext.
* in plex and pyacc programs, for unix,
try to find installed yyparse.cod using
path of paramstr(0).

git-svn-id: trunk@40619 -

pierre 6 years ago
parent
commit
1d7f5fa812
5 changed files with 23 additions and 11 deletions
  1. 4 4
      utils/tply/lexbase.pas
  2. 5 1
      utils/tply/plex.pas
  3. 5 1
      utils/tply/pyacc.pas
  4. 5 1
      utils/tply/pyacc.y
  5. 4 4
      utils/tply/yaccbase.pas

+ 4 - 4
utils/tply/lexbase.pas

@@ -969,7 +969,7 @@ function path(filename : String) : String;
   var i : Integer;
   begin
     i := length(filename);
-    while (i>0) and (filename[i]<>'\') and (filename[i]<>':') do
+    while (i>0) and (filename[i]<>DirectorySeparator) and (filename[i]<>':') do
       dec(i);
     path := copy(filename, 1, i);
   end(*path*);
@@ -985,10 +985,10 @@ function root(filename : String) : String;
             root := copy(filename, 1, i-1);
             exit
           end;
-        '\': exit;
+        DirectorySeparator : exit;
         else
       end;
-  end(*addExt*);
+  end(*root*);
 function addExt(filename, ext : String) : String;
   (* implemented with goto for maximum efficiency *)
   label x;
@@ -999,7 +999,7 @@ function addExt(filename, ext : String) : String;
     for i := length(filename) downto 1 do
       case filename[i] of
         '.' : exit;
-        '\': goto x;
+        DirectorySeparator: goto x;
         else
       end;
     x : addExt := filename+'.'+ext

+ 5 - 1
utils/tply/plex.pas

@@ -597,7 +597,11 @@ var i : Integer;
 
 begin
 {$ifdef Unix}
-  codfilepath1:='/usr/local/lib/fpc/lexyacc/';
+  codfilepath1:=path(paramstr(0));
+  if (codfilepath1<>'') then
+    codfilepath1:=codfilepath1+'../lib/fpc/lexyacc/'
+  else
+    codfilepath1:='/usr/local/lib/fpc/lexyacc/';
   codfilepath2:='/usr/lib/fpc/lexyacc/';
 {$else}
   codfilepath1:=path(paramstr(0));

+ 5 - 1
utils/tply/pyacc.pas

@@ -2375,7 +2375,11 @@ var i : Integer;
 
 begin
 {$ifdef Unix}
-  codfilepath1:='/usr/local/lib/fpc/lexyacc/';
+  codfilepath1:=path(paramstr(0));
+  if (codfilepath1<>'') then
+    codfilepath1:=codfilepath1+'../lib/fpc/lexyacc/'
+  else
+    codfilepath1:='/usr/local/lib/fpc/lexyacc/';
   codfilepath2:='/usr/lib/fpc/lexyacc/';
 {$else}
   codfilepath1:=path(paramstr(0));

+ 5 - 1
utils/tply/pyacc.y

@@ -711,7 +711,11 @@ var i : Integer;
 
 begin
 {$ifdef Unix}
-  codfilepath1:='/usr/local/lib/fpc/lexyacc/';
+  codfilepath1:=path(paramstr(0));
+  if (codfilepath1<>'') then
+    codfilepath1:=codfilepath1+'../lib/fpc/lexyacc/'
+  else
+    codfilepath1:='/usr/local/lib/fpc/lexyacc/';
   codfilepath2:='/usr/lib/fpc/lexyacc/';
 {$else}
   codfilepath1:=path(paramstr(0));

+ 4 - 4
utils/tply/yaccbase.pas

@@ -640,7 +640,7 @@ function path(filename : String) : String;
   var i : Integer;
   begin
     i := length(filename);
-    while (i>0) and (filename[i]<>'\') and (filename[i]<>':') do
+    while (i>0) and (filename[i]<>DirectorySeparator) and (filename[i]<>':') do
       dec(i);
     path := copy(filename, 1, i);
   end(*path*);
@@ -656,10 +656,10 @@ function root(filename : String) : String;
             root := copy(filename, 1, i-1);
             exit
           end;
-        '\': exit;
+        DirectorySeparator: exit;
         else
       end;
-  end(*addExt*);
+  end(*root*);
 function addExt(filename, ext : String) : String;
   (* implemented with goto for maximum efficiency *)
   label x;
@@ -670,7 +670,7 @@ function addExt(filename, ext : String) : String;
     for i := length(filename) downto 1 do
       case filename[i] of
         '.' : exit;
-        '\': goto x;
+        DirectorySeparator : goto x;
         else
       end;
     x : addExt := filename+'.'+ext