summaryrefslogtreecommitdiff
path: root/gnu/dist/diffutils/lib/strcasecmp.c
blob: 7ef3034226a63f1b550997e7e0607f9701d2ee25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*	$NetBSD: strcasecmp.c,v 1.1.1.1 2003/01/26 00:43:15 wiz Exp $	*/

/* strcasecmp.c -- case insensitive string comparator
   Copyright (C) 1998, 1999 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#if HAVE_CONFIG_H
# include <config.h>
#endif

#ifdef LENGTH_LIMIT
# define STRXCASECMP_FUNCTION strncasecmp
# define STRXCASECMP_DECLARE_N , size_t n
# define LENGTH_LIMIT_EXPR(Expr) Expr
#else
# define STRXCASECMP_FUNCTION strcasecmp
# define STRXCASECMP_DECLARE_N /* empty */
# define LENGTH_LIMIT_EXPR(Expr) 0
#endif

#include <sys/types.h>
#include <ctype.h>

#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))

/* Compare {{no more than N characters of }}strings S1 and S2,
   ignoring case, returning less than, equal to or
   greater than zero if S1 is lexicographically less
   than, equal to or greater than S2.  */

int
STRXCASECMP_FUNCTION (const char *s1, const char *s2 STRXCASECMP_DECLARE_N)
{
  register const unsigned char *p1 = (const unsigned char *) s1;
  register const unsigned char *p2 = (const unsigned char *) s2;
  unsigned char c1, c2;

  if (p1 == p2 || LENGTH_LIMIT_EXPR (n == 0))
    return 0;

  do
    {
      c1 = TOLOWER (*p1);
      c2 = TOLOWER (*p2);

      if (LENGTH_LIMIT_EXPR (--n == 0) || c1 == '\0')
	break;

      ++p1;
      ++p2;
    }
  while (c1 == c2);

  return c1 - c2;
}
2020-06-30Check that DTrace's execsnoop and opensnoop work (cf. PR kern/53417).jruoho 2020-06-25Fix pastos.jruoho 2020-06-24Add input filesmartin 2020-06-24Fix directoriesmartin 2020-06-24Also install new tests.jruoho 2020-06-24Fix references in comments.jruoho 2020-06-24Add a few checks for stdethers(8) and stdhosts(8).jruoho 2020-06-24Add few basic tests for cpuctl(8). These cover PR kern/45117 and PR bin/54220.jruoho Though, the former is not explicitly tested as it hangs the system. 2019-05-13Get rid of all the -lrumpdev and -lrumpvfs that are no longer neededbad after moving rump's mainbus from rumpdev to rumpkern. Produces the same atf-run results as before. 2017-09-07Add test mtree -O with same hash value in directory and leaf.nakayama 2017-01-14PR/51876: Ngie Cooper: kyua 0.11 $TMPDIR fixeschristos 2016-08-10+ -lrumpdevkre 2014-09-20t_tcpdump: skip bridgesozaki-r tcpdump on a bridge definitely fails, so skip bridges to make the test robust. PR 49050 2013-10-20adjust output now that we don't output size info for links and directorieschristos by default. 2013-02-19Check for RUMP programs before using them.joerg 2013-02-05ignore directory sizeschristos 2013-01-02Test the netbsd and mtree flavors.christos 2012-04-19Add a test case for PR bin/39546.jruoho 2012-04-15simplifychristos 2012-04-14Add few more NICs.jruoho 2012-04-14Fix RCS string.jruoho 2012-04-14Add a test case for PR kern/46328 (tested naively with tcpdump(8)).jruoho 2012-03-25PR/41061 fixedchristos 2012-03-19Add a case for PR bin/41061.jruoho 2012-03-18Verify that bin/25693 is no longer an issue.jruoho 2012-03-17Deprecate tests/util.jruoho 2010-12-31avoid temp file per clue-by-four from jmmvpooka 2010-12-30Substitute a surgical rump_server configuration for rump_allserverpooka now that it's possible. With warm fs cache, the startup time of the former is 0.01s and the latter 0.1s. With cold caches it's 0.2s vs 2s. 2010-12-18Fix test to use atf_check. My development machine still hadpooka /usr/bin/atf-check installed .... 2010-12-15Hook traceroute test case to build. it was added to lists so unbreak build now.haad 2010-12-15Add simple tests for traceroute. The test bootstraps a three-nodepooka network with one router in the middle and checks traceroute from one endpoint to another with both UDP and ICMP. (i guess these test networking at least as much as traceroute itself, but then again that's not a bad thing)