From 252e01e398b09804513f881be4850de79eb5c694 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 8 Feb 2002 20:39:56 -0200 Subject: `setlocale' may be used to query the current locale --- liolib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'liolib.c') diff --git a/liolib.c b/liolib.c index fdc5edce..3ac3146f 100644 --- a/liolib.c +++ b/liolib.c @@ -5,6 +5,8 @@ */ +#include +#include #include #include #include @@ -17,11 +19,6 @@ #include "lualib.h" -#ifndef OLD_ANSI -#include -#include -#endif - #ifdef POPEN @@ -568,9 +565,12 @@ static int io_setloc (lua_State *L) { LC_NUMERIC, LC_TIME}; static const char *const catnames[] = {"all", "collate", "ctype", "monetary", "numeric", "time", NULL}; + const char *l = lua_tostring(L, 1); int op = luaL_findstring(luaL_opt_string(L, 2, "all"), catnames); + luaL_arg_check(L, l || lua_isnil(L, 1) || lua_isnone(L, 1), 1, + "string expected"); luaL_arg_check(L, op != -1, 2, "invalid option"); - lua_pushstring(L, setlocale(cat[op], luaL_check_string(L, 1))); + lua_pushstring(L, setlocale(cat[op], l)); return 1; } -- cgit v1.2.3-55-g6feb