1: # include   <stdio.h>
   2: # include   "constants.h"
   3: # include   "globals.h"
   4: # include   <sccs.h>
   5: 
   6: SCCSID(@(#)getkey.c	8.1	12/31/84)
   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: }

Defined functions

getkey defined in line 6; used 2 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 747
Valid CSS Valid XHTML 1.0 Strict