aboutsummaryrefslogtreecommitdiff
path: root/lbuiltin.c
diff options
context:
space:
mode:
Diffstat (limited to 'lbuiltin.c')
-rw-r--r--lbuiltin.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lbuiltin.c b/lbuiltin.c
index 589e591b..53dd4032 100644
--- a/lbuiltin.c
+++ b/lbuiltin.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbuiltin.c,v 1.9 1997/11/26 18:53:45 roberto Exp roberto $ 2** $Id: lbuiltin.c,v 1.10 1997/11/26 19:40:27 roberto Exp roberto $
3** Built-in functions 3** Built-in functions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -217,19 +217,29 @@ static void luaI_assert (void)
217} 217}
218 218
219 219
220static void check_globalname (char *n)
221{
222 if (n[0] == '.')
223 luaL_verror("cannot change variable `%.50s' (starts with `.')", n);
224}
225
220static void setglobal (void) 226static void setglobal (void)
221{ 227{
228 char *n = luaL_check_string(1);
222 lua_Object value = luaL_nonnullarg(2); 229 lua_Object value = luaL_nonnullarg(2);
230 check_globalname(n);
223 lua_pushobject(value); 231 lua_pushobject(value);
224 lua_setglobal(luaL_check_string(1)); 232 lua_setglobal(n);
225 lua_pushobject(value); /* return given value */ 233 lua_pushobject(value); /* return given value */
226} 234}
227 235
228static void rawsetglobal (void) 236static void rawsetglobal (void)
229{ 237{
238 char *n = luaL_check_string(1);
230 lua_Object value = luaL_nonnullarg(2); 239 lua_Object value = luaL_nonnullarg(2);
240 check_globalname(n);
231 lua_pushobject(value); 241 lua_pushobject(value);
232 lua_rawsetglobal(luaL_check_string(1)); 242 lua_rawsetglobal(n);
233 lua_pushobject(value); /* return given value */ 243 lua_pushobject(value); /* return given value */
234} 244}
235 245