mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
fix init when value is empty
This commit is contained in:
parent
075f060271
commit
159b7675ce
@ -2,6 +2,7 @@
|
||||
|
||||
2021/02/20
|
||||
* 完善编译脚本(感谢雨欣提供补丁)
|
||||
* 修复ini的值为空的问题。
|
||||
|
||||
2021/02/19
|
||||
* fscript支持return语句。
|
||||
|
@ -126,9 +126,14 @@ conf_doc_t* conf_doc_load_ini(const char* data) {
|
||||
break;
|
||||
}
|
||||
case STATE_BEFORE_VALUE: {
|
||||
if (!isspace(c)) {
|
||||
if (c != ' ' && c != '\t') {
|
||||
state = STATE_VALUE;
|
||||
str_set_with_len(s, &c, 1);
|
||||
if (c == '\r' || c == '\n') {
|
||||
str_set(s, "");
|
||||
p -= 1;
|
||||
} else {
|
||||
str_set_with_len(s, &c, 1);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -302,6 +302,19 @@ TEST(Ini, last_first) {
|
||||
conf_doc_destroy(doc);
|
||||
}
|
||||
|
||||
TEST(Ini, empty) {
|
||||
value_t v;
|
||||
conf_doc_t* doc = conf_doc_load_ini("[hello]\na=\nb=2\nc=3\n");
|
||||
ASSERT_EQ(conf_doc_get(doc, "hello.a", &v), RET_OK);
|
||||
ASSERT_STREQ(value_str(&v), "");
|
||||
ASSERT_EQ(conf_doc_get(doc, "hello.b", &v), RET_OK);
|
||||
ASSERT_STREQ(value_str(&v), "2");
|
||||
ASSERT_EQ(conf_doc_get(doc, "hello.c", &v), RET_OK);
|
||||
ASSERT_STREQ(value_str(&v), "3");
|
||||
|
||||
conf_doc_destroy(doc);
|
||||
}
|
||||
|
||||
TEST(Ini, move_up) {
|
||||
value_t v;
|
||||
conf_doc_t* doc = conf_doc_load_ini("[hello]\n[ world ]\n[awtk]\nname=aaa\n");
|
||||
|
Loading…
Reference in New Issue
Block a user