]> git.sur5r.net Git - cc65/blob - test/ref/init.c
remote TABs in doc/ and test/
[cc65] / test / ref / init.c
1 /*
2   !!DESCRIPTION!! variable initialization
3   !!ORIGIN!!      LCC 4.1 Testsuite
4   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
5 */
6
7 #include "common.h"
8 /* todo: add back conditional stuff here ! */
9
10 typedef struct { int codes[3]; char name[6]; } Word;
11
12 #ifdef NO_IMPLICIT_FUNC_PROTOTYPES
13
14 #ifdef NO_OLD_FUNC_DECL
15 f();
16 void g(Word *p);
17 h();
18 #else
19 f();
20 g();
21 h();
22 #endif
23
24 #endif
25
26 /*
27 Word words[] = {
28         1, 2, 3,"if",
29         { { 4, 5 }, { 'f', 'o', 'r' } },
30         6, 7, 8, {"else"},
31         { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },
32         { 0 },
33 }, *wordlist = words;
34 */
35
36 Word words[] = {
37         {{1, 2, 3},"if"},
38         { { 4, 5 }, { 'f', 'o', 'r' } },
39         {{6, 7, 8}, "else"},
40         { { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }},
41         {{ 0 }},
42 }, *wordlist = words;
43
44 /*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/
45 int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };
46 int *y[] = { x[0], x[1], x[2], 0 };
47
48 main()
49 {
50         int i, j;
51
52         for (i = 0; y[i]; i++) {
53                 for (j = 0; y[i][j]; j++)
54                         printf(" %d", y[i][j]);
55                 printf("\n");
56         }
57         f();
58         g(wordlist);
59         return 0;
60 }
61
62 f() {
63         static char *keywords[] = {"if", "for", "else", "while", 0, };
64         char **p;
65
66         for (p = keywords; *p; p++)
67                 printf("%s\n", *p);
68 }
69
70 #ifdef NO_OLD_FUNC_DECL
71 void g(Word *p)
72 #else
73 g(p)
74 Word *p;
75 #endif
76 {
77         int i;
78
79         for ( ; p->codes[0]; p++) {
80                 for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)
81                         printf("%d ", p->codes[i]);
82                 printf("%s\n", p->name);
83         }
84         h();
85 }
86
87 h()
88 {
89         int i;
90
91         for (i = 0; i < sizeof(words)/sizeof(Word); i++)
92                 printf("%d %d %d %s\n", words[i].codes[0],
93                         words[i].codes[1], words[i].codes[2],
94                         &words[i].name[0]);
95 }