aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 8e49c311..46c7e4f9 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.200 2010/02/18 19:32:41 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.201 2010/02/18 19:37:57 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -393,8 +393,19 @@ LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
393 393
394 394
395LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { 395LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
396 while (l--) 396 while (l) {
397 luaL_addchar(B, *s++); 397 size_t space = bufffree(B);
398 if (space == 0) {
399 luaL_prepbuffer(B);
400 lua_assert(bufffree(B) == LUAL_BUFFERSIZE);
401 space = LUAL_BUFFERSIZE;
402 }
403 if (space > l) space = l;
404 memcpy(B->p, s, space);
405 B->p += space;
406 s += space;
407 l -= space;
408 }
398} 409}
399 410
400 411