Annotation of researchv10no/cmd/cflow/nmf.c, revision 1.1.1.1

1.1       root        1: /*     @(#)nmf.c       1.5     83/08/05        */
                      2: #if defined(UNIX5) && !defined(pdp11)
                      3: #include "stdio.h"
                      4: 
                      5: main(argc, argv)
                      6: char   *argv[];
                      7: {
                      8:        char name[BUFSIZ], buf[BUFSIZ], *fname = NULL, *pty, *strncpy();
                      9:        register char *p;
                     10:        int nsize, tysize, lineno;
                     11: 
                     12:        strcpy(name, argc > 1? argv[1] : "???");
                     13:        if (argc > 2)
                     14:                fname = argv[2];
                     15:        else
                     16:                fname = "???";
                     17:        while (gets(buf))
                     18:        {
                     19:                p = buf;
                     20:                while (*p != ' ' && *p != '|')
                     21:                        ++p;
                     22:                nsize = p - buf;
                     23:                do ; while (*p++ != '|');               /* skip rem of name */
                     24:                do ; while (*p++ != '|');               /* skip value */
                     25:                do ; while (*p++ != '|');               /* skip class */
                     26:                while (*p == ' ')
                     27:                        ++p;
                     28:                if (*p != '|')
                     29:                {
                     30:                        pty = p++;
                     31:                        while (*p != '|')
                     32:                                ++p;
                     33:                        tysize = p - pty;
                     34:                }
                     35:                else
                     36:                        pty = (char *) NULL;
                     37:                ++p;
                     38:                do ; while (*p++ != '|');               /* skip size */
                     39:                while (*p == ' ')
                     40:                        ++p;
                     41:                lineno = atoi(p);
                     42:                do ; while (*p++ != '|');               /* and xlated line */
                     43:                while (*p == ' ')
                     44:                        ++p;
                     45:                if (!strncmp(p, ".text", 5) || !strncmp(p, ".data", 5))
                     46:                {                                       /* it's defined */
                     47:                        strncpy(name, buf, nsize);
                     48:                        name[nsize] = '\0';
                     49:                        printf("%s = ", name);
                     50:                        if (pty)
                     51:                                printf("%.*s", tysize, pty);
                     52:                        else
                     53:                        {
                     54:                                fputs("???", stdout);
                     55:                                if (!strncmp(p, ".text", 5))
                     56:                                        fputs("()", stdout);
                     57:                        }
                     58:                        printf(", <%s %d>\n", fname, lineno);
                     59:                }
                     60:                else
                     61:                        printf("%s : %.*s\n", name, nsize, buf);
                     62:        }
                     63:        exit(0);
                     64: }
                     65: #else
                     66: #include "stdio.h"
                     67: 
                     68: #if u3b || u3b5 || vax
                     69: #define SYMSTART 11
                     70: #define SYMCLASS 9
                     71: #endif
                     72: 
                     73: #if pdp11
                     74: #define SYMSTART 9
                     75: #define SYMCLASS 7
                     76: #endif
                     77: 
                     78: main(argc, argv)
                     79: char   *argv[];
                     80: {
                     81:        char    name[15], buf[64];
                     82:        char    *fname = NULL;
                     83:        char    *p;
                     84: 
                     85:        strcpy(name, argc > 1? argv[1] : "");
                     86:        if (argc > 2)
                     87:                fname = argv[2];
                     88:        while (gets(buf)) {
                     89:                p = &buf[SYMSTART];
                     90:                if (*p == '_')
                     91:                        ++p;
                     92:                switch (buf[SYMCLASS]) {
                     93:                case 'U':
                     94:                        printf("%s : %s\n", name, p);
                     95:                        continue;
                     96:                case 'T':
                     97:                        printf("%s = text", p);
                     98:                        strcpy(name, p);
                     99:                        break;
                    100:                case 'D':
                    101:                        printf("%s = data", p);
                    102:                        if (strcmp(name, "") == 0)
                    103:                                strcpy(name, p);
                    104:                        break;
                    105:                case 'B':
                    106:                        printf("%s = bss", p);
                    107:                        break;
                    108:                case 'A':
                    109:                        printf("%s = abs", p);
                    110:                        break;
                    111:                default:
                    112:                        continue;
                    113:                }
                    114:                if (fname != NULL)
                    115:                        printf(", %s", fname);
                    116:                printf("\n");
                    117:        }
                    118:        exit(0);
                    119: }

unix.superglobalmegacorp.com

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