These are bug fixes from the 2.1 branch in the official LuaJIT repository that never made it into a release since there have been none since 2.1.0-beta3.
35 lines
864 B
Diff
35 lines
864 B
Diff
From f0e865dd4861520258299d0f2a56491bd9d602e1 Mon Sep 17 00:00:00 2001
|
|
From: Mike Pall <mike>
|
|
Date: Thu, 10 Jan 2019 13:09:17 +0100
|
|
Subject: [PATCH 59/72] Improve luaL_addlstring().
|
|
|
|
Thanks to Domingo Alvarez Duarte.
|
|
---
|
|
src/lib_aux.c | 11 +++++++++--
|
|
1 file changed, 9 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/lib_aux.c b/src/lib_aux.c
|
|
index c40565c..2682a38 100644
|
|
--- a/src/lib_aux.c
|
|
+++ b/src/lib_aux.c
|
|
@@ -218,8 +218,15 @@ LUALIB_API char *luaL_prepbuffer(luaL_Buffer *B)
|
|
|
|
LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l)
|
|
{
|
|
- while (l--)
|
|
- luaL_addchar(B, *s++);
|
|
+ if (l <= bufffree(B)) {
|
|
+ memcpy(B->p, s, l);
|
|
+ B->p += l;
|
|
+ } else {
|
|
+ emptybuffer(B);
|
|
+ lua_pushlstring(B->L, s, l);
|
|
+ B->lvl++;
|
|
+ adjuststack(B);
|
|
+ }
|
|
}
|
|
|
|
LUALIB_API void luaL_addstring(luaL_Buffer *B, const char *s)
|
|
--
|
|
2.20.1
|
|
|