FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
str_midassign.c
Go to the documentation of this file.
1
/* mid$ statement */
2
3
#include "
fb.h
"
4
5
FBCALL
void
fb_StrAssignMid
(
FBSTRING
*dst, ssize_t start, ssize_t len,
FBSTRING
*src )
6
{
7
ssize_t src_len, dst_len;
8
9
FB_STRLOCK
();
10
11
if
( (dst ==
NULL
) || (dst->
data
==
NULL
) || (
FB_STRSIZE
( dst ) == 0) )
12
{
13
fb_hStrDelTemp_NoLock
( src );
14
fb_hStrDelTemp_NoLock
( dst );
15
FB_STRUNLOCK
();
16
return
;
17
}
18
19
if
( (src ==
NULL
) || (src->
data
==
NULL
) || (
FB_STRSIZE
( src ) == 0) ) {
20
fb_hStrDelTemp_NoLock
( src );
21
fb_hStrDelTemp_NoLock
( dst );
22
FB_STRUNLOCK
();
23
return ;
24
}
25
26
src_len =
FB_STRSIZE
( src );
27
dst_len =
FB_STRSIZE
( dst );
28
29
if
( (start > 0) && (start <= dst_len) && (len != 0) )
30
{
31
--start;
32
33
if
( (len < 0) || (len > src_len) )
34
len = src_len;
35
36
if
( start + len > dst_len )
37
len = (dst_len - start);
38
39
memcpy( dst->
data
+ start, src->
data
, len );
40
}
41
42
/* del if temp */
43
fb_hStrDelTemp_NoLock
( src );
44
fb_hStrDelTemp_NoLock
( dst );
45
46
FB_STRUNLOCK
();
47
}
rtlib
str_midassign.c
Generated on Thu Jan 23 2014 19:40:13 for FreeBASIC by
1.8.4