Selaa lähdekoodia

* move fpgetenv(pchar) to unit system for syscall based *nix rtls.
It was already available for libc based *nix rtls

git-svn-id: trunk@22365 -

marco 13 vuotta sitten
vanhempi
commit
1a895a875b
6 muutettua tiedostoa jossa 47 lisäystä ja 41 poistoa
  1. 1 0
      .gitattributes
  2. 1 0
      rtl/bsd/sysos.inc
  3. 1 0
      rtl/linux/sysos.inc
  4. 2 2
      rtl/unix/bunxh.inc
  5. 0 39
      rtl/unix/genfuncs.inc
  6. 42 0
      rtl/unix/syscgen.inc

+ 1 - 0
.gitattributes

@@ -8544,6 +8544,7 @@ rtl/unix/serial.pp svneol=native#text/plain
 rtl/unix/settimeo.inc svneol=native#text/plain
 rtl/unix/sockets.pp svneol=native#text/plain
 rtl/unix/syscall.pp svneol=native#text/plain
+rtl/unix/syscgen.inc svneol=native#text/plain
 rtl/unix/sysdir.inc svneol=native#text/plain
 rtl/unix/sysfile.inc svneol=native#text/plain
 rtl/unix/sysheap.inc svneol=native#text/plain

+ 1 - 0
rtl/bsd/sysos.inc

@@ -90,6 +90,7 @@ end;
   {$I syscall.inc}
   {$I sysnr.inc}
   {$I ossysc.inc}
+  {$I syscgen.inc}
 {$endif}
 
 

+ 1 - 0
rtl/linux/sysos.inc

@@ -67,6 +67,7 @@ end;
   {$I syscall.inc}
   {$I sysnr.inc}
   {$I ossysc.inc}
+  {$I syscgen.inc}
 {$endif}
 
 {$I osmacro.inc}

+ 2 - 2
rtl/unix/bunxh.inc

@@ -2,7 +2,7 @@
     This file is part of the Free Pascal run time library.
     Copyright (c) 2002 by Marco van de Voort
 
-    The interface part of the baseunix unit.
+    The interface part of the baseunix unit for syscall based rtls.
 
     See the file COPYING.FPC, included in this distribution,
     for details about the copyright.
@@ -107,7 +107,7 @@ Type TGrpArr = Array [0..0] of TGid;            { C style array workarounds}
     Function  Fpmmap(start:pointer;len:size_t;prot:cint;flags:cint;fd:cint;offst:off_t):pointer; external name 'FPC_SYSC_MMAP';
     Function  Fpmunmap(start:pointer;len:size_t):cint;  external name 'FPC_SYSC_MUNMAP';
 
-    Function  FpGetEnv     (name : pChar): pChar;
+    Function  FpGetEnv (name : pChar): pChar; external name 'FPC_SYSC_FPGETENVPCHAR';
     function  fpsettimeofday(tp:ptimeval;tzp:ptimezone):cint;
 
     function FpGetRLimit(resource:cint;rlim:PRLimit):cint; external name 'FPC_SYSC_GETRLIMIT';

+ 0 - 39
rtl/unix/genfuncs.inc

@@ -60,45 +60,6 @@ begin
    end;
 end;
 
-{$ifndef FPC_USE_LIBC}
-Function fpgetenv(name:pchar):pchar;
-
-var
-  p     : ppchar;
-  found : boolean;
-  np,cp : pchar;
-  len,i : longint;
-Begin
-  if (name=nil) or (envp=NIL) Then
-   exit(NIL);
-  np:=name;
-  while (np^<>#0) and (np^<>'=') DO
-   inc(np);
-  len:=np-name;
-  p:=envp;
-  while (p^<>NIL) DO
-   Begin
-    cp:=p^;
-    np:=name;
-    i:=len;
-    while (i<>0) and (cp^<>#0) DO
-      Begin
-        if cp^<>np^ Then
-          Begin
-           inc(cp); inc(np);
-           break;
-         End;
-        inc(cp); inc(np);
-        dec(i)
-      End;
-    if (i=0) and (cp^='=') Then
-        exit(cp+1);
-   inc(p);
-  end;
- fpgetenv:=nil;
-End;
-{$ENDIF}
-
 Function fpgetenv(name:string):Pchar; [public, alias : 'FPC_SYSC_FPGETENV'];
 {
   Searches the environment for a string with name p and

+ 42 - 0
rtl/unix/syscgen.inc

@@ -0,0 +1,42 @@
+
+// general purpose unix routines for syscall based *nix system unit.
+
+{$ifndef FPC_USE_LIBC}
+Function fpgetenv(name:pchar):pchar;[public, alias : 'FPC_SYSC_FPGETENVPCHAR'];
+
+var
+  p     : ppchar;
+  found : boolean;
+  np,cp : pchar;
+  len,i : longint;
+Begin
+  if (name=nil) or (envp=NIL) Then
+   exit(NIL);
+  np:=name;
+  while (np^<>#0) and (np^<>'=') DO
+   inc(np);
+  len:=np-name;
+  p:=envp;
+  while (p^<>NIL) DO
+   Begin
+    cp:=p^;
+    np:=name;
+    i:=len;
+    while (i<>0) and (cp^<>#0) DO
+      Begin
+        if cp^<>np^ Then
+          Begin
+           inc(cp); inc(np);
+           break;
+         End;
+        inc(cp); inc(np);
+        dec(i)
+      End;
+    if (i=0) and (cp^='=') Then
+        exit(cp+1);
+   inc(p);
+  end;
+ fpgetenv:=nil;
+End;
+{$ENDIF}
+