home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / ast_comp / sql.txt / rwsearch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-04  |  637 b   |  30 lines

  1. # include <ctype.h>
  2. rwsearch( str )
  3. char    *str;
  4. {
  5. int     x;
  6. int     mid;
  7. int     low=0;
  8. int     high=RWORDS - 1;
  9.  
  10.         upshift(str);
  11.         while(low <= high)
  12.         {
  13.                 mid = (low+high)/2;
  14.                 if( !(x=strcmp(str, rwords[mid])) )
  15.                         return(rnums[mid]);
  16.                 else if( x<0 ) /* if lesser */
  17.                         high = mid-1;
  18.                 else if( x>0 ) /* if greater */
  19.                         low = mid+1;
  20.         }
  21.         return(IDENTIFIER);
  22. }
  23.  
  24. upshift(str)
  25. char    *str;
  26. {
  27.         for(;*str;str++)
  28.                 *str = (isupper(*str))? *str : toupper(*str);
  29. }
  30.