home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / comm / mail / smail / src / rcs / str.c,v < prev    next >
Text File  |  1993-12-21  |  2KB  |  135 lines

  1. head    1.2;
  2. access;
  3. symbols
  4.     C_1:1.2;
  5. locks; strict;
  6. comment    @ * @;
  7.  
  8.  
  9. 1.2
  10. date    93.09.18.16.47.47;    author Aussem;    state Exp;
  11. branches;
  12. next    1.1;
  13.  
  14. 1.1
  15. date    93.09.08.16.27.13;    author Aussem;    state Exp;
  16. branches;
  17. next    ;
  18.  
  19.  
  20. desc
  21. @stricmp() and strnicmp()
  22. @
  23.  
  24.  
  25. 1.2
  26. log
  27. @insert GNU license text in the header
  28. @
  29. text
  30. @/*
  31.  * str.c
  32.  *
  33.  * Routines for string compare
  34.  *
  35.  * This program is free software; you can redistribute it and/or
  36.  * modify it under the terms of the GNU General Public License as
  37.  * published by the Free Software Foundation; either version 2 of
  38.  * the License, or (at your option) any later version.
  39.  *
  40.  * This program is distributed in the hope that it will be useful,
  41.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  42.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  43.  * General Public License for more details.
  44.  *
  45.  * You should have received a copy of the GNU General Public License
  46.  * along with this program; if not, write to the Free Software
  47.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  48.  *
  49.  * $Log: str.c,v $
  50.  * Revision 1.1  1993/09/08  16:27:13  Aussem
  51.  * Initial revision
  52.  *
  53.  *
  54.  */
  55.  
  56. static char     *rcsid="$Id: str.c,v 1.1 1993/09/08 16:27:13 Aussem Exp Aussem $";
  57.  
  58. #include <ctype.h>
  59. #include <stdio.h>
  60. #include "defs.h"
  61.  
  62. /*
  63. **    strncmpic: string compare, ignore case, stop after 'n' chars
  64. */
  65.  
  66. strncmpic(s1, s2, n)
  67. char *s1, *s2;
  68. int n;
  69. {
  70.     register char *u = s1;
  71.     register char *p = s2;
  72.  
  73.     while((n > 0) && (*p != '\0'  && *u != '\0' )) {
  74.         /* chars match or only case different */
  75.         if(lower(*u) == lower(*p)) {
  76.             p++;    /* examine next char */
  77.             u++;
  78.         } else {
  79.             break;    /* no match - stop comparison */
  80.         }
  81.         n--;
  82.     }
  83.     if(n > 0) {
  84.         return(lower(*u) - lower(*p)); /* return "difference" */
  85.     } else {
  86.         return(0);
  87.     }
  88. }
  89.  
  90. /*
  91. **    strcmpic: string compare, ignore case
  92. */
  93.  
  94. strcmpic(s1, s2)
  95. char *s1, *s2;
  96. {
  97.     register char *u = s1;
  98.     register char *p = s2;
  99.  
  100.     while(*p != '\0' && *u != '\0') {
  101.         /* chars match or only case different */
  102.         if(lower(*u) == lower(*p)) {
  103.             p++;    /* examine next char */
  104.             u++;
  105.         } else {
  106.             break;    /* no match - stop comparison */
  107.         }
  108.     }
  109.  
  110.     return(lower(*u) - lower(*p)); /* return "difference" */
  111. }
  112.  
  113. @
  114.  
  115.  
  116. 1.1
  117. log
  118. @Initial revision
  119. @
  120. text
  121. @d2 1
  122. a2 1
  123.  *  str.c
  124. d4 1
  125. a4 1
  126.  *  Routines for string compare
  127. d6 4
  128. a9 1
  129.  * $Log$
  130. d11 14
  131. d27 1
  132. a27 1
  133. static char     *rcsid="$Id$";
  134. @
  135.