Comments (3)
Thanks for the feedback.
Lua 5.1 stored all numbers (integers or floats) as 53 bit IEEE 754 doubles. More recent Lua releases including 5.4, but I forget when exactly, added real low level integer types. luaposix tries to work correctly with Lua 5.1 and newer, including luajit, within the constraints of the various apis exposed by each, but misses some corner cases in doing that.
Your suggestion uses a call that is not supported by Lua 5.1 and would prevent luaposix compiling there.
I thing passing a floating point number to getpwuid
is not really sensible (even though older Lua interpreters will store it as a float internally) because UNIX uids are always integers -- there is no uid 1001.25! Better to change your code to pwd.getpwuid(0)
IMHO.
Nonetheless, if you find a way to reliably force integer equivalent floats to real integers that works on luajit and Lua 5.1+ that is not too torturous, please do submit a PR.
from luaposix.
Thank you for your thorough answer.
Your suggestion uses a call that is not supported by Lua 5.1 and would prevent luaposix compiling there.
Are your referring to lua_tointegerx
? I compiled luaposix with the suggestion for 5.1 and it works with Lua 5.1 and LuaJIT. What I did see is that LuaJIT, 5.1 and 5.2 would accept 1000.25, the others didn't. But that seems to be the same behaviour as now, if I tested this correctly.
The code in
luaposix/ext/include/compat-5.2.c
Lines 514 to 520 in 5b68a50
gives
lua_tointegerx
which I think is included, if LUA_VERSION_NUM == 501
. Would that be sufficient for 5.1?
I thing passing a floating point number to
getpwuid
is not really sensible (even though older Lua interpreters will store it as a float internally) because UNIX uids are always integers -- there is no uid 1001.25! Better to change your code topwd.getpwuid(0)
IMHO.
I do agree. It shouldn't be problem to use math.tointeger()
. It was just really unfortunate that the behaviour changed and only for that one case.
Nonetheless, if you find a way to reliably force integer equivalent floats to real integers that works on luajit and Lua 5.1+ that is not too torturous,
Could you perhaps test my suggestion and see if it works for you as well? Hopefully, I didn't make a mistake compiling for 5.1
from luaposix.
I totally spaced on the compat code, and you are quite right! Let me see if I can merge this later today. Thanks for persevering with me 😁
from luaposix.
Related Issues (20)
- Small error in doc for poll(): return is not 0/1 but the number of ready fd's
- posix.fcntl is a function, not a table. HOT 15
- luxposix 36.0 won't compile properly on CentOS7 - time.h issues HOT 14
- posix.sys.socket - recv() crashes with socket and timeout in v36.1 (v36.0) HOT 6
- Lazy loading of posix.sys.stat fails in both 35.1 and 36.1 HOT 6
- luaposix won't compile in termux HOT 26
- Missing rockspec file in v36.1 HOT 7
- Get an error when trying to cross-compile HOT 1
- String overflow for unistd.read(). HOT 6
- Epoch inconsistency?
- Error on import: posix/glob.so: wrong ELF class: ELFCLASS64 HOT 7
- invalid elf header HOT 1
- luaposix does not cross compile properly HOT 5
- studio code does not seems to like the require HOT 2
- luaposix installs but I cant use it in cygwin HOT 1
- [MISSING] tcgetwinsize HOT 1
- getgrgid/getgrnam/getpwuid/getpwnam don't return error messages HOT 2
- Testing luaposix on packaging HOT 2
- posix.stat does not follow symlinks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luaposix.