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

1.1       root        1: /* Copyright Bell Telephone Laboratories Whippany, N.J.
                      2: 
                      3:  *     ***********************************
                      4:  *     ***********************************
                      5:  *     *** CALL (OVERLAY) A SUBROUTINE ***
                      6:  *     *** R. B. Drake WH 8C-005 X4163 ***
                      7:  *     **** Wed Aug 29 16:40:29 1979 *****
                      8:  *     ***********************************
                      9:  *     ***********************************
                     10:  * Calling sequence:
                     11:  *  
                     12:  *     call name,line#
                     13:  *  
                     14:  * "call" lokks at line "line#" and if that line contains "rem name"
                     15:  * it does a gosub to that line. If that line does not contain "rem name"
                     16:  * it searches the current directory for a file "name.b" and loads or
                     17:  * overlays it according to the line numbers that exist in the file.
                     18:  * then it executes a gosub line#.
                     19: 
                     20: */
                     21: /*   "@(#) call.c:  V 1.1  12/21/80" */
                     22: 
                     23: #include "bas.h"
                     24: static int li;
                     25: static char file[15],Line[15];
                     26: call()
                     27: {
                     28:        int cur;
                     29:        FILE *pathopen(),*fp;
                     30:        char *prncpy(),*pt;
                     31:        char name[15];
                     32:        extern char *expr;
                     33:        cur=inst.thing.linno;
                     34:        pt=prncpy(file,expr);
                     35:        if(*pt++ != ',')
                     36:        {
                     37:                error(cur,8);
                     38:                return(-1);
                     39:        }
                     40:        pt=prncpy(Line,pt);
                     41:        li=atoi(Line);
                     42:        if(ch()) return(0);
                     43:        strcpy(name,file);
                     44:        postb(name);
                     45:        if((fp=pathopen(name)) == 0)
                     46:        {
                     47:                error(cur,4);
                     48:                return(-1);
                     49:        }
                     50:        while(bed(fp) == 0);
                     51:        fclose(fp);
                     52:        if(ch()) return(0);
                     53:        error(cur,43);
                     54:        return(-1);
                     55: }
                     56: ch()
                     57: {
                     58:        char *ptr;
                     59:        fetch(li,&ptr);
                     60:        if(!strcmp(file,expr))
                     61:        {
                     62:                expr=Line;
                     63:                if(gosub() == -1) return(0);
                     64:                return(1);
                     65:        }
                     66:        return(0);
                     67: }

unix.superglobalmegacorp.com

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