home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / SMALL_C / LEXCMP.C < prev    next >
Text File  |  1987-10-04  |  2KB  |  50 lines

  1. #define NOCCARGC  /* no argument count passing */
  2. /*
  3. ** lexcmp(s, t) - Return a number <0, 0, or>0 
  4. **                as s is <, =, or > t.
  5. */
  6. lexcmp(s, t) char *s, *t; {
  7.   while(lexorder(*s, *t) == 0)
  8.     if(*s++) ++t;
  9.     else return (0);
  10.   return (lexorder(*s, *t));
  11.   }
  12.  
  13. /*
  14. ** lexorder(c1, c2)
  15. **
  16. ** Return a negative, zero, or positive number if
  17. ** c1 is less than, equal to, or greater than c2,
  18. ** based on a lexicographical (dictionary order)
  19. ** colating sequence.
  20. **
  21. */
  22. char Ulex[128] = {
  23.      /**** NUL - / ****/
  24.        0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
  25.       10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  26.       20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
  27.       30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
  28.       40, 41, 42, 43, 44, 45, 46, 47,
  29.      /**** 0-9 ****/
  30.       65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
  31.      /**** : ; < = > ? @ ****/
  32.       48, 49, 50, 51, 52, 53, 54,
  33.      /**** A-Z ****/
  34.       75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
  35.       88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,
  36.      /**** [ \ ] ^ U ` ****/
  37.       55, 56, 57, 58, 59, 60,
  38.      /**** a-z ****/
  39.       75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
  40.       88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,
  41.      /**** { | } ~ ****/
  42.       61, 62, 63, 64,
  43.      /**** DEL ****/
  44.      101
  45.      };
  46.  
  47. lexorder(c1, c2) char c1, c2; {
  48.   return(Ulex[c1] - Ulex[c2]);
  49.   }
  50.