1- #include <wchar.h>
21#include <stdio.h>
2+ #include <wchar.h>
33
44void sample1 () {
55 /* Test for plain char type */
@@ -16,15 +16,15 @@ void sample1() {
1616
1717 /* Test for wide char type */
1818 const wchar_t * ws1 = L"wide string1" ; // COMPLIANT: string literal assigned to
19- // a const char* variable
19+ // a const char* variable
2020 const register volatile wchar_t * ws2 =
2121 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)
2828}
2929
3030/* Testing returning a plain string literal */
@@ -39,8 +39,8 @@ const char *sample2(int x) {
3939/* Testing returning a wide string literal */
4040const wchar_t * w_sample2 (int x ) {
4141 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*
4444 else
4545 return NULL ;
4646}
@@ -56,7 +56,7 @@ char *sample3(int x) {
5656wchar_t * w_sample3 (int x ) {
5757 if (x == 1 )
5858 return L"string6" ; // NON_COMPLIANT: can return a string literal with return
59- // type being char*
59+ // type being char*
6060 else
6161 return NULL ;
6262}
0 commit comments