2 !!DESCRIPTION!! C-Manual Chapter 2.43: character constants
3 !!ORIGIN!! LCC 4.1 Testsuite
4 !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
10 int cbits; /* No. of bits per char */
12 int sbits; /* short */
14 int ubits; /* unsigned */
15 int fbits; /* float */
16 int dbits; /* double */
18 float fprec; /* Smallest number that can be */
19 float dprec; /* significantly added to 1. */
21 int flgs; /* Print return codes, by section */
22 int flgm; /* Announce machine dependencies */
23 int flgd; /* give explicit diagnostics */
24 int flgl; /* Report local return codes. */
25 int rrc; /* recent return code */
26 int crc; /* Cumulative return code */
27 char rfs[8]; /* Return from section */
31 int ubits; /* unsigned */
32 int fbits; /* float */
33 int dbits; /* double */
35 float fprec; /* Smallest number that can be */
36 float dprec; /* significantly added to 1. */
38 int flgs; /* Print return codes, by section */
39 int flgm; /* Announce machine dependencies */
40 int flgd; /* give explicit diagnostics */
41 int flgl; /* Report local return codes. */
42 int rrc; /* recent return code */
43 int crc; /* Cumulative return code */
44 char rfs[8]; /* Return from section */
46 /*********************************************************************************************
47 2.4.3 Character constants
48 **********************************************************************************************/
50 #ifndef NO_OLD_FUNC_DECL
55 void zerofill(char *x) {
59 for (j=0; j<256; j++) *x++ = 0;
62 #ifndef NO_OLD_FUNC_DECL
75 for(j=0; j<256; j++) total = total+ *p++;
81 #ifndef NO_OLD_FUNC_DECL
86 int s243(struct defs *pd0) {
88 static char s243er[] = "s243,er%d\n";
89 static char qs243[8] = "s243 ";
92 /* char chars[256]; */
99 /* One of the problems that arises when testing character constants
100 is that of definition: What, exactly, is the character set?
101 In order to guarantee a certain amount of machine independence,
102 the character set we will use here is the set of characters writ-
103 able as escape sequences in C, plus those characters used in writ-
104 ing C programs, i.e.,
107 ABCDEFGHIJKLMNOPQRSTUVWXYZ 26
108 abcdefghijklmnopqrstuvwxyz 26
112 ~!"#%&()_=-^|{}[]+;*:<>,.?/ 27
113 extra special characters:
125 Any specific implementation of C may of course support additional
128 /* Since the value of a character constant is the numerical value
129 of the character in the machine's character set, there should
130 be a one-to-one correspondence between characters and values. */
134 chars['a'] = 1; chars['A'] = 1; chars['~'] = 1; chars['0'] = 1;
135 chars['b'] = 1; chars['B'] = 1; chars['!'] = 1; chars['1'] = 1;
136 chars['c'] = 1; chars['C'] = 1; chars['"'] = 1; chars['2'] = 1;
137 chars['d'] = 1; chars['D'] = 1; chars['#'] = 1; chars['3'] = 1;
138 chars['e'] = 1; chars['E'] = 1; chars['%'] = 1; chars['4'] = 1;
139 chars['f'] = 1; chars['F'] = 1; chars['&'] = 1; chars['5'] = 1;
140 chars['g'] = 1; chars['G'] = 1; chars['('] = 1; chars['6'] = 1;
141 chars['h'] = 1; chars['H'] = 1; chars[')'] = 1; chars['7'] = 1;
142 chars['i'] = 1; chars['I'] = 1; chars['_'] = 1; chars['8'] = 1;
143 chars['j'] = 1; chars['J'] = 1; chars['='] = 1; chars['9'] = 1;
144 chars['k'] = 1; chars['K'] = 1; chars['-'] = 1;
145 chars['l'] = 1; chars['L'] = 1; chars['^'] = 1;
146 chars['m'] = 1; chars['M'] = 1; chars['|'] = 1; chars['\n'] = 1;
147 chars['n'] = 1; chars['N'] = 1; chars['\t'] = 1;
148 chars['o'] = 1; chars['O'] = 1; chars['{'] = 1; chars['\b'] = 1;
149 chars['p'] = 1; chars['P'] = 1; chars['}'] = 1; chars['\r'] = 1;
150 chars['q'] = 1; chars['Q'] = 1; chars['['] = 1; chars['\f'] = 1;
151 chars['r'] = 1; chars['R'] = 1; chars[']'] = 1;
152 chars['s'] = 1; chars['S'] = 1; chars['+'] = 1; chars['\\'] = 1;
153 chars['t'] = 1; chars['T'] = 1; chars[';'] = 1; chars['\''] = 1;
154 chars['u'] = 1; chars['U'] = 1; chars['*'] = 1;
155 chars['v'] = 1; chars['V'] = 1; chars[':'] = 1; chars['\0'] = 1;
156 chars['w'] = 1; chars['W'] = 1; chars['<'] = 1; chars[' '] = 1;
157 chars['x'] = 1; chars['X'] = 1; chars['>'] = 1;
158 chars['y'] = 1; chars['Y'] = 1; chars[','] = 1;
159 chars['z'] = 1; chars['Z'] = 1; chars['.'] = 1;
163 if(sumof(chars) != 98){
165 if(pd0->flgd != 0) printf(s243er,1);
168 #ifndef NO_BACKSLASH_CHARCODE
170 /* Finally, the escape \ddd consists of the backslash followed
171 by 1, 2, or 3 octal digits which are taken to specify the
172 desired character. */
175 this test is non portable and inaccurate, we replace it
176 by a more failproof version
217 /*********************************************************************************************
218 the main loop that launches the sections
219 *********************************************************************************************/
221 #define cq_sections 1
223 #ifndef NO_TYPELESS_STRUCT_PTR
224 int section(int j,struct* pd0){
226 int section(int j,void* pd0){
229 case 0: return s243(pd0);
234 C REFERENCE MANUAL (main)
237 #ifndef NO_OLD_FUNC_DECL
243 int main(int n,char **args) {
247 static struct defs d0, *pd0;
249 d0.flgs = 1; /* These flags dictate */
250 d0.flgm = 1; /* the verbosity of */
251 d0.flgd = 1; /* the program. */
256 for (j=0; j<cq_sections; j++) {
257 d0.rrc=section(j,pd0);
258 d0.crc=d0.crc+d0.rrc;
259 if(d0.flgs != 0) printf("Section %s returned %d.\n",d0.rfs,d0.rrc);
262 if(d0.crc == 0) printf("\nNo errors detected.\n");
263 else printf("\nFailed.\n");