From 647047de01d262b4d0c8c66172efd0fba07b5ce8 Mon Sep 17 00:00:00 2001 From: Shmuel Zeigerman Date: Sat, 7 Jan 2012 01:00:08 +0200 Subject: Tidy up --- src/oniguruma/lonig.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/oniguruma/lonig.c b/src/oniguruma/lonig.c index e0a4acd..d3cdfcc 100644 --- a/src/oniguruma/lonig.c +++ b/src/oniguruma/lonig.c @@ -174,19 +174,14 @@ static int fcmp(const void *p1, const void *p2) { } static const char *getlocale (lua_State *L, int pos) { - EncPair key; + EncPair key, *found; if ((key.name = luaL_optstring(L, pos, NULL)) == NULL) return (const char*)ONIG_ENCODING_ASCII; - else { - EncPair *pair = (EncPair*) bsearch(&key, Encodings, - sizeof(Encodings)/sizeof(EncPair), sizeof(EncPair), fcmp); - if (pair != NULL) - return (const char*)pair->value; - else { - luaL_argerror(L, pos, "invalid or unsupported encoding string"); - return NULL; - } - } + found = (EncPair*) bsearch(&key, Encodings, sizeof(Encodings)/sizeof(EncPair), + sizeof(EncPair), fcmp); + if (found == NULL) + luaL_argerror(L, pos, "invalid or unsupported encoding string"); + return (const char*)found->value; } static void *getsyntax (lua_State *L, int pos) { @@ -194,7 +189,7 @@ static void *getsyntax (lua_State *L, int pos) { if ((key.name = luaL_optstring(L, pos, NULL)) == NULL) return ONIG_SYNTAX_DEFAULT; found = (EncPair*) bsearch(&key, Syntaxes, sizeof(Syntaxes)/sizeof(EncPair), - sizeof(EncPair), fcmp); + sizeof(EncPair), fcmp); if (found == NULL) luaL_argerror(L, pos, "invalid or unsupported syntax string"); return found->value; -- cgit v1.2.1