[vlc-commits] [Git][videolan/vlc][master] lua: http: add utility function to provide deprecated math.pow()

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Mon Nov 16 07:08:33 UTC 2026



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
83613997 by Benjamin Robin at 2026-11-16T00:39:13+01:00
lua: http: add utility function to provide deprecated math.pow()

Lua's math.pow() function is deprecated as of release 5.3, as
documented here [1]. So provide a utility function inside httprequests
module to provide math.pow() for recent LUA versions. If the math.pow
is nil, use instead the built-in ^ exponentiation operator.

This fix only applies to the lua http interface.

We cannot use unconditionally the built-in ^ exponentiation operator,
since it was introduced in LUA 5.3, and LUA 5.1 and 5.2 are still
supported.

This fixes this error: /usr/lib/vlc/lua/intf/modules/httprequests.lua:37:
attempt to call a nil value.

[1] https://www.lua.org/manual/5.3/manual.html#8.2

- - - - -


1 changed file:

- share/lua/intf/modules/httprequests.lua


Changes:

=====================================
share/lua/intf/modules/httprequests.lua
=====================================
@@ -27,6 +27,13 @@ local common = require ("common")
 local dkjson = require ("dkjson")
 
 
+--utility function for LUA version without math.pow()
+function math_pow(num, power)
+    if math.pow == nil then
+        return num^power
+    end
+    return math.pow(num, power)
+end
 
 --Round the number to the specified precision
 function round(what, precision)
@@ -34,7 +41,7 @@ function round(what, precision)
         what = common.us_tonumber(what)
     end
     if type(what) == "number" then
-        return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision)
+        return math.floor(what*math_pow(10,precision)+0.5) / math_pow(10,precision)
     end
     return nil
 end



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8361399713267b27921ef773fa4e58b668f76680

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8361399713267b27921ef773fa4e58b668f76680
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list