gobolinux / Recipes

The GoboLinux recipes repository
107 stars 30 forks source link

Awesome 4.3 patch (lua54 compatibility) #232

Closed sage-etcher closed 4 months ago

sage-etcher commented 4 months ago

Awesome's -v version flag, was written with Lua53's require in mind, which only returns 1 value. However, in Lua54, the require built-in now returns 2 values. Awesome doesn't handle this causing the version information to display incorrectly.

Rather than checking LUA_VERSION_NUM, the patch handles this at runtime, so no matter the version of Lua used at build time, the runtime information should be correct for the given Lua + LGI softwares.

I tested the patch with Lua versions: 5.4.3, 5.3.5, and 5.3.6, and it works in each.

Example (w/o the patch) running Lua 5.4.3 and LGI-GIT:

$ awesome -v
awesome v4.3 (Too long)
 ? Compiled against Lua 5.4.3 (running with 0.9.2)
 ? D-Bus support: ?
 ? execinfo support: ?
 ? xcb-randr version: 1.6
 ? LGI version: /System/Aliens/LuaRocks/share/lua/5.4/lgi/version.lua

Example (w/ the patch)

$ awesome -v
awesome v4.3 (Too long)
 ? Compiled against Lua 5.4.3 (running with Lua 5.4)
 ? D-Bus support: ?
 ? execinfo support: ?
 ? xcb-randr version: 1.6
 ? LGI version: 0.9.2

The patch isn't essential, Awesome will run fine without it, but it's nice having the version information not be wrong ://

for Issue #128

Nuc1eoN commented 4 months ago

LGTM and looks useful, ty!

sage-etcher commented 4 months ago

It's unneeded, however, I realized after the fact that I overcomplicated this a bit. I have a simplified (slightly faster) version of this patch as well; I'd forgot to commit it earlier. Would that be something you'd be interested in?

Instead of using the lua_pop macro and a second call to lua_gettop, it manually sets the top, saving a function call and quite a few computations by using

lua_settop(L, top+1);

I think it's also a bit clearer what is going on, for example in an edge-case where require doesn't push anything. In such scenario, previous implementation would say lua_pop(-1) which would push a value onto the stack to align the data, which works but is unclear. However lua_settop is clearer in that it will always make sure the data is aligned by +1.

Nuc1eoN commented 4 months ago

Sure why not, feel free to submit it:)