1 Star 0 Fork 5

Meredith/luajit

forked from src-anolis-os/luajit 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0044-From-Lua-5.3-assert-accepts-any-type-of-error-object.patch 1.55 KB
一键复制 编辑 原始数据 按行查看 历史
xingwei-liu 提交于 2022-07-28 14:43 . init package version for an8.6
From a5a89ab586a3b5bb4f266949bbf3dc2b140e2374 Mon Sep 17 00:00:00 2001
From: Mike Pall <mike>
Date: Tue, 5 Jun 2018 12:23:56 +0200
Subject: [PATCH 44/72] From Lua 5.3: assert() accepts any type of error
object.
---
doc/extensions.html | 1 +
src/lib_base.c | 10 +++++-----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/doc/extensions.html b/doc/extensions.html
index 55c4b70..7379041 100644
--- a/doc/extensions.html
+++ b/doc/extensions.html
@@ -373,6 +373,7 @@ LuaJIT supports some extensions from Lua&nbsp;5.3:
<li>Unicode escape <tt>'\u{XX...}'</tt> embeds the UTF-8 encoding in string literals.</li>
<li>The argument table <tt>arg</tt> can be read (and modified) by <tt>LUA_INIT</tt> and <tt>-e</tt> chunks.</li>
<li><tt>io.read()</tt> and <tt>file:read()</tt> accept formats with or without a leading <tt>*</tt>.</li>
+<li><tt>assert()</tt> accepts any type of error object.</li>
<li><tt>table.move(a1, f, e, t [,a2])</tt>.</li>
<li><tt>coroutine.isyieldable()</tt>.</li>
<li>Lua/C API extensions:
diff --git a/src/lib_base.c b/src/lib_base.c
index d61e876..1cd8305 100644
--- a/src/lib_base.c
+++ b/src/lib_base.c
@@ -42,13 +42,13 @@
LJLIB_ASM(assert) LJLIB_REC(.)
{
- GCstr *s;
lj_lib_checkany(L, 1);
- s = lj_lib_optstr(L, 2);
- if (s)
- lj_err_callermsg(L, strdata(s));
- else
+ if (L->top == L->base+1)
lj_err_caller(L, LJ_ERR_ASSERT);
+ else if (tvisstr(L->base+1) || tvisnumber(L->base+1))
+ lj_err_callermsg(L, strdata(lj_lib_checkstr(L, 2)));
+ else
+ lj_err_run(L);
return FFH_UNREACHABLE;
}
--
2.20.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yueeranna/luajit.git
git@gitee.com:yueeranna/luajit.git
yueeranna
luajit
luajit
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385