mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-09 16:21:45 +00:00
Add mg_strchr
Write unit tests for some mg_str functions. PUBLISHED_FROM=1fc7e1d5d5ef259d4023f295aec8651caa3e7e86
This commit is contained in:
1 parent
5a0b6fc35a
commit
cfd28a4f7a
2 files changed
+14
No files matched your search
@@ -1446,6 +1446,15 @@ struct mg_str mg_strdup_nul(const struct mg_str s) {
|
|||||||
return mg_strdup_common(s, 1 /* NUL-terminate */);
|
return mg_strdup_common(s, 1 /* NUL-terminate */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *mg_strchr(const struct mg_str s, int c) WEAK;
|
||||||
|
const char *mg_strchr(const struct mg_str s, int c) {
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < s.len; i++) {
|
||||||
|
if (s.p[i] == c) return &s.p[i];
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int mg_strcmp(const struct mg_str str1, const struct mg_str str2) WEAK;
|
int mg_strcmp(const struct mg_str str1, const struct mg_str str2) WEAK;
|
||||||
int mg_strcmp(const struct mg_str str1, const struct mg_str str2) {
|
int mg_strcmp(const struct mg_str str1, const struct mg_str str2) {
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|||||||
@@ -1801,6 +1801,11 @@ struct mg_str mg_strdup(const struct mg_str s);
|
|||||||
*/
|
*/
|
||||||
struct mg_str mg_strdup_nul(const struct mg_str s);
|
struct mg_str mg_strdup_nul(const struct mg_str s);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Locates character in a string.
|
||||||
|
*/
|
||||||
|
const char *mg_strchr(const struct mg_str s, int c);
|
||||||
|
|
||||||
int mg_strcmp(const struct mg_str str1, const struct mg_str str2);
|
int mg_strcmp(const struct mg_str str1, const struct mg_str str2);
|
||||||
int mg_strncmp(const struct mg_str str1, const struct mg_str str2, size_t n);
|
int mg_strncmp(const struct mg_str str1, const struct mg_str str2, size_t n);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user