00001
00002
00003
00004
00005
00006
00007
00008 # include "parm.h"
00009 # include "stree/ststructs.mh"
00010 # include "pass1/stt/sttdefs.h"
00011 # include "Idtable.h"
00012 # define DEBUG yes
00013
00014
00015 int nkeys = 0;
00016
00017 Identry * retrieve(key)
00018 sttrelptr key;
00019 {
00020 nkeys++;
00021 return ( &Idtable[retr1(key, 0, sttnstrings-1)] );
00022 }
00023
00024
00025
00026
00027
00028
00029
00030 retr1(key, f, l)
00031 register sttrelptr key;
00032 register int f, l;
00033 { register int c;
00034
00035 for(;;) {
00036
00037
00038
00039 if ( f > l || Idtable[f].i_sttindx > key || Idtable[l].i_sttindx < key) {
00040 dbgmsg("retr1: Can't find name!\n");
00041 return;
00042 }
00043
00044 c = f;
00045 if( l != f ) {
00046 long r;
00047 int t;
00048
00049
00050
00051
00052
00053 r= ( ((long)(l-f)) * ((long)(key-Idtable[f].i_sttindx)) );
00054 t= ( (int) (Idtable[l].i_sttindx - Idtable[f].i_sttindx) );
00055 r += t >> 1;
00056 c += r / t;
00057 }
00058
00059 if ( Idtable[c].i_sttindx == key )
00060 return(c);
00061 else if ( key < Idtable[c].i_sttindx ) {
00062 f += 1; l = c-1;
00063 } else {
00064 f = c+1; l -= 1;
00065 }
00066 }
00067 }