home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Misc / Wood.0.72 / Sources / libstring.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  963 b   |  63 lines

  1. /* libstring - flex run-time string routines */
  2.  
  3. /* $Header: /home/daffy/u0/vern/flex/RCS/libstring.c,v 1.1 93/12/02 21:19:07 vern Exp $ */
  4.  
  5. /* These routines exist only because it's a pain to portably include
  6.  * <string.h>/<strings.h>, and the generated scanner needs access to
  7.  * strcpy() to support yytext.
  8.  */
  9.  
  10. extern int yy_strcmp();
  11. extern void yy_strcpy();
  12. extern int yy_strlen();
  13.  
  14.  
  15. int yy_strcmp( s1, s2 )
  16. const char *s1;
  17. const char *s2;
  18.     {
  19.     while ( *s1 && *s2 )
  20.         {
  21.         unsigned char uc1 = (unsigned char) *s1;
  22.         unsigned char uc2 = (unsigned char) *s2;
  23.  
  24.         if ( uc1 > uc2 )
  25.             return 1;
  26.  
  27.         else if ( uc1 < uc2 )
  28.             return -1;
  29.  
  30.         ++s1;
  31.         ++s2;
  32.         }
  33.  
  34.     if ( *s1 )
  35.         /* s1 is longer than s2, so s1 > s2 */
  36.         return 1;
  37.  
  38.     else if ( *s2 )
  39.         return -1;
  40.  
  41.     else
  42.         return 0;
  43.     }
  44.  
  45. void yy_strcpy( s1, s2 )
  46. char *s1;
  47. const char *s2;
  48.     {
  49.     while ( (*(s1++) = *(s2++)) )
  50.         ;
  51.     }
  52.  
  53. int yy_strlen( s )
  54. const char* s;
  55.     {
  56.     int len = 0;
  57.  
  58.     while ( s[len] )
  59.         ++len;
  60.  
  61.     return len;
  62.     }
  63.