Annotation of researchv10no/cmd/lcc/tst/init.c, revision 1.1.1.1

1.1       root        1: 
                      2: typedef struct { int codes[3]; char name[6]; } Word;
                      3: 
                      4: Word words[] = {
                      5:        1, 2, 3, "if",
                      6:        { { 4, 5 }, { 'f', 'o', 'r' } },
                      7:        6, 7, 8, {"else"},
                      8:        { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },
                      9:        { 0 },
                     10: }, *wordlist = words;
                     11: 
                     12: int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };
                     13: int *y[] = { x[0], x[1], x[2], 0 };
                     14: 
                     15: 
                     16: main()
                     17: {
                     18:        int i, j;
                     19: 
                     20:        for (i = 0; y[i]; i++) {
                     21:                for (j = 0; y[i][j]; j++)
                     22:                        printf(" %d", y[i][j]);
                     23:                printf("\n");
                     24:        }
                     25:        f();
                     26:        g(wordlist);
                     27:        return 0;
                     28: }
                     29: 
                     30: f() {
                     31:        static char *keywords[] = {"if", "for", "else", "while", 0, };
                     32:        char **p;
                     33: 
                     34:        for (p = keywords; *p; p++)
                     35:                printf("%s\n", *p);
                     36: }
                     37: 
                     38: g(p)
                     39: Word *p;
                     40: {
                     41:        int i;
                     42: 
                     43:        for ( ; p->codes[0]; p++) {
                     44:                for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)
                     45:                        printf("%d ", p->codes[i]);
                     46:                printf("%s\n", p->name);
                     47:        }
                     48:        h();
                     49: }
                     50: 
                     51: h()
                     52: {
                     53:        int i;
                     54: 
                     55:        for (i = 0; i < sizeof(words)/sizeof(Word); i++)
                     56:                printf("%d %d %d %s\n", words[i].codes[0],
                     57:                        words[i].codes[1], words[i].codes[2],
                     58:                        &words[i].name[0]);
                     59: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.