diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-08-15 11:12:32 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-08-15 11:12:32 -0300 |
commit | 5e8a9e324ccdba03b326f8a8fafa0446042975a5 (patch) | |
tree | 0f752977249376dffd9a65690c1663be81166825 | |
parent | 16ddf86168998d500283e160977ef5ecea72c915 (diff) | |
download | lua-5e8a9e324ccdba03b326f8a8fafa0446042975a5.tar.gz lua-5e8a9e324ccdba03b326f8a8fafa0446042975a5.tar.bz2 lua-5e8a9e324ccdba03b326f8a8fafa0446042975a5.zip |
luaL_openlib -> luaL_register, luaL_putchar -> luaL_addchar
-rw-r--r-- | lbaselib.c | 6 | ||||
-rw-r--r-- | ldblib.c | 4 | ||||
-rw-r--r-- | liolib.c | 6 | ||||
-rw-r--r-- | lmathlib.c | 4 | ||||
-rw-r--r-- | loadlib.c | 4 | ||||
-rw-r--r-- | loslib.c | 4 | ||||
-rw-r--r-- | lstrlib.c | 32 | ||||
-rw-r--r-- | ltablib.c | 4 | ||||
-rw-r--r-- | ltests.c | 6 | ||||
-rw-r--r-- | luaconf.h | 11 |
10 files changed, 45 insertions, 36 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.179 2005/07/07 15:48:29 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.180 2005/07/12 18:15:11 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -602,7 +602,7 @@ static void auxopen (lua_State *L, const char *name, | |||
602 | 602 | ||
603 | static void base_open (lua_State *L) { | 603 | static void base_open (lua_State *L) { |
604 | lua_pushvalue(L, LUA_GLOBALSINDEX); | 604 | lua_pushvalue(L, LUA_GLOBALSINDEX); |
605 | luaL_openlib(L, NULL, base_funcs, 0); /* open lib into global table */ | 605 | luaL_register(L, NULL, base_funcs); /* open lib into global table */ |
606 | lua_pushliteral(L, LUA_VERSION); | 606 | lua_pushliteral(L, LUA_VERSION); |
607 | lua_setglobal(L, "_VERSION"); /* set global _VERSION */ | 607 | lua_setglobal(L, "_VERSION"); /* set global _VERSION */ |
608 | /* `ipairs' and `pairs' need auxiliary functions as upvalues */ | 608 | /* `ipairs' and `pairs' need auxiliary functions as upvalues */ |
@@ -627,7 +627,7 @@ static void base_open (lua_State *L) { | |||
627 | 627 | ||
628 | LUALIB_API int luaopen_base (lua_State *L) { | 628 | LUALIB_API int luaopen_base (lua_State *L) { |
629 | base_open(L); | 629 | base_open(L); |
630 | luaL_openlib(L, LUA_COLIBNAME, co_funcs, 0); | 630 | luaL_register(L, LUA_COLIBNAME, co_funcs); |
631 | return 2; | 631 | return 2; |
632 | } | 632 | } |
633 | 633 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.98 2005/05/17 19:49:15 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.99 2005/07/12 14:32:08 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -384,7 +384,7 @@ static const luaL_reg dblib[] = { | |||
384 | 384 | ||
385 | 385 | ||
386 | LUALIB_API int luaopen_debug (lua_State *L) { | 386 | LUALIB_API int luaopen_debug (lua_State *L) { |
387 | luaL_openlib(L, LUA_DBLIBNAME, dblib, 0); | 387 | luaL_register(L, LUA_DBLIBNAME, dblib); |
388 | return 1; | 388 | return 1; |
389 | } | 389 | } |
390 | 390 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.63 2005/06/06 18:42:21 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.64 2005/07/12 14:32:08 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -493,7 +493,7 @@ static void createmeta (lua_State *L) { | |||
493 | luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ | 493 | luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ |
494 | lua_pushvalue(L, -1); /* push metatable */ | 494 | lua_pushvalue(L, -1); /* push metatable */ |
495 | lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ | 495 | lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ |
496 | luaL_openlib(L, NULL, flib, 0); /* file methods */ | 496 | luaL_register(L, NULL, flib); /* file methods */ |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
@@ -513,7 +513,7 @@ LUALIB_API int luaopen_io (lua_State *L) { | |||
513 | lua_newtable(L); | 513 | lua_newtable(L); |
514 | lua_replace(L, LUA_ENVIRONINDEX); | 514 | lua_replace(L, LUA_ENVIRONINDEX); |
515 | /* open library */ | 515 | /* open library */ |
516 | luaL_openlib(L, LUA_IOLIBNAME, iolib, 0); | 516 | luaL_register(L, LUA_IOLIBNAME, iolib); |
517 | /* create (and set) default files */ | 517 | /* create (and set) default files */ |
518 | createstdfile(L, stdin, IO_INPUT, "stdin"); | 518 | createstdfile(L, stdin, IO_INPUT, "stdin"); |
519 | createstdfile(L, stdout, IO_OUTPUT, "stdout"); | 519 | createstdfile(L, stdout, IO_OUTPUT, "stdout"); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.64 2005/06/13 21:20:14 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.65 2005/07/11 23:58:35 roberto Exp roberto $ |
3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -249,7 +249,7 @@ static const luaL_reg mathlib[] = { | |||
249 | ** Open math library | 249 | ** Open math library |
250 | */ | 250 | */ |
251 | LUALIB_API int luaopen_math (lua_State *L) { | 251 | LUALIB_API int luaopen_math (lua_State *L) { |
252 | luaL_openlib(L, LUA_MATHLIBNAME, mathlib, 0); | 252 | luaL_register(L, LUA_MATHLIBNAME, mathlib); |
253 | lua_pushnumber(L, PI); | 253 | lua_pushnumber(L, PI); |
254 | lua_setfield(L, -2, "pi"); | 254 | lua_setfield(L, -2, "pi"); |
255 | lua_pushnumber(L, HUGE_VAL); | 255 | lua_pushnumber(L, HUGE_VAL); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loadlib.c,v 1.36 2005/08/09 17:58:09 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.37 2005/08/10 18:06:58 roberto Exp roberto $ |
3 | ** Dynamic library loader for Lua | 3 | ** Dynamic library loader for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | ** | 5 | ** |
@@ -625,7 +625,7 @@ LUALIB_API int luaopen_package (lua_State *L) { | |||
625 | #endif | 625 | #endif |
626 | lua_setfield(L, -2, "loadlib"); | 626 | lua_setfield(L, -2, "loadlib"); |
627 | lua_pushvalue(L, LUA_GLOBALSINDEX); | 627 | lua_pushvalue(L, LUA_GLOBALSINDEX); |
628 | luaL_openlib(L, NULL, ll_funcs, 0); /* open lib into global table */ | 628 | luaL_register(L, NULL, ll_funcs); /* open lib into global table */ |
629 | return 1; | 629 | return 1; |
630 | } | 630 | } |
631 | 631 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loslib.c,v 1.9 2005/05/17 19:49:15 roberto Exp roberto $ | 2 | ** $Id: loslib.c,v 1.10 2005/05/25 13:21:26 roberto Exp roberto $ |
3 | ** Standard Operating System library | 3 | ** Standard Operating System library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -229,7 +229,7 @@ static const luaL_reg syslib[] = { | |||
229 | 229 | ||
230 | 230 | ||
231 | LUALIB_API int luaopen_os (lua_State *L) { | 231 | LUALIB_API int luaopen_os (lua_State *L) { |
232 | luaL_openlib(L, LUA_OSLIBNAME, syslib, 0); | 232 | luaL_register(L, LUA_OSLIBNAME, syslib); |
233 | return 1; | 233 | return 1; |
234 | } | 234 | } |
235 | 235 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.120 2005/07/31 16:47:34 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.121 2005/08/09 17:42:02 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -58,7 +58,7 @@ static int str_reverse (lua_State *L) { | |||
58 | luaL_Buffer b; | 58 | luaL_Buffer b; |
59 | const char *s = luaL_checklstring(L, 1, &l); | 59 | const char *s = luaL_checklstring(L, 1, &l); |
60 | luaL_buffinit(L, &b); | 60 | luaL_buffinit(L, &b); |
61 | while (l--) luaL_putchar(&b, s[l]); | 61 | while (l--) luaL_addchar(&b, s[l]); |
62 | luaL_pushresult(&b); | 62 | luaL_pushresult(&b); |
63 | return 1; | 63 | return 1; |
64 | } | 64 | } |
@@ -71,7 +71,7 @@ static int str_lower (lua_State *L) { | |||
71 | const char *s = luaL_checklstring(L, 1, &l); | 71 | const char *s = luaL_checklstring(L, 1, &l); |
72 | luaL_buffinit(L, &b); | 72 | luaL_buffinit(L, &b); |
73 | for (i=0; i<l; i++) | 73 | for (i=0; i<l; i++) |
74 | luaL_putchar(&b, tolower(uchar(s[i]))); | 74 | luaL_addchar(&b, tolower(uchar(s[i]))); |
75 | luaL_pushresult(&b); | 75 | luaL_pushresult(&b); |
76 | return 1; | 76 | return 1; |
77 | } | 77 | } |
@@ -84,7 +84,7 @@ static int str_upper (lua_State *L) { | |||
84 | const char *s = luaL_checklstring(L, 1, &l); | 84 | const char *s = luaL_checklstring(L, 1, &l); |
85 | luaL_buffinit(L, &b); | 85 | luaL_buffinit(L, &b); |
86 | for (i=0; i<l; i++) | 86 | for (i=0; i<l; i++) |
87 | luaL_putchar(&b, toupper(uchar(s[i]))); | 87 | luaL_addchar(&b, toupper(uchar(s[i]))); |
88 | luaL_pushresult(&b); | 88 | luaL_pushresult(&b); |
89 | return 1; | 89 | return 1; |
90 | } | 90 | } |
@@ -127,7 +127,7 @@ static int str_char (lua_State *L) { | |||
127 | for (i=1; i<=n; i++) { | 127 | for (i=1; i<=n; i++) { |
128 | int c = luaL_checkint(L, i); | 128 | int c = luaL_checkint(L, i); |
129 | luaL_argcheck(L, uchar(c) == c, i, "invalid value"); | 129 | luaL_argcheck(L, uchar(c) == c, i, "invalid value"); |
130 | luaL_putchar(&b, uchar(c)); | 130 | luaL_addchar(&b, uchar(c)); |
131 | } | 131 | } |
132 | luaL_pushresult(&b); | 132 | luaL_pushresult(&b); |
133 | return 1; | 133 | return 1; |
@@ -594,11 +594,11 @@ static void add_s (MatchState *ms, luaL_Buffer *b, | |||
594 | size_t i; | 594 | size_t i; |
595 | for (i=0; i<l; i++) { | 595 | for (i=0; i<l; i++) { |
596 | if (news[i] != L_ESC) | 596 | if (news[i] != L_ESC) |
597 | luaL_putchar(b, news[i]); | 597 | luaL_addchar(b, news[i]); |
598 | else { | 598 | else { |
599 | i++; /* skip ESC */ | 599 | i++; /* skip ESC */ |
600 | if (!isdigit(uchar(news[i]))) | 600 | if (!isdigit(uchar(news[i]))) |
601 | luaL_putchar(b, news[i]); | 601 | luaL_addchar(b, news[i]); |
602 | else { | 602 | else { |
603 | if (news[i] == '0') | 603 | if (news[i] == '0') |
604 | lua_pushlstring(L, s, e - s); /* add whole match */ | 604 | lua_pushlstring(L, s, e - s); /* add whole match */ |
@@ -651,7 +651,7 @@ static int str_gsub (lua_State *L) { | |||
651 | if (e && e>src) /* non empty match? */ | 651 | if (e && e>src) /* non empty match? */ |
652 | src = e; /* skip it */ | 652 | src = e; /* skip it */ |
653 | else if (src < ms.src_end) | 653 | else if (src < ms.src_end) |
654 | luaL_putchar(&b, *src++); | 654 | luaL_addchar(&b, *src++); |
655 | else break; | 655 | else break; |
656 | if (anchor) break; | 656 | if (anchor) break; |
657 | } | 657 | } |
@@ -673,12 +673,12 @@ static int str_gsub (lua_State *L) { | |||
673 | static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { | 673 | static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { |
674 | size_t l; | 674 | size_t l; |
675 | const char *s = luaL_checklstring(L, arg, &l); | 675 | const char *s = luaL_checklstring(L, arg, &l); |
676 | luaL_putchar(b, '"'); | 676 | luaL_addchar(b, '"'); |
677 | while (l--) { | 677 | while (l--) { |
678 | switch (*s) { | 678 | switch (*s) { |
679 | case '"': case '\\': case '\n': { | 679 | case '"': case '\\': case '\n': { |
680 | luaL_putchar(b, '\\'); | 680 | luaL_addchar(b, '\\'); |
681 | luaL_putchar(b, *s); | 681 | luaL_addchar(b, *s); |
682 | break; | 682 | break; |
683 | } | 683 | } |
684 | case '\0': { | 684 | case '\0': { |
@@ -686,13 +686,13 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { | |||
686 | break; | 686 | break; |
687 | } | 687 | } |
688 | default: { | 688 | default: { |
689 | luaL_putchar(b, *s); | 689 | luaL_addchar(b, *s); |
690 | break; | 690 | break; |
691 | } | 691 | } |
692 | } | 692 | } |
693 | s++; | 693 | s++; |
694 | } | 694 | } |
695 | luaL_putchar(b, '"'); | 695 | luaL_addchar(b, '"'); |
696 | } | 696 | } |
697 | 697 | ||
698 | 698 | ||
@@ -728,9 +728,9 @@ static int str_format (lua_State *L) { | |||
728 | luaL_buffinit(L, &b); | 728 | luaL_buffinit(L, &b); |
729 | while (strfrmt < strfrmt_end) { | 729 | while (strfrmt < strfrmt_end) { |
730 | if (*strfrmt != L_ESC) | 730 | if (*strfrmt != L_ESC) |
731 | luaL_putchar(&b, *strfrmt++); | 731 | luaL_addchar(&b, *strfrmt++); |
732 | else if (*++strfrmt == L_ESC) | 732 | else if (*++strfrmt == L_ESC) |
733 | luaL_putchar(&b, *strfrmt++); /* %% */ | 733 | luaL_addchar(&b, *strfrmt++); /* %% */ |
734 | else { /* format item */ | 734 | else { /* format item */ |
735 | char form[MAX_FORMAT]; /* to store the format (`%...') */ | 735 | char form[MAX_FORMAT]; /* to store the format (`%...') */ |
736 | char buff[MAX_ITEM]; /* to store the formatted item */ | 736 | char buff[MAX_ITEM]; /* to store the formatted item */ |
@@ -818,7 +818,7 @@ static void createmetatable (lua_State *L) { | |||
818 | ** Open string library | 818 | ** Open string library |
819 | */ | 819 | */ |
820 | LUALIB_API int luaopen_string (lua_State *L) { | 820 | LUALIB_API int luaopen_string (lua_State *L) { |
821 | luaL_openlib(L, LUA_STRLIBNAME, strlib, 0); | 821 | luaL_register(L, LUA_STRLIBNAME, strlib); |
822 | #if defined(LUA_COMPAT_GFIND) | 822 | #if defined(LUA_COMPAT_GFIND) |
823 | lua_getfield(L, -1, "gmatch"); | 823 | lua_getfield(L, -1, "gmatch"); |
824 | lua_setfield(L, -2, "gfind"); | 824 | lua_setfield(L, -2, "gfind"); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltablib.c,v 1.32 2005/07/11 18:48:02 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.33 2005/07/12 14:32:08 roberto Exp roberto $ |
3 | ** Library for Table Manipulation | 3 | ** Library for Table Manipulation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -250,7 +250,7 @@ static const luaL_reg tab_funcs[] = { | |||
250 | 250 | ||
251 | 251 | ||
252 | LUALIB_API int luaopen_table (lua_State *L) { | 252 | LUALIB_API int luaopen_table (lua_State *L) { |
253 | luaL_openlib(L, LUA_TABLIBNAME, tab_funcs, 0); | 253 | luaL_register(L, LUA_TABLIBNAME, tab_funcs); |
254 | return 1; | 254 | return 1; |
255 | } | 255 | } |
256 | 256 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.26 2005/07/11 14:00:59 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.27 2005/07/12 14:32:08 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -730,7 +730,7 @@ static int loadlib (lua_State *L) { | |||
730 | lua_State *L1 = cast(lua_State *, | 730 | lua_State *L1 = cast(lua_State *, |
731 | cast(unsigned long, luaL_checknumber(L, 1))); | 731 | cast(unsigned long, luaL_checknumber(L, 1))); |
732 | lua_pushvalue(L1, LUA_GLOBALSINDEX); | 732 | lua_pushvalue(L1, LUA_GLOBALSINDEX); |
733 | luaL_openlib(L1, NULL, libs, 0); | 733 | luaL_register(L1, NULL, libs); |
734 | return 0; | 734 | return 0; |
735 | } | 735 | } |
736 | 736 | ||
@@ -1161,7 +1161,7 @@ int luaB_opentests (lua_State *L) { | |||
1161 | lua_assert(ud == cast(void *, &memcontrol)); | 1161 | lua_assert(ud == cast(void *, &memcontrol)); |
1162 | lua_atpanic(L, l_panic); | 1162 | lua_atpanic(L, l_panic); |
1163 | lua_state = L; /* keep first state to be opened */ | 1163 | lua_state = L; /* keep first state to be opened */ |
1164 | luaL_openlib(L, "T", tests_funcs, 0); | 1164 | luaL_register(L, "T", tests_funcs); |
1165 | atexit(fim); | 1165 | atexit(fim); |
1166 | return 0; | 1166 | return 0; |
1167 | } | 1167 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.57 2005/08/04 13:37:10 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.58 2005/08/09 17:57:29 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -330,6 +330,15 @@ | |||
330 | #define LUA_COMPAT_GFIND | 330 | #define LUA_COMPAT_GFIND |
331 | 331 | ||
332 | 332 | ||
333 | /* | ||
334 | @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' | ||
335 | @* behavior. | ||
336 | ** CHANGE it to undefined as soon as you replace to 'luaL_registry' | ||
337 | ** your uses of 'luaL_openlib' | ||
338 | */ | ||
339 | #define LUA_COMPAT_OPENLIB | ||
340 | |||
341 | |||
333 | 342 | ||
334 | /* | 343 | /* |
335 | @@ luai_apicheck is the assert macro used by the Lua-C API. | 344 | @@ luai_apicheck is the assert macro used by the Lua-C API. |