mirror of
https://github.com/lua/lua
synced 2025-04-16 18:02:47 +03:00
luaL_openlib -> luaL_register, luaL_putchar -> luaL_addchar
This commit is contained in:
parent
16ddf86168
commit
5e8a9e324c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lbaselib.c,v 1.179 2005/07/07 15:48:29 roberto Exp roberto $
|
** $Id: lbaselib.c,v 1.180 2005/07/12 18:15:11 roberto Exp roberto $
|
||||||
** Basic library
|
** Basic library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -602,7 +602,7 @@ static void auxopen (lua_State *L, const char *name,
|
|||||||
|
|
||||||
static void base_open (lua_State *L) {
|
static void base_open (lua_State *L) {
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||||
luaL_openlib(L, NULL, base_funcs, 0); /* open lib into global table */
|
luaL_register(L, NULL, base_funcs); /* open lib into global table */
|
||||||
lua_pushliteral(L, LUA_VERSION);
|
lua_pushliteral(L, LUA_VERSION);
|
||||||
lua_setglobal(L, "_VERSION"); /* set global _VERSION */
|
lua_setglobal(L, "_VERSION"); /* set global _VERSION */
|
||||||
/* `ipairs' and `pairs' need auxiliary functions as upvalues */
|
/* `ipairs' and `pairs' need auxiliary functions as upvalues */
|
||||||
@ -627,7 +627,7 @@ static void base_open (lua_State *L) {
|
|||||||
|
|
||||||
LUALIB_API int luaopen_base (lua_State *L) {
|
LUALIB_API int luaopen_base (lua_State *L) {
|
||||||
base_open(L);
|
base_open(L);
|
||||||
luaL_openlib(L, LUA_COLIBNAME, co_funcs, 0);
|
luaL_register(L, LUA_COLIBNAME, co_funcs);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
ldblib.c
4
ldblib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldblib.c,v 1.98 2005/05/17 19:49:15 roberto Exp roberto $
|
** $Id: ldblib.c,v 1.99 2005/07/12 14:32:08 roberto Exp roberto $
|
||||||
** Interface from Lua to its debug API
|
** Interface from Lua to its debug API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -384,7 +384,7 @@ static const luaL_reg dblib[] = {
|
|||||||
|
|
||||||
|
|
||||||
LUALIB_API int luaopen_debug (lua_State *L) {
|
LUALIB_API int luaopen_debug (lua_State *L) {
|
||||||
luaL_openlib(L, LUA_DBLIBNAME, dblib, 0);
|
luaL_register(L, LUA_DBLIBNAME, dblib);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
liolib.c
6
liolib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: liolib.c,v 2.63 2005/06/06 18:42:21 roberto Exp roberto $
|
** $Id: liolib.c,v 2.64 2005/07/12 14:32:08 roberto Exp roberto $
|
||||||
** Standard I/O (and system) library
|
** Standard I/O (and system) library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -493,7 +493,7 @@ static void createmeta (lua_State *L) {
|
|||||||
luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */
|
luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */
|
||||||
lua_pushvalue(L, -1); /* push metatable */
|
lua_pushvalue(L, -1); /* push metatable */
|
||||||
lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
|
lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */
|
||||||
luaL_openlib(L, NULL, flib, 0); /* file methods */
|
luaL_register(L, NULL, flib); /* file methods */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ LUALIB_API int luaopen_io (lua_State *L) {
|
|||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_replace(L, LUA_ENVIRONINDEX);
|
lua_replace(L, LUA_ENVIRONINDEX);
|
||||||
/* open library */
|
/* open library */
|
||||||
luaL_openlib(L, LUA_IOLIBNAME, iolib, 0);
|
luaL_register(L, LUA_IOLIBNAME, iolib);
|
||||||
/* create (and set) default files */
|
/* create (and set) default files */
|
||||||
createstdfile(L, stdin, IO_INPUT, "stdin");
|
createstdfile(L, stdin, IO_INPUT, "stdin");
|
||||||
createstdfile(L, stdout, IO_OUTPUT, "stdout");
|
createstdfile(L, stdout, IO_OUTPUT, "stdout");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lmathlib.c,v 1.64 2005/06/13 21:20:14 roberto Exp roberto $
|
** $Id: lmathlib.c,v 1.65 2005/07/11 23:58:35 roberto Exp roberto $
|
||||||
** Standard mathematical library
|
** Standard mathematical library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -249,7 +249,7 @@ static const luaL_reg mathlib[] = {
|
|||||||
** Open math library
|
** Open math library
|
||||||
*/
|
*/
|
||||||
LUALIB_API int luaopen_math (lua_State *L) {
|
LUALIB_API int luaopen_math (lua_State *L) {
|
||||||
luaL_openlib(L, LUA_MATHLIBNAME, mathlib, 0);
|
luaL_register(L, LUA_MATHLIBNAME, mathlib);
|
||||||
lua_pushnumber(L, PI);
|
lua_pushnumber(L, PI);
|
||||||
lua_setfield(L, -2, "pi");
|
lua_setfield(L, -2, "pi");
|
||||||
lua_pushnumber(L, HUGE_VAL);
|
lua_pushnumber(L, HUGE_VAL);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: loadlib.c,v 1.36 2005/08/09 17:58:09 roberto Exp roberto $
|
** $Id: loadlib.c,v 1.37 2005/08/10 18:06:58 roberto Exp roberto $
|
||||||
** Dynamic library loader for Lua
|
** Dynamic library loader for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
**
|
**
|
||||||
@ -625,7 +625,7 @@ LUALIB_API int luaopen_package (lua_State *L) {
|
|||||||
#endif
|
#endif
|
||||||
lua_setfield(L, -2, "loadlib");
|
lua_setfield(L, -2, "loadlib");
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||||
luaL_openlib(L, NULL, ll_funcs, 0); /* open lib into global table */
|
luaL_register(L, NULL, ll_funcs); /* open lib into global table */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
loslib.c
4
loslib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: loslib.c,v 1.9 2005/05/17 19:49:15 roberto Exp roberto $
|
** $Id: loslib.c,v 1.10 2005/05/25 13:21:26 roberto Exp roberto $
|
||||||
** Standard Operating System library
|
** Standard Operating System library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -229,7 +229,7 @@ static const luaL_reg syslib[] = {
|
|||||||
|
|
||||||
|
|
||||||
LUALIB_API int luaopen_os (lua_State *L) {
|
LUALIB_API int luaopen_os (lua_State *L) {
|
||||||
luaL_openlib(L, LUA_OSLIBNAME, syslib, 0);
|
luaL_register(L, LUA_OSLIBNAME, syslib);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
lstrlib.c
32
lstrlib.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lstrlib.c,v 1.120 2005/07/31 16:47:34 roberto Exp roberto $
|
** $Id: lstrlib.c,v 1.121 2005/08/09 17:42:02 roberto Exp roberto $
|
||||||
** Standard library for string operations and pattern-matching
|
** Standard library for string operations and pattern-matching
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -58,7 +58,7 @@ static int str_reverse (lua_State *L) {
|
|||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
const char *s = luaL_checklstring(L, 1, &l);
|
const char *s = luaL_checklstring(L, 1, &l);
|
||||||
luaL_buffinit(L, &b);
|
luaL_buffinit(L, &b);
|
||||||
while (l--) luaL_putchar(&b, s[l]);
|
while (l--) luaL_addchar(&b, s[l]);
|
||||||
luaL_pushresult(&b);
|
luaL_pushresult(&b);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ static int str_lower (lua_State *L) {
|
|||||||
const char *s = luaL_checklstring(L, 1, &l);
|
const char *s = luaL_checklstring(L, 1, &l);
|
||||||
luaL_buffinit(L, &b);
|
luaL_buffinit(L, &b);
|
||||||
for (i=0; i<l; i++)
|
for (i=0; i<l; i++)
|
||||||
luaL_putchar(&b, tolower(uchar(s[i])));
|
luaL_addchar(&b, tolower(uchar(s[i])));
|
||||||
luaL_pushresult(&b);
|
luaL_pushresult(&b);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ static int str_upper (lua_State *L) {
|
|||||||
const char *s = luaL_checklstring(L, 1, &l);
|
const char *s = luaL_checklstring(L, 1, &l);
|
||||||
luaL_buffinit(L, &b);
|
luaL_buffinit(L, &b);
|
||||||
for (i=0; i<l; i++)
|
for (i=0; i<l; i++)
|
||||||
luaL_putchar(&b, toupper(uchar(s[i])));
|
luaL_addchar(&b, toupper(uchar(s[i])));
|
||||||
luaL_pushresult(&b);
|
luaL_pushresult(&b);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ static int str_char (lua_State *L) {
|
|||||||
for (i=1; i<=n; i++) {
|
for (i=1; i<=n; i++) {
|
||||||
int c = luaL_checkint(L, i);
|
int c = luaL_checkint(L, i);
|
||||||
luaL_argcheck(L, uchar(c) == c, i, "invalid value");
|
luaL_argcheck(L, uchar(c) == c, i, "invalid value");
|
||||||
luaL_putchar(&b, uchar(c));
|
luaL_addchar(&b, uchar(c));
|
||||||
}
|
}
|
||||||
luaL_pushresult(&b);
|
luaL_pushresult(&b);
|
||||||
return 1;
|
return 1;
|
||||||
@ -594,11 +594,11 @@ static void add_s (MatchState *ms, luaL_Buffer *b,
|
|||||||
size_t i;
|
size_t i;
|
||||||
for (i=0; i<l; i++) {
|
for (i=0; i<l; i++) {
|
||||||
if (news[i] != L_ESC)
|
if (news[i] != L_ESC)
|
||||||
luaL_putchar(b, news[i]);
|
luaL_addchar(b, news[i]);
|
||||||
else {
|
else {
|
||||||
i++; /* skip ESC */
|
i++; /* skip ESC */
|
||||||
if (!isdigit(uchar(news[i])))
|
if (!isdigit(uchar(news[i])))
|
||||||
luaL_putchar(b, news[i]);
|
luaL_addchar(b, news[i]);
|
||||||
else {
|
else {
|
||||||
if (news[i] == '0')
|
if (news[i] == '0')
|
||||||
lua_pushlstring(L, s, e - s); /* add whole match */
|
lua_pushlstring(L, s, e - s); /* add whole match */
|
||||||
@ -651,7 +651,7 @@ static int str_gsub (lua_State *L) {
|
|||||||
if (e && e>src) /* non empty match? */
|
if (e && e>src) /* non empty match? */
|
||||||
src = e; /* skip it */
|
src = e; /* skip it */
|
||||||
else if (src < ms.src_end)
|
else if (src < ms.src_end)
|
||||||
luaL_putchar(&b, *src++);
|
luaL_addchar(&b, *src++);
|
||||||
else break;
|
else break;
|
||||||
if (anchor) break;
|
if (anchor) break;
|
||||||
}
|
}
|
||||||
@ -673,12 +673,12 @@ static int str_gsub (lua_State *L) {
|
|||||||
static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
|
static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
|
||||||
size_t l;
|
size_t l;
|
||||||
const char *s = luaL_checklstring(L, arg, &l);
|
const char *s = luaL_checklstring(L, arg, &l);
|
||||||
luaL_putchar(b, '"');
|
luaL_addchar(b, '"');
|
||||||
while (l--) {
|
while (l--) {
|
||||||
switch (*s) {
|
switch (*s) {
|
||||||
case '"': case '\\': case '\n': {
|
case '"': case '\\': case '\n': {
|
||||||
luaL_putchar(b, '\\');
|
luaL_addchar(b, '\\');
|
||||||
luaL_putchar(b, *s);
|
luaL_addchar(b, *s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '\0': {
|
case '\0': {
|
||||||
@ -686,13 +686,13 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
luaL_putchar(b, *s);
|
luaL_addchar(b, *s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
luaL_putchar(b, '"');
|
luaL_addchar(b, '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -728,9 +728,9 @@ static int str_format (lua_State *L) {
|
|||||||
luaL_buffinit(L, &b);
|
luaL_buffinit(L, &b);
|
||||||
while (strfrmt < strfrmt_end) {
|
while (strfrmt < strfrmt_end) {
|
||||||
if (*strfrmt != L_ESC)
|
if (*strfrmt != L_ESC)
|
||||||
luaL_putchar(&b, *strfrmt++);
|
luaL_addchar(&b, *strfrmt++);
|
||||||
else if (*++strfrmt == L_ESC)
|
else if (*++strfrmt == L_ESC)
|
||||||
luaL_putchar(&b, *strfrmt++); /* %% */
|
luaL_addchar(&b, *strfrmt++); /* %% */
|
||||||
else { /* format item */
|
else { /* format item */
|
||||||
char form[MAX_FORMAT]; /* to store the format (`%...') */
|
char form[MAX_FORMAT]; /* to store the format (`%...') */
|
||||||
char buff[MAX_ITEM]; /* to store the formatted item */
|
char buff[MAX_ITEM]; /* to store the formatted item */
|
||||||
@ -818,7 +818,7 @@ static void createmetatable (lua_State *L) {
|
|||||||
** Open string library
|
** Open string library
|
||||||
*/
|
*/
|
||||||
LUALIB_API int luaopen_string (lua_State *L) {
|
LUALIB_API int luaopen_string (lua_State *L) {
|
||||||
luaL_openlib(L, LUA_STRLIBNAME, strlib, 0);
|
luaL_register(L, LUA_STRLIBNAME, strlib);
|
||||||
#if defined(LUA_COMPAT_GFIND)
|
#if defined(LUA_COMPAT_GFIND)
|
||||||
lua_getfield(L, -1, "gmatch");
|
lua_getfield(L, -1, "gmatch");
|
||||||
lua_setfield(L, -2, "gfind");
|
lua_setfield(L, -2, "gfind");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltablib.c,v 1.32 2005/07/11 18:48:02 roberto Exp roberto $
|
** $Id: ltablib.c,v 1.33 2005/07/12 14:32:08 roberto Exp roberto $
|
||||||
** Library for Table Manipulation
|
** Library for Table Manipulation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -250,7 +250,7 @@ static const luaL_reg tab_funcs[] = {
|
|||||||
|
|
||||||
|
|
||||||
LUALIB_API int luaopen_table (lua_State *L) {
|
LUALIB_API int luaopen_table (lua_State *L) {
|
||||||
luaL_openlib(L, LUA_TABLIBNAME, tab_funcs, 0);
|
luaL_register(L, LUA_TABLIBNAME, tab_funcs);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
ltests.c
6
ltests.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltests.c,v 2.26 2005/07/11 14:00:59 roberto Exp roberto $
|
** $Id: ltests.c,v 2.27 2005/07/12 14:32:08 roberto Exp roberto $
|
||||||
** Internal Module for Debugging of the Lua Implementation
|
** Internal Module for Debugging of the Lua Implementation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -730,7 +730,7 @@ static int loadlib (lua_State *L) {
|
|||||||
lua_State *L1 = cast(lua_State *,
|
lua_State *L1 = cast(lua_State *,
|
||||||
cast(unsigned long, luaL_checknumber(L, 1)));
|
cast(unsigned long, luaL_checknumber(L, 1)));
|
||||||
lua_pushvalue(L1, LUA_GLOBALSINDEX);
|
lua_pushvalue(L1, LUA_GLOBALSINDEX);
|
||||||
luaL_openlib(L1, NULL, libs, 0);
|
luaL_register(L1, NULL, libs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1161,7 +1161,7 @@ int luaB_opentests (lua_State *L) {
|
|||||||
lua_assert(ud == cast(void *, &memcontrol));
|
lua_assert(ud == cast(void *, &memcontrol));
|
||||||
lua_atpanic(L, l_panic);
|
lua_atpanic(L, l_panic);
|
||||||
lua_state = L; /* keep first state to be opened */
|
lua_state = L; /* keep first state to be opened */
|
||||||
luaL_openlib(L, "T", tests_funcs, 0);
|
luaL_register(L, "T", tests_funcs);
|
||||||
atexit(fim);
|
atexit(fim);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
11
luaconf.h
11
luaconf.h
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: luaconf.h,v 1.57 2005/08/04 13:37:10 roberto Exp roberto $
|
** $Id: luaconf.h,v 1.58 2005/08/09 17:57:29 roberto Exp roberto $
|
||||||
** Configuration file for Lua
|
** Configuration file for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -330,6 +330,15 @@
|
|||||||
#define LUA_COMPAT_GFIND
|
#define LUA_COMPAT_GFIND
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
|
||||||
|
@* behavior.
|
||||||
|
** CHANGE it to undefined as soon as you replace to 'luaL_registry'
|
||||||
|
** your uses of 'luaL_openlib'
|
||||||
|
*/
|
||||||
|
#define LUA_COMPAT_OPENLIB
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ luai_apicheck is the assert macro used by the Lua-C API.
|
@@ luai_apicheck is the assert macro used by the Lua-C API.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user