From 4d9e404403fef0fc3dc30168f09ac5016ad116d6 Mon Sep 17 00:00:00 2001 From: Tomas Hajny Date: Sun, 28 May 2006 22:27:27 +0000 Subject: [PATCH] * remove GetEnv dependency git-svn-id: trunk@3729 - --- rtl/inc/fexpand.inc | 16 ++++++++++------ rtl/objpas/sysutils/fina.inc | 7 +++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/rtl/inc/fexpand.inc b/rtl/inc/fexpand.inc index 1121f437ab..4a032b3aad 100644 --- a/rtl/inc/fexpand.inc +++ b/rtl/inc/fexpand.inc @@ -67,7 +67,7 @@ end; {$IFDEF FPC_FEXPAND_VOLUMES} {$IFNDEF FPC_FEXPAND_NO_DEFAULT_PATHS} -procedure GetDirIO (const VolumeName: OpenString; var Dir: PathStr); +procedure GetDirIO (const VolumeName: OpenString; var Dir: string); var OldInOutRes: word; @@ -91,7 +91,8 @@ function FExpand (const Path: PathStr): PathStr; FPC_FEXPAND_NO_DOTS_UPDIR, FPC_FEXPAND_DIRSEP_IS_UPDIR, FPC_FEXPAND_DIRSEP_IS_CURDIR and FPC_FEXPAND_MULTIPLE_UPDIR conditionals might be defined to specify FExpand behaviour - see end of this file for - individual descriptions. + individual descriptions. Finally, FPC_FEXPAND_SYSUTILS allows to reuse + the same implementation for SysUtils.ExpandFileName. *) {$IFDEF FPC_FEXPAND_DRIVES} @@ -161,15 +162,15 @@ begin if (Length (Pa) >= 1) and (Pa [1] = '~') and ((Pa [2] = DirectorySeparator) or (Length (Pa) = 1)) then begin - {$IFOPT H-} + {$IFDEF FPC_FEXPAND_SYSUTILS} + S := GetEnvironmentVariable ('HOME'); + {$ELSE FPC_FEXPAND_SYSUTILS} {$IFDEF FPC_FEXPAND_GETENV_PCHAR} S := StrPas (GetEnv ('HOME')); {$ELSE FPC_FEXPAND_GETENV_PCHAR} - {$ENDIF H-} S := GetEnv ('HOME'); - {$IFOPT H-} {$ENDIF FPC_FEXPAND_GETENV_PCHAR} - {$ENDIF H-} + {$ENDIF FPC_FEXPAND_SYSUTILS} if (S = '') or (Length (S) = 1) and (S [1] = DirectorySeparator) then Delete (Pa, 1, 1) @@ -577,5 +578,8 @@ end; FPC_FEXPAND_MULTIPLE_UPDIR - grouping of more characters specifying upper directory references higher directory levels. Example: '...' (Netware). + + FPC_FEXPAND_SYSUTILS allows to reuse the same implementation for + SysUtils.ExpandFileName by avoiding things specific for unit Dos. *) diff --git a/rtl/objpas/sysutils/fina.inc b/rtl/objpas/sysutils/fina.inc index 58ce9dc809..ed4c468805 100644 --- a/rtl/objpas/sysutils/fina.inc +++ b/rtl/objpas/sysutils/fina.inc @@ -94,12 +94,11 @@ else Result := ''; end; -{$ifdef Unix} - Function getenv(name:shortstring):Pchar; external name 'FPC_SYSC_FPGETENV'; -{$endif} - type PathStr=string; + +{$DEFINE FPC_FEXPAND_SYSUTILS} + {$I fexpand.inc}