Annotation of researchv10no/cmd/basic/bite/src/list.c, revision 1.1.1.1

1.1       root        1: /* Copyright Bell Telephone Laboratories Whippany, N.J.
                      2: 
                      3:  *     ***********************************
                      4:  *     ***********************************
                      5:  *     ***** LIST THE PROGRAM BUFFER *****
                      6:  *     *** R. B. Drake WH 8C-005 X4163 ***
                      7:  *     **** Fri Aug 24 17:41:50 1979 *****
                      8:  *     ***********************************
                      9:  *     ***********************************
                     10: 
                     11: */
                     12: /*   "@(#) list.c:  V 1.1  12/21/80" */
                     13: 
                     14: #include "bas.h"
                     15: int start,finish; /* first and last line numbers */
                     16: int stpflg;
                     17: extern char linbuf[];
                     18: stopl()
                     19: {
                     20:        stpflg = 1;
                     21:        printf("\n%s %d\n","INTERRUPT LINE",inst.thing.linno);
                     22:        signal(2,stopl);
                     23: }
                     24: char *expand();
                     25: static int n;
                     26: extern int aut,autflg,inc;
                     27: #define retrn(x) {signal(2,quit);stpflg=0;return(x);}
                     28: list(opt)
                     29: int opt;
                     30: {
                     31: extern char *lbdptr,*curptr;
                     32:        int quit();
                     33:        /* if there is no expression then list the
                     34:         * entire program */
                     35: 
                     36:        signal(2,stopl);
                     37:        n=0;
                     38:        if(expr[0] == 0)
                     39:        {
                     40:                if(opt != 1)
                     41:                {
                     42:                if(fetch(0,&lbdptr) < 0)
                     43:                {
                     44:                        error(0,5);
                     45:                        retrn(-1);
                     46:                }
                     47:                prin();
                     48:                }
                     49:                else
                     50:                lbdptr = curptr;
                     51:                while(fetch(-1,&lbdptr) == 0 && stpflg == 0)
                     52:                {
                     53:                        prin();
                     54:                        if(n==23 && opt == 1) break;
                     55:                }
                     56:                retrn(0);
                     57:        }
                     58:        /* there is an expression so parse it into
                     59:         * start and finish */
                     60:        lnpars();
                     61:                if(fetch(start,&lbdptr) == -1)
                     62:                {
                     63:                        error(0,5);
                     64:                        retrn(-1);
                     65:                }
                     66:        prin(); /* print the first line */
                     67:        if(inst.thing.linno < finish)
                     68:        while(fetch(-1,&lbdptr) == 0 && stpflg == 0)
                     69:        {
                     70:                if(inst.thing.linno > finish)
                     71:                {
                     72:                        lbdptr=curptr;
                     73:                        retrn(0);
                     74:                }
                     75:                prin();
                     76:        }
                     77:        retrn(0);
                     78: }
                     79: /* print routine */
                     80: 
                     81: prin()
                     82: {
                     83:        char *op;
                     84:        int i;
                     85:        n++;
                     86:                expand();
                     87:                printf("%d",inst.thing.linno);
                     88:                if((inst.thing.opcode.hibyte&0377) > 0200)
                     89:                {
                     90:                        i=(inst.thing.opcode.hibyte&0377) - 0200;
                     91:                        while(i--)
                     92:                                printf("\t");
                     93:                }
                     94:                else printf(" ");
                     95:                op = decode(inst.thing.opcode.lobyte);
                     96:                if(op[0] == '\010')
                     97:                        printf("%s\n",linbuf);
                     98:                else
                     99:                printf("%s %s\n",op,linbuf);
                    100:        aut = inst.thing.linno;
                    101:        return(0);
                    102: }
                    103: char *expand()
                    104: {
                    105:        char c;
                    106:        char *pt,*strcat(),*carcat(),*lin;
                    107:        int i,quoflg;
                    108:        pt=lin=linbuf;
                    109:        quoflg = 1;
                    110:        for(i=0;i<LINMAX;linbuf[i++]=0);
                    111:        while((c = *expr++) != '\0')
                    112:        {
                    113:                if(c== '"') quoflg *= -1;
                    114:                if((c >= '\001') && ( c <= '\037') && !nocode(inst.thing.opcode.lobyte)
                    115:                        && quoflg != -1)
                    116:                {
                    117:                        pt=carcat(pt,' ');
                    118:                        pt=strcat(pt,keyword[c-1]);
                    119:                        pt=carcat(pt,' ');
                    120:                        if(c != '\15') /* if non an "=" */
                    121:                        lin=pt; /* after the last keyword has been
                    122:                                encountered, lin will point to the
                    123:                                line number portion of the expression */
                    124:                }
                    125:                else
                    126:                        pt=carcat(pt,c);
                    127:        }
                    128:        return(lin); /* return pointer to line number, used by resequence
                    129:                        to find referenced line numbers in "if", "goto" etc */
                    130: }

unix.superglobalmegacorp.com

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