lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

this small patch tries to avoid compilation of unreachable code in math_log10.

François
From b5bd3d59cdccc155e2a4cf8b1d5df524b9359e8d Mon Sep 17 00:00:00 2001
From: Francois Perrad <francois.perrad@gadz.org>
Date: Thu, 18 Nov 2010 19:08:15 +0100
Subject: [PATCH] avoid compilation of unreachable code

---
 src/lmathlib.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/lmathlib.c b/src/lmathlib.c
index 8494d80..b2a2c97 100644
--- a/src/lmathlib.c
+++ b/src/lmathlib.c
@@ -135,12 +135,14 @@ static int math_log (lua_State *L) {
 }
 
 static int math_log10 (lua_State *L) {
-#if !defined(LUA_COMPAT_LOG10)
+#if defined(LUA_COMPAT_LOG10)
+  lua_pushnumber(L, l_tg(log10)(luaL_checknumber(L, 1)));
+  return 1;
+#else
   luaL_error(L, "function " LUA_QL("log10")
                 " is deprecated; use log(x, 10) instead");
+  return 0;  /* to avoid warnings */
 #endif
-  lua_pushnumber(L, l_tg(log10)(luaL_checknumber(L, 1)));
-  return 1;
 }
 
 static int math_exp (lua_State *L) {
-- 
1.7.1