| 5828 | } |
| 5829 | |
| 5830 | static int bit_tohex(lua_State *L) |
| 5831 | { |
| 5832 | UBits b = barg(L, 1); |
| 5833 | SBits n = lua_isnone(L, 2) ? 8 : (SBits)barg(L, 2); |
| 5834 | const char *hexdigits = "0123456789abcdef"; |
| 5835 | char buf[8]; |
| 5836 | int i; |
| 5837 | if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; } |
| 5838 | if (n > 8) n = 8; |
| 5839 | for (i = (int)n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; } |
| 5840 | lua_pushlstring(L, buf, (size_t)n); |
| 5841 | return 1; |
| 5842 | } |
| 5843 | |
| 5844 | static const struct luaL_Reg bit_funcs[] = { |
| 5845 | { "tobit", bit_tobit }, |
nothing calls this directly
no test coverage detected