summaryrefslogtreecommitdiff
path: root/strlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-04-30 18:13:55 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-04-30 18:13:55 -0300
commit3ec9ee0d0f81fd0aabaef1303f971b2f7ee12315 (patch)
tree07c3b5bdd856340429a3567212fc86fe80fdd005 /strlib.c
parent21c9ebf4a9891786d5683537868cc348340ca89d (diff)
downloadlua-github-3ec9ee0d0f81fd0aabaef1303f971b2f7ee12315.tar.gz
new function "luaI_openlib" to help open libs.
Diffstat (limited to 'strlib.c')
-rw-r--r--strlib.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/strlib.c b/strlib.c
index 9d084b36..a3467050 100644
--- a/strlib.c
+++ b/strlib.c
@@ -3,7 +3,7 @@
** String library to LUA
*/
-char *rcs_strlib="$Id: strlib.c,v 1.21 1996/03/21 22:18:08 roberto Exp roberto $";
+char *rcs_strlib="$Id: strlib.c,v 1.22 1996/03/22 17:57:24 roberto Exp roberto $";
#include <string.h>
#include <stdio.h>
@@ -249,16 +249,28 @@ static void str_format (void)
}
+void luaI_openlib (struct lua_reg *l, int n)
+{
+ int i;
+ for (i=0; i<n; i++)
+ lua_register(l[i].name, l[i].func);
+}
+
+static struct lua_reg strlib[] = {
+{"strfind", str_find},
+{"strlen", str_len},
+{"strsub", str_sub},
+{"strlower", str_lower},
+{"strupper", str_upper},
+{"ascii", str_ascii},
+{"format", str_format}
+};
+
+
/*
** Open string library
*/
void strlib_open (void)
{
- lua_register ("strfind", str_find);
- lua_register ("strlen", str_len);
- lua_register ("strsub", str_sub);
- lua_register ("strlower", str_lower);
- lua_register ("strupper", str_upper);
- lua_register ("ascii", str_ascii);
- lua_register ("format", str_format);
+ luaI_openlib(strlib, (sizeof(strlib)/sizeof(strlib[0])));
}