diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-04-30 18:13:55 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1996-04-30 18:13:55 -0300 |
| commit | 3ec9ee0d0f81fd0aabaef1303f971b2f7ee12315 (patch) | |
| tree | 07c3b5bdd856340429a3567212fc86fe80fdd005 /strlib.c | |
| parent | 21c9ebf4a9891786d5683537868cc348340ca89d (diff) | |
| download | lua-3ec9ee0d0f81fd0aabaef1303f971b2f7ee12315.tar.gz lua-3ec9ee0d0f81fd0aabaef1303f971b2f7ee12315.tar.bz2 lua-3ec9ee0d0f81fd0aabaef1303f971b2f7ee12315.zip | |
new function "luaI_openlib" to help open libs.
Diffstat (limited to '')
| -rw-r--r-- | strlib.c | 28 |
1 files changed, 20 insertions, 8 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** String library to LUA | 3 | ** String library to LUA |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_strlib="$Id: strlib.c,v 1.21 1996/03/21 22:18:08 roberto Exp roberto $"; | 6 | char *rcs_strlib="$Id: strlib.c,v 1.22 1996/03/22 17:57:24 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| @@ -249,16 +249,28 @@ static void str_format (void) | |||
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | 251 | ||
| 252 | void luaI_openlib (struct lua_reg *l, int n) | ||
| 253 | { | ||
| 254 | int i; | ||
| 255 | for (i=0; i<n; i++) | ||
| 256 | lua_register(l[i].name, l[i].func); | ||
| 257 | } | ||
| 258 | |||
| 259 | static struct lua_reg strlib[] = { | ||
| 260 | {"strfind", str_find}, | ||
| 261 | {"strlen", str_len}, | ||
| 262 | {"strsub", str_sub}, | ||
| 263 | {"strlower", str_lower}, | ||
| 264 | {"strupper", str_upper}, | ||
| 265 | {"ascii", str_ascii}, | ||
| 266 | {"format", str_format} | ||
| 267 | }; | ||
| 268 | |||
| 269 | |||
| 252 | /* | 270 | /* |
| 253 | ** Open string library | 271 | ** Open string library |
| 254 | */ | 272 | */ |
| 255 | void strlib_open (void) | 273 | void strlib_open (void) |
| 256 | { | 274 | { |
| 257 | lua_register ("strfind", str_find); | 275 | luaI_openlib(strlib, (sizeof(strlib)/sizeof(strlib[0]))); |
| 258 | lua_register ("strlen", str_len); | ||
| 259 | lua_register ("strsub", str_sub); | ||
| 260 | lua_register ("strlower", str_lower); | ||
| 261 | lua_register ("strupper", str_upper); | ||
| 262 | lua_register ("ascii", str_ascii); | ||
| 263 | lua_register ("format", str_format); | ||
| 264 | } | 276 | } |
