Sfoglia il codice sorgente

+ added expand defines for all OSes, hopefully no OS forgotten

git-svn-id: trunk@3708 -
florian 19 anni fa
parent
commit
2a62055580
3 ha cambiato i file con 96 aggiunte e 2 eliminazioni
  1. 1 0
      .gitattributes
  2. 76 2
      rtl/objpas/sysutils/fina.inc
  3. 19 0
      tests/webtbs/tw6980.pp

+ 1 - 0
.gitattributes

@@ -6864,6 +6864,7 @@ tests/webtbs/tw6735.pp svneol=native#text/plain
 tests/webtbs/tw6742.pp svneol=native#text/plain
 tests/webtbs/tw6767.pp svneol=native#text/plain
 tests/webtbs/tw6960.pp svneol=native#text/plain
+tests/webtbs/tw6980.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain

+ 76 - 2
rtl/objpas/sysutils/fina.inc

@@ -96,11 +96,47 @@ end;
 
 {$ifdef Unix}
   Function getenv(name:shortstring):Pchar; external name 'FPC_SYSC_FPGETENV';
-  
+
   {$DEFINE FPC_FEXPAND_TILDE} { Tilde is expanded to home }
   {$DEFINE FPC_FEXPAND_GETENVPCHAR} { GetEnv result is a PChar }
 {$endif}
 
+{$if defined(win32) or defined(win64)) or defined(go32v2) or defined(wdosx)}
+  {$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
+  {$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
+{$endif}
+
+{$if defined(wince)}
+  {$DEFINE FPC_FEXPAND_NO_DEFAULT_PATHS}
+  {$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
+{$endif}
+
+{$if defined(morphos) or defined(amiga)}
+  {$DEFINE FPC_FEXPAND_VOLUMES} (* Full paths begin with drive specification *)
+  {$DEFINE FPC_FEXPAND_DRIVESEP_IS_ROOT}
+  {$DEFINE FPC_FEXPAND_NO_DEFAULT_PATHS}
+{$endif }
+
+{$if defined(OS2)}
+  {$DEFINE FPC_FEXPAND_UNC} (* UNC paths are supported *)
+  {$DEFINE FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
+  {$DEFINE FPC_FEXPAND_GETENV_PCHAR}
+{$endif}
+
+{$if defined(MACOS)}
+  {$DEFINE FPC_FEXPAND_VOLUMES}
+  {$DEFINE FPC_FEXPAND_NO_DEFAULT_PATHS}
+  {$DEFINE FPC_FEXPAND_DRIVESEP_IS_ROOT}
+  {$DEFINE FPC_FEXPAND_NO_DOTS_UPDIR}
+  {$DEFINE FPC_FEXPAND_NO_CURDIR}
+{$endif defined(MACOS)}
+
+{$if defined(NETWARE)}
+  {$DEFINE FPC_FEXPAND_DRIVES}
+  {$DEFINE FPC_FEXPAND_VOLUMES}
+  {$DEFINE FPC_FEXPAND_NO_DEFAULT_PATHS}
+{$endif defined(NETWARE)}
+
   type
     PathStr=string;
 {$I fexpand.inc}
@@ -108,7 +144,45 @@ end;
 {$ifdef Unix}
   {$UNDEF FPC_FEXPAND_GETENVPCHAR}
   {$UNDEF FPC_FEXPAND_TILDE}
-{$endif}  
+{$endif}
+
+{$if defined(win32) or defined(win64)) or defined(go32v2) or defined(wdosx)}
+  {$UNDEF FPC_FEXPAND_UNC} (* UNC paths are supported *)
+  {$UNDEF FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
+{$endif}
+
+{$if defined(wince)}
+  {$UNDEF FPC_FEXPAND_NO_DEFAULT_PATHS}
+  {$UNDEF FPC_FEXPAND_UNC} (* UNC paths are supported *)
+{$endif}
+
+{$if defined(morphos) or defined(amiga)}
+  {$UNDEF FPC_FEXPAND_VOLUMES} (* Full paths begin with drive specification *)
+  {$UNDEF FPC_FEXPAND_DRIVESEP_IS_ROOT}
+  {$UNDEF FPC_FEXPAND_NO_DEFAULT_PATHS}
+{$endif }
+
+{$if defined(OS2)}
+  {$UNDEF FPC_FEXPAND_UNC} (* UNC paths are supported *)
+  {$UNDEF FPC_FEXPAND_DRIVES} (* Full paths begin with drive specification *)
+  {$UNDEF FPC_FEXPAND_GETENV_PCHAR}
+{$endif}
+
+{$if defined(MACOS)}
+  {$UNDEF FPC_FEXPAND_VOLUMES}
+  {$UNDEF FPC_FEXPAND_NO_DEFAULT_PATHS}
+  {$UNDEF FPC_FEXPAND_DRIVESEP_IS_ROOT}
+  {$UNDEF FPC_FEXPAND_NO_DOTS_UPDIR}
+  {$UNDEF FPC_FEXPAND_NO_CURDIR}
+{$endif defined(MACOS)}
+
+
+{$if defined(NETWARE)}
+  {$UNDEF FPC_FEXPAND_DRIVES}
+  {$UNDEF FPC_FEXPAND_VOLUMES}
+  {$UNDEF FPC_FEXPAND_NO_DEFAULT_PATHS}
+{$endif defined(NETWARE)}
+
 
 function ExpandFileName (Const FileName : string): String;
 

+ 19 - 0
tests/webtbs/tw6980.pp

@@ -0,0 +1,19 @@
+{ %target=win32,go32v2,win64 }
+program Project1;
+
+{$mode objfpc}{$H+}
+
+uses
+  SysUtils
+  { add your units here };
+
+var
+  p: string;
+  e: string;
+begin
+  p := 'C:\test';
+  e := ExpandFileName('c:\test');
+  writeln('Expanded: ',e);
+  if (p<>e) then halt(1);
+  writeln('ok');
+end.