From 7bcb8e911c7fa96c65a70a7ec96d4b8c50e2b844 Mon Sep 17 00:00:00 2001 From: pierre Date: Mon, 24 Dec 2018 08:34:03 +0000 Subject: [PATCH] ------------------------------------------------------------------------ r40619 | pierre | 2018-12-23 16:17:49 +0000 (Sun, 23 Dec 2018) | 8 lines * 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). ------------------------------------------------------------------------ --- Merging r40619 into '.': U utils/tply/pyacc.pas U utils/tply/plex.pas U utils/tply/yaccbase.pas U utils/tply/lexbase.pas U utils/tply/pyacc.y --- Recording mergeinfo for merge of r40619 into '.': U . git-svn-id: branches/fixes_3_2@40627 - --- utils/tply/lexbase.pas | 8 ++++---- utils/tply/plex.pas | 6 +++++- utils/tply/pyacc.pas | 6 +++++- utils/tply/pyacc.y | 6 +++++- utils/tply/yaccbase.pas | 8 ++++---- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/utils/tply/lexbase.pas b/utils/tply/lexbase.pas index f6b329203c..719df5f2ee 100644 --- a/utils/tply/lexbase.pas +++ b/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 diff --git a/utils/tply/plex.pas b/utils/tply/plex.pas index df2aefd1d3..9ea37b962f 100644 --- a/utils/tply/plex.pas +++ b/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)); diff --git a/utils/tply/pyacc.pas b/utils/tply/pyacc.pas index 7964476f6e..530ff7842e 100644 --- a/utils/tply/pyacc.pas +++ b/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)); diff --git a/utils/tply/pyacc.y b/utils/tply/pyacc.y index ddf614e1ce..5817810d8f 100644 --- a/utils/tply/pyacc.y +++ b/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)); diff --git a/utils/tply/yaccbase.pas b/utils/tply/yaccbase.pas index d48188d016..d161ed8be9 100644 --- a/utils/tply/yaccbase.pas +++ b/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