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

1.1       root        1: /* Copyright Bell Telephone Laboratories Whippany, N.J.
                      2: 
                      3:  *     ***********************************
                      4:  *     ***********************************
                      5:  *     ********** GOSUB-RETURN ***********
                      6:  *     *** R. B. Drake WH 8C-005 X4163 ***
                      7:  *     **** Fri Aug 24 17:32:25 1979 *****
                      8:  *     ***********************************
                      9:  *     ***********************************
                     10: 
                     11: */
                     12: /*   "@(#) gosub.c:  V 1.1  12/21/80" */
                     13: 
                     14: #include "bas.h"
                     15: int rtnflg;
                     16: extern int singflg;
                     17: extern int singst;
                     18: gosub()
                     19: {
                     20:        extern char *ptr;
                     21:        extern int stpflg;
                     22:        char *save;
                     23:        int savno;
                     24:        rtnflg = 0;
                     25: 
                     26:        save = ptr; /* save the incoming program pointer */
                     27:        savno=inst.thing.linno;/* save the gosub line number for diagnostic reasons */
                     28:        if(singflg == 1)
                     29:        {
                     30:                if(singwt() < 0)
                     31:                {
                     32:                        rtnflg=stpflg=singflg=0;
                     33:                        return(0);
                     34:                }
                     35:        }
                     36:        if(fetch(atoi(expr),&ptr) != 0)
                     37:        {
                     38:                error(savno,0); /* Bad line number */
                     39:                ptr=save;
                     40:                inst.thing.linno=savno;
                     41:                return(-1);
                     42:        }
                     43:        /* the following is a local duplicate of the run command */
                     44:        if(inst.thing.linno == singst)
                     45:                singflg = 1;
                     46:        if(singflg == 1)
                     47:        {
                     48:                if(singex() < 0)
                     49:                {
                     50:                        singflg=stpflg=rtnflg=0;
                     51:                        return(0);
                     52:                }
                     53:        }
                     54:        else
                     55:        if(bascall(inst.thing.opcode.lobyte) != 0)
                     56:        {
                     57:                ptr=save;
                     58:                return(-1);
                     59:        }
                     60:        while(fetch(-1,&ptr) == 0 && stpflg == 0 && rtnflg == 0)
                     61:        {
                     62:        if(inst.thing.linno == singst)
                     63:                singflg=1;
                     64:        if(singflg == 1)
                     65:        {
                     66:                if(singex() < 0)
                     67:                {
                     68:                        singflg=stpflg=rtnflg=0;
                     69:                        return(0);
                     70:                }
                     71:        }
                     72:        else
                     73:                if(bascall(inst.thing.opcode.lobyte) != 0)
                     74:                {
                     75:                        ptr=save;
                     76:                        return(-1);
                     77:                }
                     78:        }
                     79:        ptr=save;
                     80:        if(rtnflg==0)
                     81:        {
                     82:                error(savno,14);
                     83:                return(-1);
                     84:        }
                     85:        stpflg = 0;
                     86:        rtnflg=0;
                     87:        return(0);
                     88: }
                     89: /* This is the extremely complex retrun function */
                     90: __return()
                     91: {
                     92:        rtnflg = 1;
                     93:        return(0);
                     94: }

unix.superglobalmegacorp.com

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