Annotation of researchv8dc/cmd/ideal/ideal.c, revision 1.1.1.1

1.1       root        1: #include "ideal.h"
                      2: #include "y.tab.h"
                      3: 
                      4: boolean dbg = FALSE;
                      5: int when_bug = 0;
                      6: char *filename;
                      7: int lineno = 0;
                      8: char libstr[100];
                      9: boolean radflag = FALSE;
                     10: 
                     11: BOXPTR boxlist = NULL;
                     12: 
                     13: main(argc, argv)
                     14: int argc;
                     15: char *argv[];
                     16: {
                     17:        bug_off;
                     18:        while (argc > 1 && argv[1][0] == '-') {
                     19:                switch (argv[1][1]) {
                     20:                case 'd':
                     21:                        when_bug = argv[1][2]?atoi(&argv[1][2]):~0;
                     22:                        break;
                     23:                case 'l':
                     24:                        idinclude (&argv[1][2], LIBFIL);
                     25:                        while (yyparse());
                     26:                        break;
                     27:                case 'r':
                     28:                        radflag = TRUE;
                     29:                        break;
                     30:                case 'p':
                     31:                case '4':
                     32:                case 'n':
                     33:                        break;
                     34:                default:
                     35:                        fprintf(stderr, "ideal: unknown flag %c\n", argv[1][1]);
                     36:                        break;
                     37:                }
                     38:                argc--;
                     39:                argv++;
                     40:        }
                     41:        if (argc < 2) {
                     42:                filename = "-";
                     43:                lineno = 0;
                     44:                filepush (stdin);
                     45:                while (yyparse ());
                     46:        } else
                     47:                while (argc-- > 1) {
                     48:                        filename = *argv;
                     49:                        lineno = 0;
                     50:                        idinclude (*++argv, CHATTY);
                     51:                        while (yyparse ());
                     52:                }
                     53:        exit(0);
                     54: }
                     55: 
                     56: interpret()
                     57: {
                     58:        PUTNODE dummyroot;
                     59:        if (when_bug & 01) bug_on;
                     60:        else bug_off;
                     61:        dummyroot.name = lookup("main");
                     62:        dummyroot.parm = boxgen (lookup("main"), (STMTPTR) NULL);
                     63:        /* if boxlist includes main, execute it */
                     64:        if (boxlist && findbox(lookup("main"),TRUE)->stmtlist) {
                     65:                NOADPTR noadtree;
                     66:                bug_off;
                     67:                /* make room for all variables */
                     68:                noadtree = buildnoadtree (&dummyroot);
                     69:                /* solve all equations */
                     70:                eqneval (noadtree);
                     71:                nl_eval ();
                     72:                depvarkill ();
                     73:                /* make a list of segments in the picture */
                     74:                noadtree->linelist = build (noadtree, noadtree->linelist);
                     75:                /* draw the thing */
                     76:                act (noadtree->linelist);
                     77:                /* free the thing, but save definitions */
                     78:                noadfree (noadtree);
                     79:                fflush (stdout);
                     80:                forget (lookup ("main"));
                     81:        }
                     82: }
                     83: 
                     84: idinclude (filnam, mode)
                     85: char *filnam;
                     86: int mode;
                     87: {
                     88:        FILE *nufile;
                     89:        dprintf "opening file %s\n", filnam);
                     90:        printf (".lf 1 %s\n", filnam);
                     91:        if (mode == CHATTY)
                     92:                nufile = fopen (filnam, "r");
                     93:        else if (mode == LIBFIL) {
                     94:                strcpy (libstr, getenv("LIBDIR"));
                     95:                strcat (&libstr[0],filnam);
                     96:                filnam = libstr;
                     97:                nufile = fopen (filnam, "r");
                     98:        }
                     99:        filename = filnam;
                    100:        if (!nufile) {
                    101:                fprintf (stderr, "ideal: can't open file %s\n", filnam);
                    102:                exit (1);
                    103:        } else {
                    104:                filepush (nufile);
                    105:        }
                    106: }
                    107: 
                    108: act (the_picture)
                    109: LINEPTR the_picture;
                    110: {
                    111:        LINEPTR lineseg;
                    112:        double bounds[4];
                    113: #define        maxx    bounds[MAXX]
                    114: #define        maxy    bounds[MAXY]
                    115: #define        minx    bounds[MINX]
                    116: #define        miny    bounds[MINY]
                    117:        maxx = -10000.0;
                    118:        maxy = -10000.0;
                    119:        minx = 10000.0;
                    120:        miny = 10000.0;
                    121:        for (lineseg = the_picture; lineseg; lineseg = lineseg->next) {
                    122:                switch (lineseg->kind) {
                    123:                case LINE:
                    124:                        bbline (lineseg, bounds);
                    125:                        break;
                    126:                case CIRCLE:
                    127:                        bbcirc ((CIRCPTR) lineseg, bounds);
                    128:                        break;
                    129:                case ARC:
                    130:                        bbarc ((ARCPTR) lineseg, bounds);
                    131:                        break;
                    132:                case STRING:
                    133:                        bbstring ((TEXTPTR) lineseg, bounds);
                    134:                        break;
                    135:                case SPLINE:
                    136:                        break;
                    137:                default:
                    138:                        fprintf (stderr, "ideal: act: can't happen\n");
                    139:                        break;
                    140:                }
                    141:        }
                    142:        if (the_picture) {
                    143:                boundscall (bounds);
                    144:        }
                    145:        for (lineseg = the_picture; lineseg; lineseg = lineseg->next) {
                    146:                switch (lineseg->kind) {
                    147:                case LINE:
                    148:                        linecall (lineseg);
                    149:                        break;
                    150:                case CIRCLE:
                    151:                        circcall ((CIRCPTR) lineseg);
                    152:                        break;
                    153:                case ARC:
                    154:                        arccall ((ARCPTR) lineseg);
                    155:                        break;
                    156:                case STRING:
                    157:                        textcall ((TEXTPTR) lineseg);
                    158:                        break;
                    159:                case SPLINE:
                    160:                        splcall (((SPLPTR) lineseg)->knotlist);
                    161:                        break;
                    162:                default:
                    163:                        fprintf (stderr, "ideal: act: can't happen\n");
                    164:                        break;
                    165:                }
                    166:        }
                    167: }

unix.superglobalmegacorp.com

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