Debian Codegraph @

src/compat/strcasecmp.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 1999 Ross Combs ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
19 #ifndef HAVE_STRCASECMPcxx . . $ `build/config.h:77:9`!
20 #include "strcasecmp.h"
21
22 #include <ctype.h>
23 #include <cstring>
24
25 #include "common/setup_after.h"
26
27
28 namespace pvpgn
29 {
30
31 extern int strcasecmp(char const * str1, char const * str2)
32 {
33 unsigned int i;
34 int a;
35 int b;
36
37 if (!str1 || !str2)
38 return -1;
39
40 /* some versions of tolower() break when given already lowercase characters */
41 for (i = 0; str1[i] != '\0' && str2[i] != '\0'; i++)
42 {
43 if (isupper((int)str1[i]))
44 a = (int)tolower((int)str1[i]);
45 else
46 a = (int)str1[i];
47
48 if (isupper((int)str2[i]))
49 b = (int)tolower((int)str2[i]);
50 else
51 b = (int)str2[i];
52
53 if (a<b)
54 return -1;
55 if (a>b)
56 return +1;
57 }
58
59 if (str1[i] != '\0')
60 return -1;
61 if (str2[i] != '\0')
62 return +1;
63 return 0;
64 }
65
66 }
67
68 #else
69 typedef int filenotemptycxx . . $ filenotempty#; /* make ISO standard happy */
70 #endif