diff options
-rw-r--r-- | liolib.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -5,6 +5,8 @@ | |||
5 | */ | 5 | */ |
6 | 6 | ||
7 | 7 | ||
8 | #include <errno.h> | ||
9 | #include <locale.h> | ||
8 | #include <stdio.h> | 10 | #include <stdio.h> |
9 | #include <stdlib.h> | 11 | #include <stdlib.h> |
10 | #include <string.h> | 12 | #include <string.h> |
@@ -17,11 +19,6 @@ | |||
17 | #include "lualib.h" | 19 | #include "lualib.h" |
18 | 20 | ||
19 | 21 | ||
20 | #ifndef OLD_ANSI | ||
21 | #include <errno.h> | ||
22 | #include <locale.h> | ||
23 | #endif | ||
24 | |||
25 | 22 | ||
26 | 23 | ||
27 | #ifdef POPEN | 24 | #ifdef POPEN |
@@ -568,9 +565,12 @@ static int io_setloc (lua_State *L) { | |||
568 | LC_NUMERIC, LC_TIME}; | 565 | LC_NUMERIC, LC_TIME}; |
569 | static const char *const catnames[] = {"all", "collate", "ctype", "monetary", | 566 | static const char *const catnames[] = {"all", "collate", "ctype", "monetary", |
570 | "numeric", "time", NULL}; | 567 | "numeric", "time", NULL}; |
568 | const char *l = lua_tostring(L, 1); | ||
571 | int op = luaL_findstring(luaL_opt_string(L, 2, "all"), catnames); | 569 | int op = luaL_findstring(luaL_opt_string(L, 2, "all"), catnames); |
570 | luaL_arg_check(L, l || lua_isnil(L, 1) || lua_isnone(L, 1), 1, | ||
571 | "string expected"); | ||
572 | luaL_arg_check(L, op != -1, 2, "invalid option"); | 572 | luaL_arg_check(L, op != -1, 2, "invalid option"); |
573 | lua_pushstring(L, setlocale(cat[op], luaL_check_string(L, 1))); | 573 | lua_pushstring(L, setlocale(cat[op], l)); |
574 | return 1; | 574 | return 1; |
575 | } | 575 | } |
576 | 576 | ||