FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
strw_convconcat.c
Go to the documentation of this file.
1
/* wstring concatenation + convertion functions */
2
3
#include "
fb.h
"
4
5
FBCALL
FB_WCHAR
*
fb_WstrConcatWA
(
const
FB_WCHAR
*str1,
const
void
*str2, ssize_t str2_size )
6
{
7
FB_WCHAR
*dst;
8
ssize_t str1_len, str2_len;
9
char
*str2_ptr;
10
11
if
( str1 !=
NULL
)
12
str1_len =
fb_wstr_Len
( str1 );
13
else
14
str1_len = 0;
15
16
FB_STRSETUP_FIX
( str2, str2_size, str2_ptr, str2_len );
17
18
/* NULL? */
19
if
( str1_len + str2_len == 0 )
20
{
21
dst =
NULL
;
22
}
23
else
24
{
25
/* alloc temp string */
26
dst =
fb_wstr_AllocTemp
( str1_len + str2_len );
27
28
/* do the concatenation */
29
fb_wstr_Move
( dst, str1, str1_len );
30
fb_wstr_ConvFromA
( &dst[str1_len], str2_len, str2_ptr );
31
}
32
33
/* delete temp? */
34
if
( str2_size == -1 )
35
fb_hStrDelTemp
( (
FBSTRING
*)str2 );
36
37
return
dst;
38
}
39
40
FBCALL
FB_WCHAR
*
fb_WstrConcatAW
(
const
void
*str1, ssize_t str1_size,
const
FB_WCHAR
*str2 )
41
{
42
FB_WCHAR
*dst;
43
ssize_t str1_len, str2_len;
44
char
*str1_ptr;
45
46
FB_STRSETUP_FIX
( str1, str1_size, str1_ptr, str1_len );
47
48
if
( str2 !=
NULL
)
49
str2_len =
fb_wstr_Len
( str2 );
50
else
51
str2_len = 0;
52
53
/* NULL? */
54
if
( str1_len + str2_len == 0 )
55
{
56
dst =
NULL
;
57
}
58
else
59
{
60
/* alloc temp string */
61
dst =
fb_wstr_AllocTemp
( str1_len + str2_len );
62
63
/* do the concatenation */
64
fb_wstr_ConvFromA
( dst, str1_len, str1_ptr );
65
if
( str2_len > 0 )
66
fb_wstr_Move
( &dst[str1_len], str2, str2_len + 1 );
67
}
68
69
/* delete temp? */
70
if
( str1_size == -1 )
71
fb_hStrDelTemp
( (
FBSTRING
*)str1 );
72
73
return
dst;
74
}
75
rtlib
strw_convconcat.c
Generated on Thu Jan 23 2014 19:40:13 for FreeBASIC by
1.8.4