diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.142 2005/08/09 12:30:19 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.143 2005/08/10 18:47:09 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 | */ |
@@ -235,7 +235,13 @@ LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { | |||
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | LUALIB_API void luaL_openlib (lua_State *L, const char *libname, | 238 | LUALIB_API void (luaL_register) (lua_State *L, const char *libname, |
239 | const luaL_reg *l) { | ||
240 | luaI_openlib(L, libname, l, 0); | ||
241 | } | ||
242 | |||
243 | |||
244 | LUALIB_API void luaI_openlib (lua_State *L, const char *libname, | ||
239 | const luaL_reg *l, int nup) { | 245 | const luaL_reg *l, int nup) { |
240 | if (libname) { | 246 | if (libname) { |
241 | /* check whether lib already exists */ | 247 | /* check whether lib already exists */ |
@@ -338,7 +344,7 @@ LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, | |||
338 | luaL_addstring(&b, r); /* push replacement in place of pattern */ | 344 | luaL_addstring(&b, r); /* push replacement in place of pattern */ |
339 | s = wild + l; /* continue after `p' */ | 345 | s = wild + l; /* continue after `p' */ |
340 | } | 346 | } |
341 | luaL_addstring(&b, s); /* push last suffix (`n' already includes this) */ | 347 | luaL_addstring(&b, s); /* push last suffix */ |
342 | luaL_pushresult(&b); | 348 | luaL_pushresult(&b); |
343 | return lua_tostring(L, -1); | 349 | return lua_tostring(L, -1); |
344 | } | 350 | } |
@@ -446,7 +452,7 @@ LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { | |||
446 | 452 | ||
447 | LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { | 453 | LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { |
448 | while (l--) | 454 | while (l--) |
449 | luaL_putchar(B, *s++); | 455 | luaL_addchar(B, *s++); |
450 | } | 456 | } |
451 | 457 | ||
452 | 458 | ||
@@ -627,6 +633,12 @@ LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, | |||
627 | } | 633 | } |
628 | 634 | ||
629 | 635 | ||
636 | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { | ||
637 | return luaL_loadbuffer(L, s, strlen(s), s); | ||
638 | } | ||
639 | |||
640 | |||
641 | |||
630 | /* }====================================================== */ | 642 | /* }====================================================== */ |
631 | 643 | ||
632 | 644 | ||