commit 682efe2678589eebc7c982e0ed66ad4990711e5a
parent 50c7c915ee2fa239043d5456237f5145d064089b
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 25 Nov 2024 15:46:41 -0300
Change to macro 'LUAI_TRY'
The call to 'f' is done by the macro, to give it more flexibility.
Diffstat:
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/ldo.c b/ldo.c
@@ -69,22 +69,22 @@
/* C++ exceptions */
#define LUAI_THROW(L,c) throw(c)
-#define LUAI_TRY(L,c,a) \
- try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; }
-#define luai_jmpbuf int /* dummy variable */
+#define LUAI_TRY(L,c,f,ud) \
+ try { (f)(L, ud); } catch(...) { if ((c)->status == 0) (c)->status = -1; }
+#define luai_jmpbuf int /* dummy field */
#elif defined(LUA_USE_POSIX) /* }{ */
/* in POSIX, try _longjmp/_setjmp (more efficient) */
#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
-#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
+#define LUAI_TRY(L,c,f,ud) if (_setjmp((c)->b) == 0) ((f)(L, ud))
#define luai_jmpbuf jmp_buf
#else /* }{ */
/* ISO C handling with long jumps */
#define LUAI_THROW(L,c) longjmp((c)->b, 1)
-#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
+#define LUAI_TRY(L,c,f,ud) if (setjmp((c)->b) == 0) ((f)(L, ud))
#define luai_jmpbuf jmp_buf
#endif /* } */
@@ -154,9 +154,7 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
lj.status = LUA_OK;
lj.previous = L->errorJmp; /* chain new error handler */
L->errorJmp = &lj;
- LUAI_TRY(L, &lj,
- (*f)(L, ud);
- );
+ LUAI_TRY(L, &lj, f, ud); /* call 'f' catching errors */
L->errorJmp = lj.previous; /* restore old error handler */
L->nCcalls = oldnCcalls;
return lj.status;
diff --git a/testes/files.lua b/testes/files.lua
@@ -766,6 +766,7 @@ if not _port then
assert((v[3] == nil and z > 0) or v[3] == z)
end
end
+ print("(done)")
end