FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
str_set.c
Go to the documentation of this file.
1
/* lset and rset functions */
2
3
#include "
fb.h
"
4
5
FBCALL
void
fb_StrLset
(
FBSTRING
*dst,
FBSTRING
*src )
6
{
7
ssize_t slen, dlen, len;
8
9
if
( (dst !=
NULL
) && (dst->
data
!=
NULL
) && (src !=
NULL
) && (src->
data
!=
NULL
) )
10
{
11
slen =
FB_STRSIZE
( src );
12
dlen =
FB_STRSIZE
( dst );
13
14
if
( dlen > 0 )
15
{
16
len = (dlen <= slen? dlen: slen );
17
18
fb_hStrCopy
( dst->
data
, src->
data
, len );
19
20
len = dlen - slen;
21
if
( len > 0 )
22
{
23
memset( &dst->
data
[slen], 32, len );
24
25
/* null char */
26
dst->
data
[slen+len] =
'\0'
;
27
}
28
}
29
}
30
31
/* del if temp */
32
fb_hStrDelTemp
( src );
33
34
/* del if temp */
35
fb_hStrDelTemp
( dst );
36
}
37
38
FBCALL
void
fb_StrRset
(
FBSTRING
*dst,
FBSTRING
*src )
39
{
40
ssize_t slen, dlen, len, padlen;
41
42
if
( (dst !=
NULL
) && (dst->
data
!=
NULL
) && (src !=
NULL
) && (src->
data
!=
NULL
) )
43
{
44
slen =
FB_STRSIZE
( src );
45
dlen =
FB_STRSIZE
( dst );
46
47
if
( dlen > 0 )
48
{
49
padlen = dlen - slen;
50
if
( padlen > 0 )
51
memset( dst->
data
, 32, padlen );
52
else
53
padlen = 0;
54
55
len = (dlen <= slen? dlen: slen );
56
57
fb_hStrCopy
( &dst->
data
[padlen], src->
data
, len );
58
}
59
}
60
61
/* del if temp */
62
fb_hStrDelTemp
( src );
63
64
/* del if temp */
65
fb_hStrDelTemp
( dst );
66
}
rtlib
str_set.c
Generated on Thu Jan 23 2014 19:40:13 for FreeBASIC by
1.8.4