fix filename_to_name_ex

This commit is contained in:
xianjimli 2019-03-27 09:42:53 +08:00
parent 626931230d
commit 72383f2b3c
3 changed files with 12 additions and 1 deletions

View File

@ -1,4 +1,8 @@
# 最新动态
* 2019/03/27
* 修改style mutable的BUG(感谢朝泽提供补丁)
* 修改utils的BUG(感谢朝泽提供补丁)
* 2019/03/25
* 修改issue #101(感谢俊杰提供补丁)
* 修改issue #100

View File

@ -477,7 +477,7 @@ ret_t filename_to_name_ex(const char* filename, char* str, uint32_t size, bool_t
tk_strncpy(str, name, size - 1);
if (remove_extname) {
p = strchr(str, '.');
p = strrchr(str, '.');
if (p != NULL) {
*p = '\0';
}

View File

@ -184,6 +184,13 @@ TEST(Utils, filename_to_name_ex) {
ASSERT_EQ(string(name), string("test"));
}
TEST(Utils, filename_to_name_ex_dot) {
char name[TK_NAME_LEN + 1];
filename_to_name_ex("/a/app.test.png", name, TK_NAME_LEN, TRUE);
ASSERT_EQ(string(name), string("app.test"));
}
TEST(Utils, tk_skip_to_num) {
ASSERT_EQ(tk_atoi(tk_skip_to_num("123")), 123);
ASSERT_EQ(tk_atoi(tk_skip_to_num("abc123")), 123);