FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
str_lcase.c
Go to the documentation of this file.
1
/* lcase$ function */
2
3
#include "
fb.h
"
4
#include <ctype.h>
5
6
FBCALL
FBSTRING
*
fb_StrLcase2
(
FBSTRING
*src,
int
mode )
7
{
8
FBSTRING
*dst;
9
int
i, c;
10
ssize_t len = 0;
11
char
*s, *d;
12
13
if
( src ==
NULL
)
14
return
&
__fb_ctx
.
null_desc
;
15
16
FB_STRLOCK
();
17
18
if
( src->
data
) {
19
len =
FB_STRSIZE
( src );
20
/* alloc temp string */
21
dst =
fb_hStrAllocTemp_NoLock
(
NULL
, len );
22
}
else
{
23
dst =
NULL
;
24
}
25
26
if
( dst ) {
27
s = src->
data
;
28
d = dst->
data
;
29
30
if
( mode == 1 ) {
31
for
( i = 0; i < len; i++ ) {
32
c = *s++;
33
if
( (c >= 65) && (c <= 90) )
34
c += 97 - 65;
35
*d++ = c;
36
}
37
}
else
{
38
for
( i = 0; i < len; i++ ) {
39
c = *s++;
40
if
( isupper( c ) )
41
c = tolower( c );
42
*d++ = c;
43
}
44
}
45
46
/* null char */
47
*d =
'\0'
;
48
}
else
{
49
dst = &
__fb_ctx
.
null_desc
;
50
}
51
52
/* del if temp */
53
fb_hStrDelTemp_NoLock
( src );
54
55
FB_STRUNLOCK
();
56
57
return
dst;
58
}
rtlib
str_lcase.c
Generated on Thu Jan 23 2014 19:40:13 for FreeBASIC by
1.8.4