📄 cmpkeys.c
字号:
/* * cmpkeys.c - keys comparision * Kernel of GNU SQL-server * * This file is a part of GNU SQL Server * * Copyright (c) 1996, 1997, Free Software Foundation, Inc * Developed at the Institute of System Programming * This file is written by Vera Ponomarenko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Contacts: gss@ispras.ru * *//* $Id: cmpkeys.c,v 1.246 1997/04/10 06:57:28 vera Exp $ */#include "destrn.h"#include "strml.h"#include "fdcltrn.h"intcmpkeys (u2_t kn, u2_t * afn, struct des_field *df, char *pk1, char *pk2){ u2_t kk, k, n1, n2; char *k1, *kval1, *k2, *kval2; i4_t v; if (pk1 == NULL) return (1); /* The first is absent */ if (pk2 == NULL) return (-1); /* The second is absent */ k1 = kval1 = pk1 + scscal (pk1); k2 = kval2 = pk2 + scscal (pk2); for (kk = 0; kk < kn && pk1 < k1 && pk2 < k2; pk1++, pk2++) for (k = 0; k < 7 && kk < kn; kk++, k++) if ((*pk1 & BITVL(k)) != 0) { if ((*pk2 & BITVL(k)) != 0) { /* both are defined */ switch ((df + afn[kk])->field_type) { case T1B: if ((v = f1b (kval1, kval2, size1b, size1b)) != 0) return (v); kval1++; kval2++; break; case T2B: if ((v = f2b (kval1, kval2, size2b, size2b)) != 0) return (v); kval1 += size2b; kval2 += size2b; break; case T4B: if ((v = f4b (kval1, kval2, size4b, size4b)) != 0) return (v); kval1 += size4b; kval2 += size4b; break; case TFLOAT: if ((v = flcmp (kval1, kval2, size4b, size4b)) != 0) return (v); kval1 += size4b; kval2 += size4b; break; case TFL: n1 = t2bunpack (kval1); kval1 += size2b; n2 = t2bunpack (kval2); kval2 += size2b; if ((v = ffloat (kval1, kval2, n1, n2)) != 0) return (v); kval1 += n1; kval2 += n2; break; case TCH: n1 = t2bunpack (kval1); kval1 += size2b; n2 = t2bunpack (kval2); kval2 += size2b; if ((v = chcmp (kval1, kval2, n1, n2)) != 0) return (v); kval1 += n1; kval2 += n2; break; default: printf ("TRN.cmpkeys: This data type is incorrect"); break; } } else return (-1); /* The second isn't defined */ } else if ((*pk2 & BITVL(k)) != 0) return (1); /* The first isn't defined */ if (kk < kn) { if (pk1 == k1) { if (pk2 == k2) return (0); else return (1); } else return (-1); } return (0);}intcmp2keys (u2_t type, char *pk1, char *pk2){ switch (type) { case T2B: return (f2b (pk1, pk2, size2b, size2b)); break; case T4B: return (f4b (pk1, pk2, size4b, size4b)); break; default: printf ("TRN.cmp2keys: This data type is incorrect"); break; } return (0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -