mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-30 02:47:56 +08:00
fixed bugs in string::begih_with
This commit is contained in:
parent
ac3bcf1f98
commit
f1737e7a92
@ -58,6 +58,13 @@ static void test(void)
|
||||
} else {
|
||||
printf("error\r\n");
|
||||
}
|
||||
|
||||
disk = "/data2/www";
|
||||
if (path.begin_with(disk)) {
|
||||
printf("error\r\n");
|
||||
} else {
|
||||
printf("ok\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void usage(const char* procname)
|
||||
|
@ -893,18 +893,15 @@ bool string::equal(const string& s, bool case_sensitive /* = true */) const
|
||||
|
||||
bool string::begin_with(const char* s, bool case_sensitive /* = true */) const
|
||||
{
|
||||
return ncompare(s, case_sensitive) == 0 ? true : false;
|
||||
return ncompare(s, strlen(s), case_sensitive) == 0 ? true : false;
|
||||
}
|
||||
|
||||
bool string::begin_with(const void* v, size_t n) const
|
||||
{
|
||||
if (LEN(vbf_) == 0) {
|
||||
if (n == 0)
|
||||
return true;
|
||||
if (n == 0)
|
||||
return false;
|
||||
}
|
||||
if (n > LEN(vbf_))
|
||||
n = LEN(vbf_);
|
||||
return false;
|
||||
return memcmp(STR(vbf_), v, n) == 0 ? true : false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user