mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
improve fscript iformat
This commit is contained in:
parent
c0f028f9b2
commit
02ca43bf84
@ -1,4 +1,7 @@
|
||||
# 最新动态
|
||||
2024/05/8
|
||||
* 完善value_uint32(感谢华健提供补丁)
|
||||
* 完善fscript iformat(感谢华健提供补丁)
|
||||
|
||||
2024/05/7
|
||||
* 修复触摸点击edit子控件button弹出软键盘问题(感谢颖健提供补丁)
|
||||
|
@ -2677,7 +2677,8 @@ static ret_t func_iformat(fscript_t* fscript, fscript_args_t* args, value_t* res
|
||||
format = value_str(args->args);
|
||||
FSCRIPT_FUNC_CHECK(format != NULL, RET_BAD_PARAMS);
|
||||
|
||||
tk_snprintf(str->str, str->capacity - 1, format, value_int(args->args + 1));
|
||||
|
||||
tk_snprintf(str->str, str->capacity > FSCRIPT_STR_CAPACITY ? FSCRIPT_STR_CAPACITY - 1 : str->capacity - 1, format, value_int(args->args + 1));
|
||||
value_dup_str(result, str->str);
|
||||
|
||||
return RET_OK;
|
||||
|
@ -158,6 +158,8 @@ uint32_t value_uint32(const value_t* v) {
|
||||
|
||||
if (v->type == VALUE_TYPE_UINT32) {
|
||||
return v->value.u32;
|
||||
} else if (v->type == VALUE_TYPE_STRING) {
|
||||
return (uint32_t)tk_atoul(v->value.str);
|
||||
} else {
|
||||
return (uint32_t)value_int(v);
|
||||
}
|
||||
|
@ -335,6 +335,10 @@ TEST(FScript, iformat) {
|
||||
fscript_eval(obj, "iformat(\"hello:%d\", 123) + str(456)", &v);
|
||||
ASSERT_STREQ(value_str(&v), "hello:123456");
|
||||
value_reset(&v);
|
||||
|
||||
fscript_eval(obj, "iformat(\"aaaaabbbhello1234567890hello1234567890hello1234567890123456789012345:%d\",2147483647)", &v);
|
||||
ASSERT_STREQ(value_str(&v), "aaaaabbbhello1234567890hello1234567890hello1234567890123456789");
|
||||
value_reset(&v);
|
||||
|
||||
TK_OBJECT_UNREF(obj);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user