2 * This file is part of INAV.
4 * INAV is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * INAV 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.
14 * You should have received a copy of the GNU General Public License
15 * along with INAV. If not, see <http://www.gnu.org/licenses/>.
20 #include "string_light.h"
21 #include "typeconversion.h"
25 return sl_isdigit(c
) || sl_isupper(c
) || sl_islower(c
);
30 return (c
>= '0' && c
<= '9');
35 return (c
>= 'A' && c
<= 'Z');
40 return (c
>= 'a' && c
<= 'z');
45 return sl_isupper(c
) ? (c
) - 'A' + 'a' : c
;
50 return sl_islower(c
) ? (c
) - 'a' + 'A' : c
;
53 int sl_strcasecmp(const char * s1
, const char * s2
)
55 return sl_strncasecmp(s1
, s2
, INT_MAX
);
58 int sl_strncasecmp(const char * s1
, const char * s2
, int n
)
60 const unsigned char * ucs1
= (const unsigned char *) s1
;
61 const unsigned char * ucs2
= (const unsigned char *) s2
;
65 for ( ; n
!= 0; n
--) {
66 const int c1
= sl_tolower(*ucs1
++);
67 const int c2
= sl_tolower(*ucs2
++);
68 if (((d
= c1
- c2
) != 0) || (c2
== '\0')) {