| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* |
|
2
|
|
|
|
|
|
|
Copyright (C) 2015-2017 Alexander Borisov |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or |
|
5
|
|
|
|
|
|
|
modify it under the terms of the GNU Lesser General Public |
|
6
|
|
|
|
|
|
|
License as published by the Free Software Foundation; either |
|
7
|
|
|
|
|
|
|
version 2.1 of the License, or (at your option) any later version. |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This library 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 GNU |
|
12
|
|
|
|
|
|
|
Lesser General Public License for more details. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public |
|
15
|
|
|
|
|
|
|
License along with this library; if not, write to the Free Software |
|
16
|
|
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Author: lex.borisov@gmail.com (Alexander Borisov) |
|
19
|
|
|
|
|
|
|
*/ |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#include "mycore/utils.h" |
|
22
|
|
|
|
|
|
|
#include "mycore/utils/resources.h" |
|
23
|
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
size_t mycore_power(size_t t, size_t k) |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
0
|
|
|
|
|
|
size_t res = 1; |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
while (k) { |
|
29
|
0
|
0
|
|
|
|
|
if(k & 1) res *= t; |
|
30
|
0
|
|
|
|
|
|
t *= t; |
|
31
|
0
|
|
|
|
|
|
k >>= 1; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
return res; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
2112
|
|
|
|
|
|
size_t mycore_strncasecmp(const char* str1, const char* str2, size_t size) |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
2112
|
50
|
|
|
|
|
if(str1 == NULL || str2 == NULL) { |
|
|
|
50
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if(str1 == str2) |
|
41
|
0
|
|
|
|
|
|
return 0; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return 1; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
2112
|
|
|
|
|
|
const unsigned char *ustr1 = (const unsigned char *)str1; |
|
47
|
2112
|
|
|
|
|
|
const unsigned char *ustr2 = (const unsigned char *)str2; |
|
48
|
|
|
|
|
|
|
|
|
49
|
2112
|
|
|
|
|
|
size_t i = 0; |
|
50
|
1853482
|
100
|
|
|
|
|
while (i < size) { |
|
51
|
1851667
|
100
|
|
|
|
|
if(mycore_string_chars_lowercase_map[*ustr1] != mycore_string_chars_lowercase_map[*ustr2]) |
|
52
|
297
|
|
|
|
|
|
return (size - i); |
|
53
|
|
|
|
|
|
|
|
|
54
|
1851370
|
|
|
|
|
|
ustr1++; |
|
55
|
1851370
|
|
|
|
|
|
ustr2++; |
|
56
|
|
|
|
|
|
|
|
|
57
|
1851370
|
|
|
|
|
|
i++; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
1815
|
|
|
|
|
|
return 0; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
153
|
|
|
|
|
|
size_t mycore_strcasecmp(const char* str1, const char* str2) |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
153
|
50
|
|
|
|
|
if(str1 == NULL || str2 == NULL) { |
|
|
|
50
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
if(str1 == str2) |
|
67
|
0
|
|
|
|
|
|
return 0; |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return 1; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
153
|
|
|
|
|
|
const unsigned char *ustr1 = (const unsigned char *)str1; |
|
73
|
153
|
|
|
|
|
|
const unsigned char *ustr2 = (const unsigned char *)str2; |
|
74
|
|
|
|
|
|
|
|
|
75
|
153
|
|
|
|
|
|
for (size_t i = 0;;) |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
477
|
100
|
|
|
|
|
if(mycore_string_chars_lowercase_map[*ustr1] != mycore_string_chars_lowercase_map[*ustr2]) |
|
78
|
99
|
|
|
|
|
|
return (i + 1); |
|
79
|
|
|
|
|
|
|
|
|
80
|
378
|
100
|
|
|
|
|
if(*ustr1 == '\0') |
|
81
|
54
|
|
|
|
|
|
return 0; |
|
82
|
|
|
|
|
|
|
|
|
83
|
324
|
|
|
|
|
|
ustr1++; |
|
84
|
324
|
|
|
|
|
|
ustr2++; |
|
85
|
|
|
|
|
|
|
|
|
86
|
324
|
|
|
|
|
|
i++; |
|
87
|
324
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
372
|
|
|
|
|
|
size_t mycore_strncmp(const char* str1, const char* str2, size_t size) |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
372
|
50
|
|
|
|
|
if(str1 == NULL || str2 == NULL) { |
|
|
|
50
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
if(str1 == str2) |
|
94
|
0
|
|
|
|
|
|
return 0; |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return 1; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
372
|
|
|
|
|
|
const unsigned char *ustr1 = (const unsigned char *)str1; |
|
100
|
372
|
|
|
|
|
|
const unsigned char *ustr2 = (const unsigned char *)str2; |
|
101
|
|
|
|
|
|
|
|
|
102
|
372
|
|
|
|
|
|
size_t i = 0; |
|
103
|
1004
|
100
|
|
|
|
|
while (i < size) { |
|
104
|
912
|
100
|
|
|
|
|
if(*ustr1 != *ustr2) |
|
105
|
280
|
|
|
|
|
|
return (size - i); |
|
106
|
|
|
|
|
|
|
|
|
107
|
632
|
|
|
|
|
|
ustr1++; |
|
108
|
632
|
|
|
|
|
|
ustr2++; |
|
109
|
|
|
|
|
|
|
|
|
110
|
632
|
|
|
|
|
|
i++; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
92
|
|
|
|
|
|
return 0; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
249
|
|
|
|
|
|
size_t mycore_strcmp(const char* str1, const char* str2) |
|
117
|
|
|
|
|
|
|
{ |
|
118
|
249
|
50
|
|
|
|
|
if(str1 == NULL || str2 == NULL) { |
|
|
|
50
|
|
|
|
|
|
|
119
|
0
|
0
|
|
|
|
|
if(str1 == str2) |
|
120
|
0
|
|
|
|
|
|
return 0; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return 1; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
249
|
|
|
|
|
|
const unsigned char *ustr1 = (const unsigned char *)str1; |
|
126
|
249
|
|
|
|
|
|
const unsigned char *ustr2 = (const unsigned char *)str2; |
|
127
|
|
|
|
|
|
|
|
|
128
|
249
|
|
|
|
|
|
for (size_t i = 0;;) |
|
129
|
|
|
|
|
|
|
{ |
|
130
|
1404
|
100
|
|
|
|
|
if(*ustr1 != *ustr2) |
|
131
|
109
|
|
|
|
|
|
return (i + 1); |
|
132
|
|
|
|
|
|
|
|
|
133
|
1295
|
100
|
|
|
|
|
if(*ustr1 == '\0') |
|
134
|
140
|
|
|
|
|
|
return 0; |
|
135
|
|
|
|
|
|
|
|
|
136
|
1155
|
|
|
|
|
|
ustr1++; |
|
137
|
1155
|
|
|
|
|
|
ustr2++; |
|
138
|
|
|
|
|
|
|
|
|
139
|
1155
|
|
|
|
|
|
i++; |
|
140
|
1155
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
size_t mycore_strcmp_ws(const char* str1, const char* str2) |
|
144
|
|
|
|
|
|
|
{ |
|
145
|
0
|
0
|
|
|
|
|
if(str1 == NULL || str2 == NULL) { |
|
|
|
0
|
|
|
|
|
|
|
146
|
0
|
0
|
|
|
|
|
if(str1 == str2) |
|
147
|
0
|
|
|
|
|
|
return 0; |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
return 1; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
const unsigned char *ustr1 = (const unsigned char *)str1; |
|
153
|
0
|
|
|
|
|
|
const unsigned char *ustr2 = (const unsigned char *)str2; |
|
154
|
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
for (size_t i = 0;;) |
|
156
|
|
|
|
|
|
|
{ |
|
157
|
0
|
0
|
|
|
|
|
if(*ustr1 != *ustr2) |
|
158
|
0
|
|
|
|
|
|
return (i + 1); |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
if(mycore_utils_whithspace(*ustr1, ==, ||) || *ustr1 == '\0') |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
return 0; |
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
ustr1++; |
|
164
|
0
|
|
|
|
|
|
ustr2++; |
|
165
|
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
i++; |
|
167
|
0
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
30
|
|
|
|
|
|
bool mycore_ustrcasecmp_without_checks_by_secondary(const unsigned char* ustr1, const unsigned char* ustr2) |
|
171
|
|
|
|
|
|
|
{ |
|
172
|
85
|
100
|
|
|
|
|
while (*ustr1 != '\0') { |
|
173
|
77
|
100
|
|
|
|
|
if(mycore_string_chars_lowercase_map[*ustr1] != mycore_string_chars_lowercase_map[*ustr2]) |
|
174
|
22
|
|
|
|
|
|
return false; |
|
175
|
|
|
|
|
|
|
|
|
176
|
55
|
|
|
|
|
|
ustr1++; |
|
177
|
55
|
|
|
|
|
|
ustr2++; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
8
|
|
|
|
|
|
return true; |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|