From 72383f2b3cdde7182e80ad6af5d4dad2e60e172c Mon Sep 17 00:00:00 2001 From: xianjimli Date: Wed, 27 Mar 2019 09:42:53 +0800 Subject: [PATCH] fix filename_to_name_ex --- docs/changes.md | 4 ++++ src/tkc/utils.c | 2 +- tests/utils_test.cc | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/changes.md b/docs/changes.md index 6b5261dfb..022f69514 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,4 +1,8 @@ # 最新动态 +* 2019/03/27 + * 修改style mutable的BUG(感谢朝泽提供补丁) + * 修改utils的BUG(感谢朝泽提供补丁) + * 2019/03/25 * 修改issue #101(感谢俊杰提供补丁) * 修改issue #100。 diff --git a/src/tkc/utils.c b/src/tkc/utils.c index edacbf370..02c5a130f 100644 --- a/src/tkc/utils.c +++ b/src/tkc/utils.c @@ -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'; } diff --git a/tests/utils_test.cc b/tests/utils_test.cc index af7dc2bcc..300921632 100644 --- a/tests/utils_test.cc +++ b/tests/utils_test.cc @@ -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);