Annotation of 42BSD/ingres/source/equel/getkey.c, revision 1.1.1.1

1.1       root        1: # include      <stdio.h>
                      2: # include      "constants.h"
                      3: # include      "globals.h"
                      4: # include      <sccs.h>
                      5: 
                      6: SCCSID(@(#)getkey.c    7.1     2/5/81)
                      7: 
                      8: 
                      9: /*
                     10: **  GETKEY -- Get the optab entry for a keyword
                     11: **
                     12: **     Performs a binary search through Kwrdtab
                     13: **     for a given keyword.
                     14: **
                     15: **     Parameters:
                     16: **             key -- char * to the keywords character 
                     17: **                     representation.
                     18: **
                     19: **     Returns:
                     20: **             a pointer to the optab struct node for that 
                     21: **             keyword, or 0 if not found.
                     22: */
                     23: 
                     24: 
                     25: 
                     26: struct optab
                     27: *getkey(key)
                     28: char           *key;
                     29: {
                     30:        register struct optab   *op;
                     31:        int                     top, bot;
                     32:        register int            k;
                     33:        extern int              Kwrdnum;
                     34: 
                     35:        op = Kwrdtab;
                     36:        bot = 0;
                     37:        top = Kwrdnum - 1;
                     38:        do 
                     39:        {
                     40:                k = (top + bot) / 2;
                     41:                switch (scompare(key, 0, op [k].op_term, 0))
                     42:                {
                     43: 
                     44:                  case 1 :
                     45:                        bot = k + 1;
                     46:                        break;
                     47:                
                     48:                  case 0 :
                     49:                        return (&op [k]);
                     50: 
                     51:                  case -1 :
                     52:                        top = k - 1;
                     53:                        break;
                     54:                }
                     55:        }  while (bot <= top);
                     56:        return (0);
                     57: }

unix.superglobalmegacorp.com

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