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