~ubuntu-branches/ubuntu/jaunty/luatex/jaunty

« back to all changes in this revision

Viewing changes to src/texk/kpathsea/strcasecmp.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2007-09-24 12:56:11 UTC
  • Revision ID: james.westby@ubuntu.com-20070924125611-a8ge689azbptxvla
Tags: upstream-0.11.2
ImportĀ upstreamĀ versionĀ 0.11.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* strcasecmp.c - case-insensitive strcmp
 
2
 
 
3
    Copyright (C) 1991, 1992, 1995 Free Software Foundation, Inc.
 
4
    This file was part of the GNU C Library. Modified by kb@mail.tug.org to
 
5
    avoid glibc-isms.
 
6
 
 
7
    This library is free software; you can redistribute it and/or
 
8
    modify it under the terms of the GNU Lesser General Public
 
9
    License as published by the Free Software Foundation; either
 
10
    version 2.1 of the License, or (at your option) any later version.
 
11
 
 
12
    This library is distributed in the hope that it will be useful,
 
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
    Lesser General Public License for more details.
 
16
 
 
17
    You should have received a copy of the GNU Lesser General Public
 
18
    License along with this library; if not, write to the Free Software
 
19
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 
 
21
*/
 
22
 
 
23
#ifdef HAVE_CONFIG_H
 
24
#include <config.h>
 
25
#endif
 
26
 
 
27
#if !defined (__STDC__) || !__STDC__
 
28
/* This is a separate conditional since some stdc systems
 
29
   reject `defined (const)'.  */
 
30
#ifndef const
 
31
#define const
 
32
#endif
 
33
#endif
 
34
 
 
35
#include <ctype.h>
 
36
 
 
37
/* Compare S1 and S2, ignoring case, returning less than, equal to or
 
38
   greater than zero if S1 is lexiographically less than,
 
39
   equal to or greater than S2.  */
 
40
int
 
41
strcasecmp (s1, s2)
 
42
    const char *s1;
 
43
    const char *s2;
 
44
{
 
45
  register const unsigned char *p1 = (const unsigned char *) s1;
 
46
  register const unsigned char *p2 = (const unsigned char *) s2;
 
47
  unsigned char c1, c2;
 
48
 
 
49
  if (p1 == p2)
 
50
    return 0;
 
51
 
 
52
  do
 
53
    {
 
54
      c1 = tolower (*p1++);
 
55
      c2 = tolower (*p2++);
 
56
      if (c1 == '\0')
 
57
        break;
 
58
    }
 
59
  while (c1 == c2);
 
60
 
 
61
  return c1 - c2;
 
62
}
 
63
 
 
64
int
 
65
strncasecmp (s1, s2, n)
 
66
    const char *s1;
 
67
    const char *s2;
 
68
    unsigned n;
 
69
{
 
70
  register const unsigned char *p1 = (const unsigned char *) s1;
 
71
  register const unsigned char *p2 = (const unsigned char *) s2;
 
72
  unsigned char c1, c2;
 
73
 
 
74
  if (p1 == p2 || n == 0)
 
75
    return 0;
 
76
 
 
77
  do
 
78
    {
 
79
      c1 = tolower (*p1++);
 
80
      c2 = tolower (*p2++);
 
81
      if (c1 == '\0' || c1 != c2)
 
82
        return c1 - c2;
 
83
    } while (--n > 0);
 
84
 
 
85
  return c1 - c2;
 
86
}