mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
improve str_expand_vars
This commit is contained in:
parent
dcf0b6f18e
commit
e93328725c
@ -3,6 +3,7 @@
|
||||
* 修复 progressbar 类型问题(感谢尧燊提供补丁)
|
||||
* 修复 arm linux 编译问题(感谢俊杰提供补丁)
|
||||
* 完善 mledit/edit 文档 (感谢大恒提供补丁)
|
||||
* 完善 str\_expand\_vars(感谢朝泽提供补丁)
|
||||
|
||||
* 2020/01/15
|
||||
* 点击鼠标右键触发 context menu 事件。
|
||||
|
@ -280,13 +280,19 @@ ret_t system_info_set_device_pixel_ratio(system_info_t* info, float_t device_pix
|
||||
|
||||
static ret_t system_info_eval_one(system_info_t* info, str_t* str, const char* expr,
|
||||
tk_visit_t on_expr_result, void* ctx) {
|
||||
if (strchr(expr, '$') != NULL) {
|
||||
bool_t not_schema = strstr(expr, STR_SCHEMA_FILE) == NULL &&
|
||||
strstr(expr, STR_SCHEMA_HTTP) == NULL &&
|
||||
strstr(expr, STR_SCHEMA_HTTPS) == NULL;
|
||||
|
||||
if (not_schema && strchr(expr, '$') != NULL) {
|
||||
str_set(str, "");
|
||||
ENSURE(str_expand_vars(str, expr, OBJECT(info)) == RET_OK);
|
||||
} else {
|
||||
ENSURE(str_set(str, expr) == RET_OK);
|
||||
|
||||
if (str_expand_vars(str, expr, OBJECT(info)) == RET_OK) {
|
||||
return on_expr_result(ctx, str->str);
|
||||
}
|
||||
}
|
||||
|
||||
ENSURE(str_set(str, expr) == RET_OK);
|
||||
return on_expr_result(ctx, str->str);
|
||||
}
|
||||
|
||||
|
@ -557,8 +557,9 @@ ret_t str_expand_vars(str_t* str, const char* src, const object_t* obj) {
|
||||
if (c == '$') {
|
||||
if (p[1] && p[2]) {
|
||||
p = expand_var(str, p + 2, obj);
|
||||
} else {
|
||||
return RET_BAD_PARAMS;
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
str_append_char(str, c);
|
||||
p++;
|
||||
|
Loading…
Reference in New Issue
Block a user