home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / word2x0a.zip / source / strcase-os2.c < prev    next >
C/C++ Source or Header  |  1998-07-21  |  938b  |  65 lines

  1. /* $Id: strings.c,v 1.4 1997/05/07 22:36:20 dps Exp $ */
  2.  
  3. #ifdef HAVE_CONFIG_H
  4. #include <config.h>
  5. #endif /* HAVE_CONFIG_H */
  6. #include <stddef.h>
  7.  
  8. #include <ctype.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12.  
  13. #ifndef HAVE_STRCASECMP
  14. int strcasecmp(const char *s, const char *t)
  15. {
  16.     register unsigned char a,b;
  17.  
  18.     while (*s && *t)
  19.     {
  20.     a=tolower(*s);
  21.     b=tolower(*t);
  22.     if (a<b)
  23.         return -1;
  24.     if (a>b)
  25.         return 1;
  26.     s++;
  27.     t++;
  28.     }
  29.     if (*s!='\0')
  30.     return -1;
  31.     if (*t!='\0')
  32.     return 1;
  33.     return 0;
  34. }
  35. #endif
  36.  
  37. #ifndef HAVE_STRNCASECMP
  38. int strncasecmp(const char *s, const char *t, size_t ss_size)
  39. {
  40.     register unsigned char a,b;
  41.     int ii_size=0;
  42.     while (*s && *t && ii_size<ss_size)
  43.     {
  44.     a=tolower(*s);
  45.     b=tolower(*t);
  46.     if (a<b)
  47.         return -1;
  48.     if (a>b)
  49.         return 1;
  50.     s++;
  51.     t++;
  52.         ii_size++;
  53.     }
  54.     if (*s!='\0')
  55.     return -1;
  56.     if (*t!='\0')
  57.     return 1;
  58.     return 0;
  59. }
  60. #endif
  61.  
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65.