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