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

1.1       root        1: /* Copyright Bell Telephone Laboratories Whippany, N.J.
                      2: 
                      3:  *     /////////////////////////////////////
                      4:  *     /////////////////////////////////////
                      5:  *     /////////////// let.c ///////////////
                      6:  *     /// J. P. Hawkins WH X4610 8C-001 ///
                      7:  *     ///// Sun Aug 26 06:06:16 1979 //////
                      8:  *     /////////////////////////////////////
                      9:  *     /////////////////////////////////////
                     10: 
                     11:  *
                     12:  *     VARIABLE ASSIGNMENT ROUTINE for
                     13:  *         LET command
                     14:  */
                     15: /*   "@(#) let.c:  V 1.4  3/4/81" */
                     16: 
                     17: #include       "bas.h"
                     18: /*
                     19: #define        skip00() {while(*lexptr == ' ' || *lexptr == '\t') *lexptr++;}
                     20: */
                     21: #define        skip00()        {}      /* does nothing */
                     22: 
                     23: let()
                     24: {
                     25:        int     type;   /* field type */
                     26:        char    varnam[40];
                     27:        double  evalx();
                     28:        double  value;
                     29: #ifdef STRINGS
                     30:        char    field[512];
                     31: #else
                     32:        char    field[40];
                     33: #endif
                     34:        char    *lexptr;        /* string pointer for let */
                     35: 
                     36:        lexptr = expr;          /* set text pointer */
                     37: 
                     38:        type = class(&lexptr,field);    /* get field type */
                     39: 
                     40:        switch(type)
                     41:        {
                     42:                case VRCLASS:
                     43:                case VACLASS:
                     44: #ifdef STRINGS
                     45:                case SVCLASS:
                     46:                case SACLASS:
                     47: #endif
                     48:                        break;
                     49:                default:
                     50:                        error(inst.thing.linno, 3); /* ill var name */
                     51:                        return(-1);
                     52:                        break;
                     53:        }
                     54:        strcpy(varnam, field);  /* copy variable name */
                     55: 
                     56:        skip00();
                     57:        if(*lexptr++ == '\15')  /* if code for '=' */
                     58:        {
                     59:                switch(type)
                     60:                {
                     61:                        case VRCLASS: /* regular variable name */
                     62:                                value = evalx(lexptr);  /* eval right side */
                     63:                                putvar(varnam, value);
                     64:                                return(0);
                     65:                                break;
                     66:                        case VACLASS: /* subscripted var field */
                     67:                                value = evalx(lexptr);  /* eval right side */
                     68:                                aputvar(varnam, value);
                     69:                                return(0);
                     70:                                break;
                     71: #ifdef STRINGS
                     72:                        case SVCLASS: /* String variable */
                     73:                                evals(lexptr,field); /* expand expression */
                     74:                                sputvar(varnam,field); /* Store the string */
                     75:                                break;
                     76:                        case SACLASS: /* String array variable */
                     77:                                evals(lexptr,field);
                     78:                                saputvar(varnam,field);
                     79:                                break;
                     80: #endif
                     81:                        default:
                     82:                                break;
                     83:                }
                     84:        }
                     85:        else
                     86:        {
                     87:                error(inst.thing.linno, 8); /* missing = */
                     88:                return(-1);
                     89:        }
                     90:        return 0;
                     91: }

unix.superglobalmegacorp.com

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