1
- #include <wchar.h>
2
1
#include <stdio.h>
2
+ #include <wchar.h>
3
3
4
4
void sample1 () {
5
5
/* Test for plain char type */
@@ -16,15 +16,15 @@ void sample1() {
16
16
17
17
/* Test for wide char type */
18
18
const wchar_t * ws1 = L"wide string1" ; // COMPLIANT: string literal assigned to
19
- // a const char* variable
19
+ // a const char* variable
20
20
const register volatile wchar_t * ws2 =
21
21
L"wide string2" ; // COMPLIANT: string literal assigned to a const char*
22
- // variable, don't care about the qualifiers
23
- wchar_t * ws3 = L"wide string3" ; // NON_COMPLIANT: char* variable declared to hold
24
- // a string literal
25
- ws3 = L"wide string4" ; // NON_COMPLIANT: char* variable assigned a string
26
- // literal (not likely to be seen in production, since
27
- // there is strcpy)
22
+ // variable, don't care about the qualifiers
23
+ wchar_t * ws3 = L"wide string3" ; // NON_COMPLIANT: char* variable declared to
24
+ // hold a string literal
25
+ ws3 = L"wide string4" ; // NON_COMPLIANT: char* variable assigned a string
26
+ // literal (not likely to be seen in production, since
27
+ // there is strcpy)
28
28
}
29
29
30
30
/* Testing returning a plain string literal */
@@ -39,8 +39,8 @@ const char *sample2(int x) {
39
39
/* Testing returning a wide string literal */
40
40
const wchar_t * w_sample2 (int x ) {
41
41
if (x == 1 )
42
- return L"string5" ; // COMPLIANT: can return a string literal with return type
43
- // being const char* being const char*
42
+ return L"string5" ; // COMPLIANT: can return a string literal with return
43
+ // type being const char* being const char*
44
44
else
45
45
return NULL ;
46
46
}
@@ -56,7 +56,7 @@ char *sample3(int x) {
56
56
wchar_t * w_sample3 (int x ) {
57
57
if (x == 1 )
58
58
return L"string6" ; // NON_COMPLIANT: can return a string literal with return
59
- // type being char*
59
+ // type being char*
60
60
else
61
61
return NULL ;
62
62
}
0 commit comments