aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-02-08 20:39:56 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-02-08 20:39:56 -0200
commit252e01e398b09804513f881be4850de79eb5c694 (patch)
tree6de54f1ff43e3881379e86a7c0bdaed19942090d
parent87b0e3d477a8d4af32a2a200a2d8cb2c3aaa05a1 (diff)
downloadlua-252e01e398b09804513f881be4850de79eb5c694.tar.gz
lua-252e01e398b09804513f881be4850de79eb5c694.tar.bz2
lua-252e01e398b09804513f881be4850de79eb5c694.zip
`setlocale' may be used to query the current locale
-rw-r--r--liolib.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/liolib.c b/liolib.c
index fdc5edce..3ac3146f 100644
--- a/liolib.c
+++ b/liolib.c
@@ -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