FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
strw_ltrimex.c
Go to the documentation of this file.
1
/* enhanced ltrimw$ function */
2
3
#include "
fb.h
"
4
5
FBCALL
FB_WCHAR
*
fb_WstrLTrimEx
(
const
FB_WCHAR
*src,
const
FB_WCHAR
*pattern )
6
{
7
FB_WCHAR
*dst;
8
ssize_t len;
9
const
FB_WCHAR
*
p
=
NULL
;
10
11
if
( src ==
NULL
) {
12
return
NULL
;
13
}
14
15
{
16
ssize_t len_pattern =
fb_wstr_Len
( pattern );
17
len =
fb_wstr_Len
( src );
18
if
( len >= len_pattern ) {
19
if
( len_pattern==1 ) {
20
p =
fb_wstr_SkipChar
( src,
21
len,
22
*pattern );
23
len = len - (ssize_t)(p - src);
24
25
}
else
if
( len_pattern != 0 ) {
26
p = src;
27
while
(len >= len_pattern ) {
28
if
(
fb_wstr_Compare
( p, pattern, len_pattern )!=0 )
29
break
;
30
p += len_pattern;
31
len -= len_pattern;
32
}
33
}
34
}
35
}
36
37
if
( len > 0 )
38
{
39
/* alloc temp string */
40
dst =
fb_wstr_AllocTemp
( len );
41
if
( dst !=
NULL
)
42
{
43
/* simple copy */
44
fb_wstr_Copy
( dst, p, len );
45
}
46
else
47
dst =
NULL
;
48
}
49
else
50
dst =
NULL
;
51
52
return
dst;
53
}
rtlib
strw_ltrimex.c
Generated on Thu Jan 23 2014 19:40:13 for FreeBASIC by
1.8.4