From 955a811aa1ab50cc4165d88cdf5a259b7b77582a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 18 Jun 1998 14:04:28 -0300 Subject: [PATCH] category for "setlocale" is given by name --- liolib.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/liolib.c b/liolib.c index db374b44..d252931c 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 1.19 1998/06/02 21:20:54 roberto Exp roberto $ +** $Id: liolib.c,v 1.20 1998/06/05 22:17:44 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -326,8 +326,10 @@ static void setloc (void) { static int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME}; - int op = (int)luaL_opt_number(2, 0); - luaL_arg_check(0 <= op && op <= 5, 2, "invalid option"); + static char *catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + int op = luaL_findstring(luaL_opt_string(2, "all"), catnames); + luaL_arg_check(op != -1, 2, "invalid option"); lua_pushstring(setlocale(cat[op], luaL_check_string(1))); }