diff options
Diffstat (limited to '')
| -rw-r--r-- | table.c | 19 |
1 files changed, 14 insertions, 5 deletions
| @@ -3,11 +3,13 @@ | |||
| 3 | ** Module to control static tables | 3 | ** Module to control static tables |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_table="$Id: table.c,v 1.1 1993/12/17 18:41:19 celes Exp roberto $"; | 6 | char *rcs_table="$Id: table.c,v 1.2 1993/12/22 21:15:16 roberto Exp celes $"; |
| 7 | 7 | ||
| 8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
| 9 | #include <string.h> | 9 | #include <string.h> |
| 10 | 10 | ||
| 11 | #include "mm.h" | ||
| 12 | |||
| 11 | #include "opcode.h" | 13 | #include "opcode.h" |
| 12 | #include "hash.h" | 14 | #include "hash.h" |
| 13 | #include "inout.h" | 15 | #include "inout.h" |
| @@ -49,12 +51,14 @@ static struct List *searchlist=&o0; | |||
| 49 | #ifndef MAXCONSTANT | 51 | #ifndef MAXCONSTANT |
| 50 | #define MAXCONSTANT 256 | 52 | #define MAXCONSTANT 256 |
| 51 | #endif | 53 | #endif |
| 52 | static char *constantbuffer[MAXCONSTANT] = {"mark","nil","number", | 54 | /* pre-defined constants need garbage collection extra byte */ |
| 53 | "string","table", | 55 | static char *constantbuffer[MAXCONSTANT] = {" mark"+1," nil"+1, |
| 54 | "function","cfunction" | 56 | " number"+1, " string"+1, |
| 57 | " table"+1, " function"+1, | ||
| 58 | " cfunction"+1, " userdata"+1 | ||
| 55 | }; | 59 | }; |
| 56 | char **lua_constant = constantbuffer; | 60 | char **lua_constant = constantbuffer; |
| 57 | Word lua_nconstant=T_CFUNCTION+1; | 61 | Word lua_nconstant=T_USERDATA+1; |
| 58 | 62 | ||
| 59 | #ifndef MAXSTRING | 63 | #ifndef MAXSTRING |
| 60 | #define MAXSTRING 512 | 64 | #define MAXSTRING 512 |
| @@ -215,8 +219,13 @@ static void lua_pack (void) | |||
| 215 | */ | 219 | */ |
| 216 | char *lua_createstring (char *s) | 220 | char *lua_createstring (char *s) |
| 217 | { | 221 | { |
| 222 | int i; | ||
| 218 | if (s == NULL) return NULL; | 223 | if (s == NULL) return NULL; |
| 219 | 224 | ||
| 225 | for (i=0; i<lua_nstring; i++) | ||
| 226 | if (streq(s,lua_string[i])) | ||
| 227 | return s; | ||
| 228 | |||
| 220 | if (lua_nstring >= MAXSTRING-1) | 229 | if (lua_nstring >= MAXSTRING-1) |
| 221 | { | 230 | { |
| 222 | lua_pack (); | 231 | lua_pack (); |
