Merge branch 'master' into v2.1

This commit is contained in:
Mike Pall
2022-12-22 00:52:04 +01:00
15 changed files with 43 additions and 40 deletions

View File

@@ -155,7 +155,8 @@ LJLIB_CF(bit_tohex) LJLIB_REC(.)
#endif
SBuf *sb = lj_buf_tmp_(L);
SFormat sf = (STRFMT_UINT|STRFMT_T_HEX);
if (n < 0) { n = -n; sf |= STRFMT_F_UPPER; }
if (n < 0) { n = (int32_t)(~(uint32_t)n+1u); sf |= STRFMT_F_UPPER; }
if ((uint32_t)n > 254) n = 254;
sf |= ((SFormat)((n+1)&255) << STRFMT_SH_PREC);
#if LJ_HASFFI
if (n < 16) b &= ((uint64_t)1 << 4*n)-1;