Mercurial > prosody-hg
comparison util/startup.lua @ 12781:22066b02887f
util.startup: Provide a common Lua 5.3+ math.type() for Lua 5.2
Code deduplication
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 19 Oct 2022 16:25:05 +0200 |
| parents | f0474d40364c |
| children | 8815d3090928 |
comparison
equal
deleted
inserted
replaced
| 12780:2c0c1b18a02b | 12781:22066b02887f |
|---|---|
| 275 prosody.log = logger.init("general"); | 275 prosody.log = logger.init("general"); |
| 276 | 276 |
| 277 startup.detect_platform(); | 277 startup.detect_platform(); |
| 278 startup.detect_installed(); | 278 startup.detect_installed(); |
| 279 _G.prosody = prosody; | 279 _G.prosody = prosody; |
| 280 | |
| 281 -- COMPAT Lua < 5.3 | |
| 282 if not math.type then | |
| 283 -- luacheck: ignore 122/math | |
| 284 function math.type(n) | |
| 285 if type(n) == "number" then | |
| 286 if n % 1 == 0 and (n + 1 ~= n and n - 1 ~= n) then | |
| 287 return "integer" | |
| 288 else | |
| 289 return "float" | |
| 290 end | |
| 291 end | |
| 292 end | |
| 293 end | |
| 280 end | 294 end |
| 281 | 295 |
| 282 function startup.setup_datadir() | 296 function startup.setup_datadir() |
| 283 prosody.paths.data = config.get("*", "data_path") or CFG_DATADIR or "data"; | 297 prosody.paths.data = config.get("*", "data_path") or CFG_DATADIR or "data"; |
| 284 end | 298 end |
