diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2025-12-13 11:00:30 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2025-12-13 11:00:30 -0300 |
| commit | 3d03ae5bd6314f27c8635e06ec363150c2c19062 (patch) | |
| tree | f7a67004721a41a2a042fd897a49dc3fddd4edd0 | |
| parent | 82d721a8554df9b14ff520b4dd55ce5303ab560e (diff) | |
| download | lua-3d03ae5bd6314f27c8635e06ec363150c2c19062.tar.gz lua-3d03ae5bd6314f27c8635e06ec363150c2c19062.tar.bz2 lua-3d03ae5bd6314f27c8635e06ec363150c2c19062.zip | |
'luaL_newstate' starts state with warnings on
It is easier to forget to turn them on then to turn them off.
| -rw-r--r-- | lauxlib.c | 2 | ||||
| -rw-r--r-- | lua.c | 3 |
2 files changed, 3 insertions, 2 deletions
| @@ -1185,7 +1185,7 @@ LUALIB_API lua_State *(luaL_newstate) (void) { | |||
| 1185 | lua_State *L = lua_newstate(luaL_alloc, NULL, luaL_makeseed(NULL)); | 1185 | lua_State *L = lua_newstate(luaL_alloc, NULL, luaL_makeseed(NULL)); |
| 1186 | if (l_likely(L)) { | 1186 | if (l_likely(L)) { |
| 1187 | lua_atpanic(L, &panic); | 1187 | lua_atpanic(L, &panic); |
| 1188 | lua_setwarnf(L, warnfoff, L); /* default is warnings off */ | 1188 | lua_setwarnf(L, warnfon, L); |
| 1189 | } | 1189 | } |
| 1190 | return L; | 1190 | return L; |
| 1191 | } | 1191 | } |
| @@ -349,6 +349,7 @@ static int collectargs (char **argv, int *first) { | |||
| 349 | */ | 349 | */ |
| 350 | static int runargs (lua_State *L, char **argv, int n) { | 350 | static int runargs (lua_State *L, char **argv, int n) { |
| 351 | int i; | 351 | int i; |
| 352 | lua_warning(L, "@off", 0); /* by default, Lua stand-alone has warnings off */ | ||
| 352 | for (i = 1; i < n; i++) { | 353 | for (i = 1; i < n; i++) { |
| 353 | int option = argv[i][1]; | 354 | int option = argv[i][1]; |
| 354 | lua_assert(argv[i][0] == '-'); /* already checked */ | 355 | lua_assert(argv[i][0] == '-'); /* already checked */ |
| @@ -725,7 +726,7 @@ static int pmain (lua_State *L) { | |||
| 725 | if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */ | 726 | if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */ |
| 726 | return 0; /* error running LUA_INIT */ | 727 | return 0; /* error running LUA_INIT */ |
| 727 | } | 728 | } |
| 728 | if (!runargs(L, argv, optlim)) /* execute arguments -e and -l */ | 729 | if (!runargs(L, argv, optlim)) /* execute arguments -e, -l, and -W */ |
| 729 | return 0; /* something failed */ | 730 | return 0; /* something failed */ |
| 730 | if (script > 0) { /* execute main script (if there is one) */ | 731 | if (script > 0) { /* execute main script (if there is one) */ |
| 731 | if (handle_script(L, argv + script) != LUA_OK) | 732 | if (handle_script(L, argv + script) != LUA_OK) |
