Annotation of 42BSD/ingres/source/ctlmod/range.c, revision 1.1.1.1

1.1       root        1: # include      <ingres.h>
                      2: # include      <symbol.h>
                      3: # include      <range.h>
                      4: # include      <tree.h>
                      5: # include      <sccs.h>
                      6: 
                      7: SCCSID(@(#)range.c     7.1     2/5/81)
                      8: 
                      9: 
                     10: 
                     11: /*
                     12: **  CLRRANGE -- clear range table(s)
                     13: **
                     14: **     Parameters:
                     15: **             none.
                     16: **
                     17: **     Returns:
                     18: **             none.
                     19: **
                     20: **     Side Effects:
                     21: **             The range table (Qt.qt_rangev) is cleared.
                     22: */
                     23: 
                     24: clrrange()
                     25: {
                     26:        register int    i;
                     27:        register DESC   *d;
                     28: 
                     29:        for (i = 0; i < MAXRANGE; i++)
                     30:        {
                     31:                Qt.qt_rangev[i].rngvmark = FALSE;
                     32:                Qt.qt_remap[i] = i;
                     33:                d = Qt.qt_rangev[i].rngvdesc;
                     34:                if (d != NULL)
                     35:                {
                     36:                        xfree(d);
                     37:                        Qt.qt_rangev[i].rngvdesc = NULL;
                     38:                }
                     39:        }
                     40: }
                     41: /*
                     42: **  DECLARE -- declare a range variable
                     43: **
                     44: **     A range variable is declared.  If possible, the preferred varno
                     45: **     stated is used (this is the one already in the tree).  This
                     46: **     should always be possible when reading the original tree (and
                     47: **     should probably stay this way to make debugging easier).  When
                     48: **     not possible, a new varno is chosen and the tree can later
                     49: **     be patched up by 'mapvars'.
                     50: **
                     51: **     Parameters:
                     52: **             varno -- the preferred varno.
                     53: **             desc -- the descriptor for this range variable.
                     54: **
                     55: **     Returns:
                     56: **             The actual varno assigned.
                     57: **
                     58: **     Side Effects:
                     59: **             Qt.qt_rangev is updated.
                     60: **
                     61: **     Trace Flags:
                     62: **             7.0-3
                     63: */
                     64: 
                     65: declare(varno, desc)
                     66: int    varno;
                     67: DESC   *desc;
                     68: {
                     69:        register int    i;
                     70:        register int    vn;
                     71:        extern char     *trim_relname();
                     72: 
                     73:        vn = varno;
                     74: 
                     75:        /* check for preferred slot in range table available */
                     76:        if (desc != NULL && Qt.qt_rangev[vn].rngvdesc != NULL)
                     77:        {
                     78:                /* try to find another slot */
                     79:                for (i = 0; i < MAXRANGE; i++)
                     80:                        if (Qt.qt_rangev[i].rngvdesc == NULL)
                     81:                                break;
                     82: 
                     83:                if (i >= MAXRANGE)
                     84:                {
                     85:                        /* too many variables */
                     86:                        error(3100, trim_relname(desc->reldum.relid), 0);
                     87:                }
                     88: 
                     89:                vn = i;
                     90:        }
                     91: 
                     92:        /* if clearing, make sure something to clear */
                     93:        if (desc == NULL && Qt.qt_rangev[vn].rngvdesc == NULL)
                     94:                syserr("declare: null clr %d", vn);
                     95: 
                     96:        /* declare variable in the slot */
                     97:        Qt.qt_rangev[vn].rngvdesc = desc;
                     98:        Qt.qt_rangev[vn].rngvmark = (desc != NULL);
                     99: 
                    100: #      ifdef xQTR2
                    101:        if (tTf(7, 0))
                    102:                lprintf("declare(%d, %.14s) into slot %d\n", varno,
                    103:                    desc != NULL ? desc->reldum.relid : "(NULL)", vn);
                    104: #      endif
                    105: 
                    106:        return (vn);
                    107: }

unix.superglobalmegacorp.com

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