2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
gb_common_case_temp.h
|
|
|
|
|
2013-08-03 17:38:01 +02:00
|
|
|
(c) 2000-2013 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
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
|
2009-08-17 12:41:51 +02:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 17:41:49 +01:00
|
|
|
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
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __COMMON_CASE_C
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include "gb_common.h"
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
const char COMMON_tolower[256] =
|
2008-01-17 22:39:26 +01:00
|
|
|
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
|
|
|
|
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
|
|
|
|
" !\"#$%&'()*+,-./"
|
|
|
|
"0123456789:;<=>?"
|
|
|
|
"@abcdefghijklmno"
|
|
|
|
"pqrstuvwxyz[\\]^_"
|
|
|
|
"`abcdefghijklmno"
|
|
|
|
"pqrstuvwxyz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x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F"
|
|
|
|
"\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF"
|
|
|
|
"\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF"
|
|
|
|
"\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF"
|
|
|
|
"\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF"
|
|
|
|
"\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF"
|
|
|
|
"\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF";
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
int COMMON_strcasecmp(const char *s1, const char *s2)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2008-01-05 15:07:21 +01:00
|
|
|
register offset_t i;
|
2007-12-30 17:41:49 +01:00
|
|
|
register int d;
|
|
|
|
register char c;
|
|
|
|
|
|
|
|
for (i = 0;; i++)
|
|
|
|
{
|
|
|
|
c = COMMON_tolower[(unsigned char)s1[i]];
|
|
|
|
d = c - COMMON_tolower[(unsigned char)s2[i]];
|
|
|
|
if (d < 0)
|
|
|
|
return -1;
|
|
|
|
else if (d > 0)
|
|
|
|
return 1;
|
|
|
|
else if (c == 0)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
int COMMON_strncasecmp(const char *s1, const char *s2, size_t n)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2008-01-05 15:07:21 +01:00
|
|
|
register offset_t i;
|
2007-12-30 17:41:49 +01:00
|
|
|
register int d;
|
|
|
|
register char c;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
c = COMMON_tolower[(unsigned char)s1[i]];
|
|
|
|
d = c - COMMON_tolower[(unsigned char)s2[i]];
|
|
|
|
if (d < 0)
|
|
|
|
return -1;
|
|
|
|
else if (d > 0)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|