Annotation of 43BSD/ingres/source/iutil/compare.c, revision 1.1

1.1     ! root        1: # include      <ingres.h>
        !             2: # include      <access.h>
        !             3: # include      <symbol.h>
        !             4: # include      <aux.h>
        !             5: # include      <sccs.h>
        !             6: 
        !             7: SCCSID(@(#)compare.c   8.1     12/31/84)
        !             8: 
        !             9: icompare(ax, bx, frmt, frml)
        !            10: char   *ax, *bx, frmt, frml;
        !            11: {
        !            12:        register ANYTYPE        *a, *b;
        !            13:        register int            length;
        !            14:        float                   f4var;
        !            15:        double                  f8var;
        !            16:        ANYTYPE                 atemp, btemp;
        !            17: 
        !            18:        length = frml & I1MASK;
        !            19:        if (frmt == CHAR)
        !            20:                return (scompare(ax, length, bx, length));
        !            21:        a = &atemp;
        !            22:        b = &btemp;
        !            23:        bmove(ax, (char *) a, length);
        !            24:        bmove(bx, (char *) b, length);
        !            25:        if (bequal((char *) a, (char *) b, length))
        !            26:                return (0);
        !            27:        switch (frmt)
        !            28:        {
        !            29:          case INT:
        !            30:                switch (length)
        !            31:                {
        !            32:                  case 1:
        !            33:                        return (a->i1type - b->i1type);
        !            34:                  case 2:
        !            35:                        return (a->i2type - b->i2type);
        !            36:                  case 4:
        !            37:                        return (a->i4type > b->i4type ? 1 : -1);
        !            38:                }
        !            39:                break;
        !            40: 
        !            41:          case FLOAT:
        !            42:                if (frml == 4)
        !            43:                {
        !            44:                        if ( a->f4type > b->f4type )
        !            45:                                return ( 1 );
        !            46:                        else
        !            47:                                return ( -1 );
        !            48:                }
        !            49:                else
        !            50:                {
        !            51:                        if ( a->f8type > b->f8type )
        !            52:                                return ( 1 );
        !            53:                        else
        !            54:                                return ( -1 );
        !            55:                }
        !            56:                break;
        !            57:        }
        !            58:        syserr("compare: t=%d,l=%d", frmt, frml);
        !            59:        /*NOTREACHED*/
        !            60: }
        !            61: /*
        !            62: **  KCOMPARE -- key compare
        !            63: **
        !            64: **     compares all domains indicated by SETKEY in the tuple to the
        !            65: **     corressponding domains in the key.
        !            66: **     the comparison is done according to the format of the domain
        !            67: **     as specified in the descriptor.
        !            68: **
        !            69: **     function values:
        !            70: **             <0 tuple < key
        !            71: **             =0 tuple = key
        !            72: **             >0 tuple > key
        !            73: */
        !            74: 
        !            75: kcompare (dx, tuple, key)
        !            76: DESC   *dx;                    /*relation descriptor   */
        !            77: char   tuple[MAXTUP];          /*tuple to be compared  */
        !            78: char   key[MAXTUP];            /*second tuple or key   */
        !            79: {
        !            80:        register int    i, tmp;
        !            81:        register DESC   *d;
        !            82: 
        !            83:        d = dx;
        !            84:        for (i = 1; i <= d->reldum.relatts; i++)
        !            85:        {
        !            86:                if (d->relgiven[i])
        !            87:                {
        !            88:                        if (tmp = icompare(&tuple[d->reloff[i]],
        !            89:                                &key[d->reloff[i]],
        !            90:                                d->relfrmt[i],
        !            91:                                d->relfrml[i]))
        !            92:                        {
        !            93:                                return (tmp);
        !            94:                        }
        !            95:                }
        !            96:        }
        !            97:        return (0);
        !            98: }

unix.superglobalmegacorp.com

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