home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / elm-2.4-pl20.tar.Z / elm-2.4-pl20.tar / lib / strincmp.c < prev    next >
C/C++ Source or Header  |  1992-10-03  |  1KB  |  51 lines

  1.  
  2. static char rcsid[] = "@(#)$Id: strincmp.c,v 5.1 1992/10/03 22:41:36 syd Exp $";
  3.  
  4. /*******************************************************************************
  5.  *  The Elm Mail System  -  $Revision: 5.1 $   $State: Exp $
  6.  *
  7.  *            Copyright (c) 1988-1992 USENET Community Trust
  8.  *            Copyright (c) 1986,1987 Dave Taylor
  9.  *******************************************************************************
  10.  * Bug reports, patches, comments, suggestions should be sent to:
  11.  *
  12.  *    Syd Weinstein, Elm Coordinator
  13.  *    elm@DSI.COM            dsinc!elm
  14.  *
  15.  *******************************************************************************
  16.  * $Log: strincmp.c,v $
  17.  * Revision 5.1  1992/10/03  22:41:36  syd
  18.  * Initial checkin as of 2.4 Release at PL0
  19.  *
  20.  *
  21.  ******************************************************************************/
  22.  
  23. /** compare strings ignoring case - length limited
  24. **/
  25.  
  26. #include "headers.h"
  27. #include <ctype.h>
  28.  
  29. #ifdef BSD
  30. #undef tolower
  31. #undef toupper
  32. #endif
  33.  
  34. int
  35. strincmp(s1,s2,n)
  36. register char *s1, *s2;
  37. register int n;
  38. {
  39.     /* case insensitive comparison */
  40.     register int d;
  41.     while (--n >= 0) {
  42.       d = ( isupper(*s1) ? tolower(*s1) : *s1 )
  43.           - ( isupper(*s2) ? tolower(*s2) : *s2 ) ;
  44.       if ( d != 0 || *s1 == '\0' || *s2 == '\0' )
  45.         return d;
  46.       ++s1;
  47.       ++s2;
  48.     }
  49.     return(0);
  50. }
  51.