FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
str_left.c
Go to the documentation of this file.
1
/* left$ function */
2
3
#include "
fb.h
"
4
5
FBCALL
FBSTRING
*
fb_LEFT
(
FBSTRING
*src, ssize_t chars )
6
{
7
FBSTRING
*dst;
8
ssize_t len, src_len;
9
10
if
( src ==
NULL
)
11
return
&
__fb_ctx
.
null_desc
;
12
13
FB_STRLOCK
();
14
15
src_len =
FB_STRSIZE
( src );
16
if
( (src->
data
!=
NULL
) && (chars > 0) && (src_len > 0) )
17
{
18
if
( chars > src_len )
19
len = src_len;
20
else
21
len = chars;
22
23
/* alloc temp string */
24
dst =
fb_hStrAllocTemp_NoLock
(
NULL
, len );
25
if
( dst !=
NULL
)
26
{
27
/* simple copy */
28
fb_hStrCopy
( dst->
data
, src->
data
, len );
29
}
30
else
31
dst = &
__fb_ctx
.
null_desc
;
32
}
33
else
34
dst = &
__fb_ctx
.
null_desc
;
35
36
/* del if temp */
37
fb_hStrDelTemp_NoLock
( src );
38
39
FB_STRUNLOCK
();
40
41
return
dst;
42
}
43
44
rtlib
str_left.c
Generated on Thu Jan 23 2014 19:40:13 for FreeBASIC by
1.8.4