File: init.c

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (95 lines) | stat: -rw-r--r-- 1,939 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
  !!DESCRIPTION!! variable initialization
  !!ORIGIN!!      LCC 4.1 Testsuite
  !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
*/

#include "common.h"
/* todo: add back conditional stuff here ! */

typedef struct { int codes[3]; char name[6]; } Word;

#ifdef NO_IMPLICIT_FUNC_PROTOTYPES

#ifdef NO_OLD_FUNC_DECL
f();
void g(Word *p);
h();
#else
f();
g();
h();
#endif

#endif

/*
Word words[] = {
        1, 2, 3,"if",
        { { 4, 5 }, { 'f', 'o', 'r' } },
        6, 7, 8, {"else"},
        { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },
        { 0 },
}, *wordlist = words;
*/

Word words[] = {
        {{1, 2, 3},"if"},
        { { 4, 5 }, { 'f', 'o', 'r' } },
        {{6, 7, 8}, "else"},
        { { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }},
        {{ 0 }},
}, *wordlist = words;

/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/
int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };
int *y[] = { x[0], x[1], x[2], 0 };

main()
{
        int i, j;

        for (i = 0; y[i]; i++) {
                for (j = 0; y[i][j]; j++)
                        printf(" %d", y[i][j]);
                printf("\n");
        }
        f();
        g(wordlist);
        return 0;
}

f() {
        static char *keywords[] = {"if", "for", "else", "while", 0, };
        char **p;

        for (p = keywords; *p; p++)
                printf("%s\n", *p);
}

#ifdef NO_OLD_FUNC_DECL
void g(Word *p)
#else
g(p)
Word *p;
#endif
{
        int i;

        for ( ; p->codes[0]; p++) {
                for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)
                        printf("%d ", p->codes[i]);
                printf("%s\n", p->name);
        }
        h();
}

h()
{
        int i;

        for (i = 0; i < sizeof(words)/sizeof(Word); i++)
                printf("%d %d %d %s\n", words[i].codes[0],
                        words[i].codes[1], words[i].codes[2],
                        &words[i].name[0]);
}