| 167 | |
| 168 | |
| 169 | static void putinteger (lua_State *L, luaL_Buffer *b, int arg, int endian, |
| 170 | int size) { |
| 171 | lua_Number n = luaL_checknumber(L, arg); |
| 172 | Uinttype value; |
| 173 | char buff[MAXINTSIZE]; |
| 174 | if (n < 0) |
| 175 | value = (Uinttype)(Inttype)n; |
| 176 | else |
| 177 | value = (Uinttype)n; |
| 178 | if (endian == LITTLE) { |
| 179 | int i; |
| 180 | for (i = 0; i < size; i++) { |
| 181 | buff[i] = (value & 0xff); |
| 182 | value >>= 8; |
| 183 | } |
| 184 | } |
| 185 | else { |
| 186 | int i; |
| 187 | for (i = size - 1; i >= 0; i--) { |
| 188 | buff[i] = (value & 0xff); |
| 189 | value >>= 8; |
| 190 | } |
| 191 | } |
| 192 | luaL_addlstring(b, buff, size); |
| 193 | } |
| 194 | |
| 195 | |
| 196 | static void correctbytes (char *b, int size, int endian) { |
no test coverage detected