2
$Id: cgenstr.inc,v 1.2 2004/05/01 23:55:18 peter Exp $
3
This file is part of the Free Pascal run time library.
4
Copyright (c) 1999-2000 by Carl-Eric Codere,
5
member of the Free Pascal development team.
7
See the file COPYING.FPC, included in this distribution,
8
for details about the copyright.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
**********************************************************************}
16
{ we have to call the libc routines, because simply declaring our routines }
17
{ as cdecl and external in libc cause problems because the calling }
18
{ convention the interface is different }
20
{$ifndef FPC_UNIT_HAS_STRLEN}
21
{$define FPC_UNIT_HAS_STRLEN}
22
function libc_strlen(const p: pchar): cardinal; cdecl; external 'c' name 'strlen';
24
function strlen(P : pchar) : longint;
26
strlen := libc_strlen(p);
28
{$endif FPC_UNIT_HAS_STRLEN}
31
{$ifndef FPC_UNIT_HAS_STREND}
32
{$define FPC_UNIT_HAS_STREND}
34
function StrEnd(P: PChar): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
36
strend := p+strlen(p);
38
{$endif FPC_UNIT_HAS_STREND}
41
{$ifndef FPC_UNIT_HAS_STRCOPY}
42
{$define FPC_UNIT_HAS_STRCOPY}
43
function libc_strcpy(dest: pchar; const src: pchar): pchar; cdecl; external 'c' name 'strcpy';
45
Function StrCopy(Dest, Source:PChar): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
47
StrCopy := libc_strcpy(dest,source);
49
{$endif FPC_UNIT_HAS_STRCOPY}
52
{$ifndef FPC_UNIT_HAS_STRSCAN}
53
{$define FPC_UNIT_HAS_STRSCAN}
54
function libc_strchr(const p: pchar; c: longint): pchar; cdecl; external 'c' name 'strchr';
56
function StrScan(P: PChar; C: Char): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
58
StrScan := libc_strchr(p,longint(c));
60
{$endif FPC_UNIT_HAS_STRSCAN}
63
{$ifndef FPC_UNIT_HAS_STRRSCAN}
64
{$define FPC_UNIT_HAS_STRRSCAN}
65
function libc_strrchr(const p: pchar; c: longint): pchar; cdecl; external 'c' name 'strrchr';
67
function StrRScan(P: PChar; C: Char): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
69
StrRScan := libc_strrchr(p,longint(c));
71
{$endif FPC_UNIT_HAS_STRRSCAN}
74
{$ifndef FPC_UNIT_HAS_STRECOPY}
75
{$define FPC_UNIT_HAS_STRECOPY}
76
function libc_stpcpy(dest: pchar; const src: pchar): pchar; cdecl; external 'c' name 'stpcpy';
78
Function StrECopy(Dest, Source: PChar): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
80
StrECopy := libc_stpcpy(dest,source);
82
{$endif FPC_UNIT_HAS_STRECOPY}
86
{$ifndef FPC_UNIT_HAS_STRLCOPY}
87
{$define FPC_UNIT_HAS_STRLCOPY}
89
function libc_strlcpy(dest: pchar; const src: pchar; maxlen: SizeInt): SizeInt; cdecl; external 'c' name 'strlcpy';
91
Function StrLCopy(Dest,Source: PChar; MaxLen: SizeInt): PChar;{$ifdef SYSTEMINLINE}inline;{$endif}
93
libc_strlcpy(dest,source,maxlen);
96
{$endif FPC_UNIT_HAS_STRLCOPY}
99
{$ifndef FPC_UNIT_HAS_STRCOMP}
100
{$define FPC_UNIT_HAS_STRCOMP}
101
function libc_strcmp(const str1,str2: pchar): longint; cdecl; external 'c' name 'strcmp';
103
function StrComp(Str1, Str2 : PChar): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
105
strcomp := libc_strcmp(str1,str2);
107
{$endif FPC_UNIT_HAS_STRCOMP}
110
{$ifndef FPC_UNIT_HAS_STRICOMP}
111
{$define FPC_UNIT_HAS_STRICOMP}
112
function libc_strcasecmp(const str1,str2: pchar): longint; cdecl; external 'c' name 'strcasecmp';
114
function StrIComp(Str1, Str2 : PChar): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
116
stricomp := libc_strcasecmp(str1,str2);
118
{$endif FPC_UNIT_HAS_STRICOMP}
121
{$ifndef FPC_UNIT_HAS_STRLCOMP}
122
{$define FPC_UNIT_HAS_STRLCOMP}
123
function libc_strncmp(const str1,str2: pchar; l: Cardinal): longint; cdecl; external 'c' name 'strncmp';
125
function StrLComp(Str1, Str2 : PChar; L: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
127
strlcomp := libc_strncmp(str1,str2,l);
129
{$endif FPC_UNIT_HAS_STRLCOMP}
132
{$ifndef FPC_UNIT_HAS_STRLICOMP}
133
{$define FPC_UNIT_HAS_STRLICOMP}
134
function libc_strncasecmp(const str1,str2: pchar; l: Cardinal): longint; cdecl; external 'c' name 'strncasecmp';
136
function StrLIComp(Str1, Str2 : PChar; L: SizeInt): SizeInt;{$ifdef SYSTEMINLINE}inline;{$endif}
138
strlicomp := libc_strncasecmp(str1,str2,l);
140
{$endif FPC_UNIT_HAS_STRLICOMP}
144
$Log: cgenstr.inc,v $
145
Revision 1.2 2004/05/01 23:55:18 peter
146
* replace strlenint with sizeint
148
Revision 1.1 2004/05/01 15:26:33 jonas
149
* use some more string routines from libc if FPC_USE_LIBC is used