* 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 -
This commit is contained in:
marco 2012-09-10 09:21:56 +00:00
parent e245802fa8
commit 1a895a875b
6 changed files with 47 additions and 41 deletions

1
.gitattributes vendored
View File

@ -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

View File

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

View File

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

View File

@ -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';

View File

@ -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
rtl/unix/syscgen.inc Normal file
View File

@ -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}