]> git.sur5r.net Git - cc65/blob - test/val/cq22.c
remote TABs in doc/ and test/
[cc65] / test / val / cq22.c
1 /*
2   !!DESCRIPTION!! C-Manual Chapter 2.2: identifiers (names)
3   !!ORIGIN!!      LCC 4.1 Testsuite
4   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
5 */
6
7 #include "common.h"
8
9 struct defs {
10      int cbits;          /* No. of bits per char           */
11      int ibits;          /*                 int            */
12      int sbits;          /*                 short          */
13      int lbits;          /*                 long           */
14      int ubits;          /*                 unsigned       */
15      int fbits;          /*                 float          */
16      int dbits;          /*                 double         */
17      #ifndef NO_FLOATS
18         float fprec;        /* Smallest number that can be    */
19         float dprec;        /* significantly added to 1.      */
20      #endif
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            */
28 };
29
30      int lbits;          /*                 long           */
31      int ubits;          /*                 unsigned       */
32      int fbits;          /*                 float          */
33      int dbits;          /*                 double         */
34      #ifndef NO_FLOATS
35         float fprec;        /* Smallest number that can be    */
36         float dprec;        /* significantly added to 1.      */
37      #endif
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            */
45
46 /*
47         2.2 Identifiers (Names)
48 */
49
50 #ifndef NO_OLD_FUNC_DECL
51 s22(pd0)
52 struct defs *pd0;
53 {
54 #else
55 int s22(struct defs *pd0)
56 {
57 #endif
58
59    int a234, a;
60    int _, _234, A, rc;
61
62    static char s22er[] = "s22,er%d\n";
63    static char qs22[8] = "s22    ";
64
65    char *ps, *pt;
66                          /* Initialize                      */
67
68    rc = 0;
69    ps = qs22;
70    pt = pd0 -> rfs;
71    while (*pt++ = *ps++);
72
73      /* An identifier is a sequence of letters and digits;
74         the first character must be a letter. The under-
75         score _ counts as a letter.                        */
76
77    a=1;
78    _=2;
79    _234=3;
80    a234=4;
81    if(a+_+_234+a234 != 10) {
82      rc = rc+1;
83      if(pd0->flgd != 0) printf(s22er,1);
84    }
85
86    /* Upper and lower case letters are different.     */
87
88    A = 2;
89    if (A == a) {
90      rc = rc+4;
91      if (pd0->flgd != 0) printf(s22er,4);
92    }
93
94    return(rc);
95 }
96
97 /*********************************************************************************************
98  the main loop that launches the sections
99 *********************************************************************************************/
100
101 #define cq_sections 1
102
103 #ifndef NO_TYPELESS_STRUCT_PTR
104         int section(int j,struct* pd0){
105 #else
106         int section(int j,void* pd0){
107 #endif
108         switch(j){
109                 case 0: return s22(pd0);
110         }
111 }
112
113 /*
114         C REFERENCE MANUAL (main)
115 */
116
117 #ifndef NO_OLD_FUNC_DECL
118 main(n,args)
119 int n;
120 char **args;
121 {
122 #else
123 int main(int n,char **args) {
124 #endif
125
126 int j;
127 static struct defs d0, *pd0;
128         
129    d0.flgs = 1;          /* These flags dictate            */
130    d0.flgm = 1;          /*     the verbosity of           */
131    d0.flgd = 1;          /*         the program.           */
132    d0.flgl = 1;
133
134    pd0 = &d0;
135
136    for (j=0; j<cq_sections; j++) {
137      d0.rrc=section(j,pd0);
138      d0.crc=d0.crc+d0.rrc;
139      if(d0.flgs != 0) printf("Section %s returned %d.\n",d0.rfs,d0.rrc);
140    }
141
142    if(d0.crc == 0) printf("\nNo errors detected.\n");
143    else printf("\nFailed.\n");
144
145    return d0.crc;
146 }